Java Code Examples for com.google.ipc.invalidation.util.TypedUtil#equals()

The following examples show how to use com.google.ipc.invalidation.util.TypedUtil#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PersistenceUtils.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Deserializes a Ticl state blob. Returns either the parsed state or {@code null}
 * if it could not be parsed.
 */
public static PersistentTiclState deserializeState(Logger logger, byte[] stateBlobBytes,
    DigestFunction digestFn) {
  PersistentStateBlob stateBlob;
  try {
    // Try parsing the envelope protocol buffer.
    stateBlob = PersistentStateBlob.parseFrom(stateBlobBytes);
  } catch (ValidationException exception) {
    logger.severe("Failed deserializing Ticl state: %s", exception.getMessage());
    return null;
  }

  // Check the mac in the envelope against the recomputed mac from the state.
  PersistentTiclState ticlState = stateBlob.getTiclState();
  Bytes mac = generateMac(ticlState, digestFn);
  if (!TypedUtil.<Bytes>equals(mac, stateBlob.getAuthenticationCode())) {
    logger.warning("Ticl state failed MAC check: computed %s vs %s", mac,
        stateBlob.getAuthenticationCode());
    return null;
  }
  return ticlState;
}
 
Example 2
Source File: PersistenceUtils.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Deserializes a Ticl state blob. Returns either the parsed state or {@code null}
 * if it could not be parsed.
 */
public static PersistentTiclState deserializeState(Logger logger, byte[] stateBlobBytes,
    DigestFunction digestFn) {
  PersistentStateBlob stateBlob;
  try {
    // Try parsing the envelope protocol buffer.
    stateBlob = PersistentStateBlob.parseFrom(stateBlobBytes);
  } catch (InvalidProtocolBufferException exception) {
    logger.severe("Failed deserializing Ticl state: %s", exception.getMessage());
    return null;
  }

  // Check the mac in the envelope against the recomputed mac from the state.
  PersistentTiclState ticlState = stateBlob.getTiclState();
  ByteString mac = generateMac(ticlState, digestFn);
  if (!TypedUtil.<ByteString>equals(mac, stateBlob.getAuthenticationCode())) {
    logger.warning("Ticl state failed MAC check: computed %s vs %s", mac,
        stateBlob.getAuthenticationCode());
    return null;
  }
  return ticlState;
}
 
Example 3
Source File: AndroidListenerState.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Overridden for tests which compare listener states to verify that they have been correctly
 * (un)marshalled. We implement equals rather than exposing private data.
 */
@Override
public boolean equals(Object object) {
  if (this == object) {
    return true;
  }

  if (!(object instanceof AndroidListenerState)) {
    return false;
  }

  AndroidListenerState that = (AndroidListenerState) object;

  return (this.isDirty == that.isDirty)
      && (this.requestCodeSeqNum == that.requestCodeSeqNum)
      && (this.desiredRegistrations.size() == that.desiredRegistrations.size())
      && (this.desiredRegistrations.containsAll(that.desiredRegistrations))
      && TypedUtil.<Bytes>equals(this.clientId, that.clientId)
      && equals(this.delayGenerators, that.delayGenerators)
      && equals(this.registrationRetries, that.registrationRetries);
}
 
Example 4
Source File: PersistenceUtils.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Deserializes a Ticl state blob. Returns either the parsed state or {@code null}
 * if it could not be parsed.
 */
public static PersistentTiclState deserializeState(Logger logger, byte[] stateBlobBytes,
    DigestFunction digestFn) {
  PersistentStateBlob stateBlob;
  try {
    // Try parsing the envelope protocol buffer.
    stateBlob = PersistentStateBlob.parseFrom(stateBlobBytes);
  } catch (InvalidProtocolBufferException exception) {
    logger.severe("Failed deserializing Ticl state: %s", exception.getMessage());
    return null;
  }

  // Check the mac in the envelope against the recomputed mac from the state.
  PersistentTiclState ticlState = stateBlob.getTiclState();
  ByteString mac = generateMac(ticlState, digestFn);
  if (!TypedUtil.<ByteString>equals(mac, stateBlob.getAuthenticationCode())) {
    logger.warning("Ticl state failed MAC check: computed %s vs %s", mac,
        stateBlob.getAuthenticationCode());
    return null;
  }
  return ticlState;
}
 
