summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-20 09:51:42 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-20 09:51:42 +0000
commitb5d1f3f32f08c4d58e58a3214e527e2a3e191d43 (patch)
tree7dad3407978cfdb921fd4a72c4bf26a56bf58ef0 /chrome
parentff3b3624419bbdab28faf021566b22c1fa3660f5 (diff)
downloadchromium_src-b5d1f3f32f08c4d58e58a3214e527e2a3e191d43.zip
chromium_src-b5d1f3f32f08c4d58e58a3214e527e2a3e191d43.tar.gz
chromium_src-b5d1f3f32f08c4d58e58a3214e527e2a3e191d43.tar.bz2
Summary of changes to cacheinvalidation client:
- adds ResourceComponent and BasicSystemResources - adds unit tests for ProtocolHandler - adds delay before sending first message after restart, to avoid unnecessary and expensive invocation of registration sync protocol - adds a check to prevent Start() from being called multiple times - deletes all v1 code and overrides - various internal cleanups and minor refactorings Review URL: https://chromiumcodereview.appspot.com/9185038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118425 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/sync/notifier/cache_invalidation_packet_handler_unittest.cc4
-rw-r--r--chrome/browser/sync/notifier/chrome_invalidation_client.cc13
-rw-r--r--chrome/browser/sync/notifier/chrome_system_resources.cc21
-rw-r--r--chrome/browser/sync/notifier/chrome_system_resources.h14
-rw-r--r--chrome/browser/sync/notifier/invalidation_util.h4
5 files changed, 44 insertions, 12 deletions
diff --git a/chrome/browser/sync/notifier/cache_invalidation_packet_handler_unittest.cc b/chrome/browser/sync/notifier/cache_invalidation_packet_handler_unittest.cc
index ce6f87e..08cdcb6 100644
--- a/chrome/browser/sync/notifier/cache_invalidation_packet_handler_unittest.cc
+++ b/chrome/browser/sync/notifier/cache_invalidation_packet_handler_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -7,7 +7,7 @@
#include "base/base64.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop.h"
-#include "google/cacheinvalidation/callback.h"
+#include "google/cacheinvalidation/v2/callback.h"
#include "google/cacheinvalidation/v2/system-resources.h"
#include "jingle/notifier/base/fake_base_task.h"
#include "testing/gmock/include/gmock/gmock.h"
diff --git a/chrome/browser/sync/notifier/chrome_invalidation_client.cc b/chrome/browser/sync/notifier/chrome_invalidation_client.cc
index a677be6..6faa537 100644
--- a/chrome/browser/sync/notifier/chrome_invalidation_client.cc
+++ b/chrome/browser/sync/notifier/chrome_invalidation_client.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -14,7 +14,9 @@
#include "chrome/browser/sync/notifier/invalidation_util.h"
#include "chrome/browser/sync/notifier/registration_manager.h"
#include "chrome/browser/sync/syncable/model_type.h"
-#include "google/cacheinvalidation/v2/invalidation-client-impl.h"
+#include "google/cacheinvalidation/v2/invalidation-client.h"
+#include "google/cacheinvalidation/v2/invalidation-client-factory.h"
+#include "google/cacheinvalidation/v2/types.pb.h"
namespace {
@@ -84,12 +86,9 @@ void ChromeInvalidationClient::Start(
state_writer_ = state_writer;
int client_type = ipc::invalidation::ClientType::CHROME_SYNC;
- // TODO(akalin): Use InvalidationClient::Create() once it supports
- // taking a ClientConfig.
- invalidation::InvalidationClientImpl::Config client_config;
invalidation_client_.reset(
- new invalidation::InvalidationClientImpl(
- &chrome_system_resources_, client_type, client_id, client_config,
+ invalidation::CreateInvalidationClient(
+ &chrome_system_resources_, client_type, client_id,
kApplicationName, this));
ChangeBaseTask(base_task);
invalidation_client_->Start();
diff --git a/chrome/browser/sync/notifier/chrome_system_resources.cc b/chrome/browser/sync/notifier/chrome_system_resources.cc
index 9d46c73..474d0b6 100644
--- a/chrome/browser/sync/notifier/chrome_system_resources.cc
+++ b/chrome/browser/sync/notifier/chrome_system_resources.cc
@@ -55,6 +55,11 @@ void ChromeLogger::Log(LogLevel level, const char* file, int line,
}
}
+void ChromeLogger::SetSystemResources(
+ invalidation::SystemResources* resources) {
+ // Do nothing.
+}
+
ChromeScheduler::ChromeScheduler()
: ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
created_on_loop_(MessageLoop::current()),
@@ -111,6 +116,11 @@ invalidation::Time ChromeScheduler::GetCurrentTime() const {
return base::Time::Now();
}
+void ChromeScheduler::SetSystemResources(
+ invalidation::SystemResources* resources) {
+ // Do nothing.
+}
+
void ChromeScheduler::RunPostedTask(invalidation::Closure* task) {
CHECK_EQ(created_on_loop_, MessageLoop::current());
RunAndDeleteClosure(task);
@@ -163,6 +173,11 @@ void ChromeStorage::ReadAllKeys(invalidation::ReadAllKeysCallback* done) {
LOG(WARNING) << "ignoring call to ReadAllKeys(callback)";
}
+void ChromeStorage::SetSystemResources(
+ invalidation::SystemResources* resources) {
+ // Do nothing.
+}
+
void ChromeStorage::RunAndDeleteWriteKeyCallback(
invalidation::WriteKeyCallback* callback) {
callback->Run(invalidation::Status(invalidation::Status::SUCCESS, ""));
@@ -201,6 +216,11 @@ void ChromeNetwork::AddNetworkStatusReceiver(
network_status_receivers_.push_back(network_status_receiver);
}
+void ChromeNetwork::SetSystemResources(
+ invalidation::SystemResources* resources) {
+ // Do nothing.
+}
+
void ChromeNetwork::UpdatePacketHandler(
CacheInvalidationPacketHandler* packet_handler) {
packet_handler_ = packet_handler;
@@ -234,6 +254,7 @@ ChromeSystemResources::~ChromeSystemResources() {
void ChromeSystemResources::Start() {
internal_scheduler_->Start();
listener_scheduler_->Start();
+ is_started_ = true;
}
void ChromeSystemResources::Stop() {
diff --git a/chrome/browser/sync/notifier/chrome_system_resources.h b/chrome/browser/sync/notifier/chrome_system_resources.h
index a92a6c6..8614bd4 100644
--- a/chrome/browser/sync/notifier/chrome_system_resources.h
+++ b/chrome/browser/sync/notifier/chrome_system_resources.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
//
@@ -35,6 +35,9 @@ class ChromeLogger : public invalidation::Logger {
// invalidation::Logger implementation.
virtual void Log(LogLevel level, const char* file, int line,
const char* format, ...) OVERRIDE;
+
+ virtual void SetSystemResources(
+ invalidation::SystemResources* resources) OVERRIDE;
};
class ChromeScheduler : public invalidation::Scheduler {
@@ -55,6 +58,9 @@ class ChromeScheduler : public invalidation::Scheduler {
virtual invalidation::Time GetCurrentTime() const OVERRIDE;
+ virtual void SetSystemResources(
+ invalidation::SystemResources* resources) OVERRIDE;
+
private:
base::WeakPtrFactory<ChromeScheduler> weak_factory_;
// Holds all posted tasks that have not yet been run.
@@ -91,6 +97,9 @@ class ChromeStorage : public invalidation::Storage {
virtual void ReadAllKeys(
invalidation::ReadAllKeysCallback* key_callback) OVERRIDE;
+ virtual void SetSystemResources(
+ invalidation::SystemResources* resources) OVERRIDE;
+
private:
// Runs the given storage callback with SUCCESS status and deletes it.
void RunAndDeleteWriteKeyCallback(
@@ -122,6 +131,9 @@ class ChromeNetwork : public invalidation::NetworkChannel {
virtual void AddNetworkStatusReceiver(
invalidation::NetworkStatusCallback* network_status_receiver) OVERRIDE;
+ virtual void SetSystemResources(
+ invalidation::SystemResources* resources) OVERRIDE;
+
private:
void HandleInboundMessage(const std::string& incoming_message);
diff --git a/chrome/browser/sync/notifier/invalidation_util.h b/chrome/browser/sync/notifier/invalidation_util.h
index a61c89b..86d58d96 100644
--- a/chrome/browser/sync/notifier/invalidation_util.h
+++ b/chrome/browser/sync/notifier/invalidation_util.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
//
@@ -11,7 +11,7 @@
#include <string>
#include "chrome/browser/sync/syncable/model_type.h"
-#include "google/cacheinvalidation/callback.h"
+#include "google/cacheinvalidation/v2/callback.h"
namespace invalidation {