PSM fixups for Windows and synchronicity, and stdcall definition, I believe this is ready for tryserver.
authorBenjamin Smedberg <benjamin@smedbergs.us>
Tue, 09 Aug 2011 11:41:18 -0400
changeset 1 f52b92c8bd83e51fd41f0e431e0ff9c0235258f3
parent 0 a3396d3560643ce648b2d854a65982033bad2838
child 2 e614df952b2ce533d48bfa61cc6ed7ab76715707
push id2
push userbsmedberg@mozilla.com
push dateTue, 09 Aug 2011 15:41:54 +0000
PSM fixups for Windows and synchronicity, and stdcall definition, I believe this is ready for tryserver.
bug675221-partD-urlclassifier
bug675221-partF-psm
bug675221-partG-define-HAS_STDCALL
series
--- a/bug675221-partD-urlclassifier
+++ b/bug675221-partD-urlclassifier
@@ -1,10 +1,10 @@
 # HG changeset patch
-# Parent 6ce5687b851bdc7c351382d9cfa12b7edc7ef2b7
+# Parent c6bdd20bef8fc79b5ff3e03dc422cf37a317847c
 Bug 675221 part D - Fix up URL classifier to stop using XPCOM proxies, r?dcamp
 
 diff --git a/toolkit/components/url-classifier/Makefile.in b/toolkit/components/url-classifier/Makefile.in
 --- a/toolkit/components/url-classifier/Makefile.in
 +++ b/toolkit/components/url-classifier/Makefile.in
 @@ -56,16 +56,17 @@ XPIDLSRCS = \
    nsIUrlClassifierUtils.idl \
    nsIUrlListManager.idl \
@@ -21,40 +21,41 @@ diff --git a/toolkit/components/url-clas
    -I$(srcdir)/../build \
    $(SQLITE_CFLAGS) \
    $(NULL)
  
  EXTRA_COMPONENTS = \
 diff --git a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
 --- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
 +++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
-@@ -54,21 +54,21 @@
+@@ -54,22 +54,22 @@
  #include "nsIDirectoryService.h"
  #include "nsIKeyModule.h"
  #include "nsIObserverService.h"
  #include "nsIPermissionManager.h"
  #include "nsIPrefBranch.h"
  #include "nsIPrefBranch2.h"
  #include "nsIPrefService.h"
  #include "nsIProperties.h"
 -#include "nsIProxyObjectManager.h"
  #include "nsToolkitCompsCID.h"
  #include "nsIUrlClassifierUtils.h"
+ #include "nsIRandomGenerator.h"
  #include "nsUrlClassifierDBService.h"
  #include "nsUrlClassifierUtils.h"
 +#include "nsUrlClassifierProxies.h"
  #include "nsURILoader.h"
  #include "nsString.h"
  #include "nsReadableUtils.h"
  #include "nsTArray.h"
  #include "nsNetUtil.h"
  #include "nsNetCID.h"
  #include "nsThreadUtils.h"
  #include "nsXPCOMStrings.h"
-@@ -175,18 +175,17 @@ static const PRLogModuleInfo *gUrlClassi
+@@ -176,18 +176,17 @@ static const PRLogModuleInfo *gUrlClassi
  #define UPDATE_DELAY_TIME           "urlclassifier.updatetime"
  #define UPDATE_DELAY_TIME_DEFAULT   60
  
  class nsUrlClassifierDBServiceWorker;
  
  // Singleton instance.
  static nsUrlClassifierDBService* sUrlClassifierDBService;
  
@@ -64,17 +65,17 @@ diff --git a/toolkit/components/url-clas
  
  // Once we've committed to shutting down, don't do work in the background
  // thread.
  static PRBool gShuttingDownThread = PR_FALSE;
  
  static PRInt32 gFreshnessGuarantee = CONFIRM_AGE_DEFAULT_SEC;
  
  static PRInt32 gUpdateCacheSize = UPDATE_CACHE_SIZE_DEFAULT;
-@@ -3934,22 +3933,17 @@ nsUrlClassifierDBService::Init()
+@@ -3915,22 +3914,17 @@ nsUrlClassifierDBService::Init()
  
    rv = mWorker->Init(gethashNoise);
    if (NS_FAILED(rv)) {
      mWorker = nsnull;
      return rv;
    }
  
    // Proxy for calling the worker on the background thread
@@ -88,17 +89,17 @@ diff --git a/toolkit/components/url-clas
  
    mCompleters.Init();
  
    // Add an observer for shutdown
    nsCOMPtr<nsIObserverService> observerService =
        mozilla::services::GetObserverService();
    if (!observerService)
      return NS_ERROR_FAILURE;