Example 5
Source File: Statistics.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Given the serialized {@code performanceCounters} of the client statistics, returns a Statistics
 * object with the performance counter values from {@code performanceCounters}.
 */

public static Statistics deserializeStatistics(Logger logger,
    Collection<PropertyRecord> performanceCounters) {
  Statistics statistics = new Statistics();

  // For each counter, parse out the counter name and value.
  for (PropertyRecord performanceCounter : performanceCounters) {
    String counterName = performanceCounter.getName();
    String[] parts = counterName.split("\\.");
    if (parts.length != 2) {
      logger.warning("Perf counter name must of form: class.value, skipping: %s", counterName);
      continue;
    }
    String className = parts[0];
    String fieldName = parts[1];
    int counterValue = performanceCounter.getValue();

    // Call the relevant method in a loop (i.e., depending on the type of the class).
    if (TypedUtil.<String>equals(className, SENT_MESSAGE_TYPE_NAME)) {
      incrementPerformanceCounterValue(logger, SENT_MESSAGE_TYPE_NAME_TO_VALUE_MAP,
          statistics.sentMessageTypes, fieldName, counterValue);
    } else if (TypedUtil.<String>equals(className, INCOMING_OPERATION_TYPE_NAME)) {
      incrementPerformanceCounterValue(logger, INCOMING_OPERATION_TYPE_NAME_TO_VALUE_MAP,
          statistics.incomingOperationTypes, fieldName, counterValue);
    } else if (TypedUtil.<String>equals(className, RECEIVED_MESSAGE_TYPE_NAME)) {
      incrementPerformanceCounterValue(logger, RECEIVED_MESSAGE_TYPE_NAME_TO_VALUE_MAP,
          statistics.receivedMessageTypes, fieldName, counterValue);
    } else if (TypedUtil.<String>equals(className,  LISTENER_EVENT_TYPE_NAME)) {
      incrementPerformanceCounterValue(logger, LISTENER_EVENT_TYPE_NAME_TO_VALUE_MAP,
          statistics.listenerEventTypes, fieldName, counterValue);
    } else if (TypedUtil.<String>equals(className,  CLIENT_ERROR_TYPE_NAME)) {
      incrementPerformanceCounterValue(logger, CLIENT_ERROR_TYPE_NAME_TO_VALUE_MAP,
          statistics.clientErrorTypes, fieldName, counterValue);
    } else {
      logger.warning("Skipping unknown enum class name %s", className);
    }
  }
  return statistics;
}
 
Example 6
Source File: InvalidationClientCore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Returns whether the token in the header of {@code parsedMessage} matches either the
 * client token or nonce of this Ticl (depending on which is non-{@code null}).
 */
private boolean validateToken(ParsedMessage parsedMessage) {
  if (clientToken != null) {
    // Client token case.
    if (!TypedUtil.<ByteString>equals(clientToken, parsedMessage.header.token)) {
      logger.info("Incoming message has bad token: server = %s, client = %s",
          CommonProtoStrings2.toLazyCompactString(parsedMessage.header.token),
          CommonProtoStrings2.toLazyCompactString(clientToken));
      statistics.recordError(ClientErrorType.TOKEN_MISMATCH);
      return false;
    }
    return true;
  } else if (nonce != null) {
    // Nonce case.
    if (!TypedUtil.<ByteString>equals(nonce, parsedMessage.header.token)) {
      statistics.recordError(ClientErrorType.NONCE_MISMATCH);
      logger.info("Rejecting server message with mismatched nonce: Client = %s, Server = %s",
          CommonProtoStrings2.toLazyCompactString(nonce),
          CommonProtoStrings2.toLazyCompactString(parsedMessage.header.token));
      return false;
    } else {
      logger.info("Accepting server message with matching nonce: %s",
          CommonProtoStrings2.toLazyCompactString(nonce));
      return true;
    }
  }
  // Neither token nor nonce; ignore message.
  logger.warning("Neither token nor nonce was set in validateToken: %s, %s", clientToken, nonce);
  return false;
}
 
Example 7
Source File: InvalidationClientCore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Handles a token-control message.
 * @param headerToken token in the server message
 * @param newToken the new token provided, or {@code null} if this is a destroy message.
 */
