| 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/memory/scoped_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/time/clock.h" | 13 #include "base/time/clock.h" |
| 14 #include "base/timer/timer.h" |
| 13 #include "google_apis/gcm/base/fake_encryptor.h" | 15 #include "google_apis/gcm/base/fake_encryptor.h" |
| 14 #include "google_apis/gcm/base/mcs_message.h" | 16 #include "google_apis/gcm/base/mcs_message.h" |
| 15 #include "google_apis/gcm/base/mcs_util.h" | 17 #include "google_apis/gcm/base/mcs_util.h" |
| 16 #include "google_apis/gcm/engine/fake_connection_factory.h" | 18 #include "google_apis/gcm/engine/fake_connection_factory.h" |
| 17 #include "google_apis/gcm/engine/fake_connection_handler.h" | 19 #include "google_apis/gcm/engine/fake_connection_handler.h" |
| 18 #include "google_apis/gcm/engine/gservices_settings.h" | 20 #include "google_apis/gcm/engine/gservices_settings.h" |
| 19 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 21 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
| 20 #include "google_apis/gcm/protocol/android_checkin.pb.h" | 22 #include "google_apis/gcm/protocol/android_checkin.pb.h" |
| 21 #include "google_apis/gcm/protocol/checkin.pb.h" | 23 #include "google_apis/gcm/protocol/checkin.pb.h" |
| 22 #include "google_apis/gcm/protocol/mcs.pb.h" | 24 #include "google_apis/gcm/protocol/mcs.pb.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 uint64 last_android_id_; | 109 uint64 last_android_id_; |
| 108 uint64 last_security_token_; | 110 uint64 last_security_token_; |
| 109 uint8 last_message_tag_; | 111 uint8 last_message_tag_; |
| 110 mcs_proto::DataMessageStanza last_data_message_stanza_; | 112 mcs_proto::DataMessageStanza last_data_message_stanza_; |
| 111 }; | 113 }; |
| 112 | 114 |
| 113 FakeMCSClient::FakeMCSClient(base::Clock* clock, | 115 FakeMCSClient::FakeMCSClient(base::Clock* clock, |
| 114 ConnectionFactory* connection_factory, | 116 ConnectionFactory* connection_factory, |
| 115 GCMStore* gcm_store, | 117 GCMStore* gcm_store, |
| 116 GCMStatsRecorder* recorder) | 118 GCMStatsRecorder* recorder) |
| 117 : MCSClient("", clock, connection_factory, gcm_store, recorder), | 119 : MCSClient("", clock, connection_factory, gcm_store, recorder, |
| 120 make_scoped_ptr(new base::Timer(true, false))), |
| 118 last_android_id_(0u), | 121 last_android_id_(0u), |
| 119 last_security_token_(0u), | 122 last_security_token_(0u), |
| 120 last_message_tag_(kNumProtoTypes) { | 123 last_message_tag_(kNumProtoTypes) { |
| 121 } | 124 } |
| 122 | 125 |
| 123 FakeMCSClient::~FakeMCSClient() { | 126 FakeMCSClient::~FakeMCSClient() { |
| 124 } | 127 } |
| 125 | 128 |
| 126 void FakeMCSClient::Login(uint64 android_id, uint64 security_token) { | 129 void FakeMCSClient::Login(uint64 android_id, uint64 security_token) { |
| 127 last_android_id_ = android_id; | 130 last_android_id_ = android_id; |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 TEST_F(GCMClientImplStartAndStopTest, StartStopAndRestartImmediately) { | 1041 TEST_F(GCMClientImplStartAndStopTest, StartStopAndRestartImmediately) { |
| 1039 // Start the GCM and then stop and restart it immediately. | 1042 // Start the GCM and then stop and restart it immediately. |
| 1040 gcm_client()->Start(); | 1043 gcm_client()->Start(); |
| 1041 gcm_client()->Stop(); | 1044 gcm_client()->Stop(); |
| 1042 gcm_client()->Start(); | 1045 gcm_client()->Start(); |
| 1043 | 1046 |
| 1044 PumpLoopUntilIdle(); | 1047 PumpLoopUntilIdle(); |
| 1045 } | 1048 } |
| 1046 | 1049 |
| 1047 } // namespace gcm | 1050 } // namespace gcm |
| OLD | NEW |