Bug 1596220 - Document GMPProvider's findUpdates and checkForUpdates functions. r=spohl
authorBryce Seager van Dyk <bvandyk@mozilla.com>
Thu, 14 Nov 2019 17:36:22 +0000
changeset 502007 eb83c702dd4f197ab67ae3f78968e86317338773
parent 502006 868a55980ae8e0f6bda936e9a5c0cbb2311a5717
child 502008 24b134b55c5f70eab758d74682fc1f6ca829e0ff
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspohl
bugs1596220
milestone72.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 1596220 - Document GMPProvider's findUpdates and checkForUpdates functions. r=spohl Add documentation to help differentiate the use cases for these two functions. Differential Revision: https://phabricator.services.mozilla.com/D52911
toolkit/mozapps/extensions/internal/GMPProvider.jsm
--- a/toolkit/mozapps/extensions/internal/GMPProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/GMPProvider.jsm
@@ -343,21 +343,34 @@ GMPWrapper.prototype = {
       GMPPrefs.reset(GMPPrefs.KEY_PLUGIN_AUTOUPDATE, this._plugin.id);
     } else if (aVal == AddonManager.AUTOUPDATE_ENABLE) {
       GMPPrefs.setBool(GMPPrefs.KEY_PLUGIN_AUTOUPDATE, true, this._plugin.id);
     } else if (aVal == AddonManager.AUTOUPDATE_DISABLE) {
       GMPPrefs.setBool(GMPPrefs.KEY_PLUGIN_AUTOUPDATE, false, this._plugin.id);
     }
   },
 
+  /**
+   * Called by the addon manager to update GMP addons. For example this will be
+   * used if a user manually checks for GMP plugin updates by using the
+   * menu in about:addons.
+   *
+   * This function is not used if MediaKeySystemAccess is requested and
+   * Widevine is not yet installed, or if the user toggles prefs to enable EME.
+   * For the function used in those cases see `checkForUpdates`.
+   */
   findUpdates(aListener, aReason, aAppVersion, aPlatformVersion) {
     this._log.trace(
       "findUpdates() - " + this._plugin.id + " - reason=" + aReason
     );
 
+    // In the case of GMP addons we do not wish to implement AddonInstall, as
+    // we don't want to display information as in a normal addon install such
+    // as a download progress bar. As such, we short circuit our
+    // listeners by indicating that no updates exist (though some may).
     AddonManagerPrivate.callNoUpdateListeners(this, aListener);
 
     if (aReason === AddonManager.UPDATE_WHEN_PERIODIC_UPDATE) {
       if (!AddonManager.shouldAutoUpdate(this)) {
         this._log.trace(
           "findUpdates() - " + this._plugin.id + " - no autoupdate"
         );
         return Promise.resolve(false);
@@ -513,16 +526,22 @@ GMPWrapper.prototype = {
       AddonManagerPrivate.callAddonListeners("onInstalled", this);
       this.checkForUpdates(GMP_CHECK_DELAY);
     }
     if (!this.userDisabled) {
       this._handleEnabledChanged();
     }
   },
 
+  /**
+   * This is called if prefs are changed to enable EME, or if Widevine
+   * MediaKeySystemAccess is requested but the Widevine CDM is not installed.
+   *
+   * For the function used by the addon manager see `findUpdates`.
+   */
   checkForUpdates(delay) {
     if (this._isUpdateCheckPending) {
       return;
     }
     this._isUpdateCheckPending = true;
     GMPPrefs.reset(GMPPrefs.KEY_UPDATE_LAST_CHECK, null);
     // Delay this in case the user changes his mind and doesn't want to
     // enable EME after all.