OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/services/gcm/gcm_client_mock.h" | 5 #include "chrome/browser/services/gcm/gcm_client_mock.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/sys_byteorder.h" | 10 #include "base/sys_byteorder.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 content::BrowserThread::IO, | 136 content::BrowserThread::IO, |
137 FROM_HERE, | 137 FROM_HERE, |
138 base::Bind(&GCMClientMock::MessagesDeleted, | 138 base::Bind(&GCMClientMock::MessagesDeleted, |
139 weak_ptr_factory_.GetWeakPtr(), | 139 weak_ptr_factory_.GetWeakPtr(), |
140 app_id)); | 140 app_id)); |
141 } | 141 } |
142 | 142 |
143 // static | 143 // static |
144 std::string GCMClientMock::GetRegistrationIdFromSenderIds( | 144 std::string GCMClientMock::GetRegistrationIdFromSenderIds( |
145 const std::vector<std::string>& sender_ids) { | 145 const std::vector<std::string>& sender_ids) { |
146 // GCMProfileService normalizes the sender IDs by making them sorted. | 146 // GCMService normalizes the sender IDs by making them sorted. |
147 std::vector<std::string> normalized_sender_ids = sender_ids; | 147 std::vector<std::string> normalized_sender_ids = sender_ids; |
148 std::sort(normalized_sender_ids.begin(), normalized_sender_ids.end()); | 148 std::sort(normalized_sender_ids.begin(), normalized_sender_ids.end()); |
149 | 149 |
150 // Simulate the registration_id by concaternating all sender IDs. | 150 // Simulate the registration_id by concaternating all sender IDs. |
151 // Set registration_id to empty to denote an error if sender_ids contains a | 151 // Set registration_id to empty to denote an error if sender_ids contains a |
152 // hint. | 152 // hint. |
153 std::string registration_id; | 153 std::string registration_id; |
154 if (sender_ids.size() != 1 || | 154 if (sender_ids.size() != 1 || |
155 sender_ids[0].find("error") == std::string::npos) { | 155 sender_ids[0].find("error") == std::string::npos) { |
156 for (size_t i = 0; i < normalized_sender_ids.size(); ++i) { | 156 for (size_t i = 0; i < normalized_sender_ids.size(); ++i) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 208 } |
209 | 209 |
210 void GCMClientMock::MessageSendError( | 210 void GCMClientMock::MessageSendError( |
211 const std::string& app_id, | 211 const std::string& app_id, |
212 const GCMClient::SendErrorDetails& send_error_details) { | 212 const GCMClient::SendErrorDetails& send_error_details) { |
213 if (delegate_) | 213 if (delegate_) |
214 delegate_->OnMessageSendError(app_id, send_error_details); | 214 delegate_->OnMessageSendError(app_id, send_error_details); |
215 } | 215 } |
216 | 216 |
217 } // namespace gcm | 217 } // namespace gcm |
OLD | NEW |