Bug 1143562 - use /data/b2g/mozilla/gmp as the gmp storage folder on B2G. r=cpearce
authorJW Wang <jwwang@mozilla.com>
Mon, 16 Mar 2015 19:51:00 +0100
changeset 234434 57f1dab3ca956d381f8de7d2965138a05579cae5
parent 234433 e772801f3c82875c9a60742711bc9252f4d5a20e
child 234435 7a3da13b481426cc34d36d3978cd5afd189baffe
push id28446
push userkwierso@gmail.com
push dateFri, 20 Mar 2015 02:15:45 +0000
treeherdermozilla-central@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 - use /data/b2g/mozilla/gmp as the gmp storage folder on B2G. 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,36 +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);
   }
 
-#ifndef MOZ_WIDGET_GONK
   // Directory service is main thread only, so cache the profile dir here
   // so that we can use it off main thread.
-  // We only do this on non-B2G, as this fails in multi-process Gecko.
-  // TODO: Make this work in multi-process Gecko.
+#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
+
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = mStorageBaseDir->AppendNative(NS_LITERAL_CSTRING("gmp"));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = mStorageBaseDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
   if (NS_WARN_IF(NS_FAILED(rv) && rv != NS_ERROR_FILE_ALREADY_EXISTS)) {
     return rv;
   }
-#endif
 
   // Kick off scanning for plugins
   nsCOMPtr<nsIThread> thread;
   return GetThread(getter_AddRefs(thread));
 }
 
 NS_IMETHODIMP
 GeckoMediaPluginService::Observe(nsISupports* aSubject,
@@ -948,24 +949,20 @@ GeckoMediaPluginService::ReAddOnGMPThrea
   // Schedule aOld to be destroyed.  We can't destroy it from here since we
   // may be inside ActorDestroyed() for it.
   NS_DispatchToCurrentThread(WrapRunnableNM(&Dummy, aOld));
 }
 
 NS_IMETHODIMP
 GeckoMediaPluginService::GetStorageDir(nsIFile** aOutFile)
 {
-#ifndef MOZ_WIDGET_GONK
   if (NS_WARN_IF(!mStorageBaseDir)) {
     return NS_ERROR_FAILURE;
   }
   return mStorageBaseDir->Clone(aOutFile);
-#else
-  return NS_ERROR_NOT_IMPLEMENTED;
-#endif
 }
 
 static nsresult
 WriteToFile(nsIFile* aPath,
             const nsCString& aFileName,
             const nsCString& aData)
 {
   nsCOMPtr<nsIFile> path;
@@ -1059,21 +1056,16 @@ GeckoMediaPluginService::GetNodeId(const
                                    nsACString& aOutId)
 {
   MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
   LOGD(("%s::%s: (%s, %s), %s", __CLASS__, __FUNCTION__,
        NS_ConvertUTF16toUTF8(aOrigin).get(),
        NS_ConvertUTF16toUTF8(aTopLevelOrigin).get(),
        (aInPrivateBrowsing ? "PrivateBrowsing" : "NonPrivateBrowsing")));
 
-#ifdef MOZ_WIDGET_GONK
-  NS_WARNING("GeckoMediaPluginService::GetNodeId Not implemented on B2G");
-  return NS_ERROR_NOT_IMPLEMENTED;
-#endif
-
   nsresult rv;
 
   if (aOrigin.EqualsLiteral("null") ||
       aOrigin.IsEmpty() ||
       aTopLevelOrigin.EqualsLiteral("null") ||
       aTopLevelOrigin.IsEmpty()) {
     // At least one of the (origin, topLevelOrigin) is null or empty;
     // probably a local file. Generate a random node id, and don't store
@@ -1504,21 +1496,16 @@ static bool IsNodeIdValid(GMPParent* aPa
 }
 
 void
 GeckoMediaPluginService::ClearStorage()
 {
   MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
   LOGD(("%s::%s", __CLASS__, __FUNCTION__));
 
-#ifdef MOZ_WIDGET_GONK
-  NS_WARNING("GeckoMediaPluginService::ClearStorage not implemented on B2G");
-  return;
-#endif
-
   // Kill plugins with valid nodeIDs.
   KillPlugins(mPlugins, mMutex, &IsNodeIdValid);
 
   nsCOMPtr<nsIFile> path; // $profileDir/gmp/
   nsresult rv = GetStorageDir(getter_AddRefs(path));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return;
   }
--- a/dom/media/gmp/GMPService.h
+++ b/dom/media/gmp/GMPService.h
@@ -134,19 +134,17 @@ private:
   private:
     T mValue;
   };
 
   MainThreadOnly<bool> mWaitingForPluginsAsyncShutdown;
 
   nsTArray<nsRefPtr<GMPParent>> mAsyncShutdownPlugins; // GMP Thread only.
 
-#ifndef MOZ_WIDGET_GONK
   nsCOMPtr<nsIFile> mStorageBaseDir;
-#endif
 
   // Hashes of (origin,topLevelOrigin) to the node id for
   // non-persistent sessions.
   nsClassHashtable<nsUint32HashKey, nsCString> mTempNodeIds;
 
   // Hashes node id to whether that node id is allowed to store data
   // persistently on disk.
   nsDataHashtable<nsCStringHashKey, bool> mPersistentStorageAllowed;