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

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

Issue 10837214: Refactor ModelTypePayloadMap and ObjectIdPayloadMap to StateMaps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test Created 8 years, 4 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/object_id_state_map_test_util.cc ('k') | sync/notifier/p2p_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/p2p_notifier.h" 5 #include "sync/notifier/p2p_notifier.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "jingle/notifier/listener/push_client.h" 13 #include "jingle/notifier/listener/push_client.h"
14 #include "sync/internal_api/public/base/model_type_payload_map.h" 14 #include "sync/internal_api/public/base/model_type_state_map.h"
15 #include "sync/notifier/invalidation_util.h" 15 #include "sync/notifier/invalidation_util.h"
16 #include "sync/notifier/sync_notifier_observer.h" 16 #include "sync/notifier/sync_notifier_observer.h"
17 17
18 namespace syncer { 18 namespace syncer {
19 19
20 const char* kSyncP2PNotificationChannel = "http://www.google.com/chrome/sync"; 20 const char* kSyncP2PNotificationChannel = "http://www.google.com/chrome/sync";
21 21
22 namespace { 22 namespace {
23 23
24 const char kNotifySelf[] = "notifySelf"; 24 const char kNotifySelf[] = "notifySelf";
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 DVLOG(1) << "Not a target of the notification -- " 261 DVLOG(1) << "Not a target of the notification -- "
262 << "not emitting notification"; 262 << "not emitting notification";
263 return; 263 return;
264 } 264 }
265 const ModelTypeSet types_to_notify = 265 const ModelTypeSet types_to_notify =
266 Intersection(enabled_types_, notification_data.GetChangedTypes()); 266 Intersection(enabled_types_, notification_data.GetChangedTypes());
267 if (types_to_notify.Empty()) { 267 if (types_to_notify.Empty()) {
268 DVLOG(1) << "No enabled and changed types -- not emitting notification"; 268 DVLOG(1) << "No enabled and changed types -- not emitting notification";
269 return; 269 return;
270 } 270 }
271 const ModelTypePayloadMap& type_payloads = ModelTypePayloadMapFromEnumSet( 271 const ModelTypeStateMap& type_state_map = ModelTypeSetToStateMap(
272 notification_data.GetChangedTypes(), std::string()); 272 notification_data.GetChangedTypes(), std::string());
273 registrar_.DispatchInvalidationsToHandlers( 273 registrar_.DispatchInvalidationsToHandlers(
274 ModelTypePayloadMapToObjectIdPayloadMap(type_payloads), 274 ModelTypeStateMapToObjectIdStateMap(type_state_map),
275 REMOTE_NOTIFICATION); 275 REMOTE_NOTIFICATION);
276 } 276 }
277 277
278 void P2PNotifier::SendNotificationDataForTest( 278 void P2PNotifier::SendNotificationDataForTest(
279 const P2PNotificationData& notification_data) { 279 const P2PNotificationData& notification_data) {
280 DCHECK(thread_checker_.CalledOnValidThread()); 280 DCHECK(thread_checker_.CalledOnValidThread());
281 SendNotificationData(notification_data); 281 SendNotificationData(notification_data);
282 } 282 }
283 283
284 void P2PNotifier::SendNotificationData( 284 void P2PNotifier::SendNotificationData(
285 const P2PNotificationData& notification_data) { 285 const P2PNotificationData& notification_data) {
286 DCHECK(thread_checker_.CalledOnValidThread()); 286 DCHECK(thread_checker_.CalledOnValidThread());
287 if (notification_data.GetChangedTypes().Empty()) { 287 if (notification_data.GetChangedTypes().Empty()) {
288 DVLOG(1) << "Not sending XMPP notification with no changed types: " 288 DVLOG(1) << "Not sending XMPP notification with no changed types: "
289 << notification_data.ToString(); 289 << notification_data.ToString();
290 return; 290 return;
291 } 291 }
292 notifier::Notification notification; 292 notifier::Notification notification;
293 notification.channel = kSyncP2PNotificationChannel; 293 notification.channel = kSyncP2PNotificationChannel;
294 notification.data = notification_data.ToString(); 294 notification.data = notification_data.ToString();
295 DVLOG(1) << "Sending XMPP notification: " << notification.ToString(); 295 DVLOG(1) << "Sending XMPP notification: " << notification.ToString();
296 push_client_->SendNotification(notification); 296 push_client_->SendNotification(notification);
297 } 297 }
298 298
299 } // namespace syncer 299 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/notifier/object_id_state_map_test_util.cc ('k') | sync/notifier/p2p_notifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698