summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/notifier/chrome_invalidation_client.cc
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-23 00:16:45 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-23 00:16:45 +0000
commit3d47a26aed8fd135280d4924d9e9bb36cb624946 (patch)
treef515a3604302e123d67a04c80079df4da6fc6b35 /chrome/browser/sync/notifier/chrome_invalidation_client.cc
parent51e413c3e9f11186b5026123a4610dd1dc005416 (diff)
downloadchromium_src-3d47a26aed8fd135280d4924d9e9bb36cb624946.zip
chromium_src-3d47a26aed8fd135280d4924d9e9bb36cb624946.tar.gz
chromium_src-3d47a26aed8fd135280d4924d9e9bb36cb624946.tar.bz2
Implemented initial version of server-issued notification client.
Added NOTIFICATION_SERVER notification method (use --sync-notification-method=server to turn on). BUG=34647 TEST=manually Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=50479 Review URL: http://codereview.chromium.org/2827014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50550 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/notifier/chrome_invalidation_client.cc')
-rw-r--r--chrome/browser/sync/notifier/chrome_invalidation_client.cc74
1 files changed, 74 insertions, 0 deletions
diff --git a/chrome/browser/sync/notifier/chrome_invalidation_client.cc b/chrome/browser/sync/notifier/chrome_invalidation_client.cc
new file mode 100644
index 0000000..3191b8d
--- /dev/null
+++ b/chrome/browser/sync/notifier/chrome_invalidation_client.cc
@@ -0,0 +1,74 @@
+// Copyright (c) 2010 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 "chrome/browser/sync/notifier/chrome_invalidation_client.h"
+
+#include <string>
+#include <vector>
+
+#include "base/logging.h"
+#include "chrome/browser/sync/notifier/cache_invalidation_packet_handler.h"
+#include "chrome/browser/sync/notifier/invalidation_util.h"
+#include "google/cacheinvalidation/invalidation-client-impl.h"
+
+namespace sync_notifier {
+
+ChromeInvalidationClient::ChromeInvalidationClient() {
+ DCHECK(non_thread_safe_.CalledOnValidThread());
+}
+
+ChromeInvalidationClient::~ChromeInvalidationClient() {
+ DCHECK(non_thread_safe_.CalledOnValidThread());
+ Stop();
+}
+
+void ChromeInvalidationClient::Start(
+ const std::string& app_name,
+ invalidation::InvalidationListener* listener,
+ buzz::XmppClient* xmpp_client) {
+ DCHECK(non_thread_safe_.CalledOnValidThread());
+ Stop();
+
+ chrome_system_resources_.StartScheduler();
+
+ invalidation::ClientType client_type;
+ client_type.set_type(invalidation::ClientType::CHROME_SYNC);
+ invalidation::ClientConfig ticl_config;
+ invalidation_client_.reset(
+ new invalidation::InvalidationClientImpl(
+ &chrome_system_resources_, client_type, app_name, listener,
+ ticl_config));
+ cache_invalidation_packet_handler_.reset(
+ new CacheInvalidationPacketHandler(xmpp_client,
+ invalidation_client_.get()));
+}
+
+void ChromeInvalidationClient::Stop() {
+ DCHECK(non_thread_safe_.CalledOnValidThread());
+ if (!invalidation_client_.get()) {
+ DCHECK(!cache_invalidation_packet_handler_.get());
+ return;
+ }
+
+ chrome_system_resources_.StopScheduler();
+
+ cache_invalidation_packet_handler_.reset();
+ invalidation_client_.reset();
+}
+
+void ChromeInvalidationClient::Register(
+ const invalidation::ObjectId& oid,
+ invalidation::RegistrationCallback* callback) {
+ DCHECK(non_thread_safe_.CalledOnValidThread());
+ invalidation_client_->Register(oid, callback);
+}
+
+void ChromeInvalidationClient::Unregister(
+ const invalidation::ObjectId& oid,
+ invalidation::RegistrationCallback* callback) {
+ DCHECK(non_thread_safe_.CalledOnValidThread());
+ invalidation_client_->Unregister(oid, callback);
+}
+
+} // namespace sync_notifier