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 192454 d2e7bd70dd958f6379050a0cd6d1ef1571dd3d47
parent 192453 0bb895a9ba5fccb952405ec54e6fe8cb02692ad5
child 192455 4f76565b3c2cda718b4f3a859175d8638522c3e9
push id45843
push userbjacob@mozilla.com
push dateFri, 04 Jul 2014 18:04:39 +0000
treeherdermozilla-inbound@d2e7bd70dd95 [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);