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/android_invalidator_bridge.h

Issue 12022041: Separate local and remote sync invalidations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to review comments 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
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 #ifndef CHROME_BROWSER_SYNC_GLUE_CHROME_SYNC_NOTIFICATION_BRIDGE_H_ 5 #ifndef CHROME_BROWSER_SYNC_GLUE_ANDROID_INVALIDATOR_BRIDGE_H_
6 #define CHROME_BROWSER_SYNC_GLUE_CHROME_SYNC_NOTIFICATION_BRIDGE_H_ 6 #define CHROME_BROWSER_SYNC_GLUE_ANDROID_INVALIDATOR_BRIDGE_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/sequenced_task_runner.h" 10 #include "base/sequenced_task_runner.h"
11 #include "content/public/browser/notification_observer.h" 11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h" 12 #include "content/public/browser/notification_registrar.h"
13 #include "sync/notifier/invalidation_util.h" 13 #include "sync/notifier/invalidator.h"
14 14
15 class Profile; 15 class Profile;
16 16
17 namespace syncer { 17 namespace syncer {
18 class InvalidationHandler; 18 class InvalidationHandler;
19 } // namespace 19 } // namespace
20 20
21 namespace browser_sync { 21 namespace browser_sync {
22 22
23 // A bridge that converts Chrome events on the UI thread to sync 23 // A bridge that converts Chrome events on the UI thread to sync
24 // notifications on the sync task runner. 24 // notifications on the sync task runner.
25 // 25 //
26 // Listens to NOTIFICATION_SYNC_REFRESH_LOCAL and 26 // Listens to NOTIFICATION_SYNC_REFRESH_REMOTE (on the UI thread) and triggers
27 // NOTIFICATION_SYNC_REFRESH_REMOTE (on the UI thread) and triggers 27 // each observer's OnIncomingNotification method on these notifications (on the
28 // each observer's OnIncomingNotification method on these 28 // sync task runner). Android clients receive invalidations through this
29 // notifications (on the sync task runner). 29 // mechanism exclusively, hence the name.
30 class ChromeSyncNotificationBridge : public content::NotificationObserver { 30 class AndroidInvalidatorBridge
31 : public content::NotificationObserver, syncer::Invalidator {
31 public: 32 public:
32 // Must be created and destroyed on the UI thread. 33 // Must be created and destroyed on the UI thread.
33 ChromeSyncNotificationBridge( 34 AndroidInvalidatorBridge(
34 const Profile* profile, 35 const Profile* profile,
35 const scoped_refptr<base::SequencedTaskRunner>& sync_task_runner); 36 const scoped_refptr<base::SequencedTaskRunner>& sync_task_runner);
36 virtual ~ChromeSyncNotificationBridge(); 37 virtual ~AndroidInvalidatorBridge();
37 38
38 // Must be called on the UI thread while the sync task runner is still 39 // 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 // around. No other member functions on the sync thread may be called after
40 // this is called. 41 // this is called.
41 void StopForShutdown(); 42 void StopForShutdown();
42 43
43 // Must be called on the sync task runner. 44 // Invalidator implementation. Must be called on the sync task runner.
44 void RegisterHandler(syncer::InvalidationHandler* handler); 45 virtual void RegisterHandler(syncer::InvalidationHandler* handler) OVERRIDE;
45 void UpdateRegisteredIds(syncer::InvalidationHandler* handler, 46 virtual void UpdateRegisteredIds(syncer::InvalidationHandler* handler,
46 const syncer::ObjectIdSet& ids); 47 const syncer::ObjectIdSet& ids) OVERRIDE;
47 void UnregisterHandler(syncer::InvalidationHandler* handler); 48 virtual void UnregisterHandler(syncer::InvalidationHandler* handler) OVERRIDE;
49 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE;
50
51 // The following members of the Invalidator interface are not applicable to
52 // this invalidator and are implemented as no-ops.
53 virtual void SetUniqueId(const std::string& unique_id) OVERRIDE;
54 virtual void SetStateDeprecated(const std::string& state) OVERRIDE;
55 virtual void UpdateCredentials(
56 const std::string& email, const std::string& token) OVERRIDE;
57 virtual void SendInvalidation(
58 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
48 59
49 bool IsHandlerRegisteredForTest( 60 bool IsHandlerRegisteredForTest(
50 syncer::InvalidationHandler* handler) const; 61 syncer::InvalidationHandler* handler) const;
51 syncer::ObjectIdSet GetRegisteredIdsForTest( 62 syncer::ObjectIdSet GetRegisteredIdsForTest(
52 syncer::InvalidationHandler* handler) const; 63 syncer::InvalidationHandler* handler) const;
53 64
54 // NotificationObserver implementation. Called on UI thread. 65 // NotificationObserver implementation. Called on UI thread.
55 virtual void Observe(int type, 66 virtual void Observe(int type,
56 const content::NotificationSource& source, 67 const content::NotificationSource& source,
57 const content::NotificationDetails& details) OVERRIDE; 68 const content::NotificationDetails& details) OVERRIDE;
58 69
59 private: 70 private:
60 // Inner class to hold all the bits used on |sync_task_runner_|. 71 // Inner class to hold all the bits used on |sync_task_runner_|.
61 class Core; 72 class Core;
62 73
63 const scoped_refptr<base::SequencedTaskRunner> sync_task_runner_; 74 const scoped_refptr<base::SequencedTaskRunner> sync_task_runner_;
64 75
65 // Created on the UI thread, used only on |sync_task_runner_|. 76 // Created on the UI thread, used only on |sync_task_runner_|.
66 const scoped_refptr<Core> core_; 77 const scoped_refptr<Core> core_;
67 78
68 // Used only on the UI thread. 79 // Used only on the UI thread.
69 content::NotificationRegistrar registrar_; 80 content::NotificationRegistrar registrar_;
70 }; 81 };
71 82
72 } // namespace browser_sync 83 } // namespace browser_sync
73 84
74 #endif // CHROME_BROWSER_SYNC_GLUE_CHROME_SYNC_NOTIFICATION_BRIDGE_H_ 85 #endif // CHROME_BROWSER_SYNC_GLUE_ANDROID_INVALIDATOR_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698