Bug 1416986 part 1: Allow an mscom Handler to signal that it knows an interface is definitely not available. r=aklotz
authorJames Teh <jteh@mozilla.com>
Wed, 15 Nov 2017 09:59:44 +1000
changeset 444590 5d45b7151b5c1f6773ea687eb5ae8876cf911721
parent 444589 ec7ff1ef12d3ebd507d8f690b7303e5e8fbaea8d
child 444591 0a2081375228a5e9bd8caea70e31282dc12f6887
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaklotz
bugs1416986
milestone59.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 1416986 part 1: Allow an mscom Handler to signal that it knows an interface is definitely not available. r=aklotz If QueryHandlerInterface returns E_NOINTERFACE, the proxy will be queried for the interface. However, the handler might know that the interface is definitely not available and could thus avoid a pointless cross-process call. To facilitate this, the handler can now return S_FALSE to signal that the proxy should not be queried, thus immediately returning E_NOINTERFACE to the client. MozReview-Commit-ID: 4RtBsA9BTOV
ipc/mscom/oop/Handler.cpp
ipc/mscom/oop/Handler.h
--- a/ipc/mscom/oop/Handler.cpp
+++ b/ipc/mscom/oop/Handler.cpp
@@ -69,16 +69,21 @@ Handler::InternalQueryInterface(REFIID r
   if (riid == IID_IMarshal) {
     RefPtr<IMarshal> ptr(this);
     ptr.forget(ppv);
     return S_OK;
   }
 
   // Try the handler implementation
   HRESULT hr = QueryHandlerInterface(mInnerUnk, riid, ppv);
+  if (hr == S_FALSE) {
+    // The handler knows this interface is not available, so don't bother
+    // asking the proxy.
+    return E_NOINTERFACE;
+  }
   if (hr != E_NOINTERFACE) {
     return hr;
   }
 
   // Now forward to the marshaler's inner
   return mInnerUnk->QueryInterface(riid, ppv);
 }
 
--- a/ipc/mscom/oop/Handler.h
+++ b/ipc/mscom/oop/Handler.h
@@ -47,17 +47,21 @@ public:
    * those interfaces that are exposed by the underlying COM proxy.
    * @param aProxyUnknown is the IUnknown of the underlying COM proxy. This is
    *                      provided to give the handler implementation an
    *                      opportunity to acquire interfaces to the underlying
    *                      remote object, if needed.
    * @param aIid Interface requested, similar to IUnknown::QueryInterface
    * @param aOutInterface Outparam for the resulting interface to return to the
    *                      client.
-   * @return The usual HRESULT codes similarly to IUnknown::QueryInterface
+   * @return The usual HRESULT codes similarly to IUnknown::QueryInterface.
+   *         If E_NOINTERFACE is returned, the proxy will be queried.
+   *         If the handler is certain that this interface is not available,
+   *         it can return S_FALSE to avoid querying the proxy. This will be
+   *         translated to E_NOINTERFACE before it is returned to the client.
    */
   virtual HRESULT QueryHandlerInterface(IUnknown* aProxyUnknown, REFIID aIid,
                                         void** aOutInterface) = 0;
   /**
    * Called when the implementer should deserialize data in aStream.
    * @return S_OK on success;
    *         S_FALSE if the deserialization was successful but there was no data;
    *         HRESULT error code otherwise.