Follow-up for bug 608142: disallow sending between main and non-main thread only (r=orange). a=beta7+
authorAndreas Gal <gal@mozilla.com>
Sat, 30 Oct 2010 08:39:53 -0700
changeset 56711 67dd5fbeebaa
parent 56710 05e775f368f8
child 56712 18caa24f974d
child 56786 804aaa5912d8
push id16663
push userjst@mozilla.com
push dateSun, 31 Oct 2010 05:12:52 +0000
treeherdermozilla-central@67dd5fbeebaa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersorange, beta7
bugs608142
milestone2.0b8pre
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
Follow-up for bug 608142: disallow sending between main and non-main thread only (r=orange). a=beta7+
js/src/xpconnect/src/xpcprivate.h
js/src/xpconnect/src/xpcwrappedjs.cpp
--- a/js/src/xpconnect/src/xpcprivate.h
+++ b/js/src/xpconnect/src/xpcprivate.h
@@ -3066,17 +3066,17 @@ protected:
    void Unlink();
 
 private:
     JSObject* mJSObj;
     nsXPCWrappedJSClass* mClass;
     nsXPCWrappedJS* mRoot;
     nsXPCWrappedJS* mNext;
     nsISupports* mOuter;    // only set in root
-    nsCOMPtr<nsIThread> mThread;
+    bool mMainThread;
 };
 
 /***************************************************************************/
 
 class XPCJSObjectHolder : public nsIXPConnectJSObjectHolder,
                           public XPCRootSetElem
 {
 public:
--- a/js/src/xpconnect/src/xpcwrappedjs.cpp
+++ b/js/src/xpconnect/src/xpcwrappedjs.cpp
@@ -431,17 +431,17 @@ nsXPCWrappedJS::nsXPCWrappedJS(XPCCallCo
                                nsXPCWrappedJSClass* aClass,
                                nsXPCWrappedJS* root,
                                nsISupports* aOuter)
     : mJSObj(aJSObj),
       mClass(aClass),
       mRoot(root ? root : this),
       mNext(nsnull),
       mOuter(root ? nsnull : aOuter),
-      mThread(do_GetCurrentThread())
+      mMainThread(NS_IsMainThread())
 {
 #ifdef DEBUG_stats_jband
     static int count = 0;
     static const int interval = 10;
     if(0 == (++count % interval))
         printf("//////// %d instances of nsXPCWrappedJS created\n", count);
 #endif
 
@@ -566,18 +566,19 @@ nsXPCWrappedJS::GetInterfaceInfo(nsIInte
 
 NS_IMETHODIMP
 nsXPCWrappedJS::CallMethod(PRUint16 methodIndex,
                            const XPTMethodDescriptor* info,
                            nsXPTCMiniVariant* params)
 {
     if(!IsValid())
         return NS_ERROR_UNEXPECTED;
-    if (NS_GetCurrentThread() != mThread)
+    if (NS_IsMainThread() != mMainThread) {
         return NS_ERROR_NOT_SAME_THREAD;
+    }
     return GetClass()->CallMethod(this, methodIndex, info, params);
 }
 
 NS_IMETHODIMP
 nsXPCWrappedJS::GetInterfaceIID(nsIID** iid)
 {
     NS_PRECONDITION(iid, "bad param");