Commit 742de287 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Delete third_party/cacheinvalidation

It has been essentially unused for a while.
Apart from deleting the code, this CL contains the following changes:
- In ChromeGcmListenerService: stop passing incoming
  GCM messages to the cacheinvalidation code.
- In ProcessInitializationHandler: stop initializing cacheinvalidation's
  Logger class.
- Create a dummy GcmRegistrationTaskService: This service (part of the
  cacheinvalidation library) is listed in the AndroidManifest.xml as
  exported, so it's part of Chrome's public API and can't just be
  removed. Adding an empty dummy implementation lets us keep the
  manifest entry without the actual implementation from the library.

Bug: 1099672
Change-Id: I7e17415cd33cd76b864bd9e6f310f6c52bdf5503
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2274884
Commit-Queue: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarTommy Nyquist <nyquist@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#787662}
parent ff26e368
...@@ -485,7 +485,6 @@ android_library("chrome_java") { ...@@ -485,7 +485,6 @@ android_library("chrome_java") {
"//third_party/blink/public:blink_headers_java", "//third_party/blink/public:blink_headers_java",
"//third_party/blink/public/mojom:android_mojo_bindings_java", "//third_party/blink/public/mojom:android_mojo_bindings_java",
"//third_party/blink/public/mojom:mojom_platform_java", "//third_party/blink/public/mojom:mojom_platform_java",
"//third_party/cacheinvalidation:cacheinvalidation_javalib",
"//third_party/gif_player:gif_player_java", "//third_party/gif_player:gif_player_java",
"//third_party/google_android_play_core:com_google_android_play_core_java", "//third_party/google_android_play_core:com_google_android_play_core_java",
"//ui/android:ui_java", "//ui/android:ui_java",
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
chrome_java_sources = [ chrome_java_sources = [
"java/src/com/google/android/apps/chrome/appwidget/bookmarks/BookmarkThumbnailWidgetProvider.java", "java/src/com/google/android/apps/chrome/appwidget/bookmarks/BookmarkThumbnailWidgetProvider.java",
"java/src/com/google/ipc/invalidation/ticl/android2/channel/GcmRegistrationTaskService.java",
"java/src/org/chromium/chrome/browser/ActivityTabProvider.java", "java/src/org/chromium/chrome/browser/ActivityTabProvider.java",
"java/src/org/chromium/chrome/browser/AfterStartupTaskUtils.java", "java/src/org/chromium/chrome/browser/AfterStartupTaskUtils.java",
"java/src/org/chromium/chrome/browser/AppHooks.java", "java/src/org/chromium/chrome/browser/AppHooks.java",
......
...@@ -815,12 +815,6 @@ ...@@ -815,12 +815,6 @@
<receiver <receiver
android:exported="false" android:exported="false"
android:name="com.google.android.gms.cast.framework.media.MediaIntentReceiver"/> android:name="com.google.android.gms.cast.framework.media.MediaIntentReceiver"/>
<receiver
android:exported="false"
android:name="com.google.ipc.invalidation.external.client.contrib.AndroidListener$AlarmReceiver"/>
<receiver
android:exported="false"
android:name="com.google.ipc.invalidation.ticl.android2.AndroidInternalScheduler$AlarmReceiver"/>
<receiver <receiver
android:exported="false" android:exported="false"
android:name="org.chromium.chrome.browser.announcement.AnnouncementNotificationManager$Receiver"/> android:name="org.chromium.chrome.browser.announcement.AnnouncementNotificationManager$Receiver"/>
...@@ -991,19 +985,6 @@ ...@@ -991,19 +985,6 @@
<service <service
android:exported="false" android:exported="false"
android:name="com.google.android.gms.cast.framework.media.MediaNotificationService"/> android:name="com.google.android.gms.cast.framework.media.MediaNotificationService"/>
<service
android:exported="false"
android:name="com.google.ipc.invalidation.ticl.android2.TiclService"/>
<service
android:exported="false"
android:name="com.google.ipc.invalidation.ticl.android2.channel.AndroidInstanceIDListenerService">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
<service
android:exported="false"
android:name="com.google.ipc.invalidation.ticl.android2.channel.AndroidMessageSenderService"/>
<service <service
android:exported="false" android:exported="false"
android:name="org.chromium.android_webview.services.AwVariationsSeedFetcher" android:name="org.chromium.android_webview.services.AwVariationsSeedFetcher"
......
...@@ -758,12 +758,6 @@ ...@@ -758,12 +758,6 @@
<receiver <receiver
android:exported="false" android:exported="false"
android:name="com.google.android.gms.cast.framework.media.MediaIntentReceiver"/> android:name="com.google.android.gms.cast.framework.media.MediaIntentReceiver"/>
<receiver
android:exported="false"
android:name="com.google.ipc.invalidation.external.client.contrib.AndroidListener$AlarmReceiver"/>
<receiver
android:exported="false"
android:name="com.google.ipc.invalidation.ticl.android2.AndroidInternalScheduler$AlarmReceiver"/>
<receiver <receiver
android:exported="false" android:exported="false"
android:name="org.chromium.chrome.browser.announcement.AnnouncementNotificationManager$Receiver"/> android:name="org.chromium.chrome.browser.announcement.AnnouncementNotificationManager$Receiver"/>
...@@ -1175,19 +1169,6 @@ ...@@ -1175,19 +1169,6 @@
<service <service
android:exported="false" android:exported="false"
android:name="com.google.android.gms.cast.framework.media.MediaNotificationService"/> android:name="com.google.android.gms.cast.framework.media.MediaNotificationService"/>
<service
android:exported="false"
android:name="com.google.ipc.invalidation.ticl.android2.TiclService"/>
<service
android:exported="false"
android:name="com.google.ipc.invalidation.ticl.android2.channel.AndroidInstanceIDListenerService">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
<service
android:exported="false"
android:name="com.google.ipc.invalidation.ticl.android2.channel.AndroidMessageSenderService"/>
<service <service
android:exported="false" android:exported="false"
android:name="org.chromium.chrome.browser.bookmarkswidget.BookmarkWidgetService" android:name="org.chromium.chrome.browser.bookmarkswidget.BookmarkWidgetService"
......
...@@ -952,7 +952,7 @@ by a child template that "extends" this file. ...@@ -952,7 +952,7 @@ by a child template that "extends" this file.
<category android:name="{{ manifest_package }}"/> <category android:name="{{ manifest_package }}"/>
</intent-filter> </intent-filter>
</receiver> </receiver>
<!-- GcmTaskService for registration for Invalidations. --> <!-- GcmTaskService for registration for Invalidations. Not actually implemented anymore. -->
<service android:name="com.google.ipc.invalidation.ticl.android2.channel.GcmRegistrationTaskService" <service android:name="com.google.ipc.invalidation.ticl.android2.channel.GcmRegistrationTaskService"
android:exported="true" android:exported="true"
android:permission="com.google.android.gms.permission.BIND_NETWORK_TASK_SERVICE" > android:permission="com.google.android.gms.permission.BIND_NETWORK_TASK_SERVICE" >
...@@ -960,13 +960,6 @@ by a child template that "extends" this file. ...@@ -960,13 +960,6 @@ by a child template that "extends" this file.
<action android:name="com.google.android.gms.gcm.ACTION_TASK_READY"/> <action android:name="com.google.android.gms.gcm.ACTION_TASK_READY"/>
</intent-filter> </intent-filter>
</service> </service>
<!-- InstanceIDListenerService for token refresh events from GCM. -->
<service android:name="com.google.ipc.invalidation.ticl.android2.channel.AndroidInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
<!-- GcmListenerService for messages from GCM. --> <!-- GcmListenerService for messages from GCM. -->
<service android:name="org.chromium.chrome.browser.services.gcm.ChromeGcmListenerService" <service android:name="org.chromium.chrome.browser.services.gcm.ChromeGcmListenerService"
android:exported="false" > android:exported="false" >
...@@ -979,16 +972,6 @@ by a child template that "extends" this file. ...@@ -979,16 +972,6 @@ by a child template that "extends" this file.
<service android:name="org.chromium.chrome.browser.services.gcm.InvalidationGcmUpstreamSender" <service android:name="org.chromium.chrome.browser.services.gcm.InvalidationGcmUpstreamSender"
android:exported="false"/> android:exported="false"/>
<!-- Notification service for sync. -->
<service android:name="com.google.ipc.invalidation.ticl.android2.TiclService"
android:exported="false"/>
<service android:name="com.google.ipc.invalidation.ticl.android2.channel.AndroidMessageSenderService"
android:exported="false"/>
<receiver android:name="com.google.ipc.invalidation.ticl.android2.AndroidInternalScheduler$AlarmReceiver"
android:exported="false"/>
<receiver android:name="com.google.ipc.invalidation.external.client.contrib.AndroidListener$AlarmReceiver"
android:exported="false"/>
<!-- Android Notification service listener --> <!-- Android Notification service listener -->
<service android:name="org.chromium.chrome.browser.notifications.NotificationService" <service android:name="org.chromium.chrome.browser.notifications.NotificationService"
android:exported="false"/> android:exported="false"/>
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package com.google.ipc.invalidation.ticl.android2.channel;
import com.google.android.gms.gcm.GcmNetworkManager;
import com.google.android.gms.gcm.GcmTaskService;
import com.google.android.gms.gcm.TaskParams;
/**
* A class with this name was part of the cacheinvalidation library, which isn't used anymore and
* has been deleted. However, this service is exported in the AndroidManifest.xml and thus is part
* of Chrome's public API, so we need to keep this dummy class around.
*/
public class GcmRegistrationTaskService extends GcmTaskService {
@Override
public int onRunTask(TaskParams params) {
return GcmNetworkManager.RESULT_FAILURE;
}
}
...@@ -15,8 +15,6 @@ import android.view.inputmethod.InputMethodSubtype; ...@@ -15,8 +15,6 @@ import android.view.inputmethod.InputMethodSubtype;
import androidx.annotation.WorkerThread; import androidx.annotation.WorkerThread;
import com.google.ipc.invalidation.external.client.android.service.AndroidLogger;
import org.chromium.base.CommandLine; import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.Log; import org.chromium.base.Log;
...@@ -169,11 +167,6 @@ public class ProcessInitializationHandler { ...@@ -169,11 +167,6 @@ public class ProcessInitializationHandler {
AccountManagerFacadeProvider.setInstance( AccountManagerFacadeProvider.setInstance(
new AccountManagerFacadeImpl(AppHooks.get().createAccountManagerDelegate())); new AccountManagerFacadeImpl(AppHooks.get().createAccountManagerDelegate()));
// Set minimum Tango log level. This sets an in-memory static field, and needs to be
// set in the ApplicationContext instead of an activity, since Tango can be woken up
// by the system directly though messages from GCM.
AndroidLogger.setMinimumAndroidLogLevel(Log.WARN);
// Set up the identification generator for sync. The ID is actually generated // Set up the identification generator for sync. The ID is actually generated
// in the SyncController constructor. // in the SyncController constructor.
UniqueIdentificationGeneratorFactory.registerGenerator(SyncController.GENERATOR_ID, UniqueIdentificationGeneratorFactory.registerGenerator(SyncController.GENERATOR_ID,
......
...@@ -11,7 +11,6 @@ import android.os.Bundle; ...@@ -11,7 +11,6 @@ import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
import com.google.android.gms.gcm.GcmListenerService; import com.google.android.gms.gcm.GcmListenerService;
import com.google.ipc.invalidation.ticl.android2.channel.AndroidGcmController;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.Log; import org.chromium.base.Log;
...@@ -47,12 +46,6 @@ public class ChromeGcmListenerService extends GcmListenerService { ...@@ -47,12 +46,6 @@ public class ChromeGcmListenerService extends GcmListenerService {
boolean hasCollapseKey = !TextUtils.isEmpty(data.getString("collapse_key")); boolean hasCollapseKey = !TextUtils.isEmpty(data.getString("collapse_key"));
GcmUma.recordDataMessageReceived(ContextUtils.getApplicationContext(), hasCollapseKey); GcmUma.recordDataMessageReceived(ContextUtils.getApplicationContext(), hasCollapseKey);
String invalidationSenderId = AndroidGcmController.get(this).getSenderId();
if (from.equals(invalidationSenderId)) {
AndroidGcmController.get(this).onMessageReceived(data);
return;
}
// Dispatch the message to the GCM Driver for native features. // Dispatch the message to the GCM Driver for native features.
PostTask.runOrPostTask(UiThreadTaskTraits.DEFAULT, () -> { PostTask.runOrPostTask(UiThreadTaskTraits.DEFAULT, () -> {
GCMMessage message = null; GCMMessage message = null;
......
This diff is collapsed.
include_rules = [
'+base',
'+google',
]
# Owners of third_party/cacheinvalidation
#
# These are current and former members of the Sync team who have the most
# knowledge and experience with the cacheinvalidation library.
dcheng@chromium.org
nyquist@chromium.org
# COMPONENT: Services>Invalidation
Name: Google Cache Invalidation API
Short Name: google-cache-invalidation-api
URL: https://chromium.googlesource.com/chromium/src/+/master/third_party/cacheinvalidation/README.chromium
Version: unknown
License: Apache 2.0
License File: src/google/cacheinvalidation/COPYING
Security Critical: no
Description:
This is the API to talk to the Google Cache Invalidation service, used by the
invalidations consumed by Sync, Enterprise Policy, and other services. It was
previously hosted at http://code.google.com/p/google-cache-invalidation-api/
but was merged into the Chromium repository at r342.
include_rules = [
'+base',
'+testing',
]
\ No newline at end of file
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_CALLBACK_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_CALLBACK_H_
#include <memory>
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback.h"
#define INVALIDATION_CALLBACK1_TYPE(Arg1) ::base::RepeatingCallback<void(Arg1)>
// Below are a collection of types and functions that adapt base::Callback's
// pass-by-value semantics to the pointer-based callback system that
// cacheinvalidation needs.
namespace invalidation {
typedef ::base::Closure Closure;
template <class T>
bool IsCallbackRepeatable(const T* callback) {
// The default cacheinvalidation Callbacks may be self-deleting. We don't
// support this behave, so we already return true to indicate that the
// cacheinvalidation implementation should delete our Callbacks.
return true;
}
namespace internal {
// Identity<T>::type is a typedef of T. Useful for preventing the
// compiler from inferring the type of an argument in templates.
template <typename T>
struct Identity {
typedef T type;
};
} // namespace internal
// The cacheinvalidation callback system expects to take the callback by
// pointer and handle the ownership semantics itself. Adapting the
// Chromium Callback system requires returning a dynamically allocated
// copy of the result of Bind().
inline base::RepeatingClosure* NewPermanentCallback(void (*fn)()) {
return new ::base::RepeatingClosure(::base::BindRepeating(fn));
}
template <class T1, class T2>
base::RepeatingClosure* NewPermanentCallback(T1* object, void (T2::*method)()) {
return new ::base::RepeatingClosure(
::base::BindRepeating(method, base::Unretained(object)));
}
// TODO(crbug.com/1027234) Make this method variadic to avoid having so many
// expanded versions.
template <class T1, class T2, typename Arg1>
::base::Callback<void(Arg1)>* NewPermanentCallback(
T1* object, void (T2::*method)(Arg1)) {
return new ::base::Callback<void(Arg1)>(
::base::BindRepeating(method, base::Unretained(object)));
}
template <class T1, class T2, typename Arg1>
base::RepeatingClosure* NewPermanentCallback(
T1* object,
void (T2::*method)(Arg1),
typename internal::Identity<Arg1>::type arg1) {
return new ::base::RepeatingClosure(
::base::BindRepeating(method, base::Unretained(object), arg1));
}
template <typename Arg1, typename Arg2>
base::RepeatingClosure* NewPermanentCallback(
void (*fn)(Arg1, Arg2),
typename internal::Identity<Arg1>::type arg1,
typename internal::Identity<Arg2>::type arg2) {
return new ::base::RepeatingClosure(::base::BindRepeating(fn, arg1, arg2));
}
template <class T1, class T2, typename Arg1, typename Arg2>
base::RepeatingClosure* NewPermanentCallback(
T1* object,
void (T2::*method)(Arg1, Arg2),
typename internal::Identity<Arg1>::type arg1,
typename internal::Identity<Arg2>::type arg2) {
return new ::base::RepeatingClosure(
::base::BindRepeating(method, base::Unretained(object), arg1, arg2));
}
template <class T1, class T2, typename Arg1, typename Arg2>
::base::Callback<void(Arg2)>* NewPermanentCallback(
T1* object,
void (T2::*method)(Arg1, Arg2),
typename internal::Identity<Arg1>::type arg1) {
return new ::base::Callback<void(Arg2)>(
::base::BindRepeating(method, base::Unretained(object), arg1));
}
template <class T1, class T2, typename Arg1, typename Arg2, typename Arg3>
base::RepeatingClosure* NewPermanentCallback(
T1* object,
void (T2::*method)(Arg1, Arg2, Arg3),
typename internal::Identity<Arg1>::type arg1,
typename internal::Identity<Arg2>::type arg2,
typename internal::Identity<Arg3>::type arg3) {
return new ::base::RepeatingClosure(::base::BindRepeating(
method, base::Unretained(object), arg1, arg2, arg3));
}
template <class T1,
class T2,
typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4>
base::RepeatingClosure* NewPermanentCallback(
T1* object,
void (T2::*method)(Arg1, Arg2, Arg3, Arg4),
typename internal::Identity<Arg1>::type arg1,
typename internal::Identity<Arg2>::type arg2,
typename internal::Identity<Arg3>::type arg3,
typename internal::Identity<Arg4>::type arg4) {
return new ::base::RepeatingClosure(::base::BindRepeating(
method, base::Unretained(object), arg1, arg2, arg3, arg4));
}
// Creates a Closure that runs |callback| on |arg|. The returned Closure owns
// |callback|.
template <typename ArgType>
base::RepeatingClosure* NewPermanentCallback(
INVALIDATION_CALLBACK1_TYPE(ArgType) * callback,
typename internal::Identity<ArgType>::type arg) {
std::unique_ptr<::base::Callback<void(ArgType)>> deleter(callback);
return new ::base::RepeatingClosure(::base::BindRepeating(*callback, arg));
}
} // namespace invalidation
#endif // GOOGLE_CACHEINVALIDATION_DEPS_CALLBACK_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_GMOCK_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_GMOCK_H_
#include "testing/gmock/include/gmock/gmock.h"
namespace testing {
namespace internal {
// WhenDeserializedAs and EqualsProto are utilities that aren't part of gmock.
// Implements WhenDeserializedAs<Proto>(proto_matcher).
template <class Proto>
class WhenDeserializedAsMatcher {
public:
typedef Matcher<const Proto&> InnerMatcher;
explicit WhenDeserializedAsMatcher(const InnerMatcher& proto_matcher)
: proto_matcher_(proto_matcher) {}
virtual ~WhenDeserializedAsMatcher() {}
// Deserializes the string as a protobuf of the same type as the expected
// protobuf.
Proto* Deserialize(const std::string& str) const {
Proto* proto = new Proto;
if (proto->ParsePartialFromString(str)) {
return proto;
} else {
delete proto;
return NULL;
}
}
void DescribeTo(::std::ostream* os) const {
*os << "can be deserialized as a protobuf that ";
proto_matcher_.DescribeTo(os);
}
void DescribeNegationTo(::std::ostream* os) const {
*os << "cannot be deserialized as a protobuf that ";
proto_matcher_.DescribeTo(os);
}
bool MatchAndExplain(const std::string& arg,
MatchResultListener* listener) const {
// Deserializes the string arg as a protobuf of the same type as the
// expected protobuf.
std::unique_ptr<const Proto> deserialized_arg(Deserialize(arg));
// No need to explain the match result.
return (deserialized_arg.get() != NULL) &&
proto_matcher_.Matches(*deserialized_arg);
}
private:
const InnerMatcher proto_matcher_;
};
} // namespace internal
namespace proto {
// WhenDeserializedAs<Proto>(m) is a matcher that matches a string
// that can be deserialized as a protobuf of type Proto that matches
// m, which can be any valid protobuf matcher.
template <class Proto, class InnerMatcher>
inline PolymorphicMatcher<internal::WhenDeserializedAsMatcher<Proto> >
WhenDeserializedAs(const InnerMatcher& inner_matcher) {
return MakePolymorphicMatcher(
internal::WhenDeserializedAsMatcher<Proto>(
SafeMatcherCast<const Proto&>(inner_matcher)));
}
} // namespace proto
MATCHER_P(EqualsProto, message, "") {
// TODO(ghc): This implementation assume protobuf serialization is
// deterministic, which is true in practice but technically not something that
// code is supposed to rely on. However, it vastly simplifies the
// implementation...
std::string expected_serialized, actual_serialized;
message.SerializeToString(&expected_serialized);
arg.SerializeToString(&actual_serialized);
return expected_serialized == actual_serialized;
}
} // namespace testing
#endif // GOOGLE_CACHEINVALIDATION_DEPS_GMOCK_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_GOOGLETEST_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_GOOGLETEST_H_
#include "testing/gtest/include/gtest/gtest.h"
#endif // GOOGLE_CACHEINVALIDATION_DEPS_GOOGLETEST_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_LOGGING_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_LOGGING_H_
#include "base/check.h"
#include "base/logging.h"
namespace invalidation {
using logging::LogMessage;
} // namespace invalidation
#endif // GOOGLE_CACHEINVALIDATION_DEPS_LOGGING_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_MUTEX_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_MUTEX_H_
#include "base/macros.h"
#include "base/synchronization/lock.h"
namespace invalidation {
typedef base::Lock Mutex;
class MutexLock {
public:
explicit MutexLock(Mutex* m) : auto_lock_(*m) {}
private:
base::AutoLock auto_lock_;
DISALLOW_COPY_AND_ASSIGN(MutexLock);
};
} // namespace invalidation
#endif // GOOGLE_CACHEINVALIDATION_DEPS_MUTEX_H_
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "google/cacheinvalidation/deps/random.h"
namespace invalidation {
double Random::RandDouble() {
return base::RandDouble();
}
uint64_t Random::RandUint64() {
return base::RandUint64();
}
} // namespace invalidation
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_RANDOM_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_RANDOM_H_
#include <stdint.h>
#include "base/rand_util.h"
namespace invalidation {
class Random {
public:
// We don't actually use the seed.
explicit Random(int64_t seed) {}
virtual ~Random() {}
// Returns a pseudorandom value between(inclusive) and(exclusive).
virtual double RandDouble();
virtual uint64_t RandUint64();
};
} // namespace invalidation
#endif // GOOGLE_CACHEINVALIDATION_DEPS_RANDOM_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_SCOPED_PTR_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_SCOPED_PTR_H_
#include <memory>
namespace invalidation {
template <typename T, typename D = std::default_delete<T>>
using scoped_ptr = std::unique_ptr<T, D>;
} // namespace invalidation
#endif // GOOGLE_CACHEINVALIDATION_DEPS_SCOPED_PTR_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Interface to SHA1 digest computation.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_SHA1_DIGEST_FUNCTION_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_SHA1_DIGEST_FUNCTION_H_
#include <string>
#include "base/hash/sha1.h"
#include "google/cacheinvalidation/deps/digest-function.h"
#include "google/cacheinvalidation/deps/stl-namespace.h"
namespace invalidation {
using ::INVALIDATION_STL_NAMESPACE::string;
class Sha1DigestFunction : public DigestFunction {
public:
Sha1DigestFunction() : reset_needed_(false) {}
virtual void Reset() {
reset_needed_ = false;
buffer_.clear();
}
virtual void Update(const string& s) {
CHECK(!reset_needed_);
buffer_.append(s);
}
virtual string GetDigest() {
CHECK(!reset_needed_);
reset_needed_ = true;
return base::SHA1HashString(buffer_);
}
private:
string buffer_;
bool reset_needed_;
};
} // namespace invalidation
#endif // GOOGLE_CACHEINVALIDATION_DEPS_SHA1_DIGEST_FUNCTION_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_STL_NAMESPACE_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_STL_NAMESPACE_H_
#define INVALIDATION_STL_NAMESPACE std
#endif // GOOGLE_CACHEINVALIDATION_DEPS_STL_NAMESPACE_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_STRING_UTIL_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_STRING_UTIL_H_
#include <stdint.h>
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
namespace invalidation {
using base::StringAppendV;
using base::StringPrintf;
inline std::string SimpleItoa(int v) {
return base::NumberToString(v);
}
inline std::string SimpleItoa(int64_t v) {
return base::NumberToString(v);
}
} // namespace invalidation
#endif // GOOGLE_CACHEINVALIDATION_DEPS_STRING_UTIL_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_TIME_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_TIME_H_
#include "base/time/time.h"
namespace invalidation {
typedef base::Time Time;
typedef base::TimeTicks TimeTicks;
typedef base::TimeDelta TimeDelta;
} // namespace invalidation
#endif // GOOGLE_CACHEINVALIDATION_DEPS_TIME_H_
<?xml version="1.0" ?>
<!-- Copyright 2011 Google Inc. All Rights Reserved. -->
<!-- Manifest for AndroidListener sample application. Must be merged with
j/c/g/ipc/invalidation/external/client/contrib:android_listener_manifest. -->
<manifest android:versionCode="1" android:versionName="0.1" package="com.google.ipc.invalidation.examples.android2" xmlns:android="http://schemas.android.com/apk/res/android">
<!-- *** WARNING *** DO NOT EDIT! THIS IS GENERATED MANIFEST BY MERGE_MANIFEST TOOL.
Merger manifest:
java/com/google/ipc/invalidation/examples/android2/AndroidManifest.xml
Mergee manifests:
-->
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="14"/>
<!-- Declare and use permission allowing this application to receive GCM
messages. -->
<permission android:name="com.google.ipc.invalidation.examples.android2.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="com.google.ipc.invalidation.examples.android2.permission.C2D_MESSAGE"/>
<application>
<!-- Configure the listener class for the application -->
<meta-data android:name="ipc.invalidation.ticl.listener_service_class" android:value="com.google.ipc.invalidation.examples.android2.ExampleListener"/>
<!-- To enable background invalidations uncomment the following element:
-->
<!--<meta-data
android:name=
"ipc.invalidation.ticl.background_invalidation_listener_service_class"
android:value=
"com.google.ipc.invalidation.examples.android2.ExampleListener"/>-->
<!-- Example activity -->
<activity android:name="com.google.ipc.invalidation.examples.android2.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Ticl listener. -->
<service android:exported="false" android:name="com.google.ipc.invalidation.examples.android2.ExampleListener">
<intent-filter>
<action android:name="com.google.ipc.invalidation.AUTH_TOKEN_REQUEST"/>
</intent-filter>
</service>
<!-- Receiver for scheduler alarms. -->
<receiver android:exported="false" android:name="com.google.ipc.invalidation.external.client.contrib.AndroidListener$AlarmReceiver"/>
<!-- Receiver for scheduler alarms. -->
<receiver android:exported="false" android:name="com.google.ipc.invalidation.ticl.android2.AndroidInternalScheduler$AlarmReceiver"/>
<!-- GCM Broadcast Receiver -->
<receiver android:exported="true" android:name="com.google.ipc.invalidation.external.client.contrib.MultiplexingGcmListener$GCMReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="com.google.ipc.invalidation.ticl.android2"/>
</intent-filter>
</receiver>
<!-- Merged from file: java/com/google/ipc/invalidation/external/client/android2/AndroidManifest.xml -->
<receiver android:exported="false" android:name="com.google.ipc.invalidation.ticl.android2.channel.AndroidMessageReceiverService$Receiver">
<intent-filter>
<action android:name="com.google.ipc.invalidation.gcmmplex.EVENT"/>
</intent-filter>
</receiver>
<!-- Ticl service. -->
<service android:exported="false" android:name="com.google.ipc.invalidation.ticl.android2.TiclService"/>
<!-- Ticl sender. -->
<service android:exported="false" android:name="com.google.ipc.invalidation.ticl.android2.channel.AndroidMessageSenderService"/>
<!-- GCM multiplexer -->
<service android:exported="false" android:name="com.google.ipc.invalidation.external.client.contrib.MultiplexingGcmListener">
<meta-data android:name="sender_ids" android:value="ipc.invalidation@gmail.com"/>
</service>
<!-- Invalidation service multiplexed GCM receiver -->
<service android:enabled="true" android:exported="false" android:name="com.google.ipc.invalidation.ticl.android2.channel.AndroidMessageReceiverService"/>
</application>
<!-- App receives GCM messages. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<!-- GCM connects to Google Services. -->
<uses-permission android:name="android.permission.INTERNET"/>
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<!-- Merged from file: java/com/google/ipc/invalidation/external/client/android2/AndroidManifest.xml -->
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK"/>
</manifest>
Copyright 2012 Google Inc. All Rights Reserved.
This directory contains the files required to build the example application for
the Invalidation Client, the source code of which is located under
../src/java/com/google/ipc/invalidation/examples/android2.
To build the example, first run ./generate_protos.sh. Then, run ant debug or
ant release to build the application.
source.dir = ../java:generated-protos:../javaexample
<?xml version="1.0" encoding="UTF-8"?>
<project name="MainActivity" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
unless="sdk.dir"
/>
<!-- extension targets. Uncomment the ones where you want to do custom work
in between standard targets -->
<!--
<target name="-pre-build">
</target>
-->
<!--
<target name="-pre-build">
<target name="-pre-compile">
</target>
/* This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir} */
<target name="-post-compile">
</target>
-->
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>
#!/bin/sh
# Copyright 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Tool to output Java classes for the protocol buffers used by the invalidation
# client into the generated-protos/ directory.
TOOL=${PROTOC- `which protoc`}
mkdir -p generated-protos/
$TOOL --javanano_out=optional_field_style=reftypes:generated-protos/ ../proto/* --proto_path=../proto/
EXAMPLE_PATH=../javaexample/com/google/ipc/invalidation/examples/android2
$TOOL --javanano_out=optional_field_style=reftypes:generated-protos/ $EXAMPLE_PATH/example_listener.proto --proto_path=$EXAMPLE_PATH
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked in Version Control Systems,
# as it contains information specific to your local configuration.
# location of the SDK. This is only used by Ant
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=/home/dsmyers/bin/android-sdk-linux
#
# This file was derived from the Android SDK default configuration in tools/lib/proguard.cfg,
# with changes/additions explicitly commented where made
#
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
# Change: SDK defaults + code/allocation/variable required to disable proguard optimization bug
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*,!code/allocation/variable
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
# Change: not needed
#-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
#
# All changes below are additions to the Android SDK defaults, generally for the purposes of
# suppressing spurious or inconsequential warnings.
#
# Suppress duplicate warning for system classes; Blaze is passing android.jar
# to proguard multiple times.
-dontnote android.**
-dontnote java.**
-dontnote javax.**
-dontnote junit.**
-dontnote org.**
-dontnote dalvik.**
-dontnote com.android.internal.**
# Stop warnings about missing unused classes
-dontwarn com.google.common.annotations.**
-dontwarn com.google.common.base.**
-dontwarn com.google.common.collect.**
-dontnote com.google.common.flags.**
-dontwarn com.google.common.flags.**
-dontwarn com.google.common.util.concurrent.**
# Ignore missing JDK6 classes
-dontwarn java.**
# Inverting these produces significant size gains but loses significant debug info
-dontobfuscate
#-flattenpackagehierarchy
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=Google Inc.:Google APIs:15
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//third_party/protobuf/proto_library.gni")
proto_library("cacheinvalidation_proto_cpp") {
# Depend on cacheinvalidation instead.
visibility = [ "//third_party/cacheinvalidation/*" ]
sources = [
"client.proto",
"client_gateway.proto",
"client_protocol.proto",
"client_test_internal.proto",
"types.proto",
]
if (!is_android) {
sources += [
"android_channel.proto",
"channel_common.proto",
]
}
proto_out_dir = "google/cacheinvalidation"
}
This directory contains the implementation of the client library for a cache
invalidation service.
The public (stable) interfaces are those defined under include/:
invalidation-client.h
invalidation-client-factory.h
invalidation-listener.h
system-resources.h
types.h
In order to compile this library, proper implementations of the interfaces
residing under deps/ must be provided.
Interfaces and implementations defined under impl/ are subject to change, and
the test/ directory contains test helpers. Please do not depend directly
on anything in these directories.
/*
* Copyright 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// The Android delivery service's network endpoint id descriptor.
// This proto is internal to the Android channel.
syntax = "proto2";
option optimize_for = LITE_RUNTIME;
package ipc.invalidation;
import "client_protocol.proto";
// Defines the valid major versions of the android channel protocol. The
// channel version controls the expected envelope syntax and semantics of
// http and c2dm messages sent between the client and server.
enum MajorVersion {
option allow_alias = true;
// The initial version of the android channel protocol. Inbound and
// outbound channel packets contained a single binary protocol message only.
INITIAL = 0;
// Adds batching (multiple protocol messages in a single channel message)
BATCH = 1;
// The default channel version used by Android clients. Lower major numbers
// will represent earlier versions and higher numbers will represent
// experimental versions that are not yet released.
DEFAULT = 0;
// The minimum and maximum supported channel major versions. Used to validate
// incoming requests, so update as new versions are added or old versions are
// no longer supported.
MIN_SUPPORTED = 0;
MAX_SUPPORTED = 1;
}
// An id that specifies how to route a message to a Ticl on an Android device
// via C2DM.
message EndpointId {
// Field 1 was once the ProtocolVersion of this message.
// The "registration_id" returned when the client registers with c2dm. This
// id is required by c2dm in order to send a message to the device.
optional string c2dm_registration_id = 2;
// A key identifying a specific client on a device.
optional string client_key = 3;
// The C2DM sender ID to use to deliver messages to the endpoint.
optional string sender_id = 4 [deprecated = true];
// Defines the expected channel version generated by the network endpoint or
// expected in messages sent from the server.
optional Version channel_version = 5;
// The package name of the Android application that will receive the messages.
// Replaces sender_id. Must be set (unless sender_id is set; in which case it
// must not be set).
optional string package_name = 6;
}
// A message addressed to a particular Ticl on an Android device.
message AddressedAndroidMessage {
// Client on the device to which the message is destined.
optional string client_key = 1;
// Message contents (serialized ServerToClientMessage).
optional bytes message = 2;
}
// A batch of messages addressed to potentially-different Ticls on the same
// Android device.
message AddressedAndroidMessageBatch {
repeated AddressedAndroidMessage addressed_message = 1;
}
// Copyright 2011 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Common utilities used by all channel related protos.
// This is also publicly visible to all channel implementors.
syntax = "proto2";
option optimize_for = LITE_RUNTIME;
package ipc.invalidation;
message ChannelMessageEncoding {
// What kind of encoding is used for network_message
enum MessageEncoding {
// Raw proto encoding
PROTOBUF_BINARY_FORMAT = 1;
// JSPB-encoding: https://sites.google.com/a/google.com/jspblite/Home
PROTOBUF_JSON_FORMAT = 2;
}
}
message NetworkEndpointId {
enum NetworkAddress {
TEST = 1; // A delivery service for testing
// Low numbers reserved.
ANDROID = 113; // Android delivery service using c2dm / http.
}
optional NetworkAddress network_address = 1;
optional bytes client_address = 2;
// Optional. When true, the client is considered offline but the
// client_address is maintained so that the client can potentially be reached.
// When false or undefined, the client is considered online.
optional bool is_offline = 3;
}
// Copyright 2011 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Specification of protocol buffers that are used only on the client side.
//
// Note: unless otherwise specified in a comment, all fields in all messages
// are required, even though they are listed as optional.
syntax = "proto2";
option optimize_for = LITE_RUNTIME;
package ipc.invalidation;
import "client_protocol.proto";
// An object that is serialized and given to clients for acknowledgement
// purposes.
message AckHandleP {
optional InvalidationP invalidation = 1;
}
// The state persisted at a client so that it can be used after a reboot.
message PersistentTiclState {
// Last token received from the server (required).
optional bytes client_token = 1;
// Last time a message was sent to the server (optional). Must be a value
// returned by the clock in the Ticl system resources.
optional int64 last_message_send_time_ms = 2 [default = 0];
}
// An envelope containing a Ticl's internal state, along with a digest of the
// serialized representation of this state, to ensure its integrity across
// reads and writes to persistent storage.
message PersistentStateBlob {
// The (important parts of the) Ticl's internal state.
optional PersistentTiclState ticl_state = 1;
// Implementation-specific message authentication code for the Ticl state.
optional bytes authentication_code = 2;
}
// State of a Ticl RunState.
message RunStateP {
enum State {
NOT_STARTED = 1;
STARTED = 2;
STOPPED = 3;
}
optional State state = 1;
}
// Copyright 2011 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Specification of invalidation gateway internal forwarding messages and
// services.
syntax = "proto2";
option optimize_for = LITE_RUNTIME;
package ipc.invalidation;
// The message communicated between gateway and clients.
message ClientGatewayMessage {
// Whether it is client to server or server to client.
optional bool is_client_to_server = 1;
// Serialized version of the ServiceContext.
optional bytes service_context = 2;
// Rpc scheduling hash.
optional int64 rpc_scheduling_hash = 3;
// Payload of the network message (ClientToServerMessage or
// ServerToClientMessage).
optional bytes network_message = 4;
}
// Copyright 2011 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Specification of protocol buffers that are used only on the client side for
// testing.
syntax = "proto2";
option optimize_for = LITE_RUNTIME;
package ipc.invalidation;
import "client_protocol.proto";
// Registration manager state
message RegistrationManagerStateP {
optional RegistrationSummary client_summary = 1;
optional RegistrationSummary server_summary = 2;
repeated ObjectIdP registered_objects = 3;
}
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Defines callback types for the invalidation client library.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_CALLBACK_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_CALLBACK_H_
#include "base/callback.h"
#define INVALIDATION_CALLBACK1_TYPE(Arg1) ::Callback1<Arg1>
namespace invalidation {
using ::Closure;
using ::DoNothing;
using ::NewPermanentCallback;
template <class T>
bool IsCallbackRepeatable(const T* callback) {
return callback->IsRepeatable();
}
// Encapsulates a callback and its argument. Deletes the inner callback when it
// is itself deleted, regardless of whether it is ever run.
template<typename ArgumentType>
class CallbackWrapper : public Closure {
public:
// Constructs a new CallbackWrapper, which takes ownership of the inner
// callback.
CallbackWrapper(
INVALIDATION_CALLBACK1_TYPE(ArgumentType)* callback, ArgumentType arg) :
callback_(callback), arg_(arg) {}
virtual ~CallbackWrapper() {
delete callback_;
}
// Returns whether the inner callback is repeatable.
virtual bool IsRepeatable() const {
return callback_->IsRepeatable();
}
// Runs the inner callback on the argument.
virtual void Run() {
callback_->Run(arg_);
}
private:
// The callback to run.
INVALIDATION_CALLBACK1_TYPE(ArgumentType)* callback_;
// The argument on which to run it.
ArgumentType arg_;
};
// An override of NewPermanentCallback that wraps a callback and its argument,
// transferring ownership of the inner callback to the new one. We define this
// here (in deps/callback.h), along with the class above, because the Google
// implementation of callbacks is much different from the one used in Chrome. A
// Chrome Closure's destructor and Run() method are not virtual, so we can't
// define custom implementations (as above in CallbackWrapper) to get the
// semantics and memory management behavior we want.
template <typename ArgType>
Closure* NewPermanentCallback(
INVALIDATION_CALLBACK1_TYPE(ArgType)* callback, ArgType arg) {
return new CallbackWrapper<ArgType>(callback, arg);
}
} // namespace invalidation
#endif // GOOGLE_CACHEINVALIDATION_DEPS_CALLBACK_H_
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Interface specifying a function to compute digests.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_DIGEST_FUNCTION_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_DIGEST_FUNCTION_H_
#include <string>
#include "google/cacheinvalidation/deps/stl-namespace.h"
namespace invalidation {
using INVALIDATION_STL_NAMESPACE::string;
class DigestFunction {
public:
virtual ~DigestFunction() {}
/* Clears the digest state. */
virtual void Reset() = 0;
/* Adds data to the digest being computed. */
virtual void Update(const string& data) = 0;
/* Stores the digest of the data added by Update. After this call has been
* made, reset must be called before Update and GetDigest can be called.
*/
virtual string GetDigest() = 0;
};
} // namespace invalidation
#endif // GOOGLE_CACHEINVALIDATION_DEPS_DIGEST_FUNCTION_H_
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_GMOCK_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_GMOCK_H_
#error Replace with a header that imports the Google Mock library.
#endif // GOOGLE_CACHEINVALIDATION_DEPS_GMOCK_H_
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_GOOGLETEST_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_GOOGLETEST_H_
#error This file should be replaced with a stub pointing to the googletest \
header.
#endif // GOOGLE_CACHEINVALIDATION_DEPS_GOOGLETEST_H_
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_LOGGING_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_LOGGING_H_
#error This file should be replaced with a stub pointing to the google-glog \
header. Also there should be a LogMessage() function in the invalidation \
namespace.
#endif // GOOGLE_CACHEINVALIDATION_DEPS_LOGGING_H_
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_MUTEX_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_MUTEX_H_
#include "base/mutex.h"
namespace invalidation {
using ::Mutex;
using ::MutexLock;
} // invalidation
#endif // GOOGLE_CACHEINVALIDATION_DEPS_MUTEX_H_
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_RANDOM_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_RANDOM_H_
#error This file should be replaced with an implementation of the following \
interface.
namespace invalidation {
class Random {
public:
explicit Random(int64_t seed);
// Returns a pseudorandom value between 0 (inclusive) and 1 (exclusive).
virtual double RandDouble();
// Returns a pseudorandom unsigned 64-bit number.
virtual uint64_t RandUint64();
};
} // namespace invalidation
#endif // GOOGLE_CACHEINVALIDATION_DEPS_RANDOM_H_
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_SCOPED_PTR_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_SCOPED_PTR_H_
#error Override scoped_ptr.h to point to a scoped_ptr implementation.
#endif // GOOGLE_CACHEINVALIDATION_DEPS_SCOPED_PTR_H_
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Interface to SHA1 digest computation.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_SHA1_DIGEST_FUNCTION_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_SHA1_DIGEST_FUNCTION_H_
#error Replace this file with an implementation of DigestFunction based on SHA1.
#endif // GOOGLE_CACHEINVALIDATION_DEPS_SHA1_DIGEST_FUNCTION_H_
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_STL_NAMESPACE_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_STL_NAMESPACE_H_
// Google style is to use the global namespace for stl classes so we
// leave this blank.
#define INVALIDATION_STL_NAMESPACE
#endif // GOOGLE_CACHEINVALIDATION_DEPS_STL_NAMESPACE_H_
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_STRING_UTIL_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_STRING_UTIL_H_
#error This file should be replaced with a stub pointing to a file \
containing string utility functions in the invalidation namespace. \
At least StringAppendV() StringPrintf(), and IntToString() are needed.
#endif // GOOGLE_CACHEINVALIDATION_DEPS_STRING_UTIL_H_
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GOOGLE_CACHEINVALIDATION_DEPS_TIME_H_
#define GOOGLE_CACHEINVALIDATION_DEPS_TIME_H_
#error This file should be replaced with a stub pointing to something \
like base/time.h from the Chromium source tree, with definitions for types \
Time, TimeDelta, etc.
#endif // GOOGLE_CACHEINVALIDATION_DEPS_TIME_H_
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "google/cacheinvalidation/impl/basic-system-resources.h"
namespace invalidation {
BasicSystemResources::BasicSystemResources(
Logger* logger, Scheduler* internal_scheduler,
Scheduler* listener_scheduler, NetworkChannel* network,
Storage* storage, const string& platform)
: logger_(logger),
internal_scheduler_(internal_scheduler),
listener_scheduler_(listener_scheduler),
network_(network),
storage_(storage),
platform_(platform) {
logger_->SetSystemResources(this);
internal_scheduler_->SetSystemResources(this);
listener_scheduler_->SetSystemResources(this);
network_->SetSystemResources(this);
storage_->SetSystemResources(this);
}
BasicSystemResources::~BasicSystemResources() {
}
void BasicSystemResources::Start() {
CHECK(!run_state_.IsStarted()) << "resources already started";
// TODO(ghc): Investigate whether we should have Start() and Stop() methods
// on components like the scheduler. Otherwise, the resources can't start and
// stop them ...
run_state_.Start();
}
void BasicSystemResources::Stop() {
CHECK(run_state_.IsStarted()) << "cannot stop resources that aren't started";
CHECK(!run_state_.IsStopped()) << "resources already stopped";
run_state_.Stop();
}
bool BasicSystemResources::IsStarted() const {
return run_state_.IsStarted();
}
Logger* BasicSystemResources::logger() {
return logger_.get();
}
Scheduler* BasicSystemResources::internal_scheduler() {
return internal_scheduler_.get();
}
Scheduler* BasicSystemResources::listener_scheduler() {
return listener_scheduler_.get();
}
NetworkChannel* BasicSystemResources::network() {
return network_.get();
}
Storage* BasicSystemResources::storage() {
return storage_.get();
}
string BasicSystemResources::platform() const {
return platform_;
}
} // namespace invalidation
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// A simple implementation of SystemResources that just takes the resource
// components and constructs a SystemResources object.
#ifndef GOOGLE_CACHEINVALIDATION_IMPL_BASIC_SYSTEM_RESOURCES_H_
#define GOOGLE_CACHEINVALIDATION_IMPL_BASIC_SYSTEM_RESOURCES_H_
#include "google/cacheinvalidation/include/system-resources.h"
#include "google/cacheinvalidation/deps/scoped_ptr.h"
#include "google/cacheinvalidation/impl/run-state.h"
namespace invalidation {
class BasicSystemResources : public SystemResources {
public:
// Constructs an instance from resource components. Ownership of all
// components is transferred to the BasicSystemResources object.
BasicSystemResources(
Logger* logger, Scheduler* internal_scheduler,
Scheduler* listener_scheduler, NetworkChannel* network,
Storage* storage, const string& platform);
virtual ~BasicSystemResources();
// Overrides from SystemResources.
virtual void Start();
virtual void Stop();
virtual bool IsStarted() const;
virtual Logger* logger();
virtual Scheduler* internal_scheduler();
virtual Scheduler* listener_scheduler();
virtual NetworkChannel* network();
virtual Storage* storage();
virtual string platform() const;
private:
// Components comprising the system resources. We delegate calls to these as
// appropriate.
scoped_ptr<Logger> logger_;
scoped_ptr<Scheduler> internal_scheduler_;
scoped_ptr<Scheduler> listener_scheduler_;
scoped_ptr<NetworkChannel> network_;
scoped_ptr<Storage> storage_;
// The state of the resources.
RunState run_state_;
// Information about the client operating system/platform.
string platform_;
};
} // namespace invalidation
#endif // GOOGLE_CACHEINVALIDATION_IMPL_BASIC_SYSTEM_RESOURCES_H_
// Copyright 2013 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Build constant definitions
#ifndef INVALIDATION_BUILD_CONSTANTS_H_
#define INVALIDATION_BUILD_CONSTANTS_H_
namespace invalidation {
const int BUILD_DATESTAMP = 20140204;
} // namespace invalidation
#endif // INVALIDATION_BUILD_CONSTANTS_H_
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// InvalidationListener wrapper that ensures that a delegate listener is called
// on the proper thread and calls the listener method on the listener thread.
#include "google/cacheinvalidation/impl/checking-invalidation-listener.h"
#include "google/cacheinvalidation/impl/log-macro.h"
namespace invalidation {
CheckingInvalidationListener::CheckingInvalidationListener(
InvalidationListener* delegate, Statistics* statistics,
Scheduler* internal_scheduler, Scheduler* listener_scheduler,
Logger* logger)
: delegate_(delegate),
statistics_(statistics),
internal_scheduler_(internal_scheduler),
listener_scheduler_(listener_scheduler),
logger_(logger) {
CHECK(delegate != NULL);
CHECK(statistics != NULL);
CHECK(internal_scheduler_ != NULL);
CHECK(listener_scheduler != NULL);
CHECK(logger != NULL);
}
void CheckingInvalidationListener::Invalidate(
InvalidationClient* client, const Invalidation& invalidation,
const AckHandle& ack_handle) {
CHECK(internal_scheduler_->IsRunningOnThread()) << "Not on internal thread";
statistics_->RecordListenerEvent(Statistics::ListenerEventType_INVALIDATE);
listener_scheduler_->Schedule(
Scheduler::NoDelay(),
NewPermanentCallback(
delegate_, &InvalidationListener::Invalidate, client, invalidation,
ack_handle));
}
void CheckingInvalidationListener::InvalidateUnknownVersion(
InvalidationClient* client, const ObjectId& object_id,
const AckHandle& ack_handle) {
CHECK(internal_scheduler_->IsRunningOnThread()) << "Not on internal thread";
statistics_->RecordListenerEvent(
Statistics::ListenerEventType_INVALIDATE_UNKNOWN);
listener_scheduler_->Schedule(
Scheduler::NoDelay(),
NewPermanentCallback(
delegate_, &InvalidationListener::InvalidateUnknownVersion, client,
object_id, ack_handle));
}
void CheckingInvalidationListener::InvalidateAll(
InvalidationClient* client, const AckHandle& ack_handle) {
CHECK(internal_scheduler_->IsRunningOnThread()) << "Not on internal thread";
statistics_->RecordListenerEvent(
Statistics::ListenerEventType_INVALIDATE_ALL);
listener_scheduler_->Schedule(
Scheduler::NoDelay(),
NewPermanentCallback(
delegate_, &InvalidationListener::InvalidateAll, client,
ack_handle));
}
void CheckingInvalidationListener::InformRegistrationFailure(
InvalidationClient* client, const ObjectId& object_id,
bool is_transient, const string& error_message) {
CHECK(internal_scheduler_->IsRunningOnThread()) << "Not on internal thread";
statistics_->RecordListenerEvent(
Statistics::ListenerEventType_INFORM_REGISTRATION_FAILURE);
listener_scheduler_->Schedule(
Scheduler::NoDelay(),
NewPermanentCallback(
delegate_, &InvalidationListener::InformRegistrationFailure, client,
object_id, is_transient, error_message));
}
void CheckingInvalidationListener::InformRegistrationStatus(
InvalidationClient* client, const ObjectId& object_id,
RegistrationState reg_state) {
CHECK(internal_scheduler_->IsRunningOnThread()) << "Not on internal thread";
statistics_->RecordListenerEvent(
Statistics::ListenerEventType_INFORM_REGISTRATION_STATUS);
listener_scheduler_->Schedule(
Scheduler::NoDelay(),
NewPermanentCallback(
delegate_, &InvalidationListener::InformRegistrationStatus, client,
object_id, reg_state));
}
void CheckingInvalidationListener::ReissueRegistrations(
InvalidationClient* client, const string& prefix, int prefix_len) {
CHECK(internal_scheduler_->IsRunningOnThread()) << "Not on internal thread";
statistics_->RecordListenerEvent(
Statistics::ListenerEventType_REISSUE_REGISTRATIONS);
listener_scheduler_->Schedule(
Scheduler::NoDelay(),
NewPermanentCallback(
delegate_, &InvalidationListener::ReissueRegistrations,
client, prefix, prefix_len));
}
void CheckingInvalidationListener::InformError(
InvalidationClient* client, const ErrorInfo& error_info) {
CHECK(internal_scheduler_->IsRunningOnThread()) << "Not on internal thread";
statistics_->RecordListenerEvent(
Statistics::ListenerEventType_INFORM_ERROR);
listener_scheduler_->Schedule(
Scheduler::NoDelay(),
NewPermanentCallback(
delegate_, &InvalidationListener::InformError, client, error_info));
}
void CheckingInvalidationListener::Ready(InvalidationClient* client) {
CHECK(internal_scheduler_->IsRunningOnThread()) << "Not on internal thread";
TLOG(logger_, INFO, "Informing app that ticl is ready");
listener_scheduler_->Schedule(
Scheduler::NoDelay(),
NewPermanentCallback(delegate_, &InvalidationListener::Ready, client));
}
} // namespace invalidation
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// InvalidationListener wrapper that ensures that a delegate listener is called
// on the proper thread and calls the listener method on the listener thread.
#ifndef GOOGLE_CACHEINVALIDATION_IMPL_CHECKING_INVALIDATION_LISTENER_H_
#define GOOGLE_CACHEINVALIDATION_IMPL_CHECKING_INVALIDATION_LISTENER_H_
#include "google/cacheinvalidation/include/invalidation-client.h"
#include "google/cacheinvalidation/include/invalidation-listener.h"
#include "google/cacheinvalidation/include/system-resources.h"
#include "google/cacheinvalidation/include/types.h"
#include "google/cacheinvalidation/impl/statistics.h"
namespace invalidation {
class CheckingInvalidationListener : public InvalidationListener {
public:
CheckingInvalidationListener(
InvalidationListener* delegate, Statistics* statistics,
Scheduler* internal_scheduler, Scheduler* listener_scheduler,
Logger* logger);
virtual ~CheckingInvalidationListener() {}
virtual void Invalidate(
InvalidationClient* client, const Invalidation& invalidation,
const AckHandle& ack_handle);
virtual void InvalidateUnknownVersion(
InvalidationClient* client, const ObjectId& object_id,
const AckHandle& ack_handle);
virtual void InvalidateAll(
InvalidationClient* client, const AckHandle& ack_handle);
virtual void InformRegistrationFailure(
InvalidationClient* client, const ObjectId& object_id,
bool is_transient, const string& error_message);
virtual void InformRegistrationStatus(
InvalidationClient* client, const ObjectId& object_id,
RegistrationState reg_state);
virtual void ReissueRegistrations(
InvalidationClient* client, const string& prefix, int prefix_len);
virtual void InformError(
InvalidationClient* client, const ErrorInfo& error_info);
/* Returns the delegate InvalidationListener. */
InvalidationListener* delegate() {
return delegate_;
}
virtual void Ready(InvalidationClient* client);
private:
/* The actual listener to which this listener delegates. */
InvalidationListener* delegate_;
/* Statistics objects to track number of sent messages, etc. */
Statistics* statistics_;
/* The scheduler for scheduling internal events in the library. */
Scheduler* internal_scheduler_;
/* The scheduler for scheduling events for the delegate. */
Scheduler* listener_scheduler_;
Logger* logger_;
};
} // namespace invalidation
#endif // GOOGLE_CACHEINVALIDATION_IMPL_CHECKING_INVALIDATION_LISTENER_H_
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Brings invalidation client protocol buffers into invalidation namespace.
#ifndef GOOGLE_CACHEINVALIDATION_IMPL_CLIENT_PROTOCOL_NAMESPACE_FIX_H_
#define GOOGLE_CACHEINVALIDATION_IMPL_CLIENT_PROTOCOL_NAMESPACE_FIX_H_
#include "google/cacheinvalidation/client.pb.h"
#include "google/cacheinvalidation/client_protocol.pb.h"
#include "google/cacheinvalidation/types.pb.h"
#include "google/cacheinvalidation/impl/repeated-field-namespace-fix.h"
namespace invalidation {
// Client
using ::ipc::invalidation::PersistentStateBlob;
using ::ipc::invalidation::PersistentTiclState;
// ClientProtocol
using ::ipc::invalidation::AckHandleP;
using ::ipc::invalidation::ApplicationClientIdP;
using ::ipc::invalidation::ClientConfigP;
using ::ipc::invalidation::ClientHeader;
using ::ipc::invalidation::ClientVersion;
using ::ipc::invalidation::ClientToServerMessage;
using ::ipc::invalidation::ConfigChangeMessage;
using ::ipc::invalidation::ErrorMessage;
using ::ipc::invalidation::ErrorMessage_Code_AUTH_FAILURE;
using ::ipc::invalidation::ErrorMessage_Code_UNKNOWN_FAILURE;
using ::ipc::invalidation::InfoMessage;
using ::ipc::invalidation::InfoRequestMessage;
using ::ipc::invalidation::InfoRequestMessage_InfoType;
using ::ipc::invalidation::InfoRequestMessage_InfoType_GET_PERFORMANCE_COUNTERS;
using ::ipc::invalidation::InitializeMessage;
using ::ipc::invalidation::InitializeMessage_DigestSerializationType_BYTE_BASED;
using ::ipc::invalidation::InitializeMessage_DigestSerializationType_NUMBER_BASED;
using ::ipc::invalidation::InvalidationMessage;
using ::ipc::invalidation::InvalidationP;
using ::ipc::invalidation::ObjectIdP;
using ::ipc::invalidation::PropertyRecord;
using ::ipc::invalidation::ProtocolHandlerConfigP;
using ::ipc::invalidation::ProtocolVersion;
using ::ipc::invalidation::RateLimitP;
using ::ipc::invalidation::RegistrationMessage;
using ::ipc::invalidation::RegistrationP;
using ::ipc::invalidation::RegistrationP_OpType_REGISTER;
using ::ipc::invalidation::RegistrationP_OpType_UNREGISTER;
using ::ipc::invalidation::RegistrationMessage;
using ::ipc::invalidation::RegistrationStatus;
using ::ipc::invalidation::RegistrationStatusMessage;
using ::ipc::invalidation::RegistrationSubtree;
using ::ipc::invalidation::RegistrationSummary;
using ::ipc::invalidation::RegistrationSyncMessage;
using ::ipc::invalidation::RegistrationSyncRequestMessage;
using ::ipc::invalidation::ServerHeader;
using ::ipc::invalidation::ServerToClientMessage;
using ::ipc::invalidation::StatusP;
using ::ipc::invalidation::StatusP_Code_SUCCESS;
using ::ipc::invalidation::StatusP_Code_PERMANENT_FAILURE;
using ::ipc::invalidation::StatusP_Code_TRANSIENT_FAILURE;
using ::ipc::invalidation::TokenControlMessage;
using ::ipc::invalidation::Version;
// Types
using ::ipc::invalidation::ObjectSource_Type_INTERNAL;
} // namespace invalidation
#endif // GOOGLE_CACHEINVALIDATION_IMPL_CLIENT_PROTOCOL_NAMESPACE_FIX_H_
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Various constants common to clients and servers used in version 2 of the
// Ticl.
#include "google/cacheinvalidation/impl/build_constants.h"
#include "google/cacheinvalidation/impl/constants.h"
namespace invalidation {
const int Constants::kClientMajorVersion = 3;
const int Constants::kClientMinorVersion = BUILD_DATESTAMP;
const int Constants::kProtocolMajorVersion = 3;
const int Constants::kProtocolMinorVersion = 2;
const int Constants::kConfigMajorVersion = 3;
const int Constants::kConfigMinorVersion = 2;
} // namespace invalidation
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Various constants common to clients and servers used in version 2 of the
// Ticl.
#ifndef GOOGLE_CACHEINVALIDATION_IMPL_CONSTANTS_H_
#define GOOGLE_CACHEINVALIDATION_IMPL_CONSTANTS_H_
namespace invalidation {
class Constants {
public:
/* Major version of the client library. */
static const int kClientMajorVersion;
/* Minor version of the client library, defined to be equal to the datestamp
* of the build (e.g. 20130401).
*/
static const int kClientMinorVersion;
/* Major version of the protocol between the client and the server. */
static const int kProtocolMajorVersion;
/* Minor version of the protocol between the client and the server. */
static const int kProtocolMinorVersion;
/* Major version of the client config. */
static const int kConfigMajorVersion;
/* Minor version of the client config. */
static const int kConfigMinorVersion;
};
} // namespace invalidation
#endif // GOOGLE_CACHEINVALIDATION_IMPL_CONSTANTS_H_
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Interface for a store that allows objects to be added/removed along with the
// ability to get the digest for the whole or partial set of those objects.
#ifndef GOOGLE_CACHEINVALIDATION_IMPL_DIGEST_STORE_H_
#define GOOGLE_CACHEINVALIDATION_IMPL_DIGEST_STORE_H_
#include <vector>
namespace invalidation {
using INVALIDATION_STL_NAMESPACE::vector;
template<typename ElementType>
class DigestStore {
public:
virtual ~DigestStore() {}
/* Returns the number of elements. */
virtual int size() = 0;
/* Returns whether element is in the store. */
virtual bool Contains(const ElementType& element) = 0;
/* Returns a digest of the desired objects in 'digest'.
*
* NOTE: the digest computations MUST NOT depend on the order in which the
* elements were added.
*/
virtual string GetDigest() = 0;
/* Stores iterators bounding the elements whose digest prefixes begin with the
* bit prefix digest_prefix. prefix_len is the length of digest_prefix in
* bits, which may be less than digest_prefix.length (and may be 0). The
* implementing class can return *more* objects than what has been specified
* by digest_prefix, e.g., it could return all the objects in the store.
*/
virtual void GetElements(const string& digest_prefix, int prefix_len,
vector<ObjectIdP>* result) = 0;
/* Adds element to the store. No-op if element is already present.
* Returns whether the element was added.
*/
virtual bool Add(const ElementType& element) = 0;
/* Adds elements to the store. If any element in elements is already present,
* the addition is a no-op for that element. When the function returns,
* added_elements will have been modified to contain all the elements
* of elements that were not previously present.
*/
virtual void Add(const vector<ElementType>& elements,
vector<ElementType>* added_elements) = 0;
/* Removes element from the store. No-op if element is not present.
* Returns whether the element was removed.
*/
virtual bool Remove(const ElementType& element) = 0;
/* Remove elements from the store. If any element in element is not present,
* the removal is a no-op for that element.
* When the function returns, removed_elements will have been modified to
* contain all the elements of elements that were previously present
*/
virtual void Remove(const vector<ElementType>& elements,
vector<ElementType>* removed_elements) = 0;
/* Removes all elements in this and stores them in elements. */
virtual void RemoveAll(vector<ElementType>* elements) = 0;
/* Returns a string representation of this digest store. */
virtual string ToString() = 0;
};
} // namespace invalidation
#endif // GOOGLE_CACHEINVALIDATION_IMPL_DIGEST_STORE_H_
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "google/cacheinvalidation/impl/exponential-backoff-delay-generator.h"
namespace invalidation {
TimeDelta ExponentialBackoffDelayGenerator::GetNextDelay() {
TimeDelta delay = Scheduler::NoDelay(); // After a reset, delay is zero.
if (in_retry_mode) {
// We used to multiply the current_max_delay_ by the double, but this
// implicitly truncated the double to an integer, which would always be 0.
// By converting to and from milliseconds, we avoid this problem.
delay = TimeDelta::FromMilliseconds(
random_->RandDouble() * current_max_delay_.InMilliseconds());
// Adjust the max for the next run.
TimeDelta max_delay = initial_max_delay_ * max_exponential_factor_;
if (current_max_delay_ <= max_delay) { // Guard against overflow.
current_max_delay_ *= 2;
if (current_max_delay_ > max_delay) {
current_max_delay_ = max_delay;
}
}
}
in_retry_mode = true;
return delay;
}
}
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Class that generates successive intervals for random exponential backoff.
// Class tracks a "high water mark" which is doubled each time getNextDelay is
// called; each call to getNextDelay returns a value uniformly randomly
// distributed between 0 (inclusive) and the high water mark (exclusive). Note
// that this class does not dictate the time units for which the delay is
// computed.
#ifndef GOOGLE_CACHEINVALIDATION_IMPL_EXPONENTIAL_BACKOFF_DELAY_GENERATOR_H_
#define GOOGLE_CACHEINVALIDATION_IMPL_EXPONENTIAL_BACKOFF_DELAY_GENERATOR_H_
#include "google/cacheinvalidation/include/system-resources.h"
#include "google/cacheinvalidation/deps/scoped_ptr.h"
#include "google/cacheinvalidation/deps/logging.h"
#include "google/cacheinvalidation/deps/time.h"
#include "google/cacheinvalidation/deps/random.h"
#include "google/cacheinvalidation/impl/constants.h"
namespace invalidation {
class ExponentialBackoffDelayGenerator {
public:
/* Creates a generator with the given maximum and initial delays.
* Caller continues to own space for random.
*/
ExponentialBackoffDelayGenerator(Random* random, TimeDelta initial_max_delay,
int max_exponential_factor) :
initial_max_delay_(initial_max_delay),
max_exponential_factor_(max_exponential_factor), random_(random) {
CHECK_GT(max_exponential_factor_, 0) << "max factor must be positive";
CHECK(random_ != NULL);
CHECK(initial_max_delay > Scheduler::NoDelay()) <<
"Initial delay must be positive";
Reset();
}
/* Resets the exponential backoff generator to start delays at the initial
* delay.
*/
void Reset() {
current_max_delay_ = initial_max_delay_;
in_retry_mode = false;
}
/* Gets the next delay interval to use. */
TimeDelta GetNextDelay();
private:
/* Initial delay time to use. */
TimeDelta initial_max_delay_;
/* Maximum allowed delay time. */
int max_exponential_factor_;
/* Next delay time to use. */
TimeDelta current_max_delay_;
/* If the first call to getNextDelay has been made after reset. */
bool in_retry_mode;
Random* random_;
};
} // namespace invalidation
#endif // GOOGLE_CACHEINVALIDATION_IMPL_EXPONENTIAL_BACKOFF_DELAY_GENERATOR_H_
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Useful utility functions for the TICL
#ifndef GOOGLE_CACHEINVALIDATION_IMPL_INVALIDATION_CLIENT_UTIL_H_
#define GOOGLE_CACHEINVALIDATION_IMPL_INVALIDATION_CLIENT_UTIL_H_
#include <stdint.h>
#include "google/cacheinvalidation/include/system-resources.h"
#include "google/cacheinvalidation/deps/time.h"
namespace invalidation {
class InvalidationClientUtil {
public:
/* Returns the time in milliseconds. */
static int64_t GetTimeInMillis(const Time& time) {
return time.ToInternalValue() / Time::kMicrosecondsPerMillisecond;
}
/* Returns the current time in the scheduler's epoch in milliseconds. */
static int64_t GetCurrentTimeMs(Scheduler* scheduler) {
return GetTimeInMillis(scheduler->CurrentTime());
}
};
} // namespace invalidation
#endif // GOOGLE_CACHEINVALIDATION_IMPL_INVALIDATION_CLIENT_UTIL_H_
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// A simple logging macro specifically for the invalidation client library.
#ifndef GOOGLE_CACHEINVALIDATION_IMPL_LOG_MACRO_H_
#define GOOGLE_CACHEINVALIDATION_IMPL_LOG_MACRO_H_
#define TLOG(logger, level, str, ...) \
logger->Log(Logger::level ## _LEVEL, __FILE__, __LINE__, str, ##__VA_ARGS__);
#endif // GOOGLE_CACHEINVALIDATION_IMPL_LOG_MACRO_H_
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment