OLD | NEW |
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_BRIDGED_SYNC_NOTIFIER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_BRIDGED_INVALIDATOR_H_ |
6 #define CHROME_BROWSER_SYNC_GLUE_BRIDGED_SYNC_NOTIFIER_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_BRIDGED_INVALIDATOR_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "sync/notifier/sync_notifier.h" | 10 #include "sync/notifier/invalidator.h" |
11 | 11 |
12 namespace browser_sync { | 12 namespace browser_sync { |
13 | 13 |
14 class ChromeSyncNotificationBridge; | 14 class ChromeSyncNotificationBridge; |
15 | 15 |
16 // A SyncNotifier implementation that wraps a ChromeSyncNotificationBridge | 16 // An Invalidator implementation that wraps a ChromeSyncNotificationBridge |
17 // and optionally a SyncNotifier delegate (which it takes ownership of). | 17 // and optionally an Invalidator delegate (which it takes ownership of). |
18 // All SyncNotifier calls are passed straight through to the delegate, | 18 // All Invalidator calls are passed straight through to the delegate, |
19 // with the exception of AddObserver/RemoveObserver, which also result in | 19 // with the exception of RegisterHandler, UpdateRegisteredIds, and |
20 // the observer being registered/deregistered with the | 20 // UnregisterHandler, which result in the handler being registered, updated, |
21 // ChromeSyncNotificationBridge. | 21 // and unregistered with the ChromeSyncNotificationBridge, respectively. |
22 class BridgedSyncNotifier : public syncer::SyncNotifier { | 22 class BridgedInvalidator : public syncer::Invalidator { |
23 public: | 23 public: |
24 // Does not take ownership of |bridge|. Takes ownership of |delegate|. | 24 // Does not take ownership of |bridge|. Takes ownership of |delegate|. |
25 // |delegate| may be NULL. | 25 // |delegate| may be NULL. |
26 BridgedSyncNotifier(ChromeSyncNotificationBridge* bridge, | 26 BridgedInvalidator(ChromeSyncNotificationBridge* bridge, |
27 syncer::SyncNotifier* delegate); | 27 syncer::Invalidator* delegate); |
28 virtual ~BridgedSyncNotifier(); | 28 virtual ~BridgedInvalidator(); |
29 | 29 |
30 // SyncNotifier implementation. Passes through all calls to the delegate. | 30 // Invalidator implementation. Passes through all calls to the delegate. |
31 // RegisterHandler, UnregisterHandler, and UpdateRegisteredIds calls will | 31 // RegisterHandler, UpdateRegisteredIds, and UnregisterHandler calls will |
32 // also be forwarded to the bridge. | 32 // also be forwarded to the bridge. |
33 virtual void RegisterHandler(syncer::SyncNotifierObserver* handler) OVERRIDE; | 33 virtual void RegisterHandler(syncer::InvalidationHandler* handler) OVERRIDE; |
34 virtual void UpdateRegisteredIds(syncer::SyncNotifierObserver* handler, | 34 virtual void UpdateRegisteredIds(syncer::InvalidationHandler * handler, |
35 const syncer::ObjectIdSet& ids) OVERRIDE; | 35 const syncer::ObjectIdSet& ids) OVERRIDE; |
36 virtual void UnregisterHandler( | 36 virtual void UnregisterHandler(syncer::InvalidationHandler* handler) OVERRIDE; |
37 syncer::SyncNotifierObserver* handler) OVERRIDE; | |
38 virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; | 37 virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; |
39 virtual void SetStateDeprecated(const std::string& state) OVERRIDE; | 38 virtual void SetStateDeprecated(const std::string& state) OVERRIDE; |
40 virtual void UpdateCredentials( | 39 virtual void UpdateCredentials( |
41 const std::string& email, const std::string& token) OVERRIDE; | 40 const std::string& email, const std::string& token) OVERRIDE; |
42 virtual void SendNotification( | 41 virtual void SendNotification( |
43 syncer::ModelTypeSet changed_types) OVERRIDE; | 42 syncer::ModelTypeSet changed_types) OVERRIDE; |
44 | 43 |
45 private: | 44 private: |
46 // The notification bridge that we register the observers with. | 45 // The notification bridge that we register the observers with. |
47 ChromeSyncNotificationBridge* bridge_; | 46 ChromeSyncNotificationBridge* bridge_; |
48 | 47 |
49 // The delegate we are wrapping. | 48 // The delegate we are wrapping. |
50 scoped_ptr<syncer::SyncNotifier> delegate_; | 49 scoped_ptr<syncer::Invalidator> delegate_; |
51 }; | 50 }; |
52 | 51 |
53 } // namespace browser_sync | 52 } // namespace browser_sync |
54 | 53 |
55 #endif // CHROME_BROWSER_SYNC_GLUE_BRIDGED_SYNC_NOTIFIER_H_ | 54 #endif // CHROME_BROWSER_SYNC_GLUE_BRIDGED_INVALIDATOR_H_ |
OLD | NEW |