| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 content::BrowserThread::IO, | 130 content::BrowserThread::IO, |
| 131 FROM_HERE, | 131 FROM_HERE, |
| 132 base::Bind(&GCMClientMock::MessagesDeleted, | 132 base::Bind(&GCMClientMock::MessagesDeleted, |
| 133 weak_ptr_factory_.GetWeakPtr(), | 133 weak_ptr_factory_.GetWeakPtr(), |
| 134 app_id)); | 134 app_id)); |
| 135 } | 135 } |
| 136 | 136 |
| 137 // static | 137 // static |
| 138 std::string GCMClientMock::GetRegistrationIdFromSenderIds( | 138 std::string GCMClientMock::GetRegistrationIdFromSenderIds( |
| 139 const std::vector<std::string>& sender_ids) { | 139 const std::vector<std::string>& sender_ids) { |
| 140 // GCMProfileService normalizes the sender IDs by making them sorted. | 140 // GCMService normalizes the sender IDs by making them sorted. |
| 141 std::vector<std::string> normalized_sender_ids = sender_ids; | 141 std::vector<std::string> normalized_sender_ids = sender_ids; |
| 142 std::sort(normalized_sender_ids.begin(), normalized_sender_ids.end()); | 142 std::sort(normalized_sender_ids.begin(), normalized_sender_ids.end()); |
| 143 | 143 |
| 144 // Simulate the registration_id by concaternating all sender IDs. | 144 // Simulate the registration_id by concaternating all sender IDs. |
| 145 // Set registration_id to empty to denote an error if sender_ids contains a | 145 // Set registration_id to empty to denote an error if sender_ids contains a |
| 146 // hint. | 146 // hint. |
| 147 std::string registration_id; | 147 std::string registration_id; |
| 148 if (sender_ids.size() != 1 || | 148 if (sender_ids.size() != 1 || |
| 149 sender_ids[0].find("error") == std::string::npos) { | 149 sender_ids[0].find("error") == std::string::npos) { |
| 150 for (size_t i = 0; i < normalized_sender_ids.size(); ++i) { | 150 for (size_t i = 0; i < normalized_sender_ids.size(); ++i) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 } | 202 } |
| 203 | 203 |
| 204 void GCMClientMock::MessageSendError( | 204 void GCMClientMock::MessageSendError( |
| 205 const std::string& app_id, | 205 const std::string& app_id, |
| 206 const GCMClient::SendErrorDetails& send_error_details) { | 206 const GCMClient::SendErrorDetails& send_error_details) { |
| 207 if (delegate_) | 207 if (delegate_) |
| 208 delegate_->OnMessageSendError(app_id, send_error_details); | 208 delegate_->OnMessageSendError(app_id, send_error_details); |
| 209 } | 209 } |
| 210 | 210 |
| 211 } // namespace gcm | 211 } // namespace gcm |
| OLD | NEW |