Java Code Examples for com.google.ipc.invalidation.external.client.InvalidationListener#RegistrationState

The following examples show how to use com.google.ipc.invalidation.external.client.InvalidationListener#RegistrationState . 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: InvalidationClientCore.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/** Handles incoming registration statuses. */
private void handleRegistrationStatus(List<RegistrationStatus> regStatusList) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  List<Boolean> localProcessingStatuses =
      registrationManager.handleRegistrationStatus(regStatusList);
  Preconditions.checkState(localProcessingStatuses.size() == regStatusList.size(),
      "Not all registration statuses were processed");

  // Inform app about the success or failure of each registration based
  // on what the registration manager has indicated.
  for (int i = 0; i < regStatusList.size(); ++i) {
    RegistrationStatus regStatus = regStatusList.get(i);
    boolean wasSuccess = localProcessingStatuses.get(i);
    logger.fine("Process reg status: %s", regStatus);

    ObjectId objectId = ProtoWrapperConverter.convertFromObjectIdProto(
      regStatus.getRegistration().getObjectId());
    if (wasSuccess) {
      // Server operation was both successful and agreed with what the client wanted.
      int regOpType = regStatus.getRegistration().getOpType();
      InvalidationListener.RegistrationState regState = convertOpTypeToRegState(regOpType);
      listener.informRegistrationStatus(InvalidationClientCore.this, objectId, regState);
    } else {
      // Server operation either failed or disagreed with client's intent (e.g., successful
      // unregister, but the client wanted a registration).
      String description = CommonProtos.isSuccess(regStatus.getStatus())
          ? "Registration discrepancy detected" : regStatus.getStatus().getDescription();
      boolean isPermanent = CommonProtos.isPermanentFailure(regStatus.getStatus());
      listener.informRegistrationFailure(InvalidationClientCore.this, objectId, !isPermanent,
          description);
    }
  }
}
 
Example 2
Source File: InvalidationClientCore.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Converts an operation type {@code regOpType} to a
 * {@code InvalidationListener.RegistrationState}.
 */
private static InvalidationListener.RegistrationState convertOpTypeToRegState(int regOpType) {
  InvalidationListener.RegistrationState regState =
      regOpType == RegistrationP.OpType.REGISTER ?
          InvalidationListener.RegistrationState.REGISTERED :
            InvalidationListener.RegistrationState.UNREGISTERED;
  return regState;
}
 
Example 3
Source File: InvalidationClientCore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** Handles incoming registration statuses. */
private void handleRegistrationStatus(List<RegistrationStatus> regStatusList) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  List<Boolean> localProcessingStatuses =
      registrationManager.handleRegistrationStatus(regStatusList);
  Preconditions.checkState(localProcessingStatuses.size() == regStatusList.size(),
      "Not all registration statuses were processed");

  // Inform app about the success or failure of each registration based
  // on what the registration manager has indicated.
  for (int i = 0; i < regStatusList.size(); ++i) {
    RegistrationStatus regStatus = regStatusList.get(i);
    boolean wasSuccess = localProcessingStatuses.get(i);
    logger.fine("Process reg status: %s", regStatus);

    ObjectId objectId = ProtoConverter.convertFromObjectIdProto(
      regStatus.getRegistration().getObjectId());
    if (wasSuccess) {
      // Server operation was both successful and agreed with what the client wanted.
      OpType regOpType = regStatus.getRegistration().getOpType();
      InvalidationListener.RegistrationState regState = convertOpTypeToRegState(regOpType);
      listener.informRegistrationStatus(InvalidationClientCore.this, objectId, regState);
    } else {
      // Server operation either failed or disagreed with client's intent (e.g., successful
      // unregister, but the client wanted a registration).
      String description = CommonProtos2.isSuccess(regStatus.getStatus()) ?
          "Registration discrepancy detected" : regStatus.getStatus().getDescription();
      boolean isPermanent = CommonProtos2.isPermanentFailure(regStatus.getStatus());
      listener.informRegistrationFailure(InvalidationClientCore.this, objectId, !isPermanent,
          description);
    }
  }
}
 
Example 4
Source File: InvalidationClientCore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Converts an operation type {@code regOpType} to a
 * {@code InvalidationListener.RegistrationState}.
 */
private static InvalidationListener.RegistrationState convertOpTypeToRegState(
    RegistrationP.OpType regOpType) {
  InvalidationListener.RegistrationState regState =
      regOpType == RegistrationP.OpType.REGISTER ?
          InvalidationListener.RegistrationState.REGISTERED :
            InvalidationListener.RegistrationState.UNREGISTERED;
  return regState;
}
 
Example 5
Source File: InvalidationClientCore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** Handles incoming registration statuses. */
private void handleRegistrationStatus(List<RegistrationStatus> regStatusList) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  List<Boolean> localProcessingStatuses =
      registrationManager.handleRegistrationStatus(regStatusList);
  Preconditions.checkState(localProcessingStatuses.size() == regStatusList.size(),
      "Not all registration statuses were processed");

  // Inform app about the success or failure of each registration based
  // on what the registration manager has indicated.
  for (int i = 0; i < regStatusList.size(); ++i) {
    RegistrationStatus regStatus = regStatusList.get(i);
    boolean wasSuccess = localProcessingStatuses.get(i);
    logger.fine("Process reg status: %s", regStatus);

    ObjectId objectId = ProtoConverter.convertFromObjectIdProto(
      regStatus.getRegistration().getObjectId());
    if (wasSuccess) {
      // Server operation was both successful and agreed with what the client wanted.
      OpType regOpType = regStatus.getRegistration().getOpType();
      InvalidationListener.RegistrationState regState = convertOpTypeToRegState(regOpType);
      listener.informRegistrationStatus(InvalidationClientCore.this, objectId, regState);
    } else {
      // Server operation either failed or disagreed with client's intent (e.g., successful
      // unregister, but the client wanted a registration).
      String description = CommonProtos2.isSuccess(regStatus.getStatus()) ?
          "Registration discrepancy detected" : regStatus.getStatus().getDescription();
      boolean isPermanent = CommonProtos2.isPermanentFailure(regStatus.getStatus());
      listener.informRegistrationFailure(InvalidationClientCore.this, objectId, !isPermanent,
          description);
    }
  }
}
 
Example 6
Source File: InvalidationClientCore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Converts an operation type {@code regOpType} to a
 * {@code InvalidationListener.RegistrationState}.
 */
private static InvalidationListener.RegistrationState convertOpTypeToRegState(
    RegistrationP.OpType regOpType) {
  InvalidationListener.RegistrationState regState =
      regOpType == RegistrationP.OpType.REGISTER ?
          InvalidationListener.RegistrationState.REGISTERED :
            InvalidationListener.RegistrationState.UNREGISTERED;
  return regState;
}