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

Side by Side Diff: chrome/browser/sync/glue/chrome_sync_notification_bridge.cc

Issue 10875064: Rename SyncNotifier->Invalidator and SyncNotifierObserver->InvalidationHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to ToT for landing Created 8 years, 3 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sync/glue/chrome_sync_notification_bridge.h" 5 #include "chrome/browser/sync/glue/chrome_sync_notification_bridge.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/common/chrome_notification_types.h" 11 #include "chrome/common/chrome_notification_types.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/notification_service.h" 13 #include "content/public/browser/notification_service.h"
14 #include "sync/notifier/sync_notifier_observer.h" 14 #include "sync/notifier/invalidation_handler.h"
15 #include "sync/notifier/sync_notifier_registrar.h" 15 #include "sync/notifier/invalidator_registrar.h"
16 16
17 using content::BrowserThread; 17 using content::BrowserThread;
18 18
19 namespace browser_sync { 19 namespace browser_sync {
20 20
21 class ChromeSyncNotificationBridge::Core 21 class ChromeSyncNotificationBridge::Core
22 : public base::RefCountedThreadSafe<Core> { 22 : public base::RefCountedThreadSafe<Core> {
23 public: 23 public:
24 // Created on UI thread. 24 // Created on UI thread.
25 explicit Core( 25 explicit Core(
26 const scoped_refptr<base::SequencedTaskRunner>& sync_task_runner); 26 const scoped_refptr<base::SequencedTaskRunner>& sync_task_runner);
27 27
28 // All member functions below must be called on the sync task runner. 28 // All member functions below must be called on the sync task runner.
29 29
30 void InitializeOnSyncThread(); 30 void InitializeOnSyncThread();
31 void CleanupOnSyncThread(); 31 void CleanupOnSyncThread();
32 32
33 void UpdateEnabledTypes(syncer::ModelTypeSet enabled_types); 33 void UpdateEnabledTypes(syncer::ModelTypeSet enabled_types);
34 void RegisterHandler(syncer::SyncNotifierObserver* handler); 34 void RegisterHandler(syncer::InvalidationHandler* handler);
35 void UpdateRegisteredIds(syncer::SyncNotifierObserver* handler, 35 void UpdateRegisteredIds(syncer::InvalidationHandler* handler,
36 const syncer::ObjectIdSet& ids); 36 const syncer::ObjectIdSet& ids);
37 void UnregisterHandler(syncer::SyncNotifierObserver* handler); 37 void UnregisterHandler(syncer::InvalidationHandler* handler);
38 38
39 void EmitNotification( 39 void EmitNotification(
40 const syncer::ModelTypeStateMap& state_map, 40 const syncer::ModelTypeStateMap& state_map,
41 syncer::IncomingNotificationSource notification_source); 41 syncer::IncomingNotificationSource notification_source);
42 42
43 private: 43 private:
44 friend class base::RefCountedThreadSafe<Core>; 44 friend class base::RefCountedThreadSafe<Core>;
45 45
46 // Destroyed on the UI thread or on |sync_task_runner_|. 46 // Destroyed on the UI thread or on |sync_task_runner_|.
47 ~Core(); 47 ~Core();
48 48
49 const scoped_refptr<base::SequencedTaskRunner> sync_task_runner_; 49 const scoped_refptr<base::SequencedTaskRunner> sync_task_runner_;
50 50
51 // Used only on |sync_task_runner_|. 51 // Used only on |sync_task_runner_|.
52 syncer::ModelTypeSet enabled_types_; 52 syncer::ModelTypeSet enabled_types_;
53 scoped_ptr<syncer::SyncNotifierRegistrar> notifier_registrar_; 53 scoped_ptr<syncer::InvalidatorRegistrar> notifier_registrar_;
54 }; 54 };
55 55
56 ChromeSyncNotificationBridge::Core::Core( 56 ChromeSyncNotificationBridge::Core::Core(
57 const scoped_refptr<base::SequencedTaskRunner>& sync_task_runner) 57 const scoped_refptr<base::SequencedTaskRunner>& sync_task_runner)
58 : sync_task_runner_(sync_task_runner) { 58 : sync_task_runner_(sync_task_runner) {
59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
60 DCHECK(sync_task_runner_.get()); 60 DCHECK(sync_task_runner_.get());
61 } 61 }
62 62
63 ChromeSyncNotificationBridge::Core::~Core() { 63 ChromeSyncNotificationBridge::Core::~Core() {
64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || 64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
65 sync_task_runner_->RunsTasksOnCurrentThread()); 65 sync_task_runner_->RunsTasksOnCurrentThread());
66 DCHECK(!notifier_registrar_.get()); 66 DCHECK(!notifier_registrar_.get());
67 } 67 }
68 68
69 void ChromeSyncNotificationBridge::Core::InitializeOnSyncThread() { 69 void ChromeSyncNotificationBridge::Core::InitializeOnSyncThread() {
70 notifier_registrar_.reset(new syncer::SyncNotifierRegistrar()); 70 notifier_registrar_.reset(new syncer::InvalidatorRegistrar());
71 } 71 }
72 72
73 void ChromeSyncNotificationBridge::Core::CleanupOnSyncThread() { 73 void ChromeSyncNotificationBridge::Core::CleanupOnSyncThread() {
74 notifier_registrar_.reset(); 74 notifier_registrar_.reset();
75 } 75 }
76 76
77 void ChromeSyncNotificationBridge::Core::UpdateEnabledTypes( 77 void ChromeSyncNotificationBridge::Core::UpdateEnabledTypes(
78 syncer::ModelTypeSet types) { 78 syncer::ModelTypeSet types) {
79 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); 79 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
80 enabled_types_ = types; 80 enabled_types_ = types;
81 } 81 }
82 82
83 void ChromeSyncNotificationBridge::Core::RegisterHandler( 83 void ChromeSyncNotificationBridge::Core::RegisterHandler(
84 syncer::SyncNotifierObserver* handler) { 84 syncer::InvalidationHandler* handler) {
85 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); 85 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
86 notifier_registrar_->RegisterHandler(handler); 86 notifier_registrar_->RegisterHandler(handler);
87 } 87 }
88 88
89 void ChromeSyncNotificationBridge::Core::UpdateRegisteredIds( 89 void ChromeSyncNotificationBridge::Core::UpdateRegisteredIds(
90 syncer::SyncNotifierObserver* handler, 90 syncer::InvalidationHandler* handler,
91 const syncer::ObjectIdSet& ids) { 91 const syncer::ObjectIdSet& ids) {
92 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); 92 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
93 notifier_registrar_->UpdateRegisteredIds(handler, ids); 93 notifier_registrar_->UpdateRegisteredIds(handler, ids);
94 } 94 }
95 95
96 void ChromeSyncNotificationBridge::Core::UnregisterHandler( 96 void ChromeSyncNotificationBridge::Core::UnregisterHandler(
97 syncer::SyncNotifierObserver* handler) { 97 syncer::InvalidationHandler* handler) {
98 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); 98 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
99 notifier_registrar_->UnregisterHandler(handler); 99 notifier_registrar_->UnregisterHandler(handler);
100 } 100 }
101 101
102 void ChromeSyncNotificationBridge::Core::EmitNotification( 102 void ChromeSyncNotificationBridge::Core::EmitNotification(
103 const syncer::ModelTypeStateMap& state_map, 103 const syncer::ModelTypeStateMap& state_map,
104 syncer::IncomingNotificationSource notification_source) { 104 syncer::IncomingNotificationSource notification_source) {
105 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); 105 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
106 const syncer::ModelTypeStateMap& effective_state_map = 106 const syncer::ModelTypeStateMap& effective_state_map =
107 state_map.empty() ? 107 state_map.empty() ?
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 140 }
141 } 141 }
142 142
143 void ChromeSyncNotificationBridge::UpdateEnabledTypes( 143 void ChromeSyncNotificationBridge::UpdateEnabledTypes(
144 syncer::ModelTypeSet types) { 144 syncer::ModelTypeSet types) {
145 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); 145 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
146 core_->UpdateEnabledTypes(types); 146 core_->UpdateEnabledTypes(types);
147 } 147 }
148 148
149 void ChromeSyncNotificationBridge::RegisterHandler( 149 void ChromeSyncNotificationBridge::RegisterHandler(
150 syncer::SyncNotifierObserver* handler) { 150 syncer::InvalidationHandler* handler) {
151 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); 151 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
152 core_->RegisterHandler(handler); 152 core_->RegisterHandler(handler);
153 } 153 }
154 154
155 void ChromeSyncNotificationBridge::UpdateRegisteredIds( 155 void ChromeSyncNotificationBridge::UpdateRegisteredIds(
156 syncer::SyncNotifierObserver* handler, 156 syncer::InvalidationHandler* handler,
157 const syncer::ObjectIdSet& ids) { 157 const syncer::ObjectIdSet& ids) {
158 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); 158 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
159 core_->UpdateRegisteredIds(handler, ids); 159 core_->UpdateRegisteredIds(handler, ids);
160 } 160 }
161 161
162 void ChromeSyncNotificationBridge::UnregisterHandler( 162 void ChromeSyncNotificationBridge::UnregisterHandler(
163 syncer::SyncNotifierObserver* handler) { 163 syncer::InvalidationHandler* handler) {
164 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); 164 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
165 core_->UnregisterHandler(handler); 165 core_->UnregisterHandler(handler);
166 } 166 }
167 167
168 void ChromeSyncNotificationBridge::Observe( 168 void ChromeSyncNotificationBridge::Observe(
169 int type, 169 int type,
170 const content::NotificationSource& source, 170 const content::NotificationSource& source,
171 const content::NotificationDetails& details) { 171 const content::NotificationDetails& details) {
172 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 172 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
173 173
(...skipping 12 matching lines...) Expand all
186 const syncer::ModelTypeStateMap& state_map = *(state_details.ptr()); 186 const syncer::ModelTypeStateMap& state_map = *(state_details.ptr());
187 if (!sync_task_runner_->PostTask( 187 if (!sync_task_runner_->PostTask(
188 FROM_HERE, 188 FROM_HERE,
189 base::Bind(&Core::EmitNotification, 189 base::Bind(&Core::EmitNotification,
190 core_, state_map, notification_source))) { 190 core_, state_map, notification_source))) {
191 NOTREACHED(); 191 NOTREACHED();
192 } 192 }
193 } 193 }
194 194
195 } // namespace browser_sync 195 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698