com.google.ipc.invalidation.external.client.InvalidationClient Java Examples

The following examples show how to use com.google.ipc.invalidation.external.client.InvalidationClient. 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: AndroidClientProxy.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Creates a new InvalidationClient instance that the proxy will delegate requests to and listen
 * for events from.
 */
// Overridden by tests to inject mock clients or for listener interception

InvalidationClient createClient(SystemResources resources, int clientType, byte[] clientName,
    String applicationName, InvalidationListener listener, ClientConfigP config) {
  // We always use C2DM, so set the channel-supports-offline-delivery bit on our config.
  final ClientConfigP.Builder configBuilder;
  if (config == null) {
    configBuilder = InvalidationClientCore.createConfig();
  } else {
    configBuilder = ClientConfigP.newBuilder(config);
  }
  configBuilder.setChannelSupportsOfflineDelivery(true);
  config = configBuilder.build();
  Random random = new Random(resources.getInternalScheduler().getCurrentTimeMs());
  return new InvalidationClientImpl(resources, random, clientType, clientName, config,
      applicationName, listener);
}
 
Example #2
Source File: AndroidListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public final void informRegistrationFailure(final InvalidationClient client,
    final ObjectId objectId, final boolean isTransient, final String errorMessage) {
  state.informRegistrationFailure(objectId, isTransient);
  AndroidListener.this.informRegistrationFailure(state.getClientId().toByteArray(), objectId,
      isTransient, errorMessage);
}
 
Example #3
Source File: CheckingInvalidationListener.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void informRegistrationFailure(final InvalidationClient client, final ObjectId objectId,
    final boolean isTransient, final String errorMessage) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  listenerScheduler.schedule(NO_DELAY, new NamedRunnable("CheckingInvalListener.regFailure") {
    @Override
    public void run() {
      statistics.recordListenerEvent(ListenerEventType.INFORM_REGISTRATION_FAILURE);
      delegate.informRegistrationFailure(client, objectId, isTransient, errorMessage);
    }
  });
}
 
Example #4
Source File: CheckingInvalidationListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void invalidate(final InvalidationClient client, final Invalidation invalidation,
    final AckHandle ackHandle) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  Preconditions.checkNotNull(ackHandle);
  listenerScheduler.schedule(NO_DELAY, new NamedRunnable("CheckingInvalListener.invalidate") {
    @Override
    public void run() {
      statistics.recordListenerEvent(ListenerEventType.INVALIDATE);
      delegate.invalidate(client, invalidation, ackHandle);
    }
  });
}
 
Example #5
Source File: InvalidationTestListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void informError(InvalidationClient client, ErrorInfo errorInfo) {
  InvalidationListener listener = getListener(client);
  logger.fine("Received INFORM_ERROR for %s: %s", getClientKey(client), listener);
  if (listener != null) {
    listener.informError(client, errorInfo);
  }
}
 
Example #6
Source File: CheckingInvalidationListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void informRegistrationFailure(final InvalidationClient client, final ObjectId objectId,
    final boolean isTransient, final String errorMessage) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  listenerScheduler.schedule(NO_DELAY, new NamedRunnable("CheckingInvalListener.regFailure") {
    @Override
    public void run() {
      statistics.recordListenerEvent(ListenerEventType.INFORM_REGISTRATION_FAILURE);
      delegate.informRegistrationFailure(client, objectId, isTransient, errorMessage);
    }
  });
}
 
Example #7
Source File: CheckingInvalidationListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void informRegistrationFailure(final InvalidationClient client, final ObjectId objectId,
    final boolean isTransient, final String errorMessage) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  listenerScheduler.schedule(NO_DELAY, new NamedRunnable("CheckingInvalListener.regFailure") {
    @Override
    public void run() {
      statistics.recordListenerEvent(ListenerEventType.INFORM_REGISTRATION_FAILURE);
      delegate.informRegistrationFailure(client, objectId, isTransient, errorMessage);
    }
  });
}
 
Example #8
Source File: CheckingInvalidationListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void informError(final InvalidationClient client, final ErrorInfo errorInfo) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  listenerScheduler.schedule(NO_DELAY, new NamedRunnable("CheckingInvalListener.informError") {
    @Override
    public void run() {
      statistics.recordListenerEvent(ListenerEventType.INFORM_ERROR);
      delegate.informError(client, errorInfo);
    }
  });
}
 
Example #9
Source File: CheckingInvalidationListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void reissueRegistrations(final InvalidationClient client, final byte[] prefix,
    final int prefixLen) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  listenerScheduler.schedule(NO_DELAY, new NamedRunnable("CheckingInvalListener.reissueRegs") {
    @Override
    public void run() {
      statistics.recordListenerEvent(ListenerEventType.REISSUE_REGISTRATIONS);
      delegate.reissueRegistrations(client, prefix, prefixLen);
    }
  });
}
 
