Bug 785225 - Part 10: Reflect API changes in TPS; r=rnewman
authorGregory Szorc <gps@mozilla.com>
Wed, 29 Aug 2012 14:43:41 -0700
changeset 111057 cf4c39d50fd26b16f25e68cb370655ae620c0da0
parent 111056 9eeef1bbadeeee885c858bd56f46ac285a6cb250
child 111058 43e9f9c938760ecf6f90a90868421792bb4198fe
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersrnewman
bugs785225
milestone18.0a1
Bug 785225 - Part 10: Reflect API changes in TPS; r=rnewman The previous parts broke TPS. This fixes them all in one lump patch.
services/sync/tps/extensions/tps/modules/sync.jsm
services/sync/tps/extensions/tps/modules/tabs.jsm
services/sync/tps/extensions/tps/modules/tps.jsm
--- a/services/sync/tps/extensions/tps/modules/sync.jsm
+++ b/services/sync/tps/extensions/tps/modules/sync.jsm
@@ -7,19 +7,18 @@ var EXPORTED_SYMBOLS = ["TPS", "SYNC_WIP
                         "SYNC_WIPE_CLIENT"];
 
 const CC = Components.classes;
 const CI = Components.interfaces;
 const CU = Components.utils;
 
 CU.import("resource://gre/modules/XPCOMUtils.jsm");
 CU.import("resource://gre/modules/Services.jsm");
+CU.import("resource://services-sync/util.js");
 CU.import("resource://tps/logger.jsm");
-CU.import("resource://services-sync/service.js");
-CU.import("resource://services-sync/util.js");
 var utils = {}; CU.import('resource://mozmill/modules/utils.js', utils);
 
 const SYNC_RESET_CLIENT = "reset-client";
 const SYNC_WIPE_CLIENT  = "wipe-client";
 const SYNC_WIPE_REMOTE  = "wipe-remote";
 const SYNC_WIPE_SERVER  = "wipe-server";
 
 var prefs = CC["@mozilla.org/preferences-service;1"]
--- a/services/sync/tps/extensions/tps/modules/tabs.jsm
+++ b/services/sync/tps/extensions/tps/modules/tabs.jsm
@@ -2,39 +2,37 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
  /* This is a JavaScript module (JSM) to be imported via
    Components.utils.import() and acts as a singleton.
    Only the following listed symbols will exposed on import, and only when
    and where imported. */
 
-var EXPORTED_SYMBOLS = ["BrowserTabs"];
+const EXPORTED_SYMBOLS = ["BrowserTabs"];
+
+const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
-const CC = Components.classes;
-const CI = Components.interfaces;
-const CU = Components.utils;
+Cu.import("resource://services-sync/service.js");
 
-CU.import("resource://services-sync/engines.js");
-
-var BrowserTabs = {
+let BrowserTabs = {
   /**
    * Add
    *
    * Opens a new tab in the current browser window for the
    * given uri.  Throws on error.
    *
    * @param uri The uri to load in the new tab
    * @return nothing
    */
   Add: function(uri, fn) {
     // Open the uri in a new tab in the current browser window, and calls
     // the callback fn from the tab's onload handler.
-    let wm = CC["@mozilla.org/appshell/window-mediator;1"]
-             .getService(CI.nsIWindowMediator);
+    let wm = Cc["@mozilla.org/appshell/window-mediator;1"]
+               .getService(Ci.nsIWindowMediator);
     let mainWindow = wm.getMostRecentWindow("navigator:browser");
     let newtab = mainWindow.getBrowser().addTab(uri);
     mainWindow.getBrowser().selectedTab = newtab;
     let win = mainWindow.getBrowser().getBrowserForTab(newtab);
     win.addEventListener("load", function() { fn.call(); }, true);
   },
 
   /**
@@ -45,17 +43,17 @@ var BrowserTabs = {
    *
    * @param uri The uri of the tab to find
    * @param title The page title of the tab to find
    * @param profile The profile to search for tabs
    * @return true if the specified tab could be found, otherwise false
    */
   Find: function(uri, title, profile) {
     // Find the uri in Weave's list of tabs for the given profile.
-    let engine = Engines.get("tabs");
+    let engine = Service.engineManager.get("tabs");
     for (let [guid, client] in Iterator(engine.getAllClients())) {
       for each (tab in client.tabs) {
         let weaveTabUrl = tab.urlHistory[0];
         if (uri == weaveTabUrl && profile == client.clientName)
           if (title == undefined || title == tab.title)
             return true;
       }
     }
--- a/services/sync/tps/extensions/tps/modules/tps.jsm
+++ b/services/sync/tps/extensions/tps/modules/tps.jsm
@@ -6,23 +6,22 @@
   * Components.utils.import() and acts as a singleton. Only the following
   * listed symbols will exposed on import, and only when and where imported.
   */
 
 let EXPORTED_SYMBOLS = ["TPS"];
 
 const {classes: CC, interfaces: CI, utils: CU} = Components;
 
-CU.import("resource://services-sync/service.js");
-CU.import("resource://services-sync/constants.js");
-CU.import("resource://services-sync/engines.js");
-CU.import("resource://services-common/async.js");
-CU.import("resource://services-sync/util.js");
 CU.import("resource://gre/modules/XPCOMUtils.jsm");
 CU.import("resource://gre/modules/Services.jsm");
+CU.import("resource://services-common/async.js");
+CU.import("resource://services-sync/constants.js");
+CU.import("resource://services-sync/service.js");
+CU.import("resource://services-sync/util.js");
 CU.import("resource://tps/addons.jsm");
 CU.import("resource://tps/bookmarks.jsm");
 CU.import("resource://tps/logger.jsm");
 CU.import("resource://tps/passwords.jsm");
 CU.import("resource://tps/history.jsm");
 CU.import("resource://tps/forms.jsm");
 CU.import("resource://tps/prefs.jsm");
 CU.import("resource://tps/tabs.jsm");
@@ -59,18 +58,17 @@ const SYNC_START_OVER   = "start-over";
 
 const OBSERVER_TOPICS = ["weave:engine:start-tracking",
                          "weave:engine:stop-tracking",
                          "weave:service:sync:finish",
                          "weave:service:sync:error",
                          "sessionstore-windows-restored",
                          "private-browsing"];
 
-let TPS =
-{
+let TPS = {
   _waitingForSync: false,
   _isTracking: false,
   _test: null,
   _currentAction: -1,
   _currentPhase: -1,
   _errors: 0,
   _syncErrors: 0,
   _usSinceEpoch: 0,
@@ -564,20 +562,20 @@ let TPS =
       // If we have restricted the active engines, unregister engines we don't
       // care about.
       if (settings.ignoreUnusedEngines && Array.isArray(this._enabledEngines)) {
         let names = {};
         for each (let name in this._enabledEngines) {
           names[name] = true;
         }
 
-        for each (let engine in Engines.getEnabled()) {
+        for (let engine of Service.engineManager.getEnabled()) {
           if (!(engine.name in names)) {
             Logger.logInfo("Unregistering unused engine: " + engine.name);
-            Engines.unregister(engine);
+            Service.engineManager.unregister(engine);
           }
         }
       }
 
       Logger.logInfo("Starting phase " + parseInt(phase, 10) + "/" +
                      Object.keys(this._phaselist).length);
 
       Logger.logInfo("setting client.name to " + this.phases["phase" + this._currentPhase]);