当前位置: 首页>>代码示例>>Java>>正文


Java ErrorInfo.newInstance方法代码示例

本文整理汇总了Java中com.google.ipc.invalidation.external.client.types.ErrorInfo.newInstance方法的典型用法代码示例。如果您正苦于以下问题:Java ErrorInfo.newInstance方法的具体用法?Java ErrorInfo.newInstance怎么用?Java ErrorInfo.newInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.ipc.invalidation.external.client.types.ErrorInfo的用法示例。


在下文中一共展示了ErrorInfo.newInstance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleErrorMessage

import com.google.ipc.invalidation.external.client.types.ErrorInfo; //导入方法依赖的package包/类
/** Handles an error message. */
private void handleErrorMessage(ServerMessageHeader header, int code, String description) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");

  // If it is an auth failure, we shut down the ticl.
  logger.severe("Received error message: %s, %s, %s", header, code, description);

  // Translate the code to error reason.
  int reason;
  switch (code) {
    case ErrorMessage.Code.AUTH_FAILURE:
      reason = ErrorInfo.ErrorReason.AUTH_FAILURE;
      break;
    case ErrorMessage.Code.UNKNOWN_FAILURE:
    default:
      reason = ErrorInfo.ErrorReason.UNKNOWN_FAILURE;
      break;
  }

  // Issue an informError to the application.
  ErrorInfo errorInfo = ErrorInfo.newInstance(reason, false, description, null);
  listener.informError(this, errorInfo);

  // If this is an auth failure, remove registrations and stop the Ticl. Otherwise do nothing.
  if (code != ErrorMessage.Code.AUTH_FAILURE) {
    return;
  }

  // If there are any registrations, remove them and issue registration failure.
  Collection<ObjectIdP> desiredRegistrations = registrationManager.removeRegisteredObjects();
  logger.warning("Issuing failure for %s objects", desiredRegistrations.size());
  for (ObjectIdP objectId : desiredRegistrations) {
    listener.informRegistrationFailure(this,
        ProtoWrapperConverter.convertFromObjectIdProto(objectId), false,
        "Auth error: " + description);
  }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:38,代码来源:InvalidationClientCore.java

示例2: ParcelableErrorInfo

import com.google.ipc.invalidation.external.client.types.ErrorInfo; //导入方法依赖的package包/类
/**
 * Creates a new ErrorInfo wrapper by reading data from a parcel.
 */
