From 12d23f5b8a32a4c2a228d4b1f07b194c72c4fec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Qu=C3=A8ze?= Date: Thu, 28 Mar 2019 00:06:29 +0000 Subject: [PATCH] Bug 1535010 - avoid unnecessary gmp directory creations during startup, r=cpearce. Differential Revision: https://phabricator.services.mozilla.com/D23320 --HG-- extra : moz-landing-system : lando --- dom/media/gmp/GMPDiskStorage.cpp | 10 ------- dom/media/gmp/GMPServiceParent.cpp | 46 +++--------------------------- 2 files changed, 4 insertions(+), 52 deletions(-) diff --git a/dom/media/gmp/GMPDiskStorage.cpp b/dom/media/gmp/GMPDiskStorage.cpp index 3275459b761f..b0f5cfbdc3db 100644 --- a/dom/media/gmp/GMPDiskStorage.cpp +++ b/dom/media/gmp/GMPDiskStorage.cpp @@ -56,21 +56,11 @@ static nsresult GetGMPStorageDir(nsIFile** aTempDir, const nsString& aGMPName, return rv; } - rv = tmpFile->Create(nsIFile::DIRECTORY_TYPE, 0700); - if (rv != NS_ERROR_FILE_ALREADY_EXISTS && NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - rv = tmpFile->AppendNative(NS_LITERAL_CSTRING("storage")); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } - rv = tmpFile->Create(nsIFile::DIRECTORY_TYPE, 0700); - if (rv != NS_ERROR_FILE_ALREADY_EXISTS && NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - rv = tmpFile->AppendNative(aNodeId); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; diff --git a/dom/media/gmp/GMPServiceParent.cpp b/dom/media/gmp/GMPServiceParent.cpp index 50e6987db9c8..8bc29a825770 100644 --- a/dom/media/gmp/GMPServiceParent.cpp +++ b/dom/media/gmp/GMPServiceParent.cpp @@ -214,17 +214,6 @@ nsresult GeckoMediaPluginServiceParent::InitStorage() { return rv; } - rv = mStorageBaseDir->Create(nsIFile::DIRECTORY_TYPE, 0700); - if (NS_WARN_IF(NS_FAILED(rv) && rv != NS_ERROR_FILE_ALREADY_EXISTS)) { - return rv; - } - - nsCOMPtr gmpDirWithoutPlatform; - rv = mStorageBaseDir->Clone(getter_AddRefs(gmpDirWithoutPlatform)); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - nsAutoString platform; rv = GMPPlatformString(platform); if (NS_WARN_IF(NS_FAILED(rv))) { @@ -236,11 +225,6 @@ nsresult GeckoMediaPluginServiceParent::InitStorage() { return rv; } - rv = mStorageBaseDir->Create(nsIFile::DIRECTORY_TYPE, 0700); - if (NS_WARN_IF(NS_FAILED(rv) && rv != NS_ERROR_FILE_ALREADY_EXISTS)) { - return rv; - } - return GeckoMediaPluginService::Init(); } @@ -1139,28 +1123,18 @@ nsresult GeckoMediaPluginServiceParent::GetNodeId( return rv; } + // $profileDir/gmp/$platform/$gmpName/ rv = path->Append(aGMPName); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } - // $profileDir/gmp/$platform/$gmpName/ - rv = path->Create(nsIFile::DIRECTORY_TYPE, 0700); - if (rv != NS_ERROR_FILE_ALREADY_EXISTS && NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - + // $profileDir/gmp/$platform/$gmpName/id/ rv = path->AppendNative(NS_LITERAL_CSTRING("id")); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } - // $profileDir/gmp/$platform/$gmpName/id/ - rv = path->Create(nsIFile::DIRECTORY_TYPE, 0700); - if (rv != NS_ERROR_FILE_ALREADY_EXISTS && NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - nsAutoCString hashStr; hashStr.AppendInt((int64_t)hash); @@ -1325,18 +1299,6 @@ static void KillPlugins(const nsTArray>& aPlugins, } } -static nsresult DeleteDir(nsIFile* aPath) { - bool exists = false; - nsresult rv = aPath->Exists(&exists); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - if (exists) { - return aPath->Remove(true); - } - return NS_OK; -} - struct NodeFilter { explicit NodeFilter(const nsTArray& nodeIDs) : mNodeIDs(nodeIDs) {} bool operator()(GMPParent* aParent) { @@ -1416,7 +1378,7 @@ void GeckoMediaPluginServiceParent::ClearNodeIdAndPlugin( continue; } - if (NS_FAILED(DeleteDir(dirEntry))) { + if (NS_FAILED(dirEntry->Remove(true))) { NS_WARNING("Failed to delete GMP storage directory for the node"); } } @@ -1603,7 +1565,7 @@ void GeckoMediaPluginServiceParent::ClearStorage() { return; } - if (NS_FAILED(DeleteDir(path))) { + if (NS_FAILED(path->Remove(true))) { NS_WARNING("Failed to delete GMP storage directory"); }