| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |