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> |
| 8 |
7 namespace notifier { | 9 namespace notifier { |
8 | 10 |
| 11 Subscription::Subscription() {} |
| 12 Subscription::~Subscription() {} |
| 13 |
| 14 bool Subscription::Equals(const Subscription& other) const { |
| 15 return channel == other.channel && from == other.from; |
| 16 } |
| 17 |
| 18 namespace { |
| 19 |
| 20 template <typename T> |
| 21 bool ListsEqual(const T& t1, const T& t2) { |
| 22 if (t1.size() != t2.size()) { |
| 23 return false; |
| 24 } |
| 25 for (size_t i = 0; i < t1.size(); ++i) { |
| 26 if (!t1[i].Equals(t2[i])) { |
| 27 return false; |
| 28 } |
| 29 } |
| 30 return true; |
| 31 } |
| 32 |
| 33 } // namespace |
| 34 |
| 35 bool SubscriptionListsEqual(const SubscriptionList& subscriptions1, |
| 36 const SubscriptionList& subscriptions2) { |
| 37 return ListsEqual(subscriptions1, subscriptions2); |
| 38 } |
| 39 |
| 40 Recipient::Recipient() {} |
| 41 Recipient::~Recipient() {} |
| 42 |
| 43 bool Recipient::Equals(const Recipient& other) const { |
| 44 return to == other.to && user_specific_data == other.user_specific_data; |
| 45 } |
| 46 |
| 47 bool RecipientListsEqual(const RecipientList& recipients1, |
| 48 const RecipientList& recipients2) { |
| 49 return ListsEqual(recipients1, recipients2); |
| 50 } |
| 51 |
9 Notification::Notification() {} | 52 Notification::Notification() {} |
10 Notification::~Notification() {} | 53 Notification::~Notification() {} |
11 | 54 |
| 55 bool Notification::Equals(const Notification& other) const { |
| 56 return |
| 57 channel == other.channel && |
| 58 data == other.data && |
| 59 RecipientListsEqual(recipients, other.recipients); |
| 60 } |
| 61 |
12 std::string Notification::ToString() const { | 62 std::string Notification::ToString() const { |
13 return "{ channel: \"" + channel + "\", data: \"" + data + "\" }"; | 63 return "{ channel: \"" + channel + "\", data: \"" + data + "\" }"; |
14 } | 64 } |
15 | 65 |
16 } // namespace notifier | 66 } // namespace notifier |
OLD | NEW |