OLD | NEW |
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/chrome_invalidation_client.h" | 5 #include "sync/notifier/chrome_invalidation_client.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 invalidation_state_tracker_.Call( | 155 invalidation_state_tracker_.Call( |
156 FROM_HERE, | 156 FROM_HERE, |
157 &InvalidationStateTracker::SetMaxVersion, | 157 &InvalidationStateTracker::SetMaxVersion, |
158 id, invalidation.version()); | 158 id, invalidation.version()); |
159 | 159 |
160 std::string payload; | 160 std::string payload; |
161 // payload() CHECK()'s has_payload(), so we must check it ourselves first. | 161 // payload() CHECK()'s has_payload(), so we must check it ourselves first. |
162 if (invalidation.has_payload()) | 162 if (invalidation.has_payload()) |
163 payload = invalidation.payload(); | 163 payload = invalidation.payload(); |
164 | 164 |
165 ObjectIdPayloadMap id_payloads; | 165 ObjectIdStateMap id_state_map; |
166 id_payloads[id] = payload; | 166 id_state_map[id].payload = payload; |
167 EmitInvalidation(id_payloads); | 167 EmitInvalidation(id_state_map); |
168 // TODO(akalin): We should really acknowledge only after we get the | 168 // TODO(akalin): We should really acknowledge only after we get the |
169 // updates from the sync server. (see http://crbug.com/78462). | 169 // updates from the sync server. (see http://crbug.com/78462). |
170 client->Acknowledge(ack_handle); | 170 client->Acknowledge(ack_handle); |
171 } | 171 } |
172 | 172 |
173 void ChromeInvalidationClient::InvalidateUnknownVersion( | 173 void ChromeInvalidationClient::InvalidateUnknownVersion( |
174 invalidation::InvalidationClient* client, | 174 invalidation::InvalidationClient* client, |
175 const invalidation::ObjectId& object_id, | 175 const invalidation::ObjectId& object_id, |
176 const invalidation::AckHandle& ack_handle) { | 176 const invalidation::AckHandle& ack_handle) { |
177 DCHECK(CalledOnValidThread()); | 177 DCHECK(CalledOnValidThread()); |
178 DCHECK_EQ(client, invalidation_client_.get()); | 178 DCHECK_EQ(client, invalidation_client_.get()); |
179 DVLOG(1) << "InvalidateUnknownVersion"; | 179 DVLOG(1) << "InvalidateUnknownVersion"; |
180 | 180 |
181 ObjectIdPayloadMap id_payloads; | 181 ObjectIdStateMap id_state_map; |
182 id_payloads[object_id] = std::string(); | 182 id_state_map[object_id].payload = std::string(); |
183 EmitInvalidation(id_payloads); | 183 EmitInvalidation(id_state_map); |
184 // TODO(akalin): We should really acknowledge only after we get the | 184 // TODO(akalin): We should really acknowledge only after we get the |
185 // updates from the sync server. (see http://crbug.com/78462). | 185 // updates from the sync server. (see http://crbug.com/78462). |
186 client->Acknowledge(ack_handle); | 186 client->Acknowledge(ack_handle); |
187 } | 187 } |
188 | 188 |
189 // This should behave as if we got an invalidation with version | 189 // This should behave as if we got an invalidation with version |
190 // UNKNOWN_OBJECT_VERSION for all known data types. | 190 // UNKNOWN_OBJECT_VERSION for all known data types. |
191 void ChromeInvalidationClient::InvalidateAll( | 191 void ChromeInvalidationClient::InvalidateAll( |
192 invalidation::InvalidationClient* client, | 192 invalidation::InvalidationClient* client, |
193 const invalidation::AckHandle& ack_handle) { | 193 const invalidation::AckHandle& ack_handle) { |
194 DCHECK(CalledOnValidThread()); | 194 DCHECK(CalledOnValidThread()); |
195 DCHECK_EQ(client, invalidation_client_.get()); | 195 DCHECK_EQ(client, invalidation_client_.get()); |
196 DVLOG(1) << "InvalidateAll"; | 196 DVLOG(1) << "InvalidateAll"; |
197 | 197 |
198 ObjectIdPayloadMap id_payloads; | 198 ObjectIdStateMap id_state_map; |
199 for (ObjectIdSet::const_iterator it = registered_ids_.begin(); | 199 for (ObjectIdSet::const_iterator it = registered_ids_.begin(); |
200 it != registered_ids_.end(); ++it) { | 200 it != registered_ids_.end(); ++it) { |
201 id_payloads[*it] = std::string(); | 201 id_state_map[*it].payload = std::string(); |
202 } | 202 } |
203 EmitInvalidation(id_payloads); | 203 EmitInvalidation(id_state_map); |
204 // TODO(akalin): We should really acknowledge only after we get the | 204 // TODO(akalin): We should really acknowledge only after we get the |
205 // updates from the sync server. (see http://crbug.com/76482). | 205 // updates from the sync server. (see http://crbug.com/76482). |
206 client->Acknowledge(ack_handle); | 206 client->Acknowledge(ack_handle); |
207 } | 207 } |
208 | 208 |
209 void ChromeInvalidationClient::EmitInvalidation( | 209 void ChromeInvalidationClient::EmitInvalidation( |
210 const ObjectIdPayloadMap& id_payloads) { | 210 const ObjectIdStateMap& id_state_map) { |
211 DCHECK(CalledOnValidThread()); | 211 DCHECK(CalledOnValidThread()); |
212 listener_->OnInvalidate(id_payloads); | 212 listener_->OnInvalidate(id_state_map); |
213 } | 213 } |
214 | 214 |
215 void ChromeInvalidationClient::InformRegistrationStatus( | 215 void ChromeInvalidationClient::InformRegistrationStatus( |
216 invalidation::InvalidationClient* client, | 216 invalidation::InvalidationClient* client, |
217 const invalidation::ObjectId& object_id, | 217 const invalidation::ObjectId& object_id, |
218 InvalidationListener::RegistrationState new_state) { | 218 InvalidationListener::RegistrationState new_state) { |
219 DCHECK(CalledOnValidThread()); | 219 DCHECK(CalledOnValidThread()); |
220 DCHECK_EQ(client, invalidation_client_.get()); | 220 DCHECK_EQ(client, invalidation_client_.get()); |
221 DVLOG(1) << "InformRegistrationStatus: " | 221 DVLOG(1) << "InformRegistrationStatus: " |
222 << ObjectIdToString(object_id) << " " << new_state; | 222 << ObjectIdToString(object_id) << " " << new_state; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 EmitStateChange(); | 349 EmitStateChange(); |
350 } | 350 } |
351 | 351 |
352 void ChromeInvalidationClient::OnIncomingNotification( | 352 void ChromeInvalidationClient::OnIncomingNotification( |
353 const notifier::Notification& notification) { | 353 const notifier::Notification& notification) { |
354 DCHECK(CalledOnValidThread()); | 354 DCHECK(CalledOnValidThread()); |
355 // Do nothing, since this is already handled by |invalidation_client_|. | 355 // Do nothing, since this is already handled by |invalidation_client_|. |
356 } | 356 } |
357 | 357 |
358 } // namespace syncer | 358 } // namespace syncer |
OLD | NEW |