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 // Takes owner ship of notifier_options. | |
34 explicit SyncNotifierImpl(notifier::NotifierOptions* notifier_options); | |
35 | |
36 virtual ~SyncNotifierImpl(); | |
37 | |
38 // TalkMediator::Delegate implementation. | |
39 virtual void OnNotificationStateChange(bool notifications_enabled); | |
40 | |
41 virtual void OnIncomingNotification( | |
42 const IncomingNotificationData& notification_data); | |
43 | |
44 virtual void OnOutgoingNotification() {} | |
45 | |
46 // sync_notifier::StateWriter implementation. | |
47 virtual void WriteState(const std::string& state); | |
48 | |
49 // SyncNotifier implementation | |
50 virtual void UpdateCredentials( | |
51 const std::string& email, const std::string& token); | |
52 | |
53 // 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.
| |
54 virtual void SetState(const std::string& state); | |
55 | |
56 virtual void AddObserver(SyncNotifierObserver* observer); | |
57 virtual void RemoveObserver(SyncNotifierObserver* observer); | |
58 | |
59 virtual void UpdateEnabledTypes(const syncable::ModelTypeSet& types); | |
60 virtual void SendNotification(); | |
61 private: | |
62 // Login to the talk mediator with the given credentials. | |
63 void TalkMediatorLogin( | |
64 const std::string& email, const std::string& token); | |
65 | |
66 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.
| |
67 | |
68 // Notification (xmpp) handler. | |
69 scoped_ptr<notifier::TalkMediator> talk_mediator_; | |
70 syncable::ModelTypeSet enabled_types_; | |
71 std::string state_; | |
72 | |
73 ServerNotifierThread* server_notifier_thread_; | |
74 notifier::NotifierOptions* notifier_options_; | |
75 ObserverList<SyncNotifierObserver> observer_list_; | |
76 }; | |
77 | |
78 | |
79 } | |
80 #endif // CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_IMPL_H_ | |
OLD | NEW |