summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/notifier/invalidation_notifier.h
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-19 20:09:31 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-19 20:09:31 +0000
commit08dd831c4155e2bb6ccc8cd65d15945823c11aca (patch)
tree0dd3083dd0e046ea38de35663e4da6dc85366937 /chrome/browser/sync/notifier/invalidation_notifier.h
parenta4d61af802f6e868cfa1100e92a65fab3aa8f427 (diff)
downloadchromium_src-08dd831c4155e2bb6ccc8cd65d15945823c11aca.zip
chromium_src-08dd831c4155e2bb6ccc8cd65d15945823c11aca.tar.gz
chromium_src-08dd831c4155e2bb6ccc8cd65d15945823c11aca.tar.bz2
[Sync] Split SyncNotifierImpl into P2PNotifier and InvalidationNotifier
Now that we have a clean interface, there's no need to have these implementations mashed together. Streamline ServerNotifierThread now that we use it directly. BUG=76764 TEST= Review URL: http://codereview.chromium.org/6685076 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78835 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/notifier/invalidation_notifier.h')
-rw-r--r--chrome/browser/sync/notifier/invalidation_notifier.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/chrome/browser/sync/notifier/invalidation_notifier.h b/chrome/browser/sync/notifier/invalidation_notifier.h
new file mode 100644
index 0000000..6ee27e9
--- /dev/null
+++ b/chrome/browser/sync/notifier/invalidation_notifier.h
@@ -0,0 +1,63 @@
+// Copyright (c) 2011 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.
+//
+// A notifier that communicates to sync servers for server-issued
+// notifications.
+
+#ifndef CHROME_BROWSER_SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_
+#define CHROME_BROWSER_SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_
+
+#include <string>
+
+#include "base/observer_list.h"
+#include "chrome/browser/sync/notifier/server_notifier_thread.h"
+#include "chrome/browser/sync/notifier/state_writer.h"
+#include "chrome/browser/sync/notifier/sync_notifier.h"
+#include "chrome/browser/sync/syncable/model_type.h"
+#include "jingle/notifier/base/notifier_options.h"
+
+namespace sync_notifier {
+
+class InvalidationNotifier
+ : public SyncNotifier,
+ public StateWriter,
+ public ServerNotifierThread::Observer {
+ public:
+ InvalidationNotifier(const notifier::NotifierOptions& notifier_options,
+ const std::string& client_info);
+
+ virtual ~InvalidationNotifier();
+
+ // SyncNotifier implementation.
+ virtual void AddObserver(SyncNotifierObserver* observer);
+ virtual void RemoveObserver(SyncNotifierObserver* observer);
+ virtual void SetState(const std::string& state);
+ virtual void UpdateCredentials(
+ const std::string& email, const std::string& token);
+ virtual void UpdateEnabledTypes(const syncable::ModelTypeSet& types);
+ virtual void SendNotification();
+
+ // StateWriter implementation.
+ virtual void WriteState(const std::string& state);
+
+ // ServerNotifierThread::Observer implementation.
+ virtual void OnConnectionStateChange(bool logged_in);
+ virtual void OnSubscriptionStateChange(bool subscribed);
+ virtual void OnIncomingNotification(
+ const notifier::Notification& notification);
+ virtual void OnOutgoingNotification();
+
+ private:
+ const notifier::NotifierOptions notifier_options_;
+ // The actual notification listener.
+ ServerNotifierThread server_notifier_thread_;
+ // Whether we called Login() on |server_notifier_thread_| yet.
+ bool logged_in_;
+
+ ObserverList<SyncNotifierObserver> observer_list_;
+ syncable::ModelTypeSet enabled_types_;
+};
+
+}
+#endif // CHROME_BROWSER_SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_