| 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 <cstddef> | 5 #include <cstddef> |
| 6 #include <set> | 6 #include <set> |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 public: | 133 public: |
| 134 FakeListener() : reason_(TRANSIENT_NOTIFICATION_ERROR) {} | 134 FakeListener() : reason_(TRANSIENT_NOTIFICATION_ERROR) {} |
| 135 virtual ~FakeListener() {} | 135 virtual ~FakeListener() {} |
| 136 | 136 |
| 137 int GetInvalidationCount(const ObjectId& id) const { | 137 int GetInvalidationCount(const ObjectId& id) const { |
| 138 ObjectIdCountMap::const_iterator it = invalidation_counts_.find(id); | 138 ObjectIdCountMap::const_iterator it = invalidation_counts_.find(id); |
| 139 return (it == invalidation_counts_.end()) ? 0 : it->second; | 139 return (it == invalidation_counts_.end()) ? 0 : it->second; |
| 140 } | 140 } |
| 141 | 141 |
| 142 std::string GetPayload(const ObjectId& id) const { | 142 std::string GetPayload(const ObjectId& id) const { |
| 143 ObjectIdPayloadMap::const_iterator it = payloads_.find(id); | 143 ObjectIdStateMap::const_iterator it = states_.find(id); |
| 144 return (it == payloads_.end()) ? "" : it->second; | 144 return (it == states_.end()) ? "" : it->second.payload; |
| 145 } | 145 } |
| 146 | 146 |
| 147 // NO_NOTIFICATION_ERROR is the enabled state. | 147 // NO_NOTIFICATION_ERROR is the enabled state. |
| 148 NotificationsDisabledReason GetNotificationsDisabledReason() const { | 148 NotificationsDisabledReason GetNotificationsDisabledReason() const { |
| 149 return reason_; | 149 return reason_; |
| 150 } | 150 } |
| 151 | 151 |
| 152 // ChromeInvalidationClient::Listener implementation. | 152 // ChromeInvalidationClient::Listener implementation. |
| 153 | 153 |
| 154 virtual void OnInvalidate(const ObjectIdPayloadMap& id_payloads) OVERRIDE { | 154 virtual void OnInvalidate(const ObjectIdStateMap& id_state_map) OVERRIDE { |
| 155 for (ObjectIdPayloadMap::const_iterator it = id_payloads.begin(); | 155 for (ObjectIdStateMap::const_iterator it = id_state_map.begin(); |
| 156 it != id_payloads.end(); ++it) { | 156 it != id_state_map.end(); ++it) { |
| 157 ++invalidation_counts_[it->first]; | 157 ++invalidation_counts_[it->first]; |
| 158 payloads_[it->first] = it->second; | 158 states_[it->first] = it->second; |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 | 161 |
| 162 virtual void OnNotificationsEnabled() { | 162 virtual void OnNotificationsEnabled() { |
| 163 reason_ = NO_NOTIFICATION_ERROR; | 163 reason_ = NO_NOTIFICATION_ERROR; |
| 164 } | 164 } |
| 165 | 165 |
| 166 virtual void OnNotificationsDisabled(NotificationsDisabledReason reason) { | 166 virtual void OnNotificationsDisabled(NotificationsDisabledReason reason) { |
| 167 reason_ = reason; | 167 reason_ = reason; |
| 168 } | 168 } |
| 169 | 169 |
| 170 private: | 170 private: |
| 171 typedef std::map<ObjectId, int, ObjectIdLessThan> ObjectIdCountMap; | 171 typedef std::map<ObjectId, int, ObjectIdLessThan> ObjectIdCountMap; |
| 172 ObjectIdCountMap invalidation_counts_; | 172 ObjectIdCountMap invalidation_counts_; |
| 173 ObjectIdPayloadMap payloads_; | 173 ObjectIdStateMap states_; |
| 174 NotificationsDisabledReason reason_; | 174 NotificationsDisabledReason reason_; |
| 175 }; | 175 }; |
| 176 | 176 |
| 177 invalidation::InvalidationClient* CreateFakeInvalidationClient( | 177 invalidation::InvalidationClient* CreateFakeInvalidationClient( |
| 178 FakeInvalidationClient** fake_invalidation_client, | 178 FakeInvalidationClient** fake_invalidation_client, |
| 179 invalidation::SystemResources* resources, | 179 invalidation::SystemResources* resources, |
| 180 int client_type, | 180 int client_type, |
| 181 const invalidation::string& client_name, | 181 const invalidation::string& client_name, |
| 182 const invalidation::string& application_name, | 182 const invalidation::string& application_name, |
| 183 invalidation::InvalidationListener* listener) { | 183 invalidation::InvalidationListener* listener) { |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 GetNotificationsDisabledReason()); | 755 GetNotificationsDisabledReason()); |
| 756 | 756 |
| 757 client_.Ready(fake_invalidation_client_); | 757 client_.Ready(fake_invalidation_client_); |
| 758 | 758 |
| 759 EXPECT_EQ(NO_NOTIFICATION_ERROR, GetNotificationsDisabledReason()); | 759 EXPECT_EQ(NO_NOTIFICATION_ERROR, GetNotificationsDisabledReason()); |
| 760 } | 760 } |
| 761 | 761 |
| 762 } // namespace | 762 } // namespace |
| 763 | 763 |
| 764 } // namespace syncer | 764 } // namespace syncer |
| OLD | NEW |