public ParcelableErrorInfo(Parcel in) {
  int reason = in.readInt();
  boolean isTransient = in.createBooleanArray()[0];
  String message = in.readString();
  this.errorInfo = ErrorInfo.newInstance(reason, isTransient, message, null);
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:10,代码来源:ParcelableErrorInfo.java

示例3: handleIntent

import com.google.ipc.invalidation.external.client.types.ErrorInfo; //导入方法依赖的package包/类
/**
 * Handles a listener upcall by decoding the protocol buffer in {@code intent} and dispatching
 * to the appropriate method on the {@link #listener}.
 */
public void handleIntent(Intent intent) {
  // TODO: use wakelocks

  // Unmarshall the arguments from the Intent and make the appropriate call on the listener.
  ListenerUpcall upcall = tryParseIntent(intent);
  if (upcall == null) {
    return;
  }

  if (upcall.hasReady()) {
    listener.ready(client);
  } else if (upcall.getNullableInvalidate() != null) {
    // Handle all invalidation-related upcalls on a common path, since they require creating
    // an AckHandleP.
    onInvalidateUpcall(upcall.getNullableInvalidate(), listener);
  } else if (upcall.getNullableRegistrationStatus() != null) {
    RegistrationStatusUpcall regStatus = upcall.getNullableRegistrationStatus();
    listener.informRegistrationStatus(client,
        ProtoWrapperConverter.convertFromObjectIdProto(regStatus.getObjectId()),
        regStatus.getIsRegistered() ?
            RegistrationState.REGISTERED : RegistrationState.UNREGISTERED);
  } else if (upcall.getNullableRegistrationFailure() != null) {
    RegistrationFailureUpcall failure = upcall.getNullableRegistrationFailure();
    listener.informRegistrationFailure(client,
        ProtoWrapperConverter.convertFromObjectIdProto(failure.getObjectId()),
        failure.getTransient(),
        failure.getMessage());
  } else if (upcall.getNullableReissueRegistrations() != null) {
    ReissueRegistrationsUpcall reissueRegs = upcall.getNullableReissueRegistrations();
    listener.reissueRegistrations(client, reissueRegs.getPrefix().getByteArray(),
        reissueRegs.getLength());
  } else if (upcall.getNullableError() != null) {
    ErrorUpcall error = upcall.getNullableError();
    ErrorInfo errorInfo = ErrorInfo.newInstance(error.getErrorCode(), error.getIsTransient(),
        error.getErrorMessage(), null);
    listener.informError(client, errorInfo);
  } else {
    logger.warning("Dropping listener Intent with unknown call: %s", upcall);
  }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:45,代码来源:AndroidInvalidationListenerIntentMapper.java

示例4: informListenerOfPermanentError

import com.google.ipc.invalidation.external.client.types.ErrorInfo; //导入方法依赖的package包/类
/** Informs the listener of a non-retryable {@code error}. */
private void informListenerOfPermanentError(final String error) {
  ErrorInfo errorInfo = ErrorInfo.newInstance(0, false, error, null);
  Intent errorIntent = ProtocolIntents.ListenerUpcalls.newErrorIntent(errorInfo);
  IntentForwardingListener.issueIntent(this, errorIntent);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:7,代码来源:TiclService.java

示例5: handleIntent

import com.google.ipc.invalidation.external.client.types.ErrorInfo; //导入方法依赖的package包/类
/**
 * Handles a listener upcall by decoding the protocol buffer in {@code intent} and dispatching
 * to the appropriate method on the {@link #listener}.
 */
public void handleIntent(Intent intent) {
  // TODO: use wakelocks

  // Unmarshall the arguments from the Intent and make the appropriate call on the listener.
  ListenerUpcall upcall = tryParseIntent(intent);
  if (upcall == null) {
    return;
  }

  if (upcall.hasReady()) {
    listener.ready(client);
  } else if (upcall.hasInvalidate()) {
    // Handle all invalidation-related upcalls on a common path, since they require creating
    // an AckHandleP.
    onInvalidateUpcall(upcall, listener);
  } else if (upcall.hasRegistrationStatus()) {
    RegistrationStatusUpcall regStatus = upcall.getRegistrationStatus();
    listener.informRegistrationStatus(client,
        ProtoConverter.convertFromObjectIdProto(regStatus.getObjectId()),
        regStatus.getIsRegistered() ?
            RegistrationState.REGISTERED : RegistrationState.UNREGISTERED);
  } else if (upcall.hasRegistrationFailure()) {
    RegistrationFailureUpcall failure = upcall.getRegistrationFailure();
    listener.informRegistrationFailure(client,
        ProtoConverter.convertFromObjectIdProto(failure.getObjectId()),
        failure.getTransient(),
        failure.getMessage());
  } else if (upcall.hasReissueRegistrations()) {
    ReissueRegistrationsUpcall reissueRegs = upcall.getReissueRegistrations();
    listener.reissueRegistrations(client, reissueRegs.getPrefix().toByteArray(),
        reissueRegs.getLength());
  } else if (upcall.hasError()) {
    ErrorUpcall error = upcall.getError();
    ErrorInfo errorInfo = ErrorInfo.newInstance(error.getErrorCode(), error.getIsTransient(),
        error.getErrorMessage(), null);
    listener.informError(client, errorInfo);
  } else {
    logger.warning("Dropping listener Intent with unknown call: %s", upcall);
  }
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:45,代码来源:AndroidInvalidationListenerIntentMapper.java

示例6: handleErrorMessage

import com.google.ipc.invalidation.external.client.types.ErrorInfo; //导入方法依赖的package包/类
/** Handles an error message. */
private void handleErrorMessage(ServerMessageHeader header,
    ErrorMessage.Code code, String description) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");

  // If it is an auth failure, we shut down the ticl.
  logger.severe("Received error message: %s, %s, %s", header, code, description);

  // Translate the code to error reason.
  int reason;
  switch (code) {
    case AUTH_FAILURE:
      reason = ErrorInfo.ErrorReason.AUTH_FAILURE;
      break;
    case UNKNOWN_FAILURE:
      reason = ErrorInfo.ErrorReason.UNKNOWN_FAILURE;
      break;
    default:
      reason = ErrorInfo.ErrorReason.UNKNOWN_FAILURE;
      break;
  }

  // Issue an informError to the application.
  ErrorInfo errorInfo = ErrorInfo.newInstance(reason, false, description, null);
  listener.informError(this, errorInfo);

  // If this is an auth failure, remove registrations and stop the Ticl. Otherwise do nothing.
  if (code != ErrorMessage.Code.AUTH_FAILURE) {
    return;
  }

  // If there are any registrations, remove them and issue registration failure.
  Collection<ProtoWrapper<ObjectIdP>> desiredRegistrations =
      registrationManager.removeRegisteredObjects();
  logger.warning("Issuing failure for %s objects", desiredRegistrations.size());
  for (ProtoWrapper<ObjectIdP> objectIdWrapper : desiredRegistrations) {
    ObjectIdP objectId = objectIdWrapper.getProto();
    listener.informRegistrationFailure(this,
      ProtoConverter.convertFromObjectIdProto(objectId), false, "Auth error: " + description);
  }
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:42,代码来源:InvalidationClientCore.java


注:本文中的com.google.ipc.invalidation.external.client.types.ErrorInfo.newInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。