function onStartup() {
    this._migratePrefs();

    // Status is instantiated before us and is the first to grab an instance of
    // the IdentityManager. We use that instance because IdentityManager really
    // needs to be a singleton. Ideally, the longer-lived object would spawn
    // this service instance.
    if (!Status || !Status._authManager) {
      throw new Error("Status or Status._authManager not initialized.");
    }

    this.status = Status;
    this.identity = Status._authManager;
    this.collectionKeys = new CollectionKeyManager();

    this.errorHandler = new ErrorHandler(this);

    this._log = Log.repository.getLogger("Sync.Service");
    this._log.level =
      Log.Level[Svc.Prefs.get("log.logger.service.main")];

    this._log.info("Loading Weave " + WEAVE_VERSION);

    this._clusterManager = this.identity.createClusterManager(this);
    this.recordManager = new RecordManager(this);

    this.enabled = true;

    this._registerEngines();

    let ua = Cc["@mozilla.org/network/protocol;1?name=http"].
      getService(Ci.nsIHttpProtocolHandler).userAgent;
    this._log.info(ua);

    if (!this._checkCrypto()) {
      this.enabled = false;
      this._log.info("Could not load the Weave crypto component. Disabling " +
                      "Weave, since it will not work correctly.");
    }

    Svc.Obs.add("weave:service:setup-complete", this);
    Svc.Prefs.observe("engine.", this);

    this.scheduler = new SyncScheduler(this);

    if (!this.enabled) {
      this._log.info("Firefox Sync disabled.");
    }

    this._updateCachedURLs();

    let status = this._checkSetup();
    if (status != STATUS_DISABLED && status != CLIENT_NOT_CONFIGURED) {
      Svc.Obs.notify("weave:engine:start-tracking");
    }

    // Telemetry probes to indicate if the user is using custom servers.
    for (let [probeName, prefName] of Iterator(TELEMETRY_CUSTOM_SERVER_PREFS)) {
      let isCustomized = Services.prefs.prefHasUserValue(prefName);
      Services.telemetry.getHistogramById(probeName).add(isCustomized);
    }

    // Send an event now that Weave service is ready.  We don't do this
    // synchronously so that observers can import this module before
    // registering an observer.
    Utils.nextTick(function onNextTick() {
      this.status.ready = true;

      // UI code uses the flag on the XPCOM service so it doesn't have
      // to load a bunch of modules.
      let xps = Cc["@mozilla.org/weave/service;1"]
                  .getService(Ci.nsISupports)
                  .wrappedJSObject;
      xps.ready = true;

      Svc.Obs.notify("weave:service:ready");
    }.bind(this));
  }
/**
   * Prepare to initialize the rest of Weave after waiting a little bit
   */
Prepare to initialize the rest of Weave after waiting a little bit
Prepare to initialize the rest of Weave after waiting a little bit
function onStartup() {
    this._migratePrefs();
    if (!Status || !Status._authManager) {
      throw new Error("Status or Status._authManager not initialized.");
    }
    this.status = Status;
    this.identity = Status._authManager;
    this.collectionKeys = new CollectionKeyManager();
    this.errorHandler = new ErrorHandler(this);
    this._log = Log.repository.getLogger("Sync.Service");
    this._log.level =
      Log.Level[Svc.Prefs.get("log.logger.service.main")];
    this._log.info("Loading Weave " + WEAVE_VERSION);
    this._clusterManager = this.identity.createClusterManager(this);
    this.recordManager = new RecordManager(this);
    this.enabled = true;
    this._registerEngines();
    let ua = Cc["@mozilla.org/network/protocol;1?name=http"].
      getService(Ci.nsIHttpProtocolHandler).userAgent;
    this._log.info(ua);
    if (!this._checkCrypto()) {
      this.enabled = false;
      this._log.info("Could not load the Weave crypto component. Disabling " +
                      "Weave, since it will not work correctly.");
    }
    Svc.Obs.add("weave:service:setup-complete", this);
    Svc.Prefs.observe("engine.", this);
    this.scheduler = new SyncScheduler(this);
    if (!this.enabled) {
      this._log.info("Firefox Sync disabled.");
    }
    this._updateCachedURLs();
    let status = this._checkSetup();
    if (status != STATUS_DISABLED && status != CLIENT_NOT_CONFIGURED) {
      Svc.Obs.notify("weave:engine:start-tracking");
    }
    for (let [probeName, prefName] of Iterator(TELEMETRY_CUSTOM_SERVER_PREFS)) {
      let isCustomized = Services.prefs.prefHasUserValue(prefName);
      Services.telemetry.getHistogramById(probeName).add(isCustomized);
    }
    Utils.nextTick(function onNextTick() {
      this.status.ready = true;
      let xps = Cc["@mozilla.org/weave/service;1"]
                  .getService(Ci.nsISupports)
                  .wrappedJSObject;
      xps.ready = true;
      Svc.Obs.notify("weave:service:ready");
    }.bind(this));
  }
