From 6b35519b8f169558db803b7234cf95549a964cce Mon Sep 17 00:00:00 2001 From: Rutuja Date: Tue, 19 Apr 2016 10:39:12 -0400 Subject: [PATCH] Bug 1115006 - Use Downloads.getSystemDownloadsDirectory to get download directory for about:memory on Fennec. r=mconley,margaret MozReview-Commit-ID: JBod1Ltcz0w --HG-- extra : rebase_source : 3fdf3b1160f36b77c10641cab4e056c2a77dc151 --- mobile/android/components/DirectoryProvider.js | 7 ------- .../components/aboutmemory/content/aboutMemory.js | 13 ++++++++++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mobile/android/components/DirectoryProvider.js b/mobile/android/components/DirectoryProvider.js index e0e4b26421f5..458916dffa7a 100644 --- a/mobile/android/components/DirectoryProvider.js +++ b/mobile/android/components/DirectoryProvider.js @@ -27,7 +27,6 @@ const XRE_APP_DISTRIBUTION_DIR = "XREAppDist"; const XRE_UPDATE_ROOT_DIR = "UpdRootD"; const ENVVAR_UPDATE_DIR = "UPDATES_DIRECTORY"; const WEBAPPS_DIR = "webappsDir"; -const DOWNLOAD_DIR = "DfltDwnld"; const SYSTEM_DIST_PATH = `/system/${AppConstants.ANDROID_PACKAGE_NAME}/distribution`; @@ -69,12 +68,6 @@ DirectoryProvider.prototype = { } } return new FileUtils.File(env.get("DOWNLOADS_DIRECTORY")); - } else if (prop == DOWNLOAD_DIR) { - // Downloads.getSystemDownloadsDirectory is asynchronous, but getFile is - // synchronous, so just return what the getSystemDownloadsDirectory - // implementation would have returned. - let env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment); - return new FileUtils.File(env.get("DOWNLOADS_DIRECTORY")); } // We are retuning null to show failure instead for throwing an error. The diff --git a/toolkit/components/aboutmemory/content/aboutMemory.js b/toolkit/components/aboutmemory/content/aboutMemory.js index 54b674d7abf2..8691af755183 100644 --- a/toolkit/components/aboutmemory/content/aboutMemory.js +++ b/toolkit/components/aboutmemory/content/aboutMemory.js @@ -35,6 +35,10 @@ const UNITS_PERCENTAGE = Ci.nsIMemoryReporter.UNITS_PERCENTAGE; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/NetUtil.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "Downloads", + "resource://gre/modules/Downloads.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "FileUtils", + "resource://gre/modules/FileUtils.jsm"); XPCOMUtils.defineLazyGetter(this, "nsBinaryStream", () => CC("@mozilla.org/binaryinputstream;1", @@ -2026,9 +2030,12 @@ function saveReportsToFile() } catch(ex) { // This will fail on Android, since there is no Save as file picker there. // Just save to the default downloads dir if it does. - let file = Services.dirsvc.get("DfltDwnld", Ci.nsIFile); - file.append(fp.defaultString); - fpFinish(file); + Downloads.getSystemDownloadsDirectory().then(function(dirPath) { + let file = FileUtils.File(dirPath); + file.append(fp.defaultString); + fpFinish(file); + }); + return; } fp.open(fpCallback);