private void handleTokenChanged(ByteString headerToken, final ByteString newToken) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");

  // The server is either supplying a new token in response to an InitializeMessage, spontaneously
  // destroying a token we hold, or spontaneously upgrading a token we hold.

  if (newToken != null) {
    // Note: headerToken cannot be null, so a null nonce or clientToken will always be non-equal.
    boolean headerTokenMatchesNonce = TypedUtil.<ByteString>equals(headerToken, nonce);
    boolean headerTokenMatchesExistingToken =
        TypedUtil.<ByteString>equals(headerToken, clientToken);
    boolean shouldAcceptToken = headerTokenMatchesNonce || headerTokenMatchesExistingToken;
    if (!shouldAcceptToken) {
      logger.info("Ignoring new token; %s does not match nonce = %s or existing token = %s",
          newToken, nonce, clientToken);
      return;
    }
    logger.info("New token being assigned at client: %s, Old = %s",
        CommonProtoStrings2.toLazyCompactString(newToken),
        CommonProtoStrings2.toLazyCompactString(clientToken));

    // Start the regular heartbeats now.
    heartbeatTask.ensureScheduled("Heartbeat-after-new-token");
    setNonce(null);
    setClientToken(newToken);
    persistentWriteTask.ensureScheduled("Write-after-new-token");
  } else {
    logger.info("Destroying existing token: %s",
        CommonProtoStrings2.toLazyCompactString(clientToken));
    acquireToken("Destroy");
  }
}
 
Example 8
Source File: Statistics.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Given the serialized {@code performanceCounters} of the client statistics, returns a Statistics
 * object with the performance counter values from {@code performanceCounters}.
 */

public static Statistics deserializeStatistics(Logger logger,
    Collection<PropertyRecord> performanceCounters) {
  Statistics statistics = new Statistics();

  // For each counter, parse out the counter name and value.
  for (PropertyRecord performanceCounter : performanceCounters) {
    String counterName = performanceCounter.getName();
    String[] parts = counterName.split("\\.");
    if (parts.length != 2) {
      logger.warning("Perf counter name must of form: class.value, skipping: %s", counterName);
      continue;
    }
    String className = parts[0];
    String fieldName = parts[1];
    int counterValue = performanceCounter.getValue();

    // Call the relevant method in a loop (i.e., depending on the type of the class).
    if (TypedUtil.<String>equals(className, SENT_MESSAGE_TYPE_NAME)) {
      incrementPerformanceCounterValue(logger, SENT_MESSAGE_TYPE_NAME_TO_VALUE_MAP,
          statistics.sentMessageTypes, fieldName, counterValue);
    } else if (TypedUtil.<String>equals(className, INCOMING_OPERATION_TYPE_NAME)) {
      incrementPerformanceCounterValue(logger, INCOMING_OPERATION_TYPE_NAME_TO_VALUE_MAP,
          statistics.incomingOperationTypes, fieldName, counterValue);
    } else if (TypedUtil.<String>equals(className, RECEIVED_MESSAGE_TYPE_NAME)) {
      incrementPerformanceCounterValue(logger, RECEIVED_MESSAGE_TYPE_NAME_TO_VALUE_MAP,
          statistics.receivedMessageTypes, fieldName, counterValue);
    } else if (TypedUtil.<String>equals(className,  LISTENER_EVENT_TYPE_NAME)) {
      incrementPerformanceCounterValue(logger, LISTENER_EVENT_TYPE_NAME_TO_VALUE_MAP,
          statistics.listenerEventTypes, fieldName, counterValue);
    } else if (TypedUtil.<String>equals(className,  CLIENT_ERROR_TYPE_NAME)) {
      incrementPerformanceCounterValue(logger, CLIENT_ERROR_TYPE_NAME_TO_VALUE_MAP,
          statistics.clientErrorTypes, fieldName, counterValue);
    } else {
      logger.warning("Skipping unknown enum class name %s", className);
    }
  }
  return statistics;
}
 
Example 9
Source File: InvalidationClientCore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Returns whether the token in the header of {@code parsedMessage} matches either the
 * client token or nonce of this Ticl (depending on which is non-{@code null}).
 */
