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

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

Issue 159773006: [invalidations] Added table with registered objectsIds (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@about_invalidations_clean
Patch Set: Removed a redefinition of GetOwnerName 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 #include "chrome/browser/invalidation/invalidation_logger.h" 5 #include "chrome/browser/invalidation/invalidation_logger.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/invalidation/invalidation_logger_observer.h" 9 #include "chrome/browser/invalidation/invalidation_logger_observer.h"
10 #include "sync/notifier/invalidation_handler.h"
10 11
11 namespace syncer { 12 namespace syncer {
12 class ObjectIdInvalidationMap; 13 class ObjectIdInvalidationMap;
13 } 14 }
14 15
15 namespace invalidation { 16 namespace invalidation {
16 class InvalidationLoggerObserver; 17 class InvalidationLoggerObserver;
17 18
18 InvalidationLogger::InvalidationLogger() 19 InvalidationLogger::InvalidationLogger()
19 : last_invalidator_state_(syncer::TRANSIENT_INVALIDATION_ERROR) {} 20 : last_invalidator_state_(syncer::TRANSIENT_INVALIDATION_ERROR) {}
(...skipping 16 matching lines...) Expand all
36 last_invalidator_state_ = newState; 37 last_invalidator_state_ = newState;
37 EmitState(); 38 EmitState();
38 } 39 }
39 40
40 void InvalidationLogger::EmitState() { 41 void InvalidationLogger::EmitState() {
41 FOR_EACH_OBSERVER(InvalidationLoggerObserver, 42 FOR_EACH_OBSERVER(InvalidationLoggerObserver,
42 observer_list_, 43 observer_list_,
43 OnStateChange(last_invalidator_state_)); 44 OnStateChange(last_invalidator_state_));
44 } 45 }
45 46
46 void InvalidationLogger::OnUpdateIds(const base::DictionaryValue& details) { 47 void InvalidationLogger::OnUpdateIds(
47 FOR_EACH_OBSERVER( 48 std::map<std::string, syncer::ObjectIdSet> updatedIds) {
48 InvalidationLoggerObserver, observer_list_, OnUpdateIds(details)); 49 for (std::map<std::string, syncer::ObjectIdSet>::iterator it =
50 updatedIds.begin();
51 it != updatedIds.end();
52 ++it) {
53 latest_ids_[it->first] = syncer::ObjectIdSet(it->second);
54 }
55 EmitUpdatedIds();
56 }
57
58 void InvalidationLogger::EmitUpdatedIds() {
59 for (std::map<std::string, syncer::ObjectIdSet>::iterator it =
60 latest_ids_.begin();
61 it != latest_ids_.end();
62 ++it) {
63 FOR_EACH_OBSERVER(InvalidationLoggerObserver,
64 observer_list_,
65 OnUpdateIds(it->first, it->second));
66 }
49 } 67 }
50 68
51 void InvalidationLogger::OnDebugMessage(const base::DictionaryValue& details) { 69 void InvalidationLogger::OnDebugMessage(const base::DictionaryValue& details) {
52 FOR_EACH_OBSERVER( 70 FOR_EACH_OBSERVER(
53 InvalidationLoggerObserver, observer_list_, OnDebugMessage(details)); 71 InvalidationLoggerObserver, observer_list_, OnDebugMessage(details));
54 } 72 }
55 73
56 void InvalidationLogger::OnInvalidation( 74 void InvalidationLogger::OnInvalidation(
57 const syncer::ObjectIdInvalidationMap& details) { 75 const syncer::ObjectIdInvalidationMap& details) {
58 FOR_EACH_OBSERVER( 76 FOR_EACH_OBSERVER(
59 InvalidationLoggerObserver, observer_list_, OnInvalidation(details)); 77 InvalidationLoggerObserver, observer_list_, OnInvalidation(details));
60 } 78 }
61 79
62 void InvalidationLogger::EmitContent() { 80 void InvalidationLogger::EmitContent() {
63 // Here we add content to send to the observers not via real time push 81 // Here we add content to send to the observers not via real time push
64 // but on explicit request. 82 // but on explicit request.
65 EmitState(); 83 EmitState();
84 EmitUpdatedIds();
66 } 85 }
67 86
68 // Obtain a target object to call whenever we have 87 // Obtain a target object to call whenever we have
69 // debug messages to display 88 // debug messages to display
70 void InvalidationLogger::RegisterForDebug( 89 void InvalidationLogger::RegisterForDebug(
71 InvalidationLoggerObserver* debug_observer) { 90 InvalidationLoggerObserver* debug_observer) {
72 observer_list_.AddObserver(debug_observer); 91 observer_list_.AddObserver(debug_observer);
73 } 92 }
74 93
75 // Removes the target object to call whenever we have 94 // Removes the target object to call whenever we have
76 // debug messages to display 95 // debug messages to display
77 void InvalidationLogger::UnregisterForDebug( 96 void InvalidationLogger::UnregisterForDebug(
78 InvalidationLoggerObserver* debug_observer) { 97 InvalidationLoggerObserver* debug_observer) {
79 observer_list_.RemoveObserver(debug_observer); 98 observer_list_.RemoveObserver(debug_observer);
80 } 99 }
81 } // namespace invalidation 100 } // namespace invalidation
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698