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

Side by Side Diff: components/invalidation/impl/p2p_invalidator.cc

Issue 2889163002: Remove raw DictionaryValue::Set in //components (Closed)
Patch Set: Nits Created 3 years, 6 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 "components/invalidation/impl/p2p_invalidator.h" 5 #include "components/invalidation/impl/p2p_invalidator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 return 99 return
100 (sender_id_ == other.sender_id_) && 100 (sender_id_ == other.sender_id_) &&
101 (target_ == other.target_) && 101 (target_ == other.target_) &&
102 (invalidation_map_ == other.invalidation_map_); 102 (invalidation_map_ == other.invalidation_map_);
103 } 103 }
104 104
105 std::string P2PNotificationData::ToString() const { 105 std::string P2PNotificationData::ToString() const {
106 base::DictionaryValue dict; 106 base::DictionaryValue dict;
107 dict.SetString(kSenderIdKey, sender_id_); 107 dict.SetString(kSenderIdKey, sender_id_);
108 dict.SetString(kNotificationTypeKey, P2PNotificationTargetToString(target_)); 108 dict.SetString(kNotificationTypeKey, P2PNotificationTargetToString(target_));
109 dict.Set(kInvalidationsKey, invalidation_map_.ToValue().release()); 109 dict.Set(kInvalidationsKey, invalidation_map_.ToValue());
110 std::string json; 110 std::string json;
111 base::JSONWriter::Write(dict, &json); 111 base::JSONWriter::Write(dict, &json);
112 return json; 112 return json;
113 } 113 }
114 114
115 bool P2PNotificationData::ResetFromString(const std::string& str) { 115 bool P2PNotificationData::ResetFromString(const std::string& str) {
116 std::unique_ptr<base::Value> data_value = base::JSONReader::Read(str); 116 std::unique_ptr<base::Value> data_value = base::JSONReader::Read(str);
117 const base::DictionaryValue* data_dict = NULL; 117 const base::DictionaryValue* data_dict = NULL;
118 if (!data_value.get() || !data_value->GetAsDictionary(&data_dict)) { 118 if (!data_value.get() || !data_value->GetAsDictionary(&data_dict)) {
119 LOG(WARNING) << "Could not parse " << str << " as a dictionary"; 119 LOG(WARNING) << "Could not parse " << str << " as a dictionary";
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 return; 294 return;
295 } 295 }
296 notifier::Notification notification; 296 notifier::Notification notification;
297 notification.channel = kSyncP2PNotificationChannel; 297 notification.channel = kSyncP2PNotificationChannel;
298 notification.data = notification_data.ToString(); 298 notification.data = notification_data.ToString();
299 DVLOG(1) << "Sending XMPP notification: " << notification.ToString(); 299 DVLOG(1) << "Sending XMPP notification: " << notification.ToString();
300 push_client_->SendNotification(notification); 300 push_client_->SendNotification(notification);
301 } 301 }
302 302
303 } // namespace syncer 303 } // namespace syncer
OLDNEW
« no previous file with comments | « components/history/core/browser/web_history_service.cc ('k') | components/invalidation/impl/sync_invalidation_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698