Bug 844970 - Use a grace period for all process priority downgrades. r=cjones

This was originally not uplifted to b2g18 v1.0.1.  But the diff in bug
844323 relies on it.  Bug 844323 is a complete rewrite of
ProcessPriorityManager.cpp, so, strictly speaking, we don't need this
commit; we could squash it into bug 844323.  But I think it's better for
the diffs to match between b2g18 and b2g18 v1.0.1.
Bug 844323 - Prelude part 1: Use a pref to in nsHTMLMediaElement to control whether we talk to the audio service. r=amarchesini

Previously, we used #ifdef B2G.  Using a pref allows us to write mochitests which run in desktop Firefox that test the audio service and its interaction with other components.
Bug 844323 - Prelude part 2: Switch xpcom/base/StaticPtr from NULL to nullptr, and add a necessary include. r=khuey

This is necessary to make this header compile in one of the places I use it.  Anyway it's the right change.
Bug 844323 - Prelude part 3: Change ProcessPriorityManager's export directory. r=khuey

It was mozilla/dom/ipc/ before, but this changes it to mozilla/, which matches the class's namespace.
Bug 844323 - Prelude part 4: Use 's' prefix on class-static variables, not 'g'. r=me
Bug 844323 - Part 1: Move process preallocation logic out of ContentParent and into a new file, PreallocatedProcessManager. r=bent

Also make the PreallocatedProcessManager respond to pref changes.  This allows us to write a test involving the preallocated process.  Making this change was the main motivation for this patch; I moved the logic out of ContentParent because with the pref-watching code it was becoming unweildy.
Bug 844323 - Part 2 (The Main Event): Move ProcesPriorityManager to the main process. r=bent,khuey
Bug 844323 - Part 3: ProcessPriorityManager tests. r=nsm,khuey
Bug 844323 - Follow-up: Fix typo in BrowserElementChildPreload that was breaking bg --> fg transitions in childVisibilityChanged. r=khuey, a=tef+

Also modify the test so it catches this mistake.
Bug 860799 - Part 1: Give frames expecting a system message priority at least BACKGROUND_PERCEIVABLE, so long as either haven't yet handled the system message or are holding the CPU/high-priority wake lock. r=khuey
Bug 860799 - Part 2: Test that we give frames expecting a system message priority above vanilla BACKGROUND. r=khuey, a=tef+