Example #10
Source File: AndroidClientProxy.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void informRegistrationStatus(
    InvalidationClient client, ObjectId objectId, RegistrationState regState) {
  Event event = Event.newBuilder(Event.Action.INFORM_REGISTRATION_STATUS)
      .setClientKey(clientKey).setObjectId(objectId).setRegistrationState(regState).build();
  sendEvent(event);
}
 
Example #11
Source File: AndroidClientProxy.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void informRegistrationFailure(
    InvalidationClient client, ObjectId objectId, boolean isTransient, String errorMessage) {
  Event event = Event.newBuilder(Event.Action.INFORM_REGISTRATION_FAILURE)
      .setClientKey(clientKey).setObjectId(objectId).setIsTransient(isTransient)
      .setError(errorMessage).build();
  sendEvent(event);
}
 
Example #12
Source File: AndroidClientProxy.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void invalidateUnknownVersion(
    InvalidationClient client, ObjectId objectId, AckHandle ackHandle) {
  Event event = Event.newBuilder(Event.Action.INVALIDATE_UNKNOWN)
      .setClientKey(clientKey).setObjectId(objectId).setAckHandle(ackHandle).build();
  sendEvent(event);
}
 
Example #13
Source File: InvalidationTestListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void informRegistrationFailure(
    InvalidationClient client, ObjectId objectId, boolean isTransient, String errorMessage) {
  InvalidationListener listener = getListener(client);
  logger.fine("Received INFORM_REGISTRATION_FAILURE for %s: %s", getClientKey(client), listener);
  if (listener != null) {
    listener.informRegistrationFailure(client, objectId, isTransient, errorMessage);
  }
}
 
Example #14
Source File: AndroidClientProxy.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void invalidate(
    InvalidationClient client, Invalidation invalidation, AckHandle ackHandle) {
  Event event = Event.newBuilder(Event.Action.INVALIDATE)
      .setClientKey(clientKey).setInvalidation(invalidation).setAckHandle(ackHandle).build();
  sendEvent(event);
}
 
Example #15
Source File: AndroidListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public final void informRegistrationStatus(final InvalidationClient client,
    final ObjectId objectId, final RegistrationState regState) {
  state.informRegistrationSuccess(objectId);
  AndroidListener.this.informRegistrationStatus(state.getClientId().toByteArray(),
      objectId, regState);
}
 
Example #16
Source File: AndroidInvalidationClientImpl.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void invalidate(InvalidationClient client, Invalidation invalidation,
    AckHandle ackHandle) {
  try {
    AckHandleP ackHandleP = AckHandleP.parseFrom(ackHandle.getHandleData());
    issueIntent(context, ListenerUpcalls.newInvalidateIntent(
        ProtoWrapperConverter.convertToInvalidationProto(invalidation), ackHandleP));
  } catch (ValidationException exception) {
    // Log and drop invalid call.
    logBadAckHandle("invalidate", ackHandle);
  }
}
 
Example #17
Source File: InvalidationTestListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void ready(InvalidationClient client) {
  InvalidationListener listener = getListener(client);
  logger.fine("Received READY for %s: %s", getClientKey(client), listener);
  if (listener != null) {
    listener.ready(client);
  }
}
 
Example #18
Source File: InvalidationTestListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void invalidate(
    InvalidationClient client, Invalidation invalidation, AckHandle ackHandle) {
  InvalidationListener listener = getListener(client);
  logger.fine("Received INVALIDATE for %s: %s", getClientKey(client), listener);
  if (listener != null) {
    listener.invalidate(client, invalidation, ackHandle);
  }
}
 
Example #19
Source File: InvalidationTestListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void invalidateUnknownVersion(
    InvalidationClient client, ObjectId objectId, AckHandle ackHandle) {
  InvalidationListener listener = getListener(client);
  logger.fine("Received INVALIDATE_UNKNOWN_VERSION for %s: %s", getClientKey(client), listener);
  if (listener != null) {
    listener.invalidateUnknownVersion(client, objectId, ackHandle);
  }
}
 
Example #20
Source File: InvalidationTestListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void invalidateAll(InvalidationClient client, AckHandle ackHandle) {
  InvalidationListener listener = getListener(client);
  logger.fine("Received INVALIDATE_ALL for %s: %s", getClientKey(client), listener);
  if (listener != null) {
    listener.invalidateAll(client, ackHandle);
  }
}
 
