Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(498)

Side by Side Diff: chrome/browser/sync/notifier/sync_notifier_impl.h

Issue 6621062: Refactor sync notifier out of sync api. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix build. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 Login(
51 const std::string& email, const std::string& token,
52 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(bool* notification_pending);
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 notifier::TalkMediator* talk_mediator() { return talk_mediator_.get(); }
65
66 // Helper to handle the details of initializing the TalkMediator.
67 // Must be called only after OpenDirectory() is called.
68 void InitializeTalkMediator(const std::string& state,
69 const notifier::NotifierOptions& notifier_options);
70
71 // Notification (xmpp) handler.
72 scoped_ptr<notifier::TalkMediator> talk_mediator_;
73 syncable::ModelTypeSet enabled_types_;
74
75 ServerNotifierThread* server_notifier_thread_;
76 notifier::NotifierOptions* notifier_options_;
77 ObserverList<SyncNotifierObserver> observer_list_;
78 };
79
80
81 }
82 #endif // CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698