-@@ -4052,47 +4046,36 @@ nsUrlClassifierDBService::LookupURI(nsIU
+@@ -4033,47 +4027,36 @@ nsUrlClassifierDBService::LookupURI(nsIU
    // Create an nsUrlClassifierLookupCallback object.  This object will
    // take care of confirming partial hash matches if necessary before
    // calling the client's callback.
    nsCOMPtr<nsIUrlClassifierLookupCallback> callback =
      new nsUrlClassifierLookupCallback(this, c);
    if (!callback)
      return NS_ERROR_OUT_OF_MEMORY;
  
@@ -140,17 +141,17 @@ diff --git a/toolkit/components/url-clas
  
    return mWorkerProxy->GetTables(proxyCallback);
  }
  
  NS_IMETHODIMP
  nsUrlClassifierDBService::SetHashCompleter(const nsACString &tableName,
                                             nsIUrlClassifierHashCompleter *completer)
  {
-@@ -4117,23 +4100,18 @@ nsUrlClassifierDBService::BeginUpdate(ns
+@@ -4098,23 +4081,18 @@ nsUrlClassifierDBService::BeginUpdate(ns
    if (mInUpdate)
      return NS_ERROR_NOT_AVAILABLE;
  
    mInUpdate = PR_TRUE;
  
    nsresult rv;
  
    // The proxy observer uses the current thread
@@ -166,17 +167,17 @@ diff --git a/toolkit/components/url-clas
  
    return mWorkerProxy->BeginUpdate(proxyObserver, updateTables, clientKey);
  }
  
  NS_IMETHODIMP
  nsUrlClassifierDBService::BeginStream(const nsACString &table,
                                        const nsACString &serverMAC)
  {
-@@ -4298,8 +4276,15 @@ nsUrlClassifierDBService::Shutdown()
+@@ -4279,8 +4257,15 @@ nsUrlClassifierDBService::Shutdown()
  
    nsIThread *backgroundThread = gDbBackgroundThread;
    gDbBackgroundThread = nsnull;
    backgroundThread->Shutdown();
    NS_RELEASE(backgroundThread);
  
    return NS_OK;
  }
--- a/bug675221-partF-psm
+++ b/bug675221-partF-psm
@@ -1,10 +1,11 @@
 # HG changeset patch
-# Parent c38d33994ff48bf1372b858217738bdb3b77222e
+# Parent 1a4655c0045e8f4c96e44b29cb9e96c990ae45f0
+Bug 675221 part F - Replace PSMs use of synchronous XPCOM proxies with compiled proxy classes which do synchronous proxying but don't spin a nested event loop, r?bsmith sr?bz
 
 diff --git a/security/manager/boot/src/nsSecureBrowserUIImpl.cpp b/security/manager/boot/src/nsSecureBrowserUIImpl.cpp
 --- a/security/manager/boot/src/nsSecureBrowserUIImpl.cpp
 +++ b/security/manager/boot/src/nsSecureBrowserUIImpl.cpp
 @@ -74,22 +74,22 @@
  #include "nsITransportSecurityInfo.h"
  #include "nsIIdentityInfo.h"
  #include "nsIURI.h"
@@ -1962,17 +1963,17 @@ diff --git a/security/manager/ssl/src/ns
    {
      nsPSMUITracker tracker;
      if (tracker.isUIForbidden()) {
        rv = NS_ERROR_NOT_AVAILABLE;
 diff --git a/security/manager/ssl/src/nsSyncRunnableHelpers.cpp b/security/manager/ssl/src/nsSyncRunnableHelpers.cpp
 new file mode 100644
 --- /dev/null
 +++ b/security/manager/ssl/src/nsSyncRunnableHelpers.cpp
-@@ -0,0 +1,779 @@
+@@ -0,0 +1,920 @@
 +/* ***** BEGIN LICENSE BLOCK *****
 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 + *
 + * The contents of this file are subject to the Mozilla Public License Version
 + * 1.1 (the "License"); you may not use this file except in compliance with
 + * the License. You may obtain a copy of the License at
 + * http://www.mozilla.org/MPL/
 + *
@@ -2001,16 +2002,18 @@ new file mode 100644
 + * and other provisions required by the GPL or the LGPL. If you do not delete
 + * the provisions above, a recipient may use your version of this file under
 + * the terms of any one of the MPL, the GPL or the LGPL.
 + *
 + * ***** END LICENSE BLOCK ***** */
 +
 +#include "nsSyncRunnableHelpers.h"
 +
++#include "mozilla/Monitor.h"
++
 +NS_IMPL_THREADSAFE_ISUPPORTS1(ObserverProxy, nsIObserver)
 +NS_IMPL_THREADSAFE_ISUPPORTS1(InterfaceRequestorProxy, nsIInterfaceRequestor)
 +NS_IMPL_THREADSAFE_ISUPPORTS1(PromptProxy, nsIPrompt)
 +NS_IMPL_THREADSAFE_ISUPPORTS1(SecurityWarningDialogsProxy,
 +                              nsISecurityWarningDialogs)
 +NS_IMPL_THREADSAFE_ISUPPORTS1(TokenPasswordDialogsProxy,
 +                              nsITokenPasswordDialogs)
 +NS_IMPL_THREADSAFE_ISUPPORTS1(DocShellTreeItemProxy, nsIDocShellTreeItem)
@@ -2027,400 +2030,539 @@ new file mode 100644
 +                              nsISSLCertErrorDialog)
 +NS_IMPL_THREADSAFE_ISUPPORTS1(ClientAuthDialogsProxy, nsIClientAuthDialogs)
 +NS_IMPL_THREADSAFE_ISUPPORTS1(CertificateDialogsProxy, nsICertificateDialogs)
 +NS_IMPL_THREADSAFE_ISUPPORTS1(GeneratingKeypairInfoDialogsProxy,
 +                              nsIGeneratingKeypairInfoDialogs)
 +NS_IMPL_THREADSAFE_ISUPPORTS1(DOMCryptoDialogsProxy, nsIDOMCryptoDialogs)
 +NS_IMPL_THREADSAFE_ISUPPORTS1(CertPickDialogsProxy, nsICertPickDialogs)
 +
-+template<typename Receiver, typename Arg1>
-+class SyncRunnable1 : public nsRunnable
++namespace {
++
++// Traits class for a reference type, specialized for parameters which are
++// already references.
++template<typename T>
++struct RefType
++{
++  typedef T& type;
++};
++
++template<>
++struct RefType<nsAString&>
++{
++  typedef nsAString& type;
++};
++
++template<>
++struct RefType<const nsAString&>
++{
++  typedef const nsAString& type;
++};
++
++template<>
++struct RefType<nsACString&>
++{
++  typedef nsACString& type;
++};
++
++template<>
++struct RefType<const nsACString&>
++{
++  typedef const nsACString& type;
++};
++
++template<>
++struct RefType<const nsIID&>
++{
++  typedef const nsIID& type;
++};
++
++class SyncRunnableBase : public nsRunnable
 +{
 +public:
-+  typedef nsresult (Receiver::*ReceiverMethod)(Arg1);
++  nsresult Result() {
++    return mResult;
++  }
++
++  mozilla::Monitor& Monitor() {
++    return mMonitor;
++  }
++
++protected:
++  SyncRunnableBase()
++    : mResult(NS_ERROR_UNEXPECTED)
++    , mMonitor("SyncRunnableBase")
++  { }
++
++  nsresult mResult;
++  mozilla::Monitor mMonitor;
++};
++
++template<typename Receiver, typename Arg1>
++class SyncRunnable1 : public SyncRunnableBase
++{
++public:
++  typedef nsresult (NS_STDCALL Receiver::*ReceiverMethod)(Arg1);
++  typedef typename RefType<Arg1>::type Arg1Ref;
 +
 +  SyncRunnable1(Receiver* receiver, ReceiverMethod method,
-+                Arg1& arg1)
++                Arg1Ref arg1)
 +    : mReceiver(receiver)
 +    , mMethod(method)
 +    , mArg1(arg1)
 +  { }
 +
 +  NS_IMETHOD Run() {
-+    return (mReceiver->*mMethod)(mArg1);
++    mResult = (mReceiver->*mMethod)(mArg1);
++    mozilla::MonitorAutoLock(mMonitor).Notify();
++    return NS_OK;
 +  }
 +
 +private:
 +  Receiver* mReceiver;
 +  ReceiverMethod mMethod;
-+  Arg1& mArg1;
++  Arg1Ref mArg1;
 +};
 +
 +template<typename Receiver, typename Arg1, typename Arg2>
-+class SyncRunnable2 : public nsRunnable
++class SyncRunnable2 : public SyncRunnableBase
 +{
 +public:
-+  typedef nsresult (Receiver::*ReceiverMethod)(Arg1, Arg2);
++  typedef nsresult (NS_STDCALL Receiver::*ReceiverMethod)(Arg1, Arg2);
++  typedef typename RefType<Arg1>::type Arg1Ref;
++  typedef typename RefType<Arg2>::type Arg2Ref;
 +
 +  SyncRunnable2(Receiver* receiver, ReceiverMethod method,
-+                Arg1& arg1, Arg2& arg2)
++                Arg1Ref arg1, Arg2Ref arg2)
 +    : mReceiver(receiver)
 +    , mMethod(method)
 +    , mArg1(arg1)
 +    , mArg2(arg2)
 +  { }
 +
 +  NS_IMETHOD Run() {
-+    return (mReceiver->*mMethod)(mArg1, mArg2);
++    mResult = (mReceiver->*mMethod)(mArg1, mArg2);
++    mozilla::MonitorAutoLock(mMonitor).Notify();
++    return NS_OK;
 +  }
 +
 +private:
 +  Receiver* mReceiver;
 +  ReceiverMethod mMethod;
-+  Arg1& mArg1;
-+  Arg2& mArg2;
++  Arg1Ref mArg1;
++  Arg2Ref mArg2;
 +};
 +
 +template<typename Receiver, typename Arg1, typename Arg2, typename Arg3>
-+class SyncRunnable3 : public nsRunnable
++class SyncRunnable3 : public SyncRunnableBase
 +{
 +public:
-+  typedef nsresult (Receiver::*ReceiverMethod)(Arg1, Arg2, Arg3);
++  typedef nsresult (NS_STDCALL Receiver::*ReceiverMethod)(Arg1, Arg2, Arg3);
++  typedef typename RefType<Arg1>::type Arg1Ref;
++  typedef typename RefType<Arg2>::type Arg2Ref;
++  typedef typename RefType<Arg3>::type Arg3Ref;
 +
 +  SyncRunnable3(Receiver* receiver, ReceiverMethod method,
-+                Arg1& arg1, Arg2& arg2, Arg3& arg3)
++                Arg1Ref arg1, Arg2Ref arg2, Arg3Ref arg3)
 +    : mReceiver(receiver)
 +    , mMethod(method)
 +    , mArg1(arg1)
 +    , mArg2(arg2)
 +    , mArg3(arg3)
 +  { }
 +
 +  NS_IMETHOD Run() {
-+    return (mReceiver->*mMethod)(mArg1, mArg2, mArg3);
++    mResult = (mReceiver->*mMethod)(mArg1, mArg2, mArg3);
++    mozilla::MonitorAutoLock(mMonitor).Notify();
++    return NS_OK;
 +  }
 +
 +private:
 +  Receiver* mReceiver;
 +  ReceiverMethod mMethod;
-+  Arg1& mArg1;
-+  Arg2& mArg2;
-+  Arg3& mArg3;
++  Arg1Ref mArg1;
++  Arg2Ref mArg2;
++  Arg3Ref mArg3;
 +};
 +
 +template<typename Receiver, typename Arg1, typename Arg2, typename Arg3,
 +         typename Arg4>
-+class SyncRunnable4 : public nsRunnable
++class SyncRunnable4 : public SyncRunnableBase
 +{
 +public:
-+  typedef nsresult (Receiver::*ReceiverMethod)(Arg1, Arg2, Arg3, Arg4);
++  typedef nsresult (NS_STDCALL Receiver::*ReceiverMethod)(Arg1, Arg2, Arg3, Arg4);
++  typedef typename RefType<Arg1>::type Arg1Ref;
++  typedef typename RefType<Arg2>::type Arg2Ref;
++  typedef typename RefType<Arg3>::type Arg3Ref;
++  typedef typename RefType<Arg4>::type Arg4Ref;
 +
 +  SyncRunnable4(Receiver* receiver, ReceiverMethod method,
-+                Arg1& arg1, Arg2& arg2, Arg3& arg3, Arg4& arg4)
++                Arg1Ref arg1, Arg2Ref arg2, Arg3Ref arg3, Arg4Ref arg4)
 +    : mReceiver(receiver)
 +    , mMethod(method)
 +    , mArg1(arg1)
 +    , mArg2(arg2)
 +    , mArg3(arg3)
 +    , mArg4(arg4)
 +  { }
 +
 +  NS_IMETHOD Run() {
-+    return (mReceiver->*mMethod)(mArg1, mArg2, mArg3, mArg4);
++    mResult = (mReceiver->*mMethod)(mArg1, mArg2, mArg3, mArg4);
++    mozilla::MonitorAutoLock(mMonitor).Notify();
++    return NS_OK;
 +  }
 +
 +private:
 +  Receiver* mReceiver;
 +  ReceiverMethod mMethod;
-+  Arg1& mArg1;
-+  Arg2& mArg2;
-+  Arg3& mArg3;
-+  Arg4& mArg4;
++  Arg1Ref mArg1;
++  Arg2Ref mArg2;
++  Arg3Ref mArg3;
++  Arg4Ref mArg4;
 +};
 +
 +template<typename Receiver, typename Arg1, typename Arg2, typename Arg3,
 +         typename Arg4, typename Arg5>
-+class SyncRunnable5 : public nsRunnable
++class SyncRunnable5 : public SyncRunnableBase
 +{
 +public:
-+  typedef nsresult (Receiver::*ReceiverMethod)(Arg1, Arg2, Arg3, Arg4, Arg5);
++  typedef nsresult (NS_STDCALL Receiver::*ReceiverMethod)(Arg1, Arg2, Arg3, Arg4, Arg5);
++  typedef typename RefType<Arg1>::type Arg1Ref;
++  typedef typename RefType<Arg2>::type Arg2Ref;
++  typedef typename RefType<Arg3>::type Arg3Ref;
++  typedef typename RefType<Arg4>::type Arg4Ref;
++  typedef typename RefType<Arg5>::type Arg5Ref;
 +
 +  SyncRunnable5(Receiver* receiver, ReceiverMethod method,
-+                Arg1& arg1, Arg2& arg2, Arg3& arg3, Arg4& arg4, Arg5& arg5)
++                Arg1Ref arg1, Arg2Ref arg2, Arg3Ref arg3, Arg4Ref arg4, Arg5Ref arg5)
 +    : mReceiver(receiver)
 +    , mMethod(method)
 +    , mArg1(arg1)
 +    , mArg2(arg2)
 +    , mArg3(arg3)
 +    , mArg4(arg4)
 +    , mArg5(arg5)
 +  { }
 +
 +  NS_IMETHOD Run() {
-+    return (mReceiver->*mMethod)(mArg1, mArg2, mArg3, mArg4, mArg5);
++    mResult = (mReceiver->*mMethod)(mArg1, mArg2, mArg3, mArg4, mArg5);
++    mozilla::MonitorAutoLock(mMonitor).Notify();
++    return NS_OK;
 +  }
 +
 +private:
 +  Receiver* mReceiver;
 +  ReceiverMethod mMethod;
-+  Arg1& mArg1;
-+  Arg2& mArg2;
-+  Arg3& mArg3;
-+  Arg4& mArg4;
-+  Arg5& mArg5;
++  Arg1Ref mArg1;
++  Arg2Ref mArg2;
++  Arg3Ref mArg3;
++  Arg4Ref mArg4;
++  Arg5Ref mArg5;
 +};
 +
 +template<typename Receiver, typename Arg1, typename Arg2, typename Arg3,
 +         typename Arg4, typename Arg5, typename Arg6>
