Bug 1068393 - assume camera permission for certified apps (saves ~100ms on Flame), r=fabrice
authorMike Habicher <mikeh@mozilla.com>
Tue, 28 Oct 2014 11:54:38 -0400
changeset 212750 3f19cf6d0e622925c0e3d28cdd3bad80814940c8
parent 212749 79a8f2de3b33cb68d84e87f54887a1ed5313f8db
child 212751 dc5d3f90fe50adbab7b0251dba035544d712256e
push id51042
push userryanvm@gmail.com
push dateTue, 28 Oct 2014 20:25:03 +0000
treeherdermozilla-inbound@53d84829b2b8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs1068393
milestone36.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 1068393 - assume camera permission for certified apps (saves ~100ms on Flame), r=fabrice
dom/camera/DOMCameraManager.cpp
--- a/dom/camera/DOMCameraManager.cpp
+++ b/dom/camera/DOMCameraManager.cpp
@@ -306,16 +306,24 @@ nsDOMCameraManager::GetCamera(const nsAS
 
   nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(mWindow);
   if (!sop) {
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return nullptr;
   }
 
   nsCOMPtr<nsIPrincipal> principal = sop->GetPrincipal();
+  // If we are a CERTIFIED app, we can short-circuit the permission check,
+  // which gets us a performance win.
+  uint16_t status = nsIPrincipal::APP_STATUS_NOT_INSTALLED;
+  principal->GetAppStatus(&status);
+  if (status == nsIPrincipal::APP_STATUS_CERTIFIED && CheckPermission(mWindow)) {
+    PermissionAllowed(cameraId, aInitialConfig, successCallback, errorCallback, promise);
+    return promise.forget();
+  }
 
   nsCOMPtr<nsIRunnable> permissionRequest =
     new CameraPermissionRequest(principal, mWindow, this, cameraId, aInitialConfig,
                                 successCallback, errorCallback, promise);
 
   NS_DispatchToMainThread(permissionRequest);
   return promise.forget();
 }