| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_INVALIDATION_INVALIDATION_LOGGER_H_ | 5 #ifndef CHROME_BROWSER_INVALIDATION_INVALIDATION_LOGGER_H_ |
| 6 #define CHROME_BROWSER_INVALIDATION_INVALIDATION_LOGGER_H_ | 6 #define CHROME_BROWSER_INVALIDATION_INVALIDATION_LOGGER_H_ |
| 7 | 7 |
| 8 #include <map> |
| 8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| 11 #include "sync/notifier/invalidation_util.h" |
| 10 #include "sync/notifier/invalidator_state.h" | 12 #include "sync/notifier/invalidator_state.h" |
| 11 | 13 |
| 12 namespace base { | 14 namespace base { |
| 13 class DictionaryValue; | 15 class DictionaryValue; |
| 14 } // namespace base | 16 } // namespace base |
| 15 | 17 |
| 16 namespace syncer { | 18 namespace syncer { |
| 19 class InvalidationHandler; |
| 17 class ObjectIdInvalidationMap; | 20 class ObjectIdInvalidationMap; |
| 18 } | 21 } // namespace syncer |
| 19 | 22 |
| 20 namespace invalidation { | 23 namespace invalidation { |
| 24 |
| 21 class InvalidationLoggerObserver; | 25 class InvalidationLoggerObserver; |
| 22 | 26 |
| 23 class InvalidationLogger { | 27 class InvalidationLogger { |
| 24 public: | 28 public: |
| 29 InvalidationLogger(); |
| 30 ~InvalidationLogger(); |
| 31 |
| 25 // Pass through to any registered InvalidationLoggerObservers. | 32 // Pass through to any registered InvalidationLoggerObservers. |
| 26 // We will do local logging here too. | 33 // We will do local logging here too. |
| 27 void OnRegistration(const base::DictionaryValue& details); | 34 void OnRegistration(const base::DictionaryValue& details); |
| 28 void OnUnregistration(const base::DictionaryValue& details); | 35 void OnUnregistration(const base::DictionaryValue& details); |
| 29 void OnStateChange(const syncer::InvalidatorState& newState); | 36 void OnStateChange(const syncer::InvalidatorState& new_state); |
| 30 void OnUpdateIds(const base::DictionaryValue& details); | 37 void OnUpdateIds(std::map<std::string, syncer::ObjectIdSet> updated_ids); |
| 31 void OnDebugMessage(const base::DictionaryValue& details); | 38 void OnDebugMessage(const base::DictionaryValue& details); |
| 32 void OnInvalidation(const syncer::ObjectIdInvalidationMap& details); | 39 void OnInvalidation(const syncer::ObjectIdInvalidationMap& details); |
| 33 | 40 |
| 41 // Triggers messages to be sent to the Observers to provide them with |
| 42 // the current state of the logging. |
| 34 void EmitContent(); | 43 void EmitContent(); |
| 35 | 44 |
| 36 InvalidationLogger(); | 45 // Add and remove observers listening for messages. |
| 37 ~InvalidationLogger(); | 46 void RegisterObserver(InvalidationLoggerObserver* debug_observer); |
| 38 | 47 void UnregisterObserver(InvalidationLoggerObserver* debug_observer); |
| 39 void RegisterForDebug(InvalidationLoggerObserver* debug_observer); | |
| 40 void UnregisterForDebug(InvalidationLoggerObserver* debug_observer); | |
| 41 | 48 |
| 42 private: | 49 private: |
| 50 // Send to every Observer a OnStateChange event with the latest state. |
| 43 void EmitState(); | 51 void EmitState(); |
| 52 |
| 53 // Send to every Observer many OnUpdateIds events, each with one registrar |
| 54 // and every objectId it currently has registered. |
| 55 void EmitUpdatedIds(); |
| 56 |
| 44 // The list of every observer currently listening for notifications. | 57 // The list of every observer currently listening for notifications. |
| 45 ObserverList<InvalidationLoggerObserver> observer_list_; | 58 ObserverList<InvalidationLoggerObserver> observer_list_; |
| 59 |
| 46 // The last InvalidatorState updated by the InvalidatorService. | 60 // The last InvalidatorState updated by the InvalidatorService. |
| 47 syncer::InvalidatorState last_invalidator_state_; | 61 syncer::InvalidatorState last_invalidator_state_; |
| 62 |
| 63 // The map that contains every object id that is currently registered |
| 64 // and its owner. |
| 65 std::map<std::string, syncer::ObjectIdSet> latest_ids_; |
| 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(InvalidationLogger); |
| 48 }; | 68 }; |
| 49 | 69 |
| 50 } // namespace invalidation | 70 } // namespace invalidation |
| 71 |
| 51 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_LOGGER_H_ | 72 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_LOGGER_H_ |
| OLD | NEW |