-+class SyncRunnable6 : public nsRunnable
++class SyncRunnable6 : public SyncRunnableBase
 +{
 +public:
-+  typedef nsresult (Receiver::*ReceiverMethod)(Arg1, Arg2, Arg3, Arg4, Arg5,
++  typedef nsresult (NS_STDCALL Receiver::*ReceiverMethod)(Arg1, Arg2, Arg3, Arg4, Arg5,
 +                                               Arg6);
++  typedef typename RefType<Arg1>::type Arg1Ref;
++  typedef typename RefType<Arg2>::type Arg2Ref;
++  typedef typename RefType<Arg3>::type Arg3Ref;
++  typedef typename RefType<Arg4>::type Arg4Ref;
++  typedef typename RefType<Arg5>::type Arg5Ref;
++  typedef typename RefType<Arg6>::type Arg6Ref;
 +
 +  SyncRunnable6(Receiver* receiver, ReceiverMethod method,
-+                Arg1& arg1, Arg2& arg2, Arg3& arg3, Arg4& arg4, Arg5& arg5,
-+                Arg6& arg6)
++                Arg1Ref arg1, Arg2Ref arg2, Arg3Ref arg3, Arg4Ref arg4, Arg5Ref arg5,
++                Arg6Ref arg6)
 +    : mReceiver(receiver)
 +    , mMethod(method)
 +    , mArg1(arg1)
 +    , mArg2(arg2)
 +    , mArg3(arg3)
 +    , mArg4(arg4)
 +    , mArg5(arg5)
 +    , mArg6(arg6)
 +  { }
 +
 +  NS_IMETHOD Run() {
-+    return (mReceiver->*mMethod)(mArg1, mArg2, mArg3, mArg4, mArg5, mArg6);
++    mResult = (mReceiver->*mMethod)(mArg1, mArg2, mArg3, mArg4, mArg5, mArg6);
++    mozilla::MonitorAutoLock(mMonitor).Notify();
++    return NS_OK;
 +  }
 +
 +private:
 +  Receiver* mReceiver;
 +  ReceiverMethod mMethod;
-+  Arg1& mArg1;
-+  Arg2& mArg2;
-+  Arg3& mArg3;
-+  Arg4& mArg4;
-+  Arg5& mArg5;
-+  Arg6& mArg6;
++  Arg1Ref mArg1;
++  Arg2Ref mArg2;
++  Arg3Ref mArg3;
++  Arg4Ref mArg4;
++  Arg5Ref mArg5;
++  Arg6Ref mArg6;
 +};
 +
 +template<typename Receiver, typename Arg1, typename Arg2, typename Arg3,
 +         typename Arg4, typename Arg5, typename Arg6, typename Arg7>
