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

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: 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
6 #ifndef CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_IMPL_H_
7 #define CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_IMPL_H_
8
9 #include "chrome/browser/sync/notifier/state_writer.h"
10 #include "chrome/browser/sync/notifier/sync_notifier.h"
11 #include "chrome/browser/sync/syncable/model_type.h"
12 #include "jingle/notifier/base/notifier_options.h"
13 #include "jingle/notifier/listener/talk_mediator.h"
14 #include "jingle/notifier/listener/talk_mediator_impl.h"
15
16 namespace sync_notifier {
17 class ServerNotifierThread;
18
19 class SyncNotifierImpl
20 : public SyncNotifier,
21 public sync_notifier::StateWriter,
22 public notifier::TalkMediator::Delegate {
23 public:
24 // Takes owner ship of notifier_options.
25 explicit SyncNotifierImpl(notifier::NotifierOptions* notifier_options);
26
27 virtual ~SyncNotifierImpl();
28
29 // TalkMediator::Delegate implementation.
30 virtual void OnNotificationStateChange(bool notifications_enabled) {
31 sync_notifier_callback_->OnNotificationStateChange(notifications_enabled);
32 }
33
34 virtual void OnIncomingNotification(
35 const IncomingNotificationData& notification_data) {
36 sync_notifier_callback_->OnIncomingNotification(notification_data);
37 }
38
39 virtual void OnOutgoingNotification() {
40 sync_notifier_callback_->OnOutgoingNotification();
41 }
42
43 // sync_notifier::StateWriter implementation.
44 virtual void WriteState(const std::string& state) {
45 sync_notifier_callback_->StoreCookie(state);
46 }
47
48 // SyncNotifier implementation
49 virtual void Login(
50 const std::string& email, const std::string& token,
51 const std::string& state,
52 SyncNotifierCallback* sync_notifier_callback);
53
54 virtual void UpdateEnabledTypes(const syncable::ModelTypeSet& types);
55 virtual void Logout();
56
57 #if defined(UNIT_TEST)
58 // P2P notification, still used by tests.
59 void SendNotification();
akalin 2011/03/08 02:48:30 I think this should be part of the SyncNotifier in
Agrawal 2011/03/08 23:07:28 Added SendNotification to the interface.
60 #endif
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(); }
67
68 // Helper to handle the details of initializing the TalkMediator.
69 // Must be called only after OpenDirectory() is called.
70 void InitializeTalkMediator(const std::string& state,
71 const notifier::NotifierOptions& notifier_options);
72
73 // Notification (xmpp) handler.
74 scoped_ptr<notifier::TalkMediator> talk_mediator_;
75 syncable::ModelTypeSet enabled_types_;
76
77 // Sync Notifier Callback. We do not take ownership of the object.
78 SyncNotifierCallback* sync_notifier_callback_;
79
80 ServerNotifierThread* server_notifier_thread_;
81 notifier::NotifierOptions* notifier_options_;
82 };
83
84
85 }
86 #endif // CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698