Chromium Code Reviews| 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/gcm_client_impl.h" | 5 #include "components/gcm_driver/gcm_client_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 GCMClient::Result result) OVERRIDE {} | 251 GCMClient::Result result) OVERRIDE {} |
| 252 virtual void OnMessageReceived(const std::string& registration_id, | 252 virtual void OnMessageReceived(const std::string& registration_id, |
| 253 const GCMClient::IncomingMessage& message) | 253 const GCMClient::IncomingMessage& message) |
| 254 OVERRIDE; | 254 OVERRIDE; |
| 255 virtual void OnMessagesDeleted(const std::string& app_id) OVERRIDE; | 255 virtual void OnMessagesDeleted(const std::string& app_id) OVERRIDE; |
| 256 virtual void OnMessageSendError( | 256 virtual void OnMessageSendError( |
| 257 const std::string& app_id, | 257 const std::string& app_id, |
| 258 const gcm::GCMClient::SendErrorDetails& send_error_details) OVERRIDE; | 258 const gcm::GCMClient::SendErrorDetails& send_error_details) OVERRIDE; |
| 259 virtual void OnSendAcknowledged(const std::string& app_id, | 259 virtual void OnSendAcknowledged(const std::string& app_id, |
| 260 const std::string& message_id) OVERRIDE; | 260 const std::string& message_id) OVERRIDE; |
| 261 virtual void OnGCMReady() OVERRIDE; | 261 virtual void OnGCMReady( |
| 262 const std::vector<AccountMapping>& account_mappings) OVERRIDE; | |
| 262 virtual void OnActivityRecorded() OVERRIDE {} | 263 virtual void OnActivityRecorded() OVERRIDE {} |
| 263 virtual void OnConnected(const net::IPEndPoint& ip_endpoint) OVERRIDE {} | 264 virtual void OnConnected(const net::IPEndPoint& ip_endpoint) OVERRIDE {} |
| 264 virtual void OnDisconnected() OVERRIDE {} | 265 virtual void OnDisconnected() OVERRIDE {} |
| 265 | 266 |
| 266 GCMClientImpl* gcm_client() const { return gcm_client_.get(); } | 267 GCMClientImpl* gcm_client() const { return gcm_client_.get(); } |
| 267 FakeMCSClient* mcs_client() const { | 268 FakeMCSClient* mcs_client() const { |
| 268 return reinterpret_cast<FakeMCSClient*>(gcm_client_->mcs_client_.get()); | 269 return reinterpret_cast<FakeMCSClient*>(gcm_client_->mcs_client_.get()); |
| 269 } | 270 } |
| 270 ConnectionFactory* connection_factory() const { | 271 ConnectionFactory* connection_factory() const { |
| 271 return gcm_client_->connection_factory_.get(); | 272 return gcm_client_->connection_factory_.get(); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 483 gcm_client_->OnMessageReceivedFromMCS(message); | 484 gcm_client_->OnMessageReceivedFromMCS(message); |
| 484 } | 485 } |
| 485 | 486 |
| 486 void GCMClientImplTest::ReceiveOnMessageSentToMCS( | 487 void GCMClientImplTest::ReceiveOnMessageSentToMCS( |
| 487 const std::string& app_id, | 488 const std::string& app_id, |
| 488 const std::string& message_id, | 489 const std::string& message_id, |
| 489 const MCSClient::MessageSendStatus status) { | 490 const MCSClient::MessageSendStatus status) { |
| 490 gcm_client_->OnMessageSentToMCS(0LL, app_id, message_id, status); | 491 gcm_client_->OnMessageSentToMCS(0LL, app_id, message_id, status); |
| 491 } | 492 } |
| 492 | 493 |
| 493 void GCMClientImplTest::OnGCMReady() { | 494 void GCMClientImplTest::OnGCMReady( |
| 495 const std::vector<AccountMapping>& account_mappings) { | |
| 494 last_event_ = LOADING_COMPLETED; | 496 last_event_ = LOADING_COMPLETED; |
| 495 QuitLoop(); | 497 QuitLoop(); |
| 498 // Ignore account mappings for now. | |
|
fgorski
2014/09/24 20:02:30
Change to a TODO:
fgorski
2014/09/24 22:25:40
Done.
| |
| 496 } | 499 } |
| 497 | 500 |
| 498 void GCMClientImplTest::OnMessageReceived( | 501 void GCMClientImplTest::OnMessageReceived( |
| 499 const std::string& registration_id, | 502 const std::string& registration_id, |
| 500 const GCMClient::IncomingMessage& message) { | 503 const GCMClient::IncomingMessage& message) { |
| 501 last_event_ = MESSAGE_RECEIVED; | 504 last_event_ = MESSAGE_RECEIVED; |
| 502 last_app_id_ = registration_id; | 505 last_app_id_ = registration_id; |
| 503 last_message_ = message; | 506 last_message_ = message; |
| 504 QuitLoop(); | 507 QuitLoop(); |
| 505 } | 508 } |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 998 TEST_F(GCMClientImplStartAndStopTest, StartStopAndRestartImmediately) { | 1001 TEST_F(GCMClientImplStartAndStopTest, StartStopAndRestartImmediately) { |
| 999 // Start the GCM and then stop and restart it immediately. | 1002 // Start the GCM and then stop and restart it immediately. |
| 1000 gcm_client()->Start(); | 1003 gcm_client()->Start(); |
| 1001 gcm_client()->Stop(); | 1004 gcm_client()->Stop(); |
| 1002 gcm_client()->Start(); | 1005 gcm_client()->Start(); |
| 1003 | 1006 |
| 1004 PumpLoopUntilIdle(); | 1007 PumpLoopUntilIdle(); |
| 1005 } | 1008 } |
| 1006 | 1009 |
| 1007 } // namespace gcm | 1010 } // namespace gcm |
| OLD | NEW |