-+class SyncRunnable7 : public nsRunnable
++class SyncRunnable7 : public SyncRunnableBase
 +{
 +public:
-+  typedef nsresult (Receiver::*ReceiverMethod)(Arg1, Arg2, Arg3, Arg4, Arg5,
++  typedef nsresult (NS_STDCALL Receiver::*ReceiverMethod)(Arg1, Arg2, Arg3, Arg4, Arg5,
 +                                               Arg6, Arg7);
++  typedef typename RefType<Arg1>::type Arg1Ref;
++  typedef typename RefType<Arg2>::type Arg2Ref;
++  typedef typename RefType<Arg3>::type Arg3Ref;
++  typedef typename RefType<Arg4>::type Arg4Ref;
++  typedef typename RefType<Arg5>::type Arg5Ref;
++  typedef typename RefType<Arg6>::type Arg6Ref;
++  typedef typename RefType<Arg7>::type Arg7Ref;
 +
 +  SyncRunnable7(Receiver* receiver, ReceiverMethod method,
-+                Arg1& arg1, Arg2& arg2, Arg3& arg3, Arg4& arg4, Arg5& arg5,
-+                Arg6& arg6, Arg7& arg7)
++                Arg1Ref arg1, Arg2Ref arg2, Arg3Ref arg3, Arg4Ref arg4, Arg5Ref arg5,
++                Arg6Ref arg6, Arg7Ref arg7)
 +    : mReceiver(receiver)
 +    , mMethod(method)
 +    , mArg1(arg1)
 +    , mArg2(arg2)
 +    , mArg3(arg3)
 +    , mArg4(arg4)
 +    , mArg5(arg5)
 +    , mArg6(arg6)
 +    , mArg7(arg7)
 +  { }
 +
 +  NS_IMETHOD Run() {
-+    return (mReceiver->*mMethod)(mArg1, mArg2, mArg3, mArg4, mArg5, mArg6,
-+                                 mArg7);
++    mResult = (mReceiver->*mMethod)(mArg1, mArg2, mArg3, mArg4, mArg5, mArg6, mArg7);
++    mozilla::MonitorAutoLock(mMonitor).Notify();
++    return NS_OK;
 +  }
 +
 +private:
 +  Receiver* mReceiver;
 +  ReceiverMethod mMethod;
-+  Arg1& mArg1;
-+  Arg2& mArg2;
-+  Arg3& mArg3;
-+  Arg4& mArg4;
-+  Arg5& mArg5;
-+  Arg6& mArg6;
-+  Arg7& mArg7;
++  Arg1Ref mArg1;
++  Arg2Ref mArg2;
++  Arg3Ref mArg3;
++  Arg4Ref mArg4;
++  Arg5Ref mArg5;
++  Arg6Ref mArg6;
++  Arg7Ref mArg7;
 +};
 +
 +template<typename Receiver, typename Arg1, typename Arg2, typename Arg3,
 +         typename Arg4, typename Arg5, typename Arg6, typename Arg7,
 +         typename Arg8>
