Bug 1146201 - Use message manager instead of observer service in GMPWrapper. r=markh a=sylvestre
authorChris Pearce <cpearce@mozilla.com>
Tue, 31 Mar 2015 20:50:01 +1300
changeset 258239 c481e8a84a6c
parent 258238 7a04aad0ab5d
child 258240 e65f5a19d0e4
push id4625
push usercpearce@mozilla.com
push date2015-04-03 06:37 +0000
treeherdermozilla-beta@c481e8a84a6c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarkh, sylvestre
bugs1146201
milestone38.0
Bug 1146201 - Use message manager instead of observer service in GMPWrapper. r=markh a=sylvestre
toolkit/mozapps/extensions/internal/GMPProvider.jsm
--- a/toolkit/mozapps/extensions/internal/GMPProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/GMPProvider.jsm
@@ -59,16 +59,19 @@ const GMP_PLUGINS = [
     isEME:           true
   }];
 
 XPCOMUtils.defineLazyGetter(this, "pluginsBundle",
   () => Services.strings.createBundle("chrome://global/locale/plugins.properties"));
 XPCOMUtils.defineLazyGetter(this, "gmpService",
   () => Cc["@mozilla.org/gecko-media-plugin-service;1"].getService(Ci.mozIGeckoMediaPluginService));
 
+let messageManager = Cc["@mozilla.org/globalmessagemanager;1"]
+                       .getService(Ci.nsIMessageListenerManager);
+
 let gLogger;
 let gLogAppenderDump = null;
 
 function configureLogging() {
   if (!gLogger) {
     gLogger = Log.repository.getLogger("Toolkit.GMP");
     gLogger.addAppender(new Log.ConsoleAppender(new Log.BasicFormatter()));
   }
@@ -102,17 +105,17 @@ function GMPWrapper(aPluginInfo) {
                                           this._plugin.id),
                       this.onPrefEnabledChanged, this);
   Preferences.observe(GMPPrefs.getPrefKey(GMPPrefs.KEY_PLUGIN_VERSION,
                                           this._plugin.id),
                       this.onPrefVersionChanged, this);
   if (this._plugin.isEME) {
     Preferences.observe(GMPPrefs.KEY_EME_ENABLED,
                         this.onPrefEMEGlobalEnabledChanged, this);
-    Services.obs.addObserver(this, "mediakeys-request", false);
+    messageManager.addMessageListener("EMEVideo:ContentMediaKeysRequest", this);
   }
 }
 
 GMPWrapper.prototype = {
   // An active task that checks for plugin updates and installs them.
   _updateTask: null,
   _gmpPath: null,
   _isUpdateCheckPending: false,
@@ -360,17 +363,18 @@ GMPWrapper.prototype = {
         // We don't really care about the results, if someone is interested
         // they can check the log.
         gmpInstallManager.simpleCheckAndInstall().then(null, () => {});
       }
       this._isUpdateCheckPending = false;
     }, delay);
   },
 
-  observe: function(subject, topic, data) {
+  receiveMessage: function({target: browser, data: data}) {
+    this._log.trace("receiveMessage() data=" + data);
     let parsedData;
     try {
       parsedData = JSON.parse(data);
     } catch(ex) {
       this._log.error("Malformed EME video message with data: " + data);
       return;
     }
     let {status: status, keySystem: keySystem} = parsedData;
@@ -428,17 +432,17 @@ GMPWrapper.prototype = {
                                            this._plugin.id),
                        this.onPrefEnabledChanged, this);
     Preferences.ignore(GMPPrefs.getPrefKey(GMPPrefs.KEY_PLUGIN_VERSION,
                                            this._plugin.id),
                        this.onPrefVersionChanged, this);
     if (this._plugin.isEME) {
       Preferences.ignore(GMPPrefs.KEY_EME_ENABLED,
                          this.onPrefEMEGlobalEnabledChanged, this);
-      Services.obs.removeObserver(this, "mediakeys-request", false);
+      messageManager.removeMessageListener("EMEVideo:ContentMediaKeysRequest", this);
     }
     return this._updateTask;
   },
 };
 
 let GMPProvider = {
   get name() { return "GMPProvider"; },