Bug 1143562. Part2 - only init |mStorageBaseDir| in the chrome process. r=cpearce
authorJW Wang <jwwang@mozilla.com>
Wed, 18 Mar 2015 19:15:00 +0100
changeset 234435 7a3da13b481426cc34d36d3978cd5afd189baffe
parent 234434 57f1dab3ca956d381f8de7d2965138a05579cae5
child 234436 c95b819aba41918c41be2afc8465c369c6faa20b
push id28446
push userkwierso@gmail.com
push dateFri, 20 Mar 2015 02:15:45 +0000
treeherderautoland@3257d9c4b257 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1143562
milestone39.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 1143562. Part2 - only init |mStorageBaseDir| in the chrome process. r=cpearce
dom/media/gmp/GMPService.cpp
dom/media/gmp/GMPService.h
--- a/dom/media/gmp/GMPService.cpp
+++ b/dom/media/gmp/GMPService.cpp
@@ -186,16 +186,37 @@ GeckoMediaPluginService::Init()
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(obsService->AddObserver(this, "mediakeys-request", false)));
 #endif
 
   nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
   if (prefs) {
     prefs->AddObserver("media.gmp.plugin.crash", this, false);
   }
 
+  nsresult rv = InitStorage();
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+
+  // Kick off scanning for plugins
+  nsCOMPtr<nsIThread> thread;
+  return GetThread(getter_AddRefs(thread));
+}
+
+
+nsresult
+GeckoMediaPluginService::InitStorage()
+{
+  MOZ_ASSERT(NS_IsMainThread());
+
+  // GMP storage should be used in the chrome process only.
+  if (XRE_GetProcessType() != GeckoProcessType_Default) {
+    return NS_OK;
+  }
+
   // Directory service is main thread only, so cache the profile dir here
   // so that we can use it off main thread.
 #ifdef MOZ_WIDGET_GONK
   nsresult rv = NS_NewLocalFile(NS_LITERAL_STRING("/data/b2g/mozilla"), false, getter_AddRefs(mStorageBaseDir));
 #else
   nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(mStorageBaseDir));
 #endif
 
@@ -208,19 +229,17 @@ GeckoMediaPluginService::Init()
     return rv;
   }
 
   rv = mStorageBaseDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
   if (NS_WARN_IF(NS_FAILED(rv) && rv != NS_ERROR_FILE_ALREADY_EXISTS)) {
     return rv;
   }
 
-  // Kick off scanning for plugins
-  nsCOMPtr<nsIThread> thread;
-  return GetThread(getter_AddRefs(thread));
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 GeckoMediaPluginService::Observe(nsISupports* aSubject,
                                  const char* aTopic,
                                  const char16_t* aSomeData)
 {
   LOGD(("%s::%s topic='%s' data='%s'", __CLASS__, __FUNCTION__,
--- a/dom/media/gmp/GMPService.h
+++ b/dom/media/gmp/GMPService.h
@@ -86,16 +86,17 @@ private:
   void ClearRecentHistoryOnGMPThread(PRTime aSince);
 
 protected:
   friend class GMPParent;
   void ReAddOnGMPThread(nsRefPtr<GMPParent>& aOld);
 private:
   GMPParent* ClonePlugin(const GMPParent* aOriginal);
   nsresult EnsurePluginsOnDiskScanned();
+  nsresult InitStorage();
 
   class PathRunnable : public nsRunnable
   {
   public:
     PathRunnable(GeckoMediaPluginService* service, const nsAString& path,
                  bool add)
       : mService(service)
       , mPath(path)