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

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

Issue 15580002: Make use of InvalidationService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 years, 6 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
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_ANDROID_INVALIDATOR_BRIDGE_H_
6 #define CHROME_BROWSER_SYNC_GLUE_ANDROID_INVALIDATOR_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/invalidator.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_REMOTE (on the UI thread) and triggers
27 // each observer's OnIncomingNotification method on these notifications (on the
28 // sync task runner). Android clients receive invalidations through this
29 // mechanism exclusively, hence the name.
30 class AndroidInvalidatorBridge
31 : public content::NotificationObserver, syncer::Invalidator {
32 public:
33 // Must be created and destroyed on the UI thread.
34 AndroidInvalidatorBridge(
35 const Profile* profile,
36 const scoped_refptr<base::SequencedTaskRunner>& sync_task_runner);
37 virtual ~AndroidInvalidatorBridge();
38
39 // Must be called on the UI thread while the sync task runner is still
40 // around. No other member functions on the sync thread may be called after
41 // this is called.
42 void StopForShutdown();
43
44 // Invalidator implementation. Must be called on the sync task runner.
45 virtual void RegisterHandler(syncer::InvalidationHandler* handler) OVERRIDE;
46 virtual void UpdateRegisteredIds(syncer::InvalidationHandler* handler,
47 const syncer::ObjectIdSet& ids) OVERRIDE;
48 virtual void UnregisterHandler(syncer::InvalidationHandler* handler) OVERRIDE;
49 virtual void Acknowledge(const invalidation::ObjectId& id,
50 const syncer::AckHandle& ack_handle) OVERRIDE;
51 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE;
52
53 // The following members of the Invalidator interface are not applicable to
54 // this invalidator and are implemented as no-ops.
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;
59
60 bool IsHandlerRegisteredForTest(
61 syncer::InvalidationHandler* handler) const;
62 syncer::ObjectIdSet GetRegisteredIdsForTest(
63 syncer::InvalidationHandler* handler) const;
64
65 // NotificationObserver implementation. Called on UI thread.
66 virtual void Observe(int type,
67 const content::NotificationSource& source,
68 const content::NotificationDetails& details) OVERRIDE;
69
70 private:
71 // Inner class to hold all the bits used on |sync_task_runner_|.
72 class Core;
73
74 const scoped_refptr<base::SequencedTaskRunner> sync_task_runner_;
75
76 // Created on the UI thread, used only on |sync_task_runner_|.
77 const scoped_refptr<Core> core_;
78
79 // Used only on the UI thread.
80 content::NotificationRegistrar registrar_;
81 };
82
83 } // namespace browser_sync
84
85 #endif // CHROME_BROWSER_SYNC_GLUE_ANDROID_INVALIDATOR_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698