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

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

Issue 12022041: Separate local and remote sync invalidations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 10 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 #ifndef CHROME_BROWSER_SYNC_GLUE_CHROME_SYNC_NOTIFICATION_BRIDGE_H_
6 #define CHROME_BROWSER_SYNC_GLUE_CHROME_SYNC_NOTIFICATION_BRIDGE_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/sequenced_task_runner.h"
11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h"
13 #include "sync/notifier/invalidation_util.h"
14
15 class Profile;
16
17 namespace syncer {
18 class InvalidationHandler;
19 } // namespace
20
21 namespace browser_sync {
22
23 // A bridge that converts Chrome events on the UI thread to sync
24 // notifications on the sync task runner.
25 //
26 // Listens to NOTIFICATION_SYNC_REFRESH_LOCAL and
27 // NOTIFICATION_SYNC_REFRESH_REMOTE (on the UI thread) and triggers
28 // each observer's OnIncomingNotification method on these
29 // notifications (on the sync task runner).
30 class ChromeSyncNotificationBridge : public content::NotificationObserver {
31 public:
32 // Must be created and destroyed on the UI thread.
33 ChromeSyncNotificationBridge(
34 const Profile* profile,
35 const scoped_refptr<base::SequencedTaskRunner>& sync_task_runner);
36 virtual ~ChromeSyncNotificationBridge();
37
38 // Must be called on the UI thread while the sync task runner is still
39 // around. No other member functions on the sync thread may be called after
40 // this is called.
41 void StopForShutdown();
42
43 // Must be called on the sync task runner.
44 void RegisterHandler(syncer::InvalidationHandler* handler);
45 void UpdateRegisteredIds(syncer::InvalidationHandler* handler,
46 const syncer::ObjectIdSet& ids);
47 void UnregisterHandler(syncer::InvalidationHandler* handler);
48
49 bool IsHandlerRegisteredForTest(
50 syncer::InvalidationHandler* handler) const;
51 syncer::ObjectIdSet GetRegisteredIdsForTest(
52 syncer::InvalidationHandler* handler) const;
53
54 // NotificationObserver implementation. Called on UI thread.
55 virtual void Observe(int type,
56 const content::NotificationSource& source,
57 const content::NotificationDetails& details) OVERRIDE;
58
59 private:
60 // Inner class to hold all the bits used on |sync_task_runner_|.
61 class Core;
62
63 const scoped_refptr<base::SequencedTaskRunner> sync_task_runner_;
64
65 // Created on the UI thread, used only on |sync_task_runner_|.
66 const scoped_refptr<Core> core_;
67
68 // Used only on the UI thread.
69 content::NotificationRegistrar registrar_;
70 };
71
72 } // namespace browser_sync
73
74 #endif // CHROME_BROWSER_SYNC_GLUE_CHROME_SYNC_NOTIFICATION_BRIDGE_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/bridged_invalidator_unittest.cc ('k') | chrome/browser/sync/glue/chrome_sync_notification_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698