-+class SyncRunnable8 : public nsRunnable
++class SyncRunnable8 : public SyncRunnableBase
 +{
 +public:
-+  typedef nsresult (Receiver::*ReceiverMethod)(Arg1, Arg2, Arg3, Arg4, Arg5,
++  typedef nsresult (NS_STDCALL Receiver::*ReceiverMethod)(Arg1, Arg2, Arg3, Arg4, Arg5,
 +                                               Arg6, Arg7, Arg8);
++  typedef typename RefType<Arg1>::type Arg1Ref;
++  typedef typename RefType<Arg2>::type Arg2Ref;
++  typedef typename RefType<Arg3>::type Arg3Ref;
++  typedef typename RefType<Arg4>::type Arg4Ref;
++  typedef typename RefType<Arg5>::type Arg5Ref;
++  typedef typename RefType<Arg6>::type Arg6Ref;
++  typedef typename RefType<Arg7>::type Arg7Ref;
++  typedef typename RefType<Arg8>::type Arg8Ref;
 +
 +  SyncRunnable8(Receiver* receiver, ReceiverMethod method,
-+                Arg1& arg1, Arg2& arg2, Arg3& arg3, Arg4& arg4, Arg5& arg5,
-+                Arg6& arg6, Arg7& arg7, Arg8& arg8)
++                Arg1Ref arg1, Arg2Ref arg2, Arg3Ref arg3, Arg4Ref arg4, Arg5Ref arg5,
++                Arg6Ref arg6, Arg7Ref arg7, Arg8Ref arg8)
 +    : mReceiver(receiver)
 +    , mMethod(method)
 +    , mArg1(arg1)
 +    , mArg2(arg2)
 +    , mArg3(arg3)
 +    , mArg4(arg4)
 +    , mArg5(arg5)
 +    , mArg6(arg6)
 +    , mArg7(arg7)
 +    , mArg8(arg8)
 +  { }
 +
 +  NS_IMETHOD Run() {
-+    return (mReceiver->*mMethod)(mArg1, mArg2, mArg3, mArg4, mArg5, mArg6,
-+                                 mArg7, mArg8);
++    mResult = (mReceiver->*mMethod)(mArg1, mArg2, mArg3, mArg4, mArg5, mArg6, mArg7, mArg8);
++    mozilla::MonitorAutoLock(mMonitor).Notify();
++    return NS_OK;
 +  }
 +
 +private:
 +  Receiver* mReceiver;
 +  ReceiverMethod mMethod;
-+  Arg1& mArg1;
-+  Arg2& mArg2;
-+  Arg3& mArg3;
-+  Arg4& mArg4;
-+  Arg5& mArg5;
-+  Arg6& mArg6;
-+  Arg7& mArg7;
-+  Arg8& mArg8;
++  Arg1Ref mArg1;
++  Arg2Ref mArg2;
++  Arg3Ref mArg3;
++  Arg4Ref mArg4;
++  Arg5Ref mArg5;
++  Arg6Ref mArg6;
++  Arg7Ref mArg7;
++  Arg8Ref mArg8;
 +};
 +
 +template<typename Receiver, typename Arg1, typename Arg2, typename Arg3,
 +         typename Arg4, typename Arg5, typename Arg6, typename Arg7,
 +         typename Arg8, typename Arg9>
