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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 virtual scoped_ptr<base::Clock> BuildClock() OVERRIDE; | 161 virtual scoped_ptr<base::Clock> BuildClock() OVERRIDE; |
162 virtual scoped_ptr<MCSClient> BuildMCSClient( | 162 virtual scoped_ptr<MCSClient> BuildMCSClient( |
163 const std::string& version, | 163 const std::string& version, |
164 base::Clock* clock, | 164 base::Clock* clock, |
165 ConnectionFactory* connection_factory, | 165 ConnectionFactory* connection_factory, |
166 GCMStore* gcm_store, | 166 GCMStore* gcm_store, |
167 GCMStatsRecorder* recorder) OVERRIDE; | 167 GCMStatsRecorder* recorder) OVERRIDE; |
168 virtual scoped_ptr<ConnectionFactory> BuildConnectionFactory( | 168 virtual scoped_ptr<ConnectionFactory> BuildConnectionFactory( |
169 const std::vector<GURL>& endpoints, | 169 const std::vector<GURL>& endpoints, |
170 const net::BackoffEntry::Policy& backoff_policy, | 170 const net::BackoffEntry::Policy& backoff_policy, |
171 scoped_refptr<net::HttpNetworkSession> network_session, | 171 const scoped_refptr<net::HttpNetworkSession>& gcm_network_session, |
| 172 const scoped_refptr<net::HttpNetworkSession>& http_network_session, |
172 net::NetLog* net_log, | 173 net::NetLog* net_log, |
173 GCMStatsRecorder* recorder) OVERRIDE; | 174 GCMStatsRecorder* recorder) OVERRIDE; |
174 | 175 |
175 private: | 176 private: |
176 base::TimeDelta clock_step_; | 177 base::TimeDelta clock_step_; |
177 }; | 178 }; |
178 | 179 |
179 FakeGCMInternalsBuilder::FakeGCMInternalsBuilder(base::TimeDelta clock_step) | 180 FakeGCMInternalsBuilder::FakeGCMInternalsBuilder(base::TimeDelta clock_step) |
180 : clock_step_(clock_step) { | 181 : clock_step_(clock_step) { |
181 } | 182 } |
(...skipping 12 matching lines...) Expand all Loading... |
194 GCMStatsRecorder* recorder) { | 195 GCMStatsRecorder* recorder) { |
195 return make_scoped_ptr<MCSClient>(new FakeMCSClient(clock, | 196 return make_scoped_ptr<MCSClient>(new FakeMCSClient(clock, |
196 connection_factory, | 197 connection_factory, |
197 gcm_store, | 198 gcm_store, |
198 recorder)); | 199 recorder)); |
199 } | 200 } |
200 | 201 |
201 scoped_ptr<ConnectionFactory> FakeGCMInternalsBuilder::BuildConnectionFactory( | 202 scoped_ptr<ConnectionFactory> FakeGCMInternalsBuilder::BuildConnectionFactory( |
202 const std::vector<GURL>& endpoints, | 203 const std::vector<GURL>& endpoints, |
203 const net::BackoffEntry::Policy& backoff_policy, | 204 const net::BackoffEntry::Policy& backoff_policy, |
204 scoped_refptr<net::HttpNetworkSession> network_session, | 205 const scoped_refptr<net::HttpNetworkSession>& gcm_network_session, |
| 206 const scoped_refptr<net::HttpNetworkSession>& http_network_session, |
205 net::NetLog* net_log, | 207 net::NetLog* net_log, |
206 GCMStatsRecorder* recorder) { | 208 GCMStatsRecorder* recorder) { |
207 return make_scoped_ptr<ConnectionFactory>(new FakeConnectionFactory()); | 209 return make_scoped_ptr<ConnectionFactory>(new FakeConnectionFactory()); |
208 } | 210 } |
209 | 211 |
210 } // namespace | 212 } // namespace |
211 | 213 |
212 class GCMClientImplTest : public testing::Test, | 214 class GCMClientImplTest : public testing::Test, |
213 public GCMClient::Delegate { | 215 public GCMClient::Delegate { |
214 public: | 216 public: |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 TEST_F(GCMClientImplStartAndStopTest, StartStopAndRestartImmediately) { | 834 TEST_F(GCMClientImplStartAndStopTest, StartStopAndRestartImmediately) { |
833 // Start the GCM and then stop and restart it immediately. | 835 // Start the GCM and then stop and restart it immediately. |
834 gcm_client()->Start(); | 836 gcm_client()->Start(); |
835 gcm_client()->Stop(); | 837 gcm_client()->Stop(); |
836 gcm_client()->Start(); | 838 gcm_client()->Start(); |
837 | 839 |
838 PumpLoopUntilIdle(); | 840 PumpLoopUntilIdle(); |
839 } | 841 } |
840 | 842 |
841 } // namespace gcm | 843 } // namespace gcm |
OLD | NEW |