Bug 1422365 - Introduce nsIClearDataService - part 6 - Media devices, r=johannh
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 01 Jun 2018 14:30:00 +0200
changeset 475093 9c6127c3f4a8393217b1b9fccb02daf984b7ddfb
parent 475092 7f2aed939175cff35ca48725282f23a365d24593
child 475094 6652b69cb5d06143464b29d4a9b5309f9aedc72c
push id9374
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:43:20 +0000
treeherdermozilla-beta@160e085dfb0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1422365
milestone62.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 1422365 - Introduce nsIClearDataService - part 6 - Media devices, r=johannh
browser/modules/Sanitizer.jsm
toolkit/components/cleardata/ClearDataService.js
toolkit/components/cleardata/nsIClearDataService.idl
--- a/browser/modules/Sanitizer.jsm
+++ b/browser/modules/Sanitizer.jsm
@@ -319,27 +319,21 @@ var Sanitizer = {
         await clearData(range, Ci.nsIClearDataService.CLEAR_ALL_CACHES);
         TelemetryStopwatch.finish("FX_SANITIZE_CACHE", refObj);
       }
     },
 
     cookies: {
       async clear(range) {
         let refObj = {};
-
-        // Clear cookies and plugin data.
         TelemetryStopwatch.start("FX_SANITIZE_COOKIES_2", refObj);
         await clearData(range, Ci.nsIClearDataService.CLEAR_COOKIES |
-                               Ci.nsIClearDataService.CLEAR_PLUGIN_DATA);
+                               Ci.nsIClearDataService.CLEAR_PLUGIN_DATA |
+                               Ci.nsIClearDataService.CLEAR_MEDIA_DEVICES);
         TelemetryStopwatch.finish("FX_SANITIZE_COOKIES_2", refObj);
-
-        // Clear deviceIds. Done asynchronously (returns before complete).
-        let mediaMgr = Cc["@mozilla.org/mediaManagerService;1"]
-                         .getService(Ci.nsIMediaManagerService);
-        mediaMgr.sanitizeDeviceIds(range && range[0]);
       },
     },
 
     offlineApps: {
       async clear(range) {
         // AppCache: this doesn't wait for the cleanup to be complete.
         OfflineAppCacheHelper.clear();
 
--- a/toolkit/components/cleardata/ClearDataService.js
+++ b/toolkit/components/cleardata/ClearDataService.js
@@ -224,16 +224,36 @@ const PasswordsCleaner = {
         }
       }
 
       aResolve();
     });
   },
 };
 
+const MediaDevicesCleaner = {
+  deleteByRange(aFrom, aTo) {
+    return new Promise(aResolve => {
+      let mediaMgr = Cc["@mozilla.org/mediaManagerService;1"]
+                       .getService(Ci.nsIMediaManagerService);
+      mediaMgr.sanitizeDeviceIds(aFrom);
+      aResolve();
+    });
+  },
+
+  deleteAll() {
+    return new Promise(aResolve => {
+      let mediaMgr = Cc["@mozilla.org/mediaManagerService;1"]
+                       .getService(Ci.nsIMediaManagerService);
+      mediaMgr.sanitizeDeviceIds(null);
+      aResolve();
+    });
+  },
+};
+
 // Here the map of Flags-Cleaner.
 const FLAGS_MAP = [
  { flag: Ci.nsIClearDataService.CLEAR_COOKIES,
    cleaner: CookieCleaner },
 
  { flag: Ci.nsIClearDataService.CLEAR_NETWORK_CACHE,
    cleaner: NetworkCacheCleaner },
 
@@ -243,16 +263,19 @@ const FLAGS_MAP = [
  { flag: Ci.nsIClearDataService.CLEAR_PLUGIN_DATA,
    cleaner: PluginDataCleaner, },
 
  { flag: Ci.nsIClearDataService.CLEAR_DOWNLOADS,
    cleaner: DownloadsCleaner, },
 
  { flag: Ci.nsIClearDataService.CLEAR_PASSWORDS,
    cleaner: PasswordsCleaner, },
+
+ { flag: Ci.nsIClearDataService.CLEAR_MEDIA_DEVICES,
+   cleaner: MediaDevicesCleaner, },
 ];
 
 this.ClearDataService = function() {};
 
 ClearDataService.prototype = Object.freeze({
   classID: Components.ID("{0c06583d-7dd8-4293-b1a5-912205f779aa}"),
   QueryInterface: ChromeUtils.generateQI([Ci.nsIClearDataService]),
   _xpcom_factory: XPCOMUtils.generateSingletonFactory(ClearDataService),
--- a/toolkit/components/cleardata/nsIClearDataService.idl
+++ b/toolkit/components/cleardata/nsIClearDataService.idl
@@ -108,16 +108,21 @@ interface nsIClearDataService : nsISuppo
    */
   const uint32_t CLEAR_DOWNLOADS = 1 << 4;
 
   /**
    * Stored passwords.
    */
   const uint32_t CLEAR_PASSWORDS = 1 << 5;
 
+  /**
+   * Media devices.
+   */
+  const uint32_t CLEAR_MEDIA_DEVICES = 1 << 6;
+
   /* TODO
   const uint32_t CLEAR_EME = 1 << 4;
   const uint32_t CLEAR_PERMISSIONS = 1 << 7;
   const uint32_t CLEAR_DOM_QUOTA = 1 << 8;
   const uint32_t CLEAR_CONTENT_PREFERENCES = 1 << 9;
   const uint32_t CLEAR_PREDICTOR_CACHE = 1 << 10;
   const uint32_t CLEAR_DOM_PUSH_NOTIFICATIONS = 1 << 11;
   const uint32_t CLEAR_HSTS = 1 << 12;