function onStartup ( ) { this . _migratePrefs ( ) ; if ( ! Status || ! Status . _authManager ) { throw new Error ( "Status or Status._authManager not initialized." ) ; } this . status = Status ; this . identity = Status . _authManager ; this . collectionKeys = new CollectionKeyManager ( ) ; this . errorHandler = new ErrorHandler ( this ) ; this . _log = Log . repository . getLogger ( "Sync.Service" ) ; this . _log . level = Log . Level [ Svc . Prefs . get ( "log.logger.service.main" ) ] ; this . _log . info ( "Loading Weave " + WEAVE_VERSION ) ; this . _clusterManager = this . identity . createClusterManager ( this ) ; this . recordManager = new RecordManager ( this ) ; this . enabled = true ; this . _registerEngines ( ) ; let ua = Cc [ "@mozilla.org/network/protocol;1?name=http" ] . getService ( Ci . nsIHttpProtocolHandler ) . userAgent ; this . _log . info ( ua ) ; if ( ! this . _checkCrypto ( ) ) { this . enabled = false ; this . _log . info ( "Could not load the Weave crypto component. Disabling " + "Weave, since it will not work correctly." ) ; } Svc . Obs . add ( "weave:service:setup-complete" , this ) ; Svc . Prefs . observe ( "engine." , this ) ; this . scheduler = new SyncScheduler ( this ) ; if ( ! this . enabled ) { this . _log . info ( "Firefox Sync disabled." ) ; } this . _updateCachedURLs ( ) ; let status = this . _checkSetup ( ) ; if ( status != STATUS_DISABLED && status != CLIENT_NOT_CONFIGURED ) { Svc . Obs . notify ( "weave:engine:start-tracking" ) ; } for ( let [ probeName , prefName ] of Iterator ( TELEMETRY_CUSTOM_SERVER_PREFS ) ) { let isCustomized = Services . prefs . prefHasUserValue ( prefName ) ; Services . telemetry . getHistogramById ( probeName ) . add ( isCustomized ) ; } Utils . nextTick ( function onNextTick ( ) { this . status . ready = true ; let xps = Cc [ "@mozilla.org/weave/service;1" ] . getService ( Ci . nsISupports ) . wrappedJSObject ; xps . ready = true ; Svc . Obs . notify ( "weave:service:ready" ) ; } . bind ( this ) ) ; }
Prepare to initialize the rest of Weave after waiting a little bit
Prepare to initialize the rest of Weave after waiting a little bit
// Status is instantiated before us and is the first to grab an instance of // the IdentityManager. We use that instance because IdentityManager really // needs to be a singleton. Ideally, the longer-lived object would spawn // this service instance. // Telemetry probes to indicate if the user is using custom servers. // Send an event now that Weave service is ready.  We don't do this // synchronously so that observers can import this module before // registering an observer. // UI code uses the flag on the XPCOM service so it doesn't have // to load a bunch of modules.