本文整理汇总了Java中com.google.ipc.invalidation.external.client.types.Callback类的典型用法代码示例。如果您正苦于以下问题:Java Callback类的具体用法?Java Callback怎么用?Java Callback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Callback类属于com.google.ipc.invalidation.external.client.types包,在下文中一共展示了Callback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: scheduleStartAfterReadingStateBlob
import com.google.ipc.invalidation.external.client.types.Callback; //导入依赖的package包/类
/** Reads the Ticl state from persistent storage (if any) and calls {@code startInternal}. */
private void scheduleStartAfterReadingStateBlob() {
storage.readKey(CLIENT_TOKEN_KEY, new Callback<SimplePair<Status, byte[]>>() {
@Override
public void accept(final SimplePair<Status, byte[]> readResult) {
Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
final byte[] serializedState = readResult.getFirst().isSuccess() ?
readResult.getSecond() : null;
// Call start now.
if (!readResult.getFirst().isSuccess()) {
statistics.recordError(ClientErrorType.PERSISTENT_READ_FAILURE);
logger.warning("Could not read state blob: %s", readResult.getFirst().getMessage());
}
startInternal(serializedState);
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:18,代码来源:InvalidationClientCore.java
示例2: writeKey
import com.google.ipc.invalidation.external.client.types.Callback; //导入依赖的package包/类
@Override
public void writeKey(final String key, final byte[] value, final Callback<Status> callback) {
// Need to schedule immediately because C++ locks aren't reentrant, and
// C++ locking code assumes that this call will not return directly.
// Schedule the write even if the resources are started since the
// scheduler will prevent it from running in case the resources have been
// stopped.
scheduler.schedule(Scheduler.NO_DELAY,
new NamedRunnable("MemoryStorage.writeKey") {
@Override
public void run() {
ticlPersistentState.put(key, value);
callback.accept(Status.newInstance(Status.Code.SUCCESS, ""));
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:18,代码来源:MemoryStorageImpl.java
示例3: readKey
import com.google.ipc.invalidation.external.client.types.Callback; //导入依赖的package包/类
@Override
public void readKey(final String key, final Callback<SimplePair<Status, byte[]>> done) {
scheduler.schedule(Scheduler.NO_DELAY,
new NamedRunnable("MemoryStorage.readKey") {
@Override
public void run() {
byte[] value = TypedUtil.mapGet(ticlPersistentState, key);
final SimplePair<Status, byte[]> result;
if (value != null) {
result = SimplePair.of(Status.newInstance(Status.Code.SUCCESS, ""), value);
} else {
String error = "No value present in map for " + key;
result = SimplePair.of(Status.newInstance(Status.Code.PERMANENT_FAILURE, error), null);
}
done.accept(result);
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:19,代码来源:MemoryStorageImpl.java
示例4: readKey
import com.google.ipc.invalidation.external.client.types.Callback; //导入依赖的package包/类
@Override
public void readKey(final String key, final Callback<SimplePair<Status, byte[]>> done) {
scheduler.execute(new NamedRunnable("AndroidStorage.readKey") {
@Override
public void run() {
byte [] value = properties.get(key);
if (value != null) {
done.accept(SimplePair.of(SUCCESS, value));
} else {
Status status =
Status.newInstance(Status.Code.PERMANENT_FAILURE, "No value in map for " + key);
done.accept(SimplePair.of(status, (byte []) null));
}
}
});
}
开发者ID:morristech,项目名称:android-chromium,代码行数:17,代码来源:AndroidStorage.java
示例5: deleteKey
import com.google.ipc.invalidation.external.client.types.Callback; //导入依赖的package包/类
@Override
public void deleteKey(String key, Callback<Boolean> done) {
// We only support the CLIENT_TOKEN_KEY.
if (!key.equals(InvalidationClientCore.CLIENT_TOKEN_KEY)) {
done.accept(false);
return;
}
if (!context.getFileStreamPath(STATE_FILENAME).exists()) {
// Deletion "succeeds" if the key didn't exist.
done.accept(true);
} else {
// Otherwise it succeeds based on whether the IO operation succeeded.
done.accept(context.deleteFile(STATE_FILENAME));
}
}
开发者ID:mogoweb,项目名称:365browser,代码行数:16,代码来源:AndroidStorage.java
示例6: readAllKeys
import com.google.ipc.invalidation.external.client.types.Callback; //导入依赖的package包/类
@Override
public void readAllKeys(Callback<SimplePair<Status, String>> keyCallback) {
// If the state file exists, supply the CLIENT_TOKEN_KEY as a present key.
if (context.getFileStreamPath(STATE_FILENAME).exists()) {
Status status = Status.newInstance(Status.Code.SUCCESS, "");
keyCallback.accept(SimplePair.of(status, InvalidationClientCore.CLIENT_TOKEN_KEY));
}
keyCallback.accept(null);
}
开发者ID:mogoweb,项目名称:365browser,代码行数:10,代码来源:AndroidStorage.java
示例7: writeKey
import com.google.ipc.invalidation.external.client.types.Callback; //导入依赖的package包/类
@Override
public void writeKey(String key, byte[] value, final Callback<Status> done) {
delegate.writeKey(key, value, new Callback<Status>() {
@Override
public void accept(final Status status) {
scheduler.schedule(NO_DELAY, new NamedRunnable("SafeStorage.writeKey") {
@Override
public void run() {
done.accept(status);
}
});
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:15,代码来源:SafeStorage.java
示例8: readKey
import com.google.ipc.invalidation.external.client.types.Callback; //导入依赖的package包/类
@Override
public void readKey(String key, final Callback<SimplePair<Status, byte[]>> done) {
delegate.readKey(key, new Callback<SimplePair<Status, byte[]>>() {
@Override
public void accept(final SimplePair<Status, byte[]> result) {
scheduler.schedule(NO_DELAY, new NamedRunnable("SafeStorage.readKey") {
@Override
public void run() {
done.accept(result);
}
});
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:15,代码来源:SafeStorage.java
示例9: deleteKey
import com.google.ipc.invalidation.external.client.types.Callback; //导入依赖的package包/类
@Override
public void deleteKey(String key, final Callback<Boolean> done) {
delegate.deleteKey(key, new Callback<Boolean>() {
@Override
public void accept(final Boolean success) {
scheduler.schedule(NO_DELAY, new NamedRunnable("SafeStorage.deleteKey") {
@Override
public void run() {
done.accept(success);
}
});
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:15,代码来源:SafeStorage.java
示例10: readAllKeys
import com.google.ipc.invalidation.external.client.types.Callback; //导入依赖的package包/类
@Override
public void readAllKeys(final Callback<SimplePair<Status, String>> keyCallback) {
delegate.readAllKeys(new Callback<SimplePair<Status, String>>() {
@Override
public void accept(final SimplePair<Status, String> keyResult) {
scheduler.schedule(NO_DELAY, new NamedRunnable("SafeStorage.readAllKeys") {
@Override
public void run() {
keyCallback.accept(keyResult);
}
});
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:15,代码来源:SafeStorage.java
示例11: deleteKey
import com.google.ipc.invalidation.external.client.types.Callback; //导入依赖的package包/类
@Override
public void deleteKey(final String key, final Callback<Boolean> done) {
scheduler.schedule(Scheduler.NO_DELAY,
new NamedRunnable("MemoryStorage.deleteKey") {
@Override
public void run() {
TypedUtil.remove(ticlPersistentState, key);
done.accept(true);
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:12,代码来源:MemoryStorageImpl.java
示例12: readAllKeys
import com.google.ipc.invalidation.external.client.types.Callback; //导入依赖的package包/类
@Override
public void readAllKeys(final Callback<SimplePair<Status, String>> done) {
scheduler.schedule(Scheduler.NO_DELAY,
new NamedRunnable("MemoryStorage.readAllKeys") {
@Override
public void run() {
Status successStatus = Status.newInstance(Status.Code.SUCCESS, "");
for (String key : ticlPersistentState.keySet()) {
done.accept(SimplePair.of(successStatus, key));
}
done.accept(null);
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:15,代码来源:MemoryStorageImpl.java
示例13: deleteKey
import com.google.ipc.invalidation.external.client.types.Callback; //导入依赖的package包/类
@Override
public void deleteKey(final String key, final Callback<Boolean> done) {
scheduler.execute(new NamedRunnable("AndroidStorage.deleteKey") {
@Override
public void run() {
properties.remove(key);
store();
done.accept(true);
}
});
}
开发者ID:morristech,项目名称:android-chromium,代码行数:12,代码来源:AndroidStorage.java
示例14: readAllKeys
import com.google.ipc.invalidation.external.client.types.Callback; //导入依赖的package包/类
@Override
public void readAllKeys(final Callback<SimplePair<Status, String>> keyCallback) {
scheduler.execute(new NamedRunnable("AndroidStorage.readAllKeys") {
@Override
public void run() {
for (String key : properties.keySet()) {
keyCallback.accept(SimplePair.of(SUCCESS, key));
}
}
});
}
开发者ID:morristech,项目名称:android-chromium,代码行数:12,代码来源:AndroidStorage.java
示例15: writeKey
import com.google.ipc.invalidation.external.client.types.Callback; //导入依赖的package包/类
@Override
public void writeKey(final String key, final byte[] value, final Callback<Status> done) {
scheduler.execute(new NamedRunnable("AndroidStorage.writeKey") {
@Override
public void run() {
properties.put(key, value);
store();
done.accept(SUCCESS);
}
});
}
开发者ID:morristech,项目名称:android-chromium,代码行数:12,代码来源:AndroidStorage.java
注:本文中的com.google.ipc.invalidation.external.client.types.Callback类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论