Index: chrome/browser/sync/notifier/sync_notifier_impl.h |
diff --git a/chrome/browser/sync/notifier/sync_notifier_impl.h b/chrome/browser/sync/notifier/sync_notifier_impl.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..789de31738f52742748194b2cf16e1fae9179a84 |
--- /dev/null |
+++ b/chrome/browser/sync/notifier/sync_notifier_impl.h |
@@ -0,0 +1,80 @@ |
+// 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. |
+// |
+// Talk Mediator based implementation of the sync notifier interface. |
+// Initializes the talk mediator and registers itself as the delegate. |
+// |
+// Example usage: |
+// SyncNotifierImpl sync_notifier(...); |
+// sync_notifier.Login(...); |
+// ... |
+// sync_notifier.Logout(); |
+ |
+#ifndef CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_IMPL_H_ |
+#define CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_IMPL_H_ |
+ |
+#include "base/observer_list.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" |
+#include "jingle/notifier/listener/talk_mediator.h" |
+#include "jingle/notifier/listener/talk_mediator_impl.h" |
+ |
+namespace sync_notifier { |
+class ServerNotifierThread; |
+ |
+class SyncNotifierImpl |
+ : public SyncNotifier, |
+ public sync_notifier::StateWriter, |
+ public notifier::TalkMediator::Delegate { |
+ public: |
+ // Takes owner ship of notifier_options. |
+ explicit SyncNotifierImpl(notifier::NotifierOptions* notifier_options); |
+ |
+ virtual ~SyncNotifierImpl(); |
+ |
+ // TalkMediator::Delegate implementation. |
+ virtual void OnNotificationStateChange(bool notifications_enabled); |
+ |
+ virtual void OnIncomingNotification( |
+ const IncomingNotificationData& notification_data); |
+ |
+ virtual void OnOutgoingNotification() {} |
+ |
+ // sync_notifier::StateWriter implementation. |
+ virtual void WriteState(const std::string& state); |
+ |
+ // SyncNotifier implementation |
+ virtual void UpdateCredentials( |
+ const std::string& email, const std::string& token); |
+ |
+ // Should be called only once, before any calls to UpdateCredentials. |
akalin
2011/03/11 04:17:14
move this comment to interface file
Agrawal
2011/03/11 21:42:20
Done.
|
+ virtual void SetState(const std::string& state); |
+ |
+ virtual void AddObserver(SyncNotifierObserver* observer); |
+ virtual void RemoveObserver(SyncNotifierObserver* observer); |
+ |
+ virtual void UpdateEnabledTypes(const syncable::ModelTypeSet& types); |
+ virtual void SendNotification(); |
+ private: |
+ // Login to the talk mediator with the given credentials. |
+ void TalkMediatorLogin( |
+ const std::string& email, const std::string& token); |
+ |
+ notifier::TalkMediator* talk_mediator() { return talk_mediator_.get(); } |
akalin
2011/03/11 04:17:14
no need for this accessor
Agrawal
2011/03/11 21:42:20
Done.
|
+ |
+ // Notification (xmpp) handler. |
+ scoped_ptr<notifier::TalkMediator> talk_mediator_; |
+ syncable::ModelTypeSet enabled_types_; |
+ std::string state_; |
+ |
+ ServerNotifierThread* server_notifier_thread_; |
+ notifier::NotifierOptions* notifier_options_; |
+ ObserverList<SyncNotifierObserver> observer_list_; |
+}; |
+ |
+ |
+} |
+#endif // CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_IMPL_H_ |