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