B2G/gecko/services/healthreport/policy.jsm
/**
   * Check state and trigger actions, if necessary.
   *
   * This is what enforces the submission and notification policy detailed
   * above. You can think of this as the driver for health report data
   * submission.
   *
   * Typically this function is called automatically by the background polling.
   * But, it can safely be called manually as needed.
   */
Check state and trigger actions, if necessary.
This is what enforces the submission and notification policy detailed
above. You can think of this as the driver for health report data
submission.

Typically this function is called automatically by the background polling.
But, it can safely be called manually as needed.
Check state and trigger actions if necessary . This is what enforces the submission and notification policy detailed above . You can think of this as the driver for health report data submission . Typically this function is called automatically by the background polling . But it can safely be called manually as needed .
function checkStateAndTrigger() {
    if (!this.dataSubmissionEnabled) {
      this._log.debug("Data submission is disabled. Doing nothing.");
      return;
    }
    let now = this.now();
    let nowT = now.getTime();
    let nextSubmissionDate = this.nextDataSubmissionDate;
    if (nextSubmissionDate.getTime() >= nowT + 3 * MILLISECONDS_PER_DAY) {
      this._log.warn("Next data submission time is far away. Was the system " +
                     "clock recently readjusted? " + nextSubmissionDate);
      this._moveScheduleForward24h();
    }
    if (this._processInProgressSubmission()) {
      return;
    }
    if (this.pendingDeleteRemoteData) {
      if (nowT < nextSubmissionDate.getTime()) {
        this._log.debug("Deletion request is scheduled for the future: " +
                        nextSubmissionDate);
        return;
      }
      return this._dispatchSubmissionRequest("onRequestRemoteDelete", true);
    }
    if (!this.dataUploadEnabled) {
      this._log.debug("Data upload is disabled. Doing nothing.");
      return;
    }
    if (!this.ensureNotifyResponse(now)) {
      return;
    }
    if (!this.dataSubmissionPolicyAccepted && !this.dataSubmissionPolicyBypassAcceptance) {
      this._log.debug("Data submission has been disabled per user request.");
      return;
    }
    if (nowT < nextSubmissionDate.getTime()) {
      this._log.debug("Next data submission is scheduled in the future: " +
                     nextSubmissionDate);
      return;
    }
    return this._dispatchSubmissionRequest("onRequestDataUpload", false);
  }
function checkStateAndTrigger ( ) { if ( ! this . dataSubmissionEnabled ) { this . _log . debug ( "Data submission is disabled. Doing nothing." ) ; return ; } let now = this . now ( ) ; let nowT = now . getTime ( ) ; let nextSubmissionDate = this . nextDataSubmissionDate ; if ( nextSubmissionDate . getTime ( ) >= nowT + 3 * MILLISECONDS_PER_DAY ) { this . _log . warn ( "Next data submission time is far away. Was the system " + "clock recently readjusted? " + nextSubmissionDate ) ; this . _moveScheduleForward24h ( ) ; } if ( this . _processInProgressSubmission ( ) ) { return ; } if ( this . pendingDeleteRemoteData ) { if ( nowT < nextSubmissionDate . getTime ( ) ) { this . _log . debug ( "Deletion request is scheduled for the future: " + nextSubmissionDate ) ; return ; } return this . _dispatchSubmissionRequest ( "onRequestRemoteDelete" , true ) ; } if ( ! this . dataUploadEnabled ) { this . _log . debug ( "Data upload is disabled. Doing nothing." ) ; return ; } if ( ! this . ensureNotifyResponse ( now ) ) { return ; } if ( ! this . dataSubmissionPolicyAccepted && ! this . dataSubmissionPolicyBypassAcceptance ) { this . _log . debug ( "Data submission has been disabled per user request." ) ; return ; } if ( nowT < nextSubmissionDate . getTime ( ) ) { this . _log . debug ( "Next data submission is scheduled in the future: " + nextSubmissionDate ) ; return ; } return this . _dispatchSubmissionRequest ( "onRequestDataUpload" , false ) ; }
Check state and trigger actions, if necessary.
Check state and trigger actions if necessary .
// If the master data submission kill switch is toggled, we have nothing // to do. We don't notify about data policies because this would have // no effect. // If the system clock were ever set to a time in the distant future, // it's possible our next schedule date is far out as well. We know // we shouldn't schedule for more than a day out, so we reset the next // scheduled date appropriately. 3 days was chosen arbitrarily. // It shouldn't really matter what we set this to. 1 day in the future // should be pretty safe. // Fall through since we may have other actions. // Tend to any in progress work. // Requests to delete remote data take priority above everything else. // If the user hasn't responded to the data policy, don't do anything. // User has opted out of data submission. // User has responded to data policy and data submission is enabled. Now // comes the scheduling part.