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

Side by Side Diff: chrome/browser/invalidation/invalidation_logger.h

Issue 159773006: [invalidations] Added table with registered objectsIds (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@about_invalidations_clean
Patch Set: Change constness of iterators for android clang Created 6 years, 10 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
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
27 // This class is in charge of logging invalidation-related information.
28 // It is used store the state of the InvalidatorService that owns this object
29 // and then rebroadcast it to observers than can display it accordingly
30 // (like a debugging page). This class only stores lightweight state, as in
31 // which services are registered and listening for certain objects, and the
32 // status of the InvalidatorService (in order not to increase unnecesary
33 // memory usage).
34 //
35 // Observers can be registered and will be called to be notified of any
36 // status change immediatly. They can log there the history of what messages
37 // they recieve.
38
23 class InvalidationLogger { 39 class InvalidationLogger {
40
24 public: 41 public:
42 InvalidationLogger();
43 ~InvalidationLogger();
44
25 // Pass through to any registered InvalidationLoggerObservers. 45 // Pass through to any registered InvalidationLoggerObservers.
26 // We will do local logging here too. 46 // We will do local logging here too.
27 void OnRegistration(const base::DictionaryValue& details); 47 void OnRegistration(const base::DictionaryValue& details);
28 void OnUnregistration(const base::DictionaryValue& details); 48 void OnUnregistration(const base::DictionaryValue& details);
29 void OnStateChange(const syncer::InvalidatorState& newState); 49 void OnStateChange(const syncer::InvalidatorState& new_state);
30 void OnUpdateIds(const base::DictionaryValue& details); 50 void OnUpdateIds(std::map<std::string, syncer::ObjectIdSet> updated_ids);
31 void OnDebugMessage(const base::DictionaryValue& details); 51 void OnDebugMessage(const base::DictionaryValue& details);
32 void OnInvalidation(const syncer::ObjectIdInvalidationMap& details); 52 void OnInvalidation(const syncer::ObjectIdInvalidationMap& details);
33 53
54 // Triggers messages to be sent to the Observers to provide them with
55 // the current state of the logging.
34 void EmitContent(); 56 void EmitContent();
35 57
36 InvalidationLogger(); 58 // Add and remove observers listening for messages.
37 ~InvalidationLogger(); 59 void RegisterObserver(InvalidationLoggerObserver* debug_observer);
38 60 void UnregisterObserver(InvalidationLoggerObserver* debug_observer);
39 void RegisterForDebug(InvalidationLoggerObserver* debug_observer); 61 bool IsObserverRegistered(InvalidationLoggerObserver* debug_observer);
40 void UnregisterForDebug(InvalidationLoggerObserver* debug_observer);
41 62
42 private: 63 private:
64 // Send to every Observer a OnStateChange event with the latest state.
43 void EmitState(); 65 void EmitState();
66
67 // Send to every Observer many OnUpdateIds events, each with one registrar
68 // and every objectId it currently has registered.
69 void EmitUpdatedIds();
70
44 // The list of every observer currently listening for notifications. 71 // The list of every observer currently listening for notifications.
45 ObserverList<InvalidationLoggerObserver> observer_list_; 72 ObserverList<InvalidationLoggerObserver> observer_list_;
73
46 // The last InvalidatorState updated by the InvalidatorService. 74 // The last InvalidatorState updated by the InvalidatorService.
47 syncer::InvalidatorState last_invalidator_state_; 75 syncer::InvalidatorState last_invalidator_state_;
76
77 // The map that contains every object id that is currently registered
78 // and its owner.
79 std::map<std::string, syncer::ObjectIdSet> latest_ids_;
80
81 DISALLOW_COPY_AND_ASSIGN(InvalidationLogger);
48 }; 82 };
49 83
50 } // namespace invalidation 84 } // namespace invalidation
85
51 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_LOGGER_H_ 86 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_LOGGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698