Bug 801120 - Support T* WeakPtr<T>::get(). r=Ms2ger,ehsan

--HG--
extra : rebase_source : 662ef6f39966956be5588d9bd7508dbe59a2c537
Bug 821804 - Allow unitialized WeakPtrs to work properly. r=Waldo

This ensures that the WeakPtr always points at a valid object and avoids the
need to test for that during operations.
Bug 857833 - Remove some warnings in toolkit/xre/nsAppRunner.cpp.
Bug 857834 - Remove a warning in the startupcache.
Bug 857152 - Make IPC channels more robust against use after being closed.

This patch makes three changes.  The goal of these changes is to prevent
IPC channels from crashing if you try to send a message across one after
the channel has been closed.

1. Each message_loop object gets a unique, non-repeating ID.
AsyncChannel uses this ID, instead of a pointer to the message loop, to
assert that it's being used on the correct thread.  This allows
AsyncChannel to assert that it's being used on the correct thread after
it's cleared its pointer to the thread.

2. AsyncChannel::mMonitor isn't cleared in AsyncChannel::Clear.  There's
no reason to do so; the monitor can get cleared when the channel is
destroyed.

3. AsyncChannel's mListener pointer is changed to a mozilla::WeakPtr.
This allows us to keep the mListener reference around longer, whereas
before we cleared it in AsyncChannel::Clear.

Channels try not to crash if you Send() on them after they've been
closed, but in practice they'd dereference mListener and mMonitor before
checking whether they'd been closed.

Note that weak references are not threadsafe, so if
mListener->asWeakRef() was called on a different thread than the one
that ultimately destroys AsyncChannel, we'd have a problem.  But I don't
think this happens.
Bug 844323 - Prelude part 1: Use a pref to in nsHTMLMediaElement to control whether we talk to the audio service.

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.

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.

It was mozilla/dom/ipc/ before, but this changes it to mozilla/, which matches the class's namespace.
Bug 844323 - Part 1: Move process preallocation logic out of ContentParent and into a new file, PreallocatedProcessManager.

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.

XXX Don't forget to remove ProcessPriorityManager-old.cpp
XXX Don't forget to remove the TabParentObserved code.
Bug 844323 - Part 3: ProcessPriorityManager tests.
Bug 847592 - Part 1: Add a lowCPUPriority argument to hal::SetProcessPriority.
Bug 847592 - Part 2: When a process has priority FOREGROUND_HIGH, renice all other processes.
Bug 847592 - Tests for renicing processes when one has priority FOREGROUND_HIGH