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

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

Issue 10698014: [Sync] Rename csync namespace to syncer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 5 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 "chrome/common/chrome_notification_types.h" 7 #include "chrome/common/chrome_notification_types.h"
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 #include "content/public/browser/notification_service.h" 9 #include "content/public/browser/notification_service.h"
10 #include "sync/notifier/sync_notifier_observer.h" 10 #include "sync/notifier/sync_notifier_observer.h"
11 11
12 using content::BrowserThread; 12 using content::BrowserThread;
13 13
14 namespace browser_sync { 14 namespace browser_sync {
15 15
16 ChromeSyncNotificationBridge::ChromeSyncNotificationBridge( 16 ChromeSyncNotificationBridge::ChromeSyncNotificationBridge(
17 const Profile* profile) 17 const Profile* profile)
18 : observers_( 18 : observers_(
19 new ObserverListThreadSafe<csync::SyncNotifierObserver>()) { 19 new ObserverListThreadSafe<syncer::SyncNotifierObserver>()) {
20 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 20 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
21 DCHECK(profile); 21 DCHECK(profile);
22 registrar_.Add(this, chrome::NOTIFICATION_SYNC_REFRESH_LOCAL, 22 registrar_.Add(this, chrome::NOTIFICATION_SYNC_REFRESH_LOCAL,
23 content::Source<Profile>(profile)); 23 content::Source<Profile>(profile));
24 registrar_.Add(this, chrome::NOTIFICATION_SYNC_REFRESH_REMOTE, 24 registrar_.Add(this, chrome::NOTIFICATION_SYNC_REFRESH_REMOTE,
25 content::Source<Profile>(profile)); 25 content::Source<Profile>(profile));
26 } 26 }
27 27
28 ChromeSyncNotificationBridge::~ChromeSyncNotificationBridge() {} 28 ChromeSyncNotificationBridge::~ChromeSyncNotificationBridge() {}
29 29
30 void ChromeSyncNotificationBridge::UpdateEnabledTypes( 30 void ChromeSyncNotificationBridge::UpdateEnabledTypes(
31 const syncable::ModelTypeSet types) { 31 const syncable::ModelTypeSet types) {
32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
33 enabled_types_ = types; 33 enabled_types_ = types;
34 } 34 }
35 35
36 void ChromeSyncNotificationBridge::AddObserver( 36 void ChromeSyncNotificationBridge::AddObserver(
37 csync::SyncNotifierObserver* observer) { 37 syncer::SyncNotifierObserver* observer) {
38 observers_->AddObserver(observer); 38 observers_->AddObserver(observer);
39 } 39 }
40 40
41 void ChromeSyncNotificationBridge::RemoveObserver( 41 void ChromeSyncNotificationBridge::RemoveObserver(
42 csync::SyncNotifierObserver* observer) { 42 syncer::SyncNotifierObserver* observer) {
43 observers_->RemoveObserver(observer); 43 observers_->RemoveObserver(observer);
44 } 44 }
45 45
46 void ChromeSyncNotificationBridge::Observe( 46 void ChromeSyncNotificationBridge::Observe(
47 int type, 47 int type,
48 const content::NotificationSource& source, 48 const content::NotificationSource& source,
49 const content::NotificationDetails& details) { 49 const content::NotificationDetails& details) {
50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
51 51
52 csync::IncomingNotificationSource notification_source; 52 syncer::IncomingNotificationSource notification_source;
53 if (type == chrome::NOTIFICATION_SYNC_REFRESH_LOCAL) { 53 if (type == chrome::NOTIFICATION_SYNC_REFRESH_LOCAL) {
54 notification_source = csync::LOCAL_NOTIFICATION; 54 notification_source = syncer::LOCAL_NOTIFICATION;
55 } else if (type == chrome::NOTIFICATION_SYNC_REFRESH_REMOTE) { 55 } else if (type == chrome::NOTIFICATION_SYNC_REFRESH_REMOTE) {
56 notification_source = csync::REMOTE_NOTIFICATION; 56 notification_source = syncer::REMOTE_NOTIFICATION;
57 } else { 57 } else {
58 NOTREACHED() << "Unexpected notification type:" << type; 58 NOTREACHED() << "Unexpected notification type:" << type;
59 return; 59 return;
60 } 60 }
61 61
62 content::Details<const syncable::ModelTypePayloadMap> 62 content::Details<const syncable::ModelTypePayloadMap>
63 payload_details(details); 63 payload_details(details);
64 syncable::ModelTypePayloadMap payload_map = *(payload_details.ptr()); 64 syncable::ModelTypePayloadMap payload_map = *(payload_details.ptr());
65 65
66 if (payload_map.empty()) { 66 if (payload_map.empty()) {
67 // No model types to invalidate, invalidating all enabled types. 67 // No model types to invalidate, invalidating all enabled types.
68 payload_map = 68 payload_map =
69 syncable::ModelTypePayloadMapFromEnumSet(enabled_types_, std::string()); 69 syncable::ModelTypePayloadMapFromEnumSet(enabled_types_, std::string());
70 } 70 }
71 71
72 observers_->Notify( 72 observers_->Notify(
73 &csync::SyncNotifierObserver::OnIncomingNotification, 73 &syncer::SyncNotifierObserver::OnIncomingNotification,
74 payload_map, notification_source); 74 payload_map, notification_source);
75 } 75 }
76 76
77 } // namespace browser_sync 77 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698