private boolean validateToken(ParsedMessage parsedMessage) {
  if (clientToken != null) {
    // Client token case.
    if (!TypedUtil.<ByteString>equals(clientToken, parsedMessage.header.token)) {
      logger.info("Incoming message has bad token: server = %s, client = %s",
          CommonProtoStrings2.toLazyCompactString(parsedMessage.header.token),
          CommonProtoStrings2.toLazyCompactString(clientToken));
      statistics.recordError(ClientErrorType.TOKEN_MISMATCH);
      return false;
    }
    return true;
  } else if (nonce != null) {
    // Nonce case.
    if (!TypedUtil.<ByteString>equals(nonce, parsedMessage.header.token)) {
      statistics.recordError(ClientErrorType.NONCE_MISMATCH);
      logger.info("Rejecting server message with mismatched nonce: Client = %s, Server = %s",
          CommonProtoStrings2.toLazyCompactString(nonce),
          CommonProtoStrings2.toLazyCompactString(parsedMessage.header.token));
      return false;
    } else {
      logger.info("Accepting server message with matching nonce: %s",
          CommonProtoStrings2.toLazyCompactString(nonce));
      return true;
    }
  }
  // Neither token nor nonce; ignore message.
  logger.warning("Neither token nor nonce was set in validateToken: %s, %s", clientToken, nonce);
  return false;
}
 
Example 10
Source File: InvalidationClientCore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Handles a token-control message.
 * @param headerToken token in the server message
 * @param newToken the new token provided, or {@code null} if this is a destroy message.
 */
private void handleTokenChanged(ByteString headerToken, final ByteString newToken) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");

  // The server is either supplying a new token in response to an InitializeMessage, spontaneously
  // destroying a token we hold, or spontaneously upgrading a token we hold.

  if (newToken != null) {
    // Note: headerToken cannot be null, so a null nonce or clientToken will always be non-equal.
    boolean headerTokenMatchesNonce = TypedUtil.<ByteString>equals(headerToken, nonce);
    boolean headerTokenMatchesExistingToken =
        TypedUtil.<ByteString>equals(headerToken, clientToken);
    boolean shouldAcceptToken = headerTokenMatchesNonce || headerTokenMatchesExistingToken;
    if (!shouldAcceptToken) {
      logger.info("Ignoring new token; %s does not match nonce = %s or existing token = %s",
          newToken, nonce, clientToken);
      return;
    }
    logger.info("New token being assigned at client: %s, Old = %s",
        CommonProtoStrings2.toLazyCompactString(newToken),
        CommonProtoStrings2.toLazyCompactString(clientToken));

    // Start the regular heartbeats now.
    heartbeatTask.ensureScheduled("Heartbeat-after-new-token");
    setNonce(null);
    setClientToken(newToken);
    persistentWriteTask.ensureScheduled("Write-after-new-token");
  } else {
    logger.info("Destroying existing token: %s",
        CommonProtoStrings2.toLazyCompactString(clientToken));
    acquireToken("Destroy");
  }
}
 
Example 11
Source File: Statistics.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Given the serialized {@code performanceCounters} of the client statistics, returns a Statistics
 * object with the performance counter values from {@code performanceCounters}.
 */

