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(); | |
Nicolas Zea
2014/02/14 23:23:22
nit: newline after
mferreria_g
2014/02/14 23:57:03
Done.
| |
25 // Pass through to any registered InvalidationLoggerObservers. | 31 // Pass through to any registered InvalidationLoggerObservers. |
26 // We will do local logging here too. | 32 // We will do local logging here too. |
27 void OnRegistration(const base::DictionaryValue& details); | 33 void OnRegistration(const base::DictionaryValue& details); |
28 void OnUnregistration(const base::DictionaryValue& details); | 34 void OnUnregistration(const base::DictionaryValue& details); |
29 void OnStateChange(const syncer::InvalidatorState& newState); | 35 void OnStateChange(const syncer::InvalidatorState& newState); |
Nicolas Zea
2014/02/14 23:23:22
newState and updatedIds should be unix_hacker_styl
mferreria_g
2014/02/14 23:57:03
Done.
| |
30 void OnUpdateIds(const base::DictionaryValue& details); | 36 void OnUpdateIds(std::map<std::string, syncer::ObjectIdSet> updatedIds); |
31 void OnDebugMessage(const base::DictionaryValue& details); | 37 void OnDebugMessage(const base::DictionaryValue& details); |
32 void OnInvalidation(const syncer::ObjectIdInvalidationMap& details); | 38 void OnInvalidation(const syncer::ObjectIdInvalidationMap& details); |
33 | 39 |
40 // Triggers messages to be sent to the Observers to provide them with | |
41 // the current state of the logging. | |
34 void EmitContent(); | 42 void EmitContent(); |
35 | 43 |
36 InvalidationLogger(); | 44 // Add and remove observers listening for messages. |
37 ~InvalidationLogger(); | 45 void RegisterObserver(InvalidationLoggerObserver* debug_observer); |
38 | 46 void UnregisterObserver(InvalidationLoggerObserver* debug_observer); |
39 void RegisterForDebug(InvalidationLoggerObserver* debug_observer); | |
40 void UnregisterForDebug(InvalidationLoggerObserver* debug_observer); | |
41 | 47 |
42 private: | 48 private: |
49 // Send to every Observer a OnStateChange event with the latest state. | |
43 void EmitState(); | 50 void EmitState(); |
51 | |
52 // Send to every Observer many OnUpdateIds events, each with one registrar | |
53 // and every objectId it currently has registered. | |
54 void EmitUpdatedIds(); | |
55 | |
44 // The list of every observer currently listening for notifications. | 56 // The list of every observer currently listening for notifications. |
45 ObserverList<InvalidationLoggerObserver> observer_list_; | 57 ObserverList<InvalidationLoggerObserver> observer_list_; |
58 | |
46 // The last InvalidatorState updated by the InvalidatorService. | 59 // The last InvalidatorState updated by the InvalidatorService. |
47 syncer::InvalidatorState last_invalidator_state_; | 60 syncer::InvalidatorState last_invalidator_state_; |
61 | |
62 // The map that contains every object id that is currently registered | |
63 // and its owner. | |
64 std::map<std::string, syncer::ObjectIdSet> latest_ids_; | |
65 | |
66 DISALLOW_COPY_AND_ASSIGN(InvalidationLogger); | |
48 }; | 67 }; |
49 | 68 |
50 } // namespace invalidation | 69 } // namespace invalidation |
70 | |
51 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_LOGGER_H_ | 71 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_LOGGER_H_ |
OLD | NEW |