Bug 889778 - move NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY to the front of the QI, r=jst
authorMike Habicher <mikeh@mozilla.com>
Mon, 25 Aug 2014 11:14:49 -0400
changeset 201240 408786bfc72aeaa6ebb9d2df216326a95530693b
parent 201239 c99f0f778f7a9cc0ad1284dfbfe603eb69c9f58b
child 201241 5ffa6e21109cb90aec92cebae09db3c5205d578b
push id10019
push usermhabicher@mozilla.com
push dateMon, 25 Aug 2014 15:15:35 +0000
treeherderb2g-inbound@408786bfc72a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst
bugs889778
milestone34.0a1
Bug 889778 - move NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY to the front of the QI, r=jst
dom/camera/DOMCameraManager.cpp
--- a/dom/camera/DOMCameraManager.cpp
+++ b/dom/camera/DOMCameraManager.cpp
@@ -21,20 +21,20 @@
 #include "mozilla/dom/PermissionMessageUtils.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsDOMCameraManager, mWindow)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMCameraManager)
+  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
   NS_INTERFACE_MAP_ENTRY(nsIObserver)
-  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCameraManager)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCameraManager)
 
 /**
  * Global camera logging object
  *
@@ -111,17 +111,26 @@ nsDOMCameraManager::CreateInstance(nsPID
   if (!sActiveWindows) {
     sActiveWindows = new WindowTable();
   }
 
   nsRefPtr<nsDOMCameraManager> cameraManager =
     new nsDOMCameraManager(aWindow);
 
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
-  obs->AddObserver(cameraManager, "xpcom-shutdown", true);
+  if (!obs) {
+    DOM_CAMERA_LOGE("Camera manager failed to get observer service\n");
+    return nullptr;
+  }
+
+  nsresult rv = obs->AddObserver(cameraManager, "xpcom-shutdown", true);
+  if (NS_FAILED(rv)) {
+    DOM_CAMERA_LOGE("Camera manager failed to add 'xpcom-shutdown' observer (0x%x)\n", rv);
+    return nullptr;
+  }
 
   return cameraManager.forget();
 }
 
 class CameraPermissionRequest : public nsIContentPermissionRequest
                               , public nsIRunnable
 {
 public: