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/notifier/chrome_sync_notification_bridge.cc

Issue 9512005: [Sync] Move BridgedSyncNotifier and ChromeSyncNotificationBridge to glue/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to head Created 8 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) 2012 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 #include "chrome/browser/sync/notifier/chrome_sync_notification_bridge.h"
6
7 #include "chrome/browser/sync/notifier/sync_notifier_observer.h"
8 #include "chrome/common/chrome_notification_types.h"
9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/browser/notification_service.h"
11
12 using content::BrowserThread;
13
14 namespace sync_notifier {
15
16 ChromeSyncNotificationBridge::ChromeSyncNotificationBridge(
17 const Profile* profile)
18 : observers_(new ObserverListThreadSafe<SyncNotifierObserver>()) {
19 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
20 DCHECK(profile);
21 registrar_.Add(this, chrome::NOTIFICATION_SYNC_REFRESH,
22 content::Source<Profile>(profile));
23 }
24
25 ChromeSyncNotificationBridge::~ChromeSyncNotificationBridge() {}
26
27 void ChromeSyncNotificationBridge::AddObserver(SyncNotifierObserver* observer) {
28 observers_->AddObserver(observer);
29 }
30
31 void ChromeSyncNotificationBridge::RemoveObserver(
32 SyncNotifierObserver* observer) {
33 observers_->RemoveObserver(observer);
34 }
35
36 void ChromeSyncNotificationBridge::Observe(
37 int type,
38 const content::NotificationSource& source,
39 const content::NotificationDetails& details) {
40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
41 DCHECK_EQ(type, chrome::NOTIFICATION_SYNC_REFRESH);
42 content::Details<const syncable::ModelType> model_type_details(details);
43 const syncable::ModelType model_type = *(model_type_details.ptr());
44
45 // Currently, we only expect SESSIONS to trigger this notification.
46 DCHECK_EQ(syncable::SESSIONS, model_type);
47 syncable::ModelTypePayloadMap payload_map;
48 payload_map[model_type] = "";
49 observers_->Notify(&SyncNotifierObserver::OnIncomingNotification,
50 payload_map, LOCAL_NOTIFICATION);
51 }
52
53 } // namespace sync_notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698