public static Statistics deserializeStatistics(Logger logger,
    Collection<PropertyRecord> performanceCounters) {
  Statistics statistics = new Statistics();

  // For each counter, parse out the counter name and value.
  for (PropertyRecord performanceCounter : performanceCounters) {
    String counterName = performanceCounter.getName();
    String[] parts = counterName.split("\\.");
    if (parts.length != 2) {
      logger.warning("Perf counter name must of form: class.value, skipping: %s", counterName);
      continue;
    }
    String className = parts[0];
    String fieldName = parts[1];
    int counterValue = performanceCounter.getValue();

    // Call the relevant method in a loop (i.e., depending on the type of the class).
    if (TypedUtil.<String>equals(className, SENT_MESSAGE_TYPE_NAME)) {
      incrementPerformanceCounterValue(logger, SENT_MESSAGE_TYPE_NAME_TO_VALUE_MAP,
          statistics.sentMessageTypes, fieldName, counterValue);
    } else if (TypedUtil.<String>equals(className, INCOMING_OPERATION_TYPE_NAME)) {
      incrementPerformanceCounterValue(logger, INCOMING_OPERATION_TYPE_NAME_TO_VALUE_MAP,
          statistics.incomingOperationTypes, fieldName, counterValue);
    } else if (TypedUtil.<String>equals(className, RECEIVED_MESSAGE_TYPE_NAME)) {
      incrementPerformanceCounterValue(logger, RECEIVED_MESSAGE_TYPE_NAME_TO_VALUE_MAP,
          statistics.receivedMessageTypes, fieldName, counterValue);
    } else if (TypedUtil.<String>equals(className,  LISTENER_EVENT_TYPE_NAME)) {
      incrementPerformanceCounterValue(logger, LISTENER_EVENT_TYPE_NAME_TO_VALUE_MAP,
          statistics.listenerEventTypes, fieldName, counterValue);
    } else if (TypedUtil.<String>equals(className,  CLIENT_ERROR_TYPE_NAME)) {
      incrementPerformanceCounterValue(logger, CLIENT_ERROR_TYPE_NAME_TO_VALUE_MAP,
          statistics.clientErrorTypes, fieldName, counterValue);
    } else {
      logger.warning("Skipping unknown enum class name %s", className);
    }
  }
  return statistics;
}
 
Example 12
Source File: AndroidListenerState.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/** Compares the contents of two {@link #delayGenerators} maps. */
private static boolean equals(Map<ObjectId, TiclExponentialBackoffDelayGenerator> x,
    Map<ObjectId, TiclExponentialBackoffDelayGenerator> y) {
  if (x.size() != y.size()) {
    return false;
  }
  for (Entry<ObjectId, TiclExponentialBackoffDelayGenerator> xEntry : x.entrySet()) {
    TiclExponentialBackoffDelayGenerator yGenerator = y.get(xEntry.getKey());
    if ((yGenerator == null) || !TypedUtil.<ExponentialBackoffState>equals(
        xEntry.getValue().marshal(), yGenerator.marshal())) {
      return false;
    }
  }
  return true;
}
 
Example 13
Source File: InvalidationClientCore.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Returns whether the token in the header of {@code parsedMessage} matches either the
 * client token or nonce of this Ticl (depending on which is non-{@code null}).
 */
private boolean validateToken(ParsedMessage parsedMessage) {
  if (clientToken != null) {
    // Client token case.
    if (!TypedUtil.<Bytes>equals(clientToken, parsedMessage.header.token)) {
      logger.info("Incoming message has bad token: server = %s, client = %s",
          parsedMessage.header.token, clientToken);
      statistics.recordError(ClientErrorType.TOKEN_MISMATCH);
      return false;
    }
    return true;
  } else if (nonce != null) {
    // Nonce case.
    if (!TypedUtil.<Bytes>equals(nonce, parsedMessage.header.token)) {
      statistics.recordError(ClientErrorType.NONCE_MISMATCH);
      logger.info("Rejecting server message with mismatched nonce: Client = %s, Server = %s",
          nonce, parsedMessage.header.token);
      return false;
    } else {
      logger.info("Accepting server message with matching nonce: %s", nonce);
      return true;
    }
  }
  // Neither token nor nonce; ignore message.
  logger.warning("Neither token nor nonce was set in validateToken: %s, %s", clientToken, nonce);
  return false;
}
 
Example 14
Source File: InvalidationClientCore.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Handles a token-control message.
 * @param headerToken token in the server message
 * @param newToken the new token provided, or {@code null} if this is a destroy message.
 */
private void handleTokenChanged(Bytes headerToken, final Bytes newToken) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");

  // The server is either supplying a new token in response to an InitializeMessage, spontaneously
  // destroying a token we hold, or spontaneously upgrading a token we hold.

  if (newToken != null) {
    // Note: headerToken cannot be null, so a null nonce or clientToken will always be non-equal.
    boolean headerTokenMatchesNonce = TypedUtil.<Bytes>equals(headerToken, nonce);
    boolean headerTokenMatchesExistingToken = TypedUtil.<Bytes>equals(headerToken, clientToken);
    boolean shouldAcceptToken = headerTokenMatchesNonce || headerTokenMatchesExistingToken;
    if (!shouldAcceptToken) {
      logger.info("Ignoring new token; %s does not match nonce = %s or existing token = %s",
          newToken, nonce, clientToken);
      return;
    }
    logger.info("New token being assigned at client: %s, Old = %s", newToken, clientToken);

    // Start the regular heartbeats now.
    heartbeatTask.ensureScheduled("Heartbeat-after-new-token");
    setNonce(null);
    setClientToken(newToken);
    persistentWriteTask.ensureScheduled("Write-after-new-token");
  } else {
    logger.info("Destroying existing token: %s", clientToken);
    acquireToken("Destroy");
  }
}
 
