[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/tor-browser][tor-browser-149.0a1-16.0-2] 2 commits: fixup! TB 40933: Add tor-launcher functionality



Title: GitLab

henry pushed to branch tor-browser-149.0a1-16.0-2 at The Tor Project / Applications / Tor Browser

Commits:

  • edf9758a
    by Henry Wilkes at 2026-03-24T14:48:48+00:00
    fixup! TB 40933: Add tor-launcher functionality
    
    TB 44753: Drop TorProvider.isBootstrapDone.
    
  • 3dac4f13
    by Henry Wilkes at 2026-03-24T14:48:50+00:00
    fixup! TB 41668: Tweaks to the Base Browser updater for Tor Browser
    
    TB 44753: Use TorConnect rather than TorProvider to determine if we are
    bootstrapped.
    
    This avoids a direct and async call to the provider.
    
    We also add a safety check to determine whether the bootstrap has
    already called before adding the listener.
    

2 changed files:

Changes:

  • toolkit/components/tor-launcher/TorProvider.sys.mjs
    ... ... @@ -137,7 +137,6 @@ export class TorProvider {
    137 137
        */
    
    138 138
       #socksSettings = null;
    
    139 139
     
    
    140
    -  #isBootstrapDone = false;
    
    141 140
       /**
    
    142 141
        * Keep the last warning to avoid broadcasting an async warning if it is the
    
    143 142
        * same one as the last broadcast.
    
    ... ... @@ -510,10 +509,6 @@ export class TorProvider {
    510 509
         return TorLauncherUtil.shouldStartAndOwnTor;
    
    511 510
       }
    
    512 511
     
    
    513
    -  get isBootstrapDone() {
    
    514
    -    return this.#isBootstrapDone;
    
    515
    -  }
    
    516
    -
    
    517 512
       /**
    
    518 513
        * TODO: Rename to isReady once we remove finish the migration.
    
    519 514
        *
    
    ... ... @@ -883,7 +878,6 @@ export class TorProvider {
    883 878
             "Requested to close an already closed control port connection"
    
    884 879
           );
    
    885 880
         }
    
    886
    -    this.#isBootstrapDone = false;
    
    887 881
         this.#lastWarning = {};
    
    888 882
       }
    
    889 883
     
    
    ... ... @@ -1005,12 +999,9 @@ export class TorProvider {
    1005 999
         Services.obs.notifyObservers(statusObj, TorProviderTopics.BootstrapStatus);
    
    1006 1000
     
    
    1007 1001
         if (statusObj.PROGRESS === 100) {
    
    1008
    -      this.#isBootstrapDone = true;
    
    1009 1002
           return;
    
    1010 1003
         }
    
    1011 1004
     
    
    1012
    -    this.#isBootstrapDone = false;
    
    1013
    -
    
    1014 1005
         // Can TYPE ever be ERR for STATUS_CLIENT?
    
    1015 1006
         if (
    
    1016 1007
           isNotification &&
    

  • toolkit/mozapps/update/UpdateService.sys.mjs
    ... ... @@ -22,7 +22,9 @@ ChromeUtils.defineESModuleGetters(lazy, {
    22 22
       AddonManager: "resource://gre/modules/AddonManager.sys.mjs",
    
    23 23
       AsyncShutdown: "resource://gre/modules/AsyncShutdown.sys.mjs",
    
    24 24
       DeferredTask: "resource://gre/modules/DeferredTask.sys.mjs",
    
    25
    -  TorProviderBuilder: "resource://gre/modules/TorProviderBuilder.sys.mjs",
    
    25
    +  TorConnect: "resource://gre/modules/TorConnect.sys.mjs",
    
    26
    +  TorConnectStage: "resource://gre/modules/TorConnect.sys.mjs",
    
    27
    +  TorConnectTopics: "resource://gre/modules/TorConnect.sys.mjs",
    
    26 28
       UpdateLog: "resource://gre/modules/UpdateLog.sys.mjs",
    
    27 29
       UpdateUtils: "resource://gre/modules/UpdateUtils.sys.mjs",
    
    28 30
       WindowsRegistry: "resource://gre/modules/WindowsRegistry.sys.mjs",
    
    ... ... @@ -372,15 +374,6 @@ export function testResetIsBackgroundTaskMode() {
    372 374
       resetIsBackgroundTaskMode();
    
    373 375
     }
    
    374 376
     
    
    375
    -async function _shouldRegisterBootstrapObserver() {
    
    376
    -  try {
    
    377
    -    const provider = await lazy.TorProviderBuilder.build();
    
    378
    -    return !provider.isBootstrapDone && provider.ownsTorDaemon;
    
    379
    -  } catch {
    
    380
    -    return false;
    
    381
    -  }
    
    382
    -}
    
    383
    -
    
    384 377
     /**
    
    385 378
      * Changes `nsIApplicationUpdateService.currentState` and causes
    
    386 379
      * `nsIApplicationUpdateService.stateTransition` to resolve.
    
    ... ... @@ -2831,7 +2824,7 @@ export class UpdateService {
    2831 2824
           case "network:offline-status-changed":
    
    2832 2825
             await this._offlineStatusChanged(data);
    
    2833 2826
             break;
    
    2834
    -      case "torconnect:bootstrap-complete":
    
    2827
    +      case lazy.TorConnectTopics.BootstrapComplete:
    
    2835 2828
             this._bootstrapComplete();
    
    2836 2829
             break;
    
    2837 2830
           case "quit-application":
    
    ... ... @@ -3447,7 +3440,36 @@ export class UpdateService {
    3447 3440
         await this._attemptResume();
    
    3448 3441
       }
    
    3449 3442
     
    
    3443
    +  /**
    
    3444
    +   * Whether we should wait for the Tor bootstrap event to try again because we
    
    3445
    +   * are not yet bootstrapped.
    
    3446
    +   *
    
    3447
    +   * If the browser does not monitor the Tor connection state, this will return
    
    3448
    +   * `false` since the event will never fire.
    
    3449
    +   *
    
    3450
    +   * @returns {boolean} - Whether we should wait for the bootstrap event.
    
    3451
    +   */
    
    3452
    +  _shouldRegisterBootstrapObserver() {
    
    3453
    +    return (
    
    3454
    +      lazy.TorConnect.enabled &&
    
    3455
    +      lazy.TorConnect.stageName !== lazy.TorConnectStage.Bootstrapped
    
    3456
    +    );
    
    3457
    +  }
    
    3458
    +
    
    3459
    +  /**
    
    3460
    +   * Wait for the Tor connection to be bootstrapped before trying again.
    
    3461
    +   */
    
    3450 3462
       _registerBootstrapObserver() {
    
    3463
    +    // Double check that we haven't since become bootstrapped between the call
    
    3464
    +    // to _shouldRegisterBootstrapObserver and _registerBootstrapObserver, which
    
    3465
    +    // may be delayed. If so, we do not wait for the BootstrapComplete signal
    
    3466
    +    // since it has already fired.
    
    3467
    +    if (lazy.TorConnect.stageName === lazy.TorConnectStage.Bootstrapped) {
    
    3468
    +      LOG("UpdateService:_registerBootstrapObserver - already bootstrapped");
    
    3469
    +      this._bootstrapComplete();
    
    3470
    +      return;
    
    3471
    +    }
    
    3472
    +
    
    3451 3473
         if (this._registeredBootstrapObserver) {
    
    3452 3474
           LOG(
    
    3453 3475
             "UpdateService:_registerBootstrapObserver - observer already registered"
    
    ... ... @@ -3460,13 +3482,22 @@ export class UpdateService {
    3460 3482
             "to be complete, then forcing another check"
    
    3461 3483
         );
    
    3462 3484
     
    
    3463
    -    Services.obs.addObserver(this, "torconnect:bootstrap-complete");
    
    3485
    +    Services.obs.addObserver(this, lazy.TorConnectTopics.BootstrapComplete);
    
    3464 3486
         this._registeredBootstrapObserver = true;
    
    3465 3487
       }
    
    3466 3488
     
    
    3489
    +  /**
    
    3490
    +   * Called when the Tor connection becomes bootstrapped. This will trigger a
    
    3491
    +   * retry.
    
    3492
    +   */
    
    3467 3493
       _bootstrapComplete() {
    
    3468
    -    Services.obs.removeObserver(this, "torconnect:bootstrap-complete");
    
    3469
    -    this._registeredBootstrapObserver = false;
    
    3494
    +    if (this._registeredBootstrapObserver) {
    
    3495
    +      Services.obs.removeObserver(
    
    3496
    +        this,
    
    3497
    +        lazy.TorConnectTopics.BootstrapComplete
    
    3498
    +      );
    
    3499
    +      this._registeredBootstrapObserver = false;
    
    3500
    +    }
    
    3470 3501
     
    
    3471 3502
         LOG(
    
    3472 3503
           "UpdateService:_bootstrapComplete - bootstrapping complete, forcing " +
    
    ... ... @@ -3511,7 +3542,7 @@ export class UpdateService {
    3511 3542
           return;
    
    3512 3543
         } else if (
    
    3513 3544
           update.errorCode === PROXY_SERVER_CONNECTION_REFUSED &&
    
    3514
    -      (await _shouldRegisterBootstrapObserver())
    
    3545
    +      this._shouldRegisterBootstrapObserver()
    
    3515 3546
         ) {
    
    3516 3547
           // Register boostrap observer to try again, but only when we own the
    
    3517 3548
           // tor process.
    
    ... ... @@ -7105,7 +7136,7 @@ class Downloader {
    7105 7136
           deleteActiveUpdate = false;
    
    7106 7137
         } else if (
    
    7107 7138
           status === PROXY_SERVER_CONNECTION_REFUSED &&
    
    7108
    -      (await _shouldRegisterBootstrapObserver())
    
    7139
    +      this.updateService._shouldRegisterBootstrapObserver()
    
    7109 7140
         ) {
    
    7110 7141
           // Register a bootstrap observer to try again.
    
    7111 7142
           // The bootstrap observer will continue the incremental download by
    

  • _______________________________________________
    tor-commits mailing list -- tor-commits@xxxxxxxxxxxxxxxxxxxx
    To unsubscribe send an email to tor-commits-leave@xxxxxxxxxxxxxxxxxxxx