extensions/amp-consent/0.1/consent-state-manager.js
/**
   * Write the new value to localStorage and send updateHrefRequest
   * @param {!ConsentInfoDef} consentInfo
   */
Write the new value to localStorage and send updateHrefRequest
@param {!ConsentInfoDef} consentInfo
Write the new value to localStorage and send updateHrefRequest @param { !ConsentInfoDef } consentInfo
updateStoredValue_(consentInfo) {
    this.storagePromise_.then(storage => {
      if (!isConsentInfoStoredValueSame(
          consentInfo, this.localConsentInfo_)) {
        return;
      }
      const consentStr = consentInfo['consentString'];
      if (consentStr && consentStr.length > 150) {
        user().error(TAG,
            'Cannot store consentString which length exceeds 150 ' +
            'Previous stored consentInfo will be cleared');
        storage.remove(this.storageKey_);
        return;
      }
      const value = composeStoreValue(
          consentInfo, this.isAmpConsentV2ExperimentOn_);
      if (value == null) {
        return;
      }
      storage.setNonBoolean(this.storageKey_, value);
      this.sendUpdateHrefRequest_(consentInfo);
    });
  }
updateStoredValue_ ( consentInfo ) { this . storagePromise_ . then ( storage => { if ( ! isConsentInfoStoredValueSame ( consentInfo , this . localConsentInfo_ ) ) { return ; } const consentStr = consentInfo [ 'consentString' ] ; if ( consentStr && consentStr . length > 150 ) { user ( ) . error ( TAG , 'Cannot store consentString which length exceeds 150 ' + 'Previous stored consentInfo will be cleared' ) ; storage . remove ( this . storageKey_ ) ; return ; } const value = composeStoreValue ( consentInfo , this . isAmpConsentV2ExperimentOn_ ) ; if ( value == null ) { return ; } storage . setNonBoolean ( this . storageKey_ , value ) ; this . sendUpdateHrefRequest_ ( consentInfo ) ; } ) ; }
Write the new value to localStorage and send updateHrefRequest
 @param {!ConsentInfoDef} consentInfo
Write the new value to localStorage and send updateHrefRequest @param { !ConsentInfoDef } consentInfo
// If state has changed. do not store outdated value. // Verify the length of consentString. // 150 * 2 (utf8Encode) * 4/3 (base64) = 400 bytes. // TODO: Need utf8Encode if necessary. // If new consentInfo value cannot be stored, need to remove previous // value // TODO: Good to have a way to inform CMP service in this case // Value can be false, do not use !value check // Nothing to store to localStorage