-+class SyncRunnable9 : public nsRunnable
++class SyncRunnable9 : public SyncRunnableBase
 +{
 +public:
-+  typedef nsresult (Receiver::*ReceiverMethod)(Arg1, Arg2, Arg3, Arg4, Arg5,
++  typedef nsresult (NS_STDCALL Receiver::*ReceiverMethod)(Arg1, Arg2, Arg3, Arg4, Arg5,
 +                                               Arg6, Arg7, Arg8, Arg9);
++  typedef typename RefType<Arg1>::type Arg1Ref;
++  typedef typename RefType<Arg2>::type Arg2Ref;
++  typedef typename RefType<Arg3>::type Arg3Ref;
++  typedef typename RefType<Arg4>::type Arg4Ref;
++  typedef typename RefType<Arg5>::type Arg5Ref;
++  typedef typename RefType<Arg6>::type Arg6Ref;
++  typedef typename RefType<Arg7>::type Arg7Ref;
++  typedef typename RefType<Arg8>::type Arg8Ref;
++  typedef typename RefType<Arg9>::type Arg9Ref;
 +
 +  SyncRunnable9(Receiver* receiver, ReceiverMethod method,
-+                Arg1& arg1, Arg2& arg2, Arg3& arg3, Arg4& arg4, Arg5& arg5,
-+                Arg6& arg6, Arg7& arg7, Arg8& arg8, Arg9& arg9)
++                Arg1Ref arg1, Arg2Ref arg2, Arg3Ref arg3, Arg4Ref arg4, Arg5Ref arg5,
++                Arg6Ref arg6, Arg7Ref arg7, Arg8Ref arg8, Arg9Ref arg9)
 +    : mReceiver(receiver)
 +    , mMethod(method)
 +    , mArg1(arg1)
 +    , mArg2(arg2)
 +    , mArg3(arg3)
 +    , mArg4(arg4)
 +    , mArg5(arg5)
 +    , mArg6(arg6)
 +    , mArg7(arg7)
 +    , mArg8(arg8)
 +    , mArg9(arg9)
 +  { }
 +
 +  NS_IMETHOD Run() {
-+    return (mReceiver->*mMethod)(mArg1, mArg2, mArg3, mArg4, mArg5, mArg6,
-+                                 mArg7, mArg8, mArg9);
++    mResult = (mReceiver->*mMethod)(mArg1, mArg2, mArg3, mArg4, mArg5, mArg6, mArg7, mArg8, mArg9);
++    mozilla::MonitorAutoLock(mMonitor).Notify();
++    return NS_OK;
 +  }
 +
 +private:
 +  Receiver* mReceiver;
 +  ReceiverMethod mMethod;
-+  Arg1& mArg1;
-+  Arg2& mArg2;
-+  Arg3& mArg3;
-+  Arg4& mArg4;
-+  Arg5& mArg5;
-+  Arg6& mArg6;
-+  Arg7& mArg7;
-+  Arg8& mArg8;
-+  Arg9& mArg9;
++  Arg1Ref mArg1;
++  Arg2Ref mArg2;
++  Arg3Ref mArg3;
++  Arg4Ref mArg4;
++  Arg5Ref mArg5;
++  Arg6Ref mArg6;
++  Arg7Ref mArg7;
++  Arg8Ref mArg8;
++  Arg9Ref mArg9;
 +};
 +
