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 "jingle/notifier/listener/notification_defines.h" | 5 #include "jingle/notifier/listener/notification_defines.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 | 8 |
| 9 #include "base/json/json_writer.h" |
| 10 #include "base/logging.h" |
| 11 #include "base/string_util.h" |
| 12 #include "base/values.h" |
| 13 |
9 namespace notifier { | 14 namespace notifier { |
10 | 15 |
11 Subscription::Subscription() {} | 16 Subscription::Subscription() {} |
12 Subscription::~Subscription() {} | 17 Subscription::~Subscription() {} |
13 | 18 |
14 bool Subscription::Equals(const Subscription& other) const { | 19 bool Subscription::Equals(const Subscription& other) const { |
15 return channel == other.channel && from == other.from; | 20 return channel == other.channel && from == other.from; |
16 } | 21 } |
17 | 22 |
18 namespace { | 23 namespace { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 Notification::~Notification() {} | 58 Notification::~Notification() {} |
54 | 59 |
55 bool Notification::Equals(const Notification& other) const { | 60 bool Notification::Equals(const Notification& other) const { |
56 return | 61 return |
57 channel == other.channel && | 62 channel == other.channel && |
58 data == other.data && | 63 data == other.data && |
59 RecipientListsEqual(recipients, other.recipients); | 64 RecipientListsEqual(recipients, other.recipients); |
60 } | 65 } |
61 | 66 |
62 std::string Notification::ToString() const { | 67 std::string Notification::ToString() const { |
63 return "{ channel: \"" + channel + "\", data: \"" + data + "\" }"; | 68 // Put into a DictionaryValue and convert to a string; this gives a |
| 69 // nice hex-encoding of |data|, which may be a binary string. |
| 70 DictionaryValue dict; |
| 71 dict.SetString("channel", channel); |
| 72 dict.SetString("data", data); |
| 73 std::string str; |
| 74 base::JSONWriter::Write(&dict, &str); |
| 75 return str; |
64 } | 76 } |
65 | 77 |
66 } // namespace notifier | 78 } // namespace notifier |
OLD | NEW |