| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/gcm_driver/fake_gcm_client.h" | 5 #include "components/gcm_driver/fake_gcm_client.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/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| 11 #include "base/sys_byteorder.h" | 11 #include "base/sys_byteorder.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "google_apis/gcm/base/encryptor.h" | 13 #include "google_apis/gcm/base/encryptor.h" |
| 14 #include "google_apis/gcm/engine/account_mapping.h" |
| 14 #include "net/base/ip_endpoint.h" | 15 #include "net/base/ip_endpoint.h" |
| 15 | 16 |
| 16 namespace gcm { | 17 namespace gcm { |
| 17 | 18 |
| 18 FakeGCMClient::FakeGCMClient( | 19 FakeGCMClient::FakeGCMClient( |
| 19 StartMode start_mode, | 20 StartMode start_mode, |
| 20 const scoped_refptr<base::SequencedTaskRunner>& ui_thread, | 21 const scoped_refptr<base::SequencedTaskRunner>& ui_thread, |
| 21 const scoped_refptr<base::SequencedTaskRunner>& io_thread) | 22 const scoped_refptr<base::SequencedTaskRunner>& io_thread) |
| 22 : delegate_(NULL), | 23 : delegate_(NULL), |
| 23 status_(UNINITIALIZED), | 24 status_(UNINITIALIZED), |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 for (size_t i = 0; i < normalized_sender_ids.size(); ++i) { | 173 for (size_t i = 0; i < normalized_sender_ids.size(); ++i) { |
| 173 if (i > 0) | 174 if (i > 0) |
| 174 registration_id += ","; | 175 registration_id += ","; |
| 175 registration_id += normalized_sender_ids[i]; | 176 registration_id += normalized_sender_ids[i]; |
| 176 } | 177 } |
| 177 } | 178 } |
| 178 return registration_id; | 179 return registration_id; |
| 179 } | 180 } |
| 180 | 181 |
| 181 void FakeGCMClient::CheckinFinished() { | 182 void FakeGCMClient::CheckinFinished() { |
| 182 delegate_->OnGCMReady(); | 183 delegate_->OnGCMReady(std::vector<AccountMapping>()); |
| 183 delegate_->OnConnected(net::IPEndPoint()); | 184 delegate_->OnConnected(net::IPEndPoint()); |
| 184 } | 185 } |
| 185 | 186 |
| 186 void FakeGCMClient::RegisterFinished(const std::string& app_id, | 187 void FakeGCMClient::RegisterFinished(const std::string& app_id, |
| 187 const std::string& registrion_id) { | 188 const std::string& registrion_id) { |
| 188 delegate_->OnRegisterFinished( | 189 delegate_->OnRegisterFinished( |
| 189 app_id, registrion_id, registrion_id.empty() ? SERVER_ERROR : SUCCESS); | 190 app_id, registrion_id, registrion_id.empty() ? SERVER_ERROR : SUCCESS); |
| 190 } | 191 } |
| 191 | 192 |
| 192 void FakeGCMClient::UnregisterFinished(const std::string& app_id) { | 193 void FakeGCMClient::UnregisterFinished(const std::string& app_id) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 delegate_->OnMessageSendError(app_id, send_error_details); | 241 delegate_->OnMessageSendError(app_id, send_error_details); |
| 241 } | 242 } |
| 242 | 243 |
| 243 void FakeGCMClient::SendAcknowledgement(const std::string& app_id, | 244 void FakeGCMClient::SendAcknowledgement(const std::string& app_id, |
| 244 const std::string& message_id) { | 245 const std::string& message_id) { |
| 245 if (delegate_) | 246 if (delegate_) |
| 246 delegate_->OnSendAcknowledged(app_id, message_id); | 247 delegate_->OnSendAcknowledged(app_id, message_id); |
| 247 } | 248 } |
| 248 | 249 |
| 249 } // namespace gcm | 250 } // namespace gcm |
| OLD | NEW |