doScan_() {
    this.logger_.info('Start app status scan.');
    const promises = [];

    // Scans all sinks against all registered apps.
    this.discoveryService_.getSinks().forEach(sink => {
      promises.push.apply(promises, this.scanSink(sink));
    });

    // Scans all activities.
    this.activityRecords_.getActivities().forEach(activity => {
      promises.push(this.scanActivity_(activity));
    });

    PromiseUtils.allSettled(promises).then(() => {
      if (this.running_ && !this.timeoutId_) {
        this.logger_.fine('Scan complete; scheduling for next scan.');
        // NOTE(imcheng): setTimeout with a large delay does not work well in
        // event pages. Instead we should be using chrome.alarms API, but note
        // that it is subject to a minmum delay of 1 minute.
        this.timeoutId_ = setTimeout(() => {
          this.doRescan_();
        }, AppDiscoveryService.CHECK_INTERVAL_MILLIS);
      }
    });
  }
/**
   * Issues app info queries and updates sink app status and activities
   * according to results. Queries will be made for the following:
   * 1) All registered apps, against all discovered sinks. Note that a (app,
   * sink) combination is only queried if its status is unknown, or if enough
   * time has elapsed since its previous status was known.
   * 2) Each activity's app against its sink.
   * Once all queries have returned and all updates have been made, schedules a
   * scan in the future.
   * @private
   */
Issues app info queries and updates sink app status and activities
according to results. Queries will be made for the following:
1) All registered apps, against all discovered sinks. Note that a (app,
sink) combination is only queried if its status is unknown, or if enough
time has elapsed since its previous status was known.
2) Each activity's app against its sink.
Once all queries have returned and all updates have been made, schedules a
scan in the future.
@private
Issues app info queries and updates sink app status and activities according to results . Queries will be made for the following : 1 ) All registered apps against all discovered sinks . Note that a ( app sink ) combination is only queried if its status is unknown or if enough time has elapsed since its previous status was known . 2 ) Each activity ' s app against its sink . Once all queries have returned and all updates have been made schedules a scan in the future . @private
doScan_() {
    this.logger_.info('Start app status scan.');
    const promises = [];
    this.discoveryService_.getSinks().forEach(sink => {
      promises.push.apply(promises, this.scanSink(sink));
    });
    this.activityRecords_.getActivities().forEach(activity => {
      promises.push(this.scanActivity_(activity));
    });
    PromiseUtils.allSettled(promises).then(() => {
      if (this.running_ && !this.timeoutId_) {
        this.logger_.fine('Scan complete; scheduling for next scan.');
        this.timeoutId_ = setTimeout(() => {
          this.doRescan_();
        }, AppDiscoveryService.CHECK_INTERVAL_MILLIS);
      }
    });
  }
doScan_ ( ) { this . logger_ . info ( 'Start app status scan.' ) ; const promises = [ ] ; this . discoveryService_ . getSinks ( ) . forEach ( sink => { promises . push . apply ( promises , this . scanSink ( sink ) ) ; } ) ; this . activityRecords_ . getActivities ( ) . forEach ( activity => { promises . push ( this . scanActivity_ ( activity ) ) ; } ) ; PromiseUtils . allSettled ( promises ) . then ( ( ) => { if ( this . running_ && ! this . timeoutId_ ) { this . logger_ . fine ( 'Scan complete; scheduling for next scan.' ) ; this . timeoutId_ = setTimeout ( ( ) => { this . doRescan_ ( ) ; } , AppDiscoveryService . CHECK_INTERVAL_MILLIS ) ; } } ) ; }
Issues app info queries and updates sink app status and activities
 according to results.
Issues app info queries and updates sink app status and activities according to results .
// Scans all sinks against all registered apps. // Scans all activities. // NOTE(imcheng): setTimeout with a large delay does not work well in // event pages. Instead we should be using chrome.alarms API, but note // that it is subject to a minmum delay of 1 minute.