Bug 1255867. Remove some unnecessary AutoJSAPI uses. r=bholley
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 11 Mar 2016 23:59:10 -0500
changeset 288402 79bf9cf6fc79be06cdd63abec65a375704e262ba
parent 288401 82e7e34cedc5698a219cc9275deafd7bdc2be9e1
child 288403 3e871f2d5b4bb29d788201568d68fe48a84113f9
push id30079
push userryanvm@gmail.com
push dateSat, 12 Mar 2016 20:24:19 +0000
treeherdermozilla-central@d1d47ba19ce9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1255867
milestone48.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 1255867. Remove some unnecessary AutoJSAPI uses. r=bholley
dom/browser-element/BrowserElementAudioChannel.cpp
dom/devicestorage/nsDeviceStorage.cpp
--- a/dom/browser-element/BrowserElementAudioChannel.cpp
+++ b/dom/browser-element/BrowserElementAudioChannel.cpp
@@ -21,16 +21,17 @@
 #include "nsIDOMDOMRequest.h"
 #include "nsIObserverService.h"
 #include "nsISupportsPrimitives.h"
 #include "nsISystemMessagesInternal.h"
 #include "nsITabParent.h"
 #include "nsNetUtil.h"
 #include "nsPIDOMWindow.h"
 #include "nsServiceManagerUtils.h"
+#include "nsContentUtils.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_ADDREF_INHERITED(BrowserElementAudioChannel, DOMEventTargetHelper)
 NS_IMPL_RELEASE_INHERITED(BrowserElementAudioChannel, DOMEventTargetHelper)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BrowserElementAudioChannel)
@@ -521,22 +522,17 @@ BrowserElementAudioChannel::NotifyChanne
 
     return request.forget().downcast<DOMRequest>();
   }
 
   nsCOMPtr<nsISystemMessagesInternal> systemMessenger =
     do_GetService("@mozilla.org/system-message-internal;1");
   MOZ_ASSERT(systemMessenger);
 
-  AutoJSAPI jsAPI;
-  if (!jsAPI.Init(GetOwner())) {
-    return nullptr;
-  }
-
-  JS::Rooted<JS::Value> value(jsAPI.cx());
+  JS::Rooted<JS::Value> value(nsContentUtils::RootingCxForThread());
   value.setInt32((uint32_t)mAudioChannel);
 
   nsCOMPtr<nsIURI> manifestURI;
   nsresult rv = NS_NewURI(getter_AddRefs(manifestURI), mManifestURL);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return nullptr;
   }
 
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -3929,24 +3929,18 @@ DeviceStorageRequestManager::Resolve(uin
     return NS_OK;
   }
 
   ListIndex i = Find(aId);
   if (NS_WARN_IF(i == mPending.Length())) {
     return NS_OK;
   }
 
-  nsIGlobalObject* global = mPending[i].mRequest->GetOwnerGlobal();
-
-  AutoJSAPI jsapi;
-  if (NS_WARN_IF(!jsapi.Init(global))) {
-    return RejectInternal(i, NS_LITERAL_STRING(POST_ERROR_EVENT_UNKNOWN));
-  }
-
-  JS::RootedValue value(jsapi.cx(), JS_NumberValue((double)aValue));
+  JS::RootedValue value(nsContentUtils::RootingCxForThread(),
+                        JS_NumberValue((double)aValue));
   return ResolveInternal(i, value);
 }
 
 nsresult
 DeviceStorageRequestManager::Resolve(uint32_t aId, DeviceStorageFile* aFile,
                                      bool aForceDispatch)
 {
   MOZ_ASSERT(aFile);