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

Side by Side Diff: sync/notifier/invalidation_notifier.cc

Issue 10696087: [Sync] Move ModelType and related classes to 'syncer' namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sort headers, update copyrights Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « sync/notifier/invalidation_notifier.h ('k') | sync/notifier/invalidation_notifier_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "sync/notifier/invalidation_notifier.h" 5 #include "sync/notifier/invalidation_notifier.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "jingle/notifier/listener/push_client.h" 10 #include "jingle/notifier/listener/push_client.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 initial_max_invalidation_versions_, 80 initial_max_invalidation_versions_,
81 invalidation_state_tracker_, 81 invalidation_state_tracker_,
82 this); 82 this);
83 invalidation_state_.clear(); 83 invalidation_state_.clear();
84 state_ = STARTED; 84 state_ = STARTED;
85 } 85 }
86 invalidation_client_.UpdateCredentials(email, token); 86 invalidation_client_.UpdateCredentials(email, token);
87 } 87 }
88 88
89 void InvalidationNotifier::UpdateEnabledTypes( 89 void InvalidationNotifier::UpdateEnabledTypes(
90 syncable::ModelTypeSet enabled_types) { 90 syncer::ModelTypeSet enabled_types) {
91 DCHECK(CalledOnValidThread()); 91 DCHECK(CalledOnValidThread());
92 CHECK(!invalidation_client_id_.empty()); 92 CHECK(!invalidation_client_id_.empty());
93 ObjectIdSet ids; 93 ObjectIdSet ids;
94 for (syncable::ModelTypeSet::Iterator it = enabled_types.First(); it.Good(); 94 for (syncer::ModelTypeSet::Iterator it = enabled_types.First(); it.Good();
95 it.Inc()) { 95 it.Inc()) {
96 invalidation::ObjectId id; 96 invalidation::ObjectId id;
97 if (!RealModelTypeToObjectId(it.Get(), &id)) { 97 if (!RealModelTypeToObjectId(it.Get(), &id)) {
98 DLOG(WARNING) << "Invalid model type " << it.Get(); 98 DLOG(WARNING) << "Invalid model type " << it.Get();
99 continue; 99 continue;
100 } 100 }
101 ids.insert(id); 101 ids.insert(id);
102 } 102 }
103 invalidation_client_.RegisterIds(ids); 103 invalidation_client_.RegisterIds(ids);
104 } 104 }
105 105
106 void InvalidationNotifier::SendNotification( 106 void InvalidationNotifier::SendNotification(
107 syncable::ModelTypeSet changed_types) { 107 syncer::ModelTypeSet changed_types) {
108 DCHECK(CalledOnValidThread()); 108 DCHECK(CalledOnValidThread());
109 // Do nothing. 109 // Do nothing.
110 } 110 }
111 111
112 void InvalidationNotifier::OnInvalidate(const ObjectIdPayloadMap& id_payloads) { 112 void InvalidationNotifier::OnInvalidate(const ObjectIdPayloadMap& id_payloads) {
113 DCHECK(CalledOnValidThread()); 113 DCHECK(CalledOnValidThread());
114 // TODO(dcheng): This should probably be a utility function somewhere... 114 // TODO(dcheng): This should probably be a utility function somewhere...
115 syncable::ModelTypePayloadMap type_payloads; 115 syncer::ModelTypePayloadMap type_payloads;
116 for (ObjectIdPayloadMap::const_iterator it = id_payloads.begin(); 116 for (ObjectIdPayloadMap::const_iterator it = id_payloads.begin();
117 it != id_payloads.end(); ++it) { 117 it != id_payloads.end(); ++it) {
118 syncable::ModelType model_type; 118 syncer::ModelType model_type;
119 if (!ObjectIdToRealModelType(it->first, &model_type)) { 119 if (!ObjectIdToRealModelType(it->first, &model_type)) {
120 DLOG(WARNING) << "Invalid object ID: " << ObjectIdToString(it->first); 120 DLOG(WARNING) << "Invalid object ID: " << ObjectIdToString(it->first);
121 continue; 121 continue;
122 } 122 }
123 type_payloads[model_type] = it->second; 123 type_payloads[model_type] = it->second;
124 } 124 }
125 FOR_EACH_OBSERVER( 125 FOR_EACH_OBSERVER(
126 SyncNotifierObserver, observers_, 126 SyncNotifierObserver, observers_,
127 OnIncomingNotification(type_payloads, 127 OnIncomingNotification(type_payloads,
128 syncer::REMOTE_NOTIFICATION)); 128 syncer::REMOTE_NOTIFICATION));
129 } 129 }
130 130
131 void InvalidationNotifier::OnNotificationsEnabled() { 131 void InvalidationNotifier::OnNotificationsEnabled() {
132 DCHECK(CalledOnValidThread()); 132 DCHECK(CalledOnValidThread());
133 FOR_EACH_OBSERVER(SyncNotifierObserver, observers_, 133 FOR_EACH_OBSERVER(SyncNotifierObserver, observers_,
134 OnNotificationsEnabled()); 134 OnNotificationsEnabled());
135 } 135 }
136 136
137 void InvalidationNotifier::OnNotificationsDisabled( 137 void InvalidationNotifier::OnNotificationsDisabled(
138 NotificationsDisabledReason reason) { 138 NotificationsDisabledReason reason) {
139 DCHECK(CalledOnValidThread()); 139 DCHECK(CalledOnValidThread());
140 FOR_EACH_OBSERVER(SyncNotifierObserver, observers_, 140 FOR_EACH_OBSERVER(SyncNotifierObserver, observers_,
141 OnNotificationsDisabled(reason)); 141 OnNotificationsDisabled(reason));
142 } 142 }
143 143
144 } // namespace syncer 144 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/notifier/invalidation_notifier.h ('k') | sync/notifier/invalidation_notifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698