Bug 1028383 - Make ITopLevelProtocol assert to enforce its assumptions that things happen on the main thread - r=bent
authorBenoit Jacob <bjacob@mozilla.com>
Fri, 04 Jul 2014 14:04:13 -0400
changeset 192530 633893b148ec34a65b6ea332aefff2f1d9fcc2ce
parent 192529 b6a5d0bea2b0102d4bacc59f9af657830687663d
child 192531 128dc044d3f7b905459b609b6ec6c783b4c1707e
push id27088
push usercbook@mozilla.com
push dateMon, 07 Jul 2014 12:19:04 +0000
treeherdermozilla-central@699348fd356b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs1028383
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1028383 - Make ITopLevelProtocol assert to enforce its assumptions that things happen on the main thread - r=bent
ipc/glue/ProtocolUtils.cpp
ipc/glue/ProtocolUtils.h
--- a/ipc/glue/ProtocolUtils.cpp
+++ b/ipc/glue/ProtocolUtils.cpp
@@ -14,21 +14,24 @@
 using namespace base;
 using namespace IPC;
 
 namespace mozilla {
 namespace ipc {
 
 IToplevelProtocol::~IToplevelProtocol()
 {
+  MOZ_ASSERT(NS_IsMainThread());
   mOpenActors.clear();
 }
 
 void IToplevelProtocol::AddOpenedActor(IToplevelProtocol* aActor)
 {
+  MOZ_ASSERT(NS_IsMainThread());
+
 #ifdef DEBUG
   for (const IToplevelProtocol* actor = mOpenActors.getFirst();
        actor;
        actor = actor->getNext()) {
     NS_ASSERTION(actor != aActor,
                  "Open the same protocol for more than one time");
   }
 #endif
--- a/ipc/glue/ProtocolUtils.h
+++ b/ipc/glue/ProtocolUtils.h
@@ -16,16 +16,17 @@
 
 #include "IPCMessageStart.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/ipc/FileDescriptor.h"
 #include "mozilla/ipc/Shmem.h"
 #include "mozilla/ipc/Transport.h"
 #include "mozilla/ipc/MessageLink.h"
 #include "mozilla/LinkedList.h"
+#include "MainThreadUtils.h"
 
 #if defined(ANDROID) && defined(DEBUG)
 #include <android/log.h>
 #endif
 
 // WARNING: this takes into account the private, special-message-type
 // enum in ipc_channel.h.  They need to be kept in sync.
 namespace {
@@ -182,16 +183,17 @@ public:
  */
 class IToplevelProtocol : public LinkedListElement<IToplevelProtocol>
 {
 protected:
     IToplevelProtocol(ProtocolId aProtoId)
         : mProtocolId(aProtoId)
         , mTrans(nullptr)
     {
+      MOZ_ASSERT(NS_IsMainThread());
     }
 
     ~IToplevelProtocol();
 
     /**
      * Add an actor to the list of actors that have been opened by this
      * protocol.
      */
@@ -207,20 +209,22 @@ public:
 
     ProtocolId GetProtocolId() const { return mProtocolId; }
 
     /**
      * Return first of actors of top level protocols opened by this one.
      */
     IToplevelProtocol* GetFirstOpenedActors()
     {
+        MOZ_ASSERT(NS_IsMainThread());
         return mOpenActors.getFirst();
     }
     const IToplevelProtocol* GetFirstOpenedActors() const
     {
+        MOZ_ASSERT(NS_IsMainThread());
         return mOpenActors.getFirst();
     }
 
     virtual IToplevelProtocol*
     CloneToplevel(const InfallibleTArray<ProtocolFdMapping>& aFds,
                   base::ProcessHandle aPeerProcess,
                   ProtocolCloneContext* aCtx);