OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 // |
| 5 // Talk Mediator based implementation of the sync notifier interface. |
| 6 // Initializes the talk mediator and registers itself as the delegate. |
| 7 // |
| 8 // Example usage: |
| 9 // SyncNotifierImpl sync_notifier(...); |
| 10 // sync_notifier.Login(...); |
| 11 // ... |
| 12 // sync_notifier.Logout(); |
| 13 |
| 14 #ifndef CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_IMPL_H_ |
| 15 #define CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_IMPL_H_ |
| 16 |
| 17 #include "base/observer_list.h" |
| 18 #include "chrome/browser/sync/notifier/state_writer.h" |
| 19 #include "chrome/browser/sync/notifier/sync_notifier.h" |
| 20 #include "chrome/browser/sync/syncable/model_type.h" |
| 21 #include "jingle/notifier/base/notifier_options.h" |
| 22 #include "jingle/notifier/listener/talk_mediator.h" |
| 23 #include "jingle/notifier/listener/talk_mediator_impl.h" |
| 24 |
| 25 namespace sync_notifier { |
| 26 class ServerNotifierThread; |
| 27 |
| 28 class SyncNotifierImpl |
| 29 : public SyncNotifier, |
| 30 public sync_notifier::StateWriter, |
| 31 public notifier::TalkMediator::Delegate { |
| 32 public: |
| 33 explicit SyncNotifierImpl(const notifier::NotifierOptions& notifier_options); |
| 34 |
| 35 virtual ~SyncNotifierImpl(); |
| 36 |
| 37 // TalkMediator::Delegate implementation. |
| 38 virtual void OnNotificationStateChange(bool notifications_enabled); |
| 39 |
| 40 virtual void OnIncomingNotification( |
| 41 const IncomingNotificationData& notification_data); |
| 42 |
| 43 virtual void OnOutgoingNotification() {} |
| 44 |
| 45 // sync_notifier::StateWriter implementation. |
| 46 virtual void WriteState(const std::string& state); |
| 47 |
| 48 // SyncNotifier implementation |
| 49 virtual void UpdateCredentials( |
| 50 const std::string& email, const std::string& token); |
| 51 |
| 52 virtual void SetState(const std::string& state); |
| 53 |
| 54 virtual void AddObserver(SyncNotifierObserver* observer); |
| 55 virtual void RemoveObserver(SyncNotifierObserver* observer); |
| 56 |
| 57 virtual void UpdateEnabledTypes(const syncable::ModelTypeSet& types); |
| 58 virtual void SendNotification(); |
| 59 private: |
| 60 // Login to the talk mediator with the given credentials. |
| 61 void TalkMediatorLogin( |
| 62 const std::string& email, const std::string& token); |
| 63 |
| 64 // Notification (xmpp) handler. |
| 65 scoped_ptr<notifier::TalkMediator> talk_mediator_; |
| 66 syncable::ModelTypeSet enabled_types_; |
| 67 std::string state_; |
| 68 |
| 69 notifier::NotifierOptions notifier_options_; |
| 70 ServerNotifierThread* server_notifier_thread_; |
| 71 ObserverList<SyncNotifierObserver> observer_list_; |
| 72 }; |
| 73 |
| 74 |
| 75 } |
| 76 #endif // CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_IMPL_H_ |
OLD | NEW |