Example #21
Source File: CheckingInvalidationListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void invalidateAll(final InvalidationClient client, final AckHandle ackHandle) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  Preconditions.checkNotNull(ackHandle);
  listenerScheduler.schedule(NO_DELAY, new NamedRunnable("CheckingInvalListener.invalidateAll") {
    @Override
    public void run() {
      statistics.recordListenerEvent(ListenerEventType.INVALIDATE_ALL);
      delegate.invalidateAll(client, ackHandle);
    }
  });
}
 
Example #22
Source File: InvalidationTestListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void informRegistrationFailure(
    InvalidationClient client, ObjectId objectId, boolean isTransient, String errorMessage) {
  InvalidationListener listener = getListener(client);
  logger.fine("Received INFORM_REGISTRATION_FAILURE for %s: %s", getClientKey(client), listener);
  if (listener != null) {
    listener.informRegistrationFailure(client, objectId, isTransient, errorMessage);
  }
}
 
Example #23
Source File: InvalidationTestListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void reissueRegistrations(InvalidationClient client, byte[] prefix, int prefixLength) {
  InvalidationListener listener = getListener(client);
  logger.fine("Received REISSUE_REGISTRATIONS for %s: %s", getClientKey(client), listener);
  if (listener != null) {
    listener.reissueRegistrations(client, prefix, prefixLength);
  }
}
 
Example #24
Source File: InvalidationTestListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void informError(InvalidationClient client, ErrorInfo errorInfo) {
  InvalidationListener listener = getListener(client);
  logger.fine("Received INFORM_ERROR for %s: %s", getClientKey(client), listener);
  if (listener != null) {
    listener.informError(client, errorInfo);
  }
}
 
Example #25
Source File: AndroidInvalidationClientImpl.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void invalidate(InvalidationClient client, Invalidation invalidation,
    AckHandle ackHandle) {
  try {
    AckHandleP ackHandleP = AckHandleP.parseFrom(ackHandle.getHandleData());
    issueIntent(context, ListenerUpcalls.newInvalidateIntent(
        ProtoConverter.convertToInvalidationProto(invalidation), ackHandleP));
  } catch (InvalidProtocolBufferException exception) {
    // Log and drop invalid call.
    logBadAckHandle("invalidate", ackHandle);
  }
}
 
Example #26
Source File: AndroidInvalidationClientImpl.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void invalidateUnknownVersion(InvalidationClient client, ObjectId objectId,
    AckHandle ackHandle) {
  try {
    AckHandleP ackHandleP = AckHandleP.parseFrom(ackHandle.getHandleData());
    issueIntent(context, ListenerUpcalls.newInvalidateUnknownIntent(
        ProtoConverter.convertToObjectIdProto(objectId), ackHandleP));
  } catch (InvalidProtocolBufferException exception) {
    // Log and drop invalid call.
    logBadAckHandle("invalidateUnknownVersion", ackHandle);
  }
}
 
Example #27
Source File: AndroidInvalidationClientImpl.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void invalidateAll(InvalidationClient client, AckHandle ackHandle) {
  try {
    AckHandleP ackHandleP = AckHandleP.parseFrom(ackHandle.getHandleData());
    issueIntent(context, ListenerUpcalls.newInvalidateAllIntent(ackHandleP));
  } catch (InvalidProtocolBufferException exception) {
    // Log and drop invalid call.
    logBadAckHandle("invalidateAll", ackHandle);
  }
}
 
Example #28
Source File: AndroidInvalidationClientImpl.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void informRegistrationStatus(
    InvalidationClient client, ObjectId objectId, RegistrationState regState) {
  Intent intent = ListenerUpcalls.newRegistrationStatusIntent(
      ProtoConverter.convertToObjectIdProto(objectId),
      regState == RegistrationState.REGISTERED);
  issueIntent(context, intent);
}
 
Example #29
Source File: CheckingInvalidationListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void invalidate(final InvalidationClient client, final Invalidation invalidation,
    final AckHandle ackHandle) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  Preconditions.checkNotNull(ackHandle);
  listenerScheduler.schedule(NO_DELAY, new NamedRunnable("CheckingInvalListener.invalidate") {
    @Override
    public void run() {
      statistics.recordListenerEvent(ListenerEventType.INVALIDATE);
      delegate.invalidate(client, invalidation, ackHandle);
    }
  });
}
 
Example #30
Source File: AndroidListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public final void informRegistrationStatus(final InvalidationClient client,
    final ObjectId objectId, final RegistrationState regState) {
  state.informRegistrationSuccess(objectId);
  AndroidListener.this.informRegistrationStatus(state.getClientId().toByteArray(),
      objectId, regState);
}