| 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 | |
| 9 namespace notifier { | 7 namespace notifier { |
| 10 | 8 |
| 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 | |
| 52 Notification::Notification() {} | 9 Notification::Notification() {} |
| 53 Notification::~Notification() {} | 10 Notification::~Notification() {} |
| 54 | 11 |
| 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 | |
| 62 std::string Notification::ToString() const { | 12 std::string Notification::ToString() const { |
| 63 return "{ channel: \"" + channel + "\", data: \"" + data + "\" }"; | 13 return "{ channel: \"" + channel + "\", data: \"" + data + "\" }"; |
| 64 } | 14 } |
| 65 | 15 |
| 66 } // namespace notifier | 16 } // namespace notifier |
| OLD | NEW |