Example 15
Source File: TiclStateManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/** Returns whether the digest in {@code state} is correct. */
private static boolean isDigestValid(AndroidTiclStateWithDigest state, Logger logger) {
  Sha1DigestFunction digester = new Sha1DigestFunction();
  digester.update(state.getState().toByteArray());
  byte[] computedDigest = digester.getDigest();
  if (!TypedUtil.<Bytes>equals(new Bytes(computedDigest), state.getDigest())) {
    logger.warning("Android TICL state digest mismatch; computed %s for %s",
        computedDigest, state);
    return false;
  }
  return true;
}
 
Example 16
Source File: InvalidationClientCore.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public boolean runTask() {
  if (clientToken == null) {
    // We cannot write without a token. We must do this check before creating the
    // PersistentTiclState because newPersistentTiclState cannot handle null tokens.
    return false;
  }

  // Compute the state that we will write if we decide to go ahead with the write.
  final PersistentTiclState state =
      PersistentTiclState.create(clientToken, lastMessageSendTimeMs);
  byte[] serializedState = PersistenceUtils.serializeState(state, digestFn);

  // Decide whether or not to do the write. The decision varies depending on whether or
  // not the channel supports offline delivery. If we decide not to do the write, then
  // that means the in-memory and stored state match semantically, and the train stops.
  if (config.getChannelSupportsOfflineDelivery()) {
    // For offline delivery, we want the entire state to match, since we write the last
    // send time for every message.
    if (state.equals(lastWrittenState.get())) {
      return false;
    }
  } else {
    // If we do not support offline delivery, we avoid writing the state on each message, and
    // we avoid checking the last-sent time (we check only the client token).
    if (TypedUtil.<Bytes>equals(
        state.getClientToken(), lastWrittenState.get().getClientToken())) {
      return false;
    }
  }

  // We decided to do the write.
  storage.writeKey(CLIENT_TOKEN_KEY, serializedState, new Callback<Status>() {
    @Override
    public void accept(Status status) {
      logger.info("Write state completed: %s for %s", status, state);
      Preconditions.checkState(resources.getInternalScheduler().isRunningOnThread());
      if (status.isSuccess()) {
        // Set lastWrittenToken to be the token that was written (NOT clientToken - which
        // could have changed while the write was happening).
        lastWrittenState.set(state);
      } else {
        statistics.recordError(ClientErrorType.PERSISTENT_WRITE_FAILURE);
      }
    }
  });
  return true;  // Reschedule after timeout to make sure that write does happen.
}
 
Example 17
Source File: RegistrationManager.java    From 365browser with Apache License 2.0 2 votes vote down vote up
/**
 * Returns whether the local registration state and server state agree, based on the last
 * received server summary (from {@link #informServerRegistrationSummary}).
 */
boolean isStateInSyncWithServer() {
  return TypedUtil.<RegistrationSummary>equals(lastKnownServerSummary, getRegistrationSummary());
}
 
Example 18
Source File: RegistrationManager.java    From android-chromium with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Returns whether the local registration state and server state agree, based on the last
 * received server summary (from {@link #informServerRegistrationSummary}).
 */
boolean isStateInSyncWithServer() {
  return TypedUtil.equals(lastKnownServerSummary, ProtoWrapper.of(getRegistrationSummary()));
}
 
Example 19
Source File: RegistrationManager.java    From android-chromium with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Returns whether the local registration state and server state agree, based on the last
 * received server summary (from {@link #informServerRegistrationSummary}).
 */
boolean isStateInSyncWithServer() {
  return TypedUtil.equals(lastKnownServerSummary, ProtoWrapper.of(getRegistrationSummary()));
}