++nsresult
++DispatchSyncRunnable(SyncRunnableBase* r)
++{
++  if (NS_IsMainThread()) {
++    r->Run();
++  }
++  else {
++    mozilla::MonitorAutoLock lock(r->Monitor());
++    nsresult rv = NS_DispatchToMainThread(r);
++    if (NS_FAILED(rv))
++      return rv;
++    lock.Wait();
++  }
++  return r->Result();
++}
++
++} // anonymous namespace
++
 +#define NS_SYNCRUNNABLEMETHOD1(iface, method,                       \
 +                               arg1)                                \
 +  NS_IMETHODIMP iface##Proxy::method(arg1 a1) {                     \
-+    nsCOMPtr<nsIRunnable> r =                                       \
++    nsRefPtr<SyncRunnableBase> r =                                  \
 +      new SyncRunnable1<nsI##iface, arg1>                           \
 +      (mReceiver, &nsI##iface::method, a1);                         \
-+    return NS_DispatchToMainThread(r, NS_DISPATCH_SYNC);            \
++    return DispatchSyncRunnable(r);                                 \
 +  }
 +
 +#define NS_SYNCRUNNABLEMETHOD2(iface, method,                       \
 +                               arg1, arg2)                          \
 +  NS_IMETHODIMP iface##Proxy::method(arg1 a1, arg2 a2) {            \
-+    nsCOMPtr<nsIRunnable> r =                                       \
++    nsRefPtr<SyncRunnableBase> r =                                  \
 +      new SyncRunnable2<nsI##iface, arg1, arg2>                     \
 +      (mReceiver, &nsI##iface::method, a1, a2);                     \
-+    return NS_DispatchToMainThread(r, NS_DISPATCH_SYNC);            \
++    return DispatchSyncRunnable(r);                                 \
 +  }
 +
 +#define NS_SYNCRUNNABLEMETHOD3(iface, method,                       \
 +                               arg1, arg2, arg3)                    \
 +  NS_IMETHODIMP iface##Proxy::method(arg1 a1, arg2 a2, arg3 a3) {   \
-+    nsCOMPtr<nsIRunnable> r =                                       \
++    nsRefPtr<SyncRunnableBase> r =                                  \
 +      new SyncRunnable3<nsI##iface, arg1, arg2, arg3>               \
 +      (mReceiver, &nsI##iface::method,                              \
 +       a1, a2, a3);                                                 \
-+    return NS_DispatchToMainThread(r, NS_DISPATCH_SYNC);            \
++    return DispatchSyncRunnable(r);                                 \
 +  }
 +
 +#define NS_SYNCRUNNABLEMETHOD4(iface, method,                       \
 +                               arg1, arg2, arg3, arg4)              \
 +  NS_IMETHODIMP iface##Proxy::method(arg1 a1, arg2 a2, arg3 a3, arg4 a4) { \
-+    nsCOMPtr<nsIRunnable> r =                                       \
++    nsRefPtr<SyncRunnableBase> r =                                  \
 +      new SyncRunnable4<nsI##iface, arg1, arg2, arg3, arg4>         \
 +      (mReceiver, &nsI##iface::method,                              \
 +       a1, a2, a3, a4);                                             \
-+    return NS_DispatchToMainThread(r, NS_DISPATCH_SYNC);            \
++    return DispatchSyncRunnable(r);                                 \
 +  }
 +
 +#define NS_SYNCRUNNABLEMETHOD5(iface, method,                       \
 +                               arg1, arg2, arg3, arg4, arg5)        \
 +  NS_IMETHODIMP iface##Proxy::method(arg1 a1, arg2 a2, arg3 a3, arg4 a4, arg5 a5) {   \
-+    nsCOMPtr<nsIRunnable> r =                                       \
++    nsRefPtr<SyncRunnableBase> r =                                  \
 +      new SyncRunnable5<nsI##iface, arg1, arg2, arg3, arg4, arg5>   \
 +      (mReceiver, &nsI##iface::method,                              \
 +       a1, a2, a3, a4, a5);                                         \
-+    return NS_DispatchToMainThread(r, NS_DISPATCH_SYNC);            \
++    return DispatchSyncRunnable(r);                                 \
 +  }
 +
 +#define NS_SYNCRUNNABLEMETHOD6(iface, method,                       \
 +                               arg1, arg2, arg3, arg4, arg5, arg6)  \
 +  NS_IMETHODIMP iface##Proxy::method(arg1 a1, arg2 a2, arg3 a3, arg4 a4, arg5 a5, arg6 a6) { \
-+    nsCOMPtr<nsIRunnable> r =                                       \
++    nsRefPtr<SyncRunnableBase> r =                                  \
 +      new SyncRunnable6<nsI##iface, arg1, arg2, arg3, arg4, arg5, arg6> \
 +      (mReceiver, &nsI##iface::method,                              \
 +       a1, a2, a3, a4, a5, a6);                                     \
-+    return NS_DispatchToMainThread(r, NS_DISPATCH_SYNC);            \
++    return DispatchSyncRunnable(r);                                 \
 +  }
 +
 +#define NS_SYNCRUNNABLEMETHOD7(iface, method,                       \
 +                               arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
 +  NS_IMETHODIMP iface##Proxy::method(arg1 a1, arg2 a2, arg3 a3, arg4 a4, arg5 a5, arg6 a6, arg7 a7) { \
-+    nsCOMPtr<nsIRunnable> r =                                       \
++    nsRefPtr<SyncRunnableBase> r =                                  \
 +      new SyncRunnable7<nsI##iface, arg1, arg2, arg3, arg4, arg5, arg6, arg7> \
 +      (mReceiver, &nsI##iface::method,                              \
 +       a1, a2, a3, a4, a5, a6, a7);                                 \
-+    return NS_DispatchToMainThread(r, NS_DISPATCH_SYNC);            \
++    return DispatchSyncRunnable(r);                                 \
 +  }
 +
 +#define NS_SYNCRUNNABLEMETHOD8(iface, method,                       \
 +                               arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
 +  NS_IMETHODIMP iface##Proxy::method(arg1 a1, arg2 a2, arg3 a3, arg4 a4, arg5 a5, arg6 a6, arg7 a7, arg8 a8) { \
-+    nsCOMPtr<nsIRunnable> r =                                       \
++    nsRefPtr<SyncRunnableBase> r =                                  \
 +      new SyncRunnable8<nsI##iface, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8> \
 +      (mReceiver, &nsI##iface::method,                              \
 +       a1, a2, a3, a4, a5, a6, a7, a8);                             \
-+    return NS_DispatchToMainThread(r, NS_DISPATCH_SYNC);            \
++    return DispatchSyncRunnable(r);                                 \
 +  }
 +
 +#define NS_SYNCRUNNABLEMETHOD9(iface, method,                       \
 +                               arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \
 +  NS_IMETHODIMP iface##Proxy::method(arg1 a1, arg2 a2, arg3 a3, arg4 a4, arg5 a5, arg6 a6, arg7 a7, arg8 a8, arg9 a9) { \
-+    nsCOMPtr<nsIRunnable> r =                                       \
++    nsRefPtr<SyncRunnableBase> r =                                  \
 +      new SyncRunnable9<nsI##iface, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9> \
 +        (mReceiver, &nsI##iface::method,                            \
 +         a1, a2, a3, a4, a5, a6, a7, a8, a9);                       \
-+    return NS_DispatchToMainThread(r, NS_DISPATCH_SYNC);            \
++    return DispatchSyncRunnable(r);                                 \
 +  }
 +
 +#define NS_NOTIMPLEMENTED \
 +  { NS_RUNTIMEABORT("Not implemented"); return NS_ERROR_UNEXPECTED; }
 +
 +NS_SYNCRUNNABLEMETHOD3(Observer, Observe,
 +                       nsISupports*, const char*, const PRUnichar*)
 +
new file mode 100644
--- /dev/null
+++ b/bug675221-partG-define-HAS_STDCALL
@@ -0,0 +1,23 @@
+# HG changeset patch
+# Parent 4c57c0dc34c99963b2fda73fd3a5b7fb27b235a1
+diff --git a/configure.in b/configure.in
+--- a/configure.in
++++ b/configure.in
+@@ -937,16 +937,17 @@ if test -n "$_WIN32_MSVC"; then
+     SKIP_COMPILER_CHECKS=1
+     SKIP_LIBRARY_CHECKS=1
+ 
+     # Since we're skipping compiler and library checks, hard-code
+     # some facts here.
+     AC_DEFINE(HAVE_IO_H)
+     AC_DEFINE(HAVE_SETBUF)
+     AC_DEFINE(HAVE_ISATTY)
++    AC_DEFINE(HAVE_STDCALL)
+ fi
+ 
+ fi # COMPILE_ENVIRONMENT
+ 
+ AC_SUBST(MIDL_FLAGS)
+ AC_SUBST(_MSC_VER)
+ 
+ AC_SUBST(GNU_AS)
--- a/series
+++ b/series
@@ -1,6 +1,7 @@
 bug675221-partA-xpcom
 bug675221-partB-unimplement
 bug675221-partC-necko
 bug675221-partD-urlclassifier
 bug675221-partE-domstorage
 bug675221-partF-psm
+bug675221-partG-define-HAS_STDCALL