summaryrefslogtreecommitdiff
path: root/chromium/third_party/cacheinvalidation/src
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/cacheinvalidation/src')
-rw-r--r--chromium/third_party/cacheinvalidation/src/google/cacheinvalidation/impl/build_constants.h2
-rw-r--r--chromium/third_party/cacheinvalidation/src/google/cacheinvalidation/impl/client-protocol-namespace-fix.h4
-rw-r--r--chromium/third_party/cacheinvalidation/src/google/cacheinvalidation/impl/repeated-field-namespace-fix.h30
-rw-r--r--chromium/third_party/cacheinvalidation/src/java/com/google/ipc/invalidation/common/BuildConstants.java2
-rw-r--r--chromium/third_party/cacheinvalidation/src/java/com/google/ipc/invalidation/external/client/InvalidationClientTestHelper.java47
-rw-r--r--chromium/third_party/cacheinvalidation/src/java/com/google/ipc/invalidation/ticl/android2/AndroidTiclManifest.java120
6 files changed, 93 insertions, 112 deletions
diff --git a/chromium/third_party/cacheinvalidation/src/google/cacheinvalidation/impl/build_constants.h b/chromium/third_party/cacheinvalidation/src/google/cacheinvalidation/impl/build_constants.h
index f2adec1cf45..f4c44c69d3b 100644
--- a/chromium/third_party/cacheinvalidation/src/google/cacheinvalidation/impl/build_constants.h
+++ b/chromium/third_party/cacheinvalidation/src/google/cacheinvalidation/impl/build_constants.h
@@ -17,6 +17,6 @@
#ifndef INVALIDATION_BUILD_CONSTANTS_H_
#define INVALIDATION_BUILD_CONSTANTS_H_
namespace invalidation {
-const int BUILD_DATESTAMP = 20130807;
+const int BUILD_DATESTAMP = 20130604;
} // namespace invalidation
#endif // INVALIDATION_BUILD_CONSTANTS_H_
diff --git a/chromium/third_party/cacheinvalidation/src/google/cacheinvalidation/impl/client-protocol-namespace-fix.h b/chromium/third_party/cacheinvalidation/src/google/cacheinvalidation/impl/client-protocol-namespace-fix.h
index 9366a392313..b8a714f5ccf 100644
--- a/chromium/third_party/cacheinvalidation/src/google/cacheinvalidation/impl/client-protocol-namespace-fix.h
+++ b/chromium/third_party/cacheinvalidation/src/google/cacheinvalidation/impl/client-protocol-namespace-fix.h
@@ -20,10 +20,12 @@
#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 {
+using ::google::protobuf::RepeatedField;
+using ::google::protobuf::RepeatedPtrField;
+
// Client
using ::ipc::invalidation::PersistentStateBlob;
using ::ipc::invalidation::PersistentTiclState;
diff --git a/chromium/third_party/cacheinvalidation/src/google/cacheinvalidation/impl/repeated-field-namespace-fix.h b/chromium/third_party/cacheinvalidation/src/google/cacheinvalidation/impl/repeated-field-namespace-fix.h
deleted file mode 100644
index 94ba25ad5d5..00000000000
--- a/chromium/third_party/cacheinvalidation/src/google/cacheinvalidation/impl/repeated-field-namespace-fix.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2013 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 RepeatedField classes into invalidation namespace.
-
-#ifndef GOOGLE_CACHEINVALIDATION_IMPL_REPEATED_FIELD_NAMESPACE_FIX_H_
-#define GOOGLE_CACHEINVALIDATION_IMPL_REPEATED_FIELD_NAMESPACE_FIX_H_
-
-#include "google/protobuf/repeated_field.h"
-
-namespace invalidation {
-
-using ::google::protobuf::RepeatedField;
-using ::google::protobuf::RepeatedPtrField;
-
-} // namespace invalidation
-
-#endif // GOOGLE_CACHEINVALIDATION_IMPL_REPEATED_FIELD_NAMESPACE_FIX_H_
diff --git a/chromium/third_party/cacheinvalidation/src/java/com/google/ipc/invalidation/common/BuildConstants.java b/chromium/third_party/cacheinvalidation/src/java/com/google/ipc/invalidation/common/BuildConstants.java
index 8e65cf3942c..c206a510471 100644
--- a/chromium/third_party/cacheinvalidation/src/java/com/google/ipc/invalidation/common/BuildConstants.java
+++ b/chromium/third_party/cacheinvalidation/src/java/com/google/ipc/invalidation/common/BuildConstants.java
@@ -33,5 +33,5 @@ package com.google.ipc.invalidation.common;
/** Build constant definitions. */
class BuildConstants {
- static final int BUILD_DATESTAMP = 20130807;
+ static final int BUILD_DATESTAMP = 20130604;
}
diff --git a/chromium/third_party/cacheinvalidation/src/java/com/google/ipc/invalidation/external/client/InvalidationClientTestHelper.java b/chromium/third_party/cacheinvalidation/src/java/com/google/ipc/invalidation/external/client/InvalidationClientTestHelper.java
new file mode 100644
index 00000000000..c8b4c114014
--- /dev/null
+++ b/chromium/third_party/cacheinvalidation/src/java/com/google/ipc/invalidation/external/client/InvalidationClientTestHelper.java
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+package com.google.ipc.invalidation.external.client;
+
+import com.google.ipc.invalidation.ticl.InvalidationClientCore;
+import com.google.ipc.invalidation.ticl.InvalidationClientImpl;
+import com.google.protos.ipc.invalidation.ClientProtocol.ClientConfigP;
+
+import java.util.Random;
+
+/**
+ * Helper utility functions for testing with the invalidation client.
+ *
+ *
+ */
+public class InvalidationClientTestHelper {
+
+ /**
+ * Constructs an invalidation client library instance with parameters set for unit tests.
+ *
+ * @param clientType client type code as assigned by the notification system's backend
+ * @param clientName id/name of the client in the application's own naming scheme
+ * @param applicationName name of the application using the library (for debugging/monitoring)
+ * @param listener callback object for invalidation events
+ */
+ public static InvalidationClient createForTest(SystemResources resources,
+ int clientType, byte[] clientName, String applicationName, InvalidationListener listener) {
+ ClientConfigP config = InvalidationClientCore.createConfigForTest().build();
+ Random random = new Random(resources.getInternalScheduler().getCurrentTimeMs());
+ return new InvalidationClientImpl(resources, random, clientType, clientName, config,
+ applicationName, listener);
+ }
+}
diff --git a/chromium/third_party/cacheinvalidation/src/java/com/google/ipc/invalidation/ticl/android2/AndroidTiclManifest.java b/chromium/third_party/cacheinvalidation/src/java/com/google/ipc/invalidation/ticl/android2/AndroidTiclManifest.java
index acea0e87dfe..09d69ca5ae9 100644
--- a/chromium/third_party/cacheinvalidation/src/java/com/google/ipc/invalidation/ticl/android2/AndroidTiclManifest.java
+++ b/chromium/third_party/cacheinvalidation/src/java/com/google/ipc/invalidation/ticl/android2/AndroidTiclManifest.java
@@ -33,107 +33,67 @@ import java.util.Map;
*
*/
public class AndroidTiclManifest {
+ /**
+ * Name of the {@code <application>} metadata element whose value gives the Java class that
+ * implements the application {@code InvalidationListener}. Must be set if
+ * {@link #LISTENER_SERVICE_NAME_KEY} is not set.
+ */
+ private static final String LISTENER_NAME_KEY = "ipc.invalidation.ticl.listener_class";
+
+ /**
+ * Name of the {@code <application>} metadata element whose value gives the Java class that
+ * implements the Ticl service. Should only be set in tests.
+ */
+ private static final String TICL_SERVICE_NAME_KEY = "ipc.invalidation.ticl.service_class";
/**
- * Cache of {@link ApplicationMetadata} to avoid repeatedly scanning manifest. The key is the
- * package name for the context.
+ * Name of the {@code <application>} metadata element whose value gives the Java class that
+ * implements the application's invalidation listener intent service.
*/
- private static final Map<String, ApplicationMetadata> applicationMetadataCache =
- new HashMap<String, ApplicationMetadata>();
+ private static final String LISTENER_SERVICE_NAME_KEY =
+ "ipc.invalidation.ticl.listener_service_class";
+
+ /** Default values returned if not overriden by the manifest file. */
+ private static final Map<String, String> DEFAULTS = new HashMap<String, String>();
+ static {
+ DEFAULTS.put(TICL_SERVICE_NAME_KEY,
+ "com.google.ipc.invalidation.ticl.android2.TiclService");
+ DEFAULTS.put(LISTENER_NAME_KEY, "");
+ DEFAULTS.put(LISTENER_SERVICE_NAME_KEY,
+ "com.google.ipc.invalidation.ticl.android2.AndroidInvalidationListenerStub");
+ }
- /** Application metadata from the Android manifest. */
- private final ApplicationMetadata metadata;
+ private final Context context;
public AndroidTiclManifest(Context context) {
- metadata = createApplicationMetadata(Preconditions.checkNotNull(context));
+ this.context = Preconditions.checkNotNull(context);
}
/** Returns the name of the class implementing the Ticl service. */
public String getTiclServiceClass() {
- return metadata.ticlServiceClass;
+ return Preconditions.checkNotNull(readApplicationMetadata(TICL_SERVICE_NAME_KEY));
}
/** Returns the name of the class on which listener events will be invoked. */
String getListenerClass() {
- return metadata.listenerClass;
+ return Preconditions.checkNotNull(readApplicationMetadata(LISTENER_NAME_KEY));
}
/** Returns the name of the class implementing the invalidation listener intent service. */
public String getListenerServiceClass() {
- return metadata.listenerServiceClass;
+ return Preconditions.checkNotNull(readApplicationMetadata(LISTENER_SERVICE_NAME_KEY));
}
/**
- * If it has not already been cached for the given {@code context}, creates and caches application
- * metadata from the manifest.
+ * Returns the metadata-provided value for {@code key} in {@code AndroidManifest.xml} if one
+ * exists, or the value from {@link #DEFAULTS} if one does not.
*/
- private static ApplicationMetadata createApplicationMetadata(Context context) {
- synchronized (applicationMetadataCache) {
- String packageName = context.getPackageName();
- ApplicationMetadata metadata = applicationMetadataCache.get(packageName);
- if (metadata == null) {
- metadata = new ApplicationMetadata(context);
- applicationMetadataCache.put(packageName, metadata);
- }
- return metadata;
- }
- }
-
- /** Application metadata for a specific context. */
- private static final class ApplicationMetadata {
- /**
- * Name of the {@code <application>} metadata element whose value gives the Java class that
- * implements the application {@code InvalidationListener}. Must be set if
- * {@link #LISTENER_SERVICE_NAME_KEY} is not set.
- */
- private static final String LISTENER_NAME_KEY = "ipc.invalidation.ticl.listener_class";
-
- /**
- * Name of the {@code <application>} metadata element whose value gives the Java class that
- * implements the Ticl service. Should only be set in tests.
- */
- private static final String TICL_SERVICE_NAME_KEY = "ipc.invalidation.ticl.service_class";
-
- /**
- * Name of the {@code <application>} metadata element whose value gives the Java class that
- * implements the application's invalidation listener intent service.
- */
- private static final String LISTENER_SERVICE_NAME_KEY =
- "ipc.invalidation.ticl.listener_service_class";
-
- /** Default values returned if not overriden by the manifest file. */
- private static final Map<String, String> DEFAULTS = new HashMap<String, String>();
- static {
- DEFAULTS.put(TICL_SERVICE_NAME_KEY,
- "com.google.ipc.invalidation.ticl.android2.TiclService");
- DEFAULTS.put(LISTENER_NAME_KEY, "");
- DEFAULTS.put(LISTENER_SERVICE_NAME_KEY,
- "com.google.ipc.invalidation.ticl.android2.AndroidInvalidationListenerStub");
- }
-
- private final String ticlServiceClass;
- private final String listenerClass;
- private final String listenerServiceClass;
-
- ApplicationMetadata(Context context) {
- ApplicationInfo appInfo;
- try {
- // Read metadata from manifest.xml
- appInfo = context.getPackageManager()
- .getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
- } catch (NameNotFoundException exception) {
- throw new RuntimeException("Cannot read own application info", exception);
- }
- ticlServiceClass = readApplicationMetadata(appInfo, TICL_SERVICE_NAME_KEY);
- listenerClass = readApplicationMetadata(appInfo, LISTENER_NAME_KEY);
- listenerServiceClass = readApplicationMetadata(appInfo, LISTENER_SERVICE_NAME_KEY);
- }
-
- /**
- * Returns the metadata-provided value for {@code key} in {@code appInfo} if one
- * exists, or the value from {@link #DEFAULTS} if one does not.
- */
- private static String readApplicationMetadata(ApplicationInfo appInfo, String key) {
+ private String readApplicationMetadata(String key) {
+ ApplicationInfo appInfo;
+ try {
+ // Read the manifest-provided value.
+ appInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(),
+ PackageManager.GET_META_DATA);
String value = null;
if (appInfo.metaData != null) {
value = appInfo.metaData.getString(key);
@@ -141,6 +101,8 @@ public class AndroidTiclManifest {
// Return the manifest value if present or the default value if not.
return (value != null) ?
value : Preconditions.checkNotNull(DEFAULTS.get(key), "No default value for %s", key);
+ } catch (NameNotFoundException exception) {
+ throw new RuntimeException("Cannot read own application info", exception);
}
}
}