Bug 1367885: Backed out changeset 3f6e08c5233f for bc4 bustage on a CLOSED TREE; r=backout
authorAaron Klotz <aklotz@mozilla.com>
Mon, 05 Jun 2017 12:51:52 -0600
changeset 362397 ab4ef8ca799e413049ff66c26328f409b15eb223
parent 362396 fc854def3953aed24632eb910aa568702d67a522
child 362398 f904e3d130ab951280c19ab2f32384fe30374bce
push id31976
push userkwierso@gmail.com
push dateTue, 06 Jun 2017 00:34:17 +0000
treeherdermozilla-central@2c6289f56812 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1367885
milestone55.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 1367885: Backed out changeset 3f6e08c5233f for bc4 bustage on a CLOSED TREE; r=backout MozReview-Commit-ID: 4CDliBImLR7
ipc/mscom/Interceptor.cpp
ipc/mscom/Interceptor.h
--- a/ipc/mscom/Interceptor.cpp
+++ b/ipc/mscom/Interceptor.cpp
@@ -20,41 +20,42 @@
 #include "nsDirectoryServiceUtils.h"
 #include "nsThreadUtils.h"
 
 namespace mozilla {
 namespace mscom {
 
 /* static */ HRESULT
 Interceptor::Create(STAUniquePtr<IUnknown> aTarget, IInterceptorSink* aSink,
-                    REFIID aInitialIid, void** aOutInterface)
+                    REFIID aIid, void** aOutput)
 {
-  MOZ_ASSERT(aOutInterface && aTarget && aSink);
-  if (!aOutInterface) {
+  MOZ_ASSERT(aOutput && aTarget && aSink);
+  if (!aOutput) {
     return E_INVALIDARG;
   }
 
-  *aOutInterface = nullptr;
+  *aOutput = nullptr;
 
   if (!aTarget || !aSink) {
     return E_INVALIDARG;
   }
 
-  RefPtr<Interceptor> intcpt(new Interceptor(aSink));
-  return intcpt->GetInitialInterceptorForIID(aInitialIid, Move(aTarget),
-                                             aOutInterface);
+  RefPtr<WeakReferenceSupport> intcpt(new Interceptor(Move(aTarget), aSink));
+  return intcpt->QueryInterface(aIid, aOutput);
 }
 
-Interceptor::Interceptor(IInterceptorSink* aSink)
+Interceptor::Interceptor(STAUniquePtr<IUnknown> aTarget, IInterceptorSink* aSink)
   : WeakReferenceSupport(WeakReferenceSupport::Flags::eDestroyOnMainThread)
+  , mTarget(Move(aTarget))
   , mEventSink(aSink)
   , mMutex("mozilla::mscom::Interceptor::mMutex")
   , mStdMarshal(nullptr)
 {
   MOZ_ASSERT(aSink);
+  MOZ_ASSERT(!IsProxy(mTarget.get()));
   RefPtr<IWeakReference> weakRef;
   if (SUCCEEDED(GetWeakReference(getter_AddRefs(weakRef)))) {
     aSink->SetInterceptor(weakRef);
   }
 }
 
 Interceptor::~Interceptor()
 {
@@ -199,65 +200,16 @@ Interceptor::CreateInterceptor(REFIID aI
                                       (void**)aOutput);
   // If this assert fires then the interceptor doesn't like something about
   // the format of the typelib. One thing in particular that it doesn't like
   // is complex types that contain unions.
   MOZ_ASSERT(SUCCEEDED(hr));
   return hr;
 }
 
-HRESULT
-Interceptor::GetInitialInterceptorForIID(REFIID aTargetIid,
-                                         STAUniquePtr<IUnknown> aTarget,
-                                         void** aOutInterceptor)
-{
-  MOZ_ASSERT(aOutInterceptor);
-  MOZ_ASSERT(aTargetIid != IID_IUnknown && aTargetIid != IID_IMarshal);
-  MOZ_ASSERT(!IsProxy(aTarget.get()));
-
-  // Raise the refcount for stabilization purposes during aggregation
-  RefPtr<IUnknown> kungFuDeathGrip(static_cast<IUnknown*>(
-        static_cast<WeakReferenceSupport*>(this)));
-
-  RefPtr<IUnknown> unkInterceptor;
-  HRESULT hr = CreateInterceptor(aTargetIid, kungFuDeathGrip,
-                                 getter_AddRefs(unkInterceptor));
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  RefPtr<ICallInterceptor> interceptor;
-  hr = unkInterceptor->QueryInterface(IID_ICallInterceptor,
-                                      getter_AddRefs(interceptor));
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  hr = interceptor->RegisterSink(mEventSink);
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  // mTarget is a weak reference to aTarget. This is safe because we transfer
-  // ownership of aTarget into mInterceptorMap which remains live for the
-  // lifetime of this Interceptor.
-  mTarget = ToInterceptorTargetPtr(aTarget);
-
-  // Now we transfer aTarget's ownership into mInterceptorMap.
-  mInterceptorMap.AppendElement(MapEntry(aTargetIid,
-                                         unkInterceptor,
-                                         aTarget.release()));
-
-  if (mEventSink->MarshalAs(aTargetIid) == aTargetIid) {
-    return unkInterceptor->QueryInterface(aTargetIid, aOutInterceptor);
-  }
-
-  return GetInterceptorForIID(aTargetIid, aOutInterceptor);
-}
-
 /**
  * This method contains the core guts of the handling of QueryInterface calls
  * that are delegated to us from the ICallInterceptor.
  *
  * @param aIid ID of the desired interface
  * @param aOutInterceptor The resulting emulated vtable that corresponds to
  * the interface specified by aIid.
  */
--- a/ipc/mscom/Interceptor.h
+++ b/ipc/mscom/Interceptor.h
@@ -62,17 +62,17 @@ struct IInterceptor : public IUnknown
  */
 class Interceptor final : public WeakReferenceSupport
                         , public IStdMarshalInfo
                         , public IMarshal
                         , public IInterceptor
 {
 public:
   static HRESULT Create(STAUniquePtr<IUnknown> aTarget, IInterceptorSink* aSink,
-                        REFIID aInitialIid, void** aOutInterface);
+                        REFIID aIid, void** aOutput);
 
   // IUnknown
   STDMETHODIMP QueryInterface(REFIID riid, void** ppv) override;
   STDMETHODIMP_(ULONG) AddRef() override;
   STDMETHODIMP_(ULONG) Release() override;
 
   // IStdMarshalInfo
   STDMETHODIMP GetClassForHandler(DWORD aDestContext, void* aDestContextPtr,
@@ -107,29 +107,26 @@ private:
       , mTargetInterface(aTargetInterface)
     {}
     IID               mIID;
     RefPtr<IUnknown>  mInterceptor;
     IUnknown*         mTargetInterface;
   };
 
 private:
-  explicit Interceptor(IInterceptorSink* aSink);
+  Interceptor(STAUniquePtr<IUnknown> aTarget, IInterceptorSink* aSink);
   ~Interceptor();
-  HRESULT GetInitialInterceptorForIID(REFIID aTargetIid,
-                                      STAUniquePtr<IUnknown> aTarget,
-                                      void** aOutInterface);
   MapEntry* Lookup(REFIID aIid);
   HRESULT QueryInterfaceTarget(REFIID aIid, void** aOutput);
   HRESULT ThreadSafeQueryInterface(REFIID aIid,
                                    IUnknown** aOutInterface) override;
   HRESULT CreateInterceptor(REFIID aIid, IUnknown* aOuter, IUnknown** aOutput);
 
 private:
-  InterceptorTargetPtr<IUnknown>  mTarget;
+  STAUniquePtr<IUnknown>    mTarget;
   RefPtr<IInterceptorSink>  mEventSink;
   mozilla::Mutex            mMutex; // Guards mInterceptorMap
   // Using a nsTArray since the # of interfaces is not going to be very high
   nsTArray<MapEntry>        mInterceptorMap;
   RefPtr<IUnknown>          mStdMarshalUnk;
   IMarshal*                 mStdMarshal; // WEAK
 };