| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "google_apis/gcm/engine/connection_factory_impl.h" | 5 #include "google_apis/gcm/engine/connection_factory_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 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" |
| 11 #include "base/test/simple_test_tick_clock.h" | 11 #include "base/test/simple_test_tick_clock.h" |
| 12 #include "google_apis/gcm/base/mcs_util.h" | 12 #include "google_apis/gcm/base/mcs_util.h" |
| 13 #include "google_apis/gcm/engine/fake_connection_handler.h" | 13 #include "google_apis/gcm/engine/fake_connection_handler.h" |
| 14 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 14 #include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h" |
| 15 #include "net/base/backoff_entry.h" | 15 #include "net/base/backoff_entry.h" |
| 16 #include "net/http/http_network_session.h" | 16 #include "net/http/http_network_session.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 18 |
| 19 class Policy; | 19 class Policy; |
| 20 | 20 |
| 21 namespace gcm { | 21 namespace gcm { |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 const char kMCSEndpoint[] = "http://my.server"; | 24 const char kMCSEndpoint[] = "http://my.server"; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 int num_expected_attempts_; | 143 int num_expected_attempts_; |
| 144 // Whether all expected connection attempts have been fulfilled since an | 144 // Whether all expected connection attempts have been fulfilled since an |
| 145 // expectation was last set. | 145 // expectation was last set. |
| 146 bool connections_fulfilled_; | 146 bool connections_fulfilled_; |
| 147 // Whether to delay a login handshake completion or not. | 147 // Whether to delay a login handshake completion or not. |
| 148 bool delay_login_; | 148 bool delay_login_; |
| 149 // Callback to invoke when all connection attempts have been made. | 149 // Callback to invoke when all connection attempts have been made. |
| 150 base::Closure finished_callback_; | 150 base::Closure finished_callback_; |
| 151 // The current fake connection handler.. | 151 // The current fake connection handler.. |
| 152 FakeConnectionHandler* fake_handler_; | 152 FakeConnectionHandler* fake_handler_; |
| 153 GCMStatsRecorder dummy_recorder_; | 153 FakeGCMStatsRecorder dummy_recorder_; |
| 154 }; | 154 }; |
| 155 | 155 |
| 156 TestConnectionFactoryImpl::TestConnectionFactoryImpl( | 156 TestConnectionFactoryImpl::TestConnectionFactoryImpl( |
| 157 const base::Closure& finished_callback) | 157 const base::Closure& finished_callback) |
| 158 : ConnectionFactoryImpl(BuildEndpoints(), | 158 : ConnectionFactoryImpl(BuildEndpoints(), |
| 159 net::BackoffEntry::Policy(), | 159 net::BackoffEntry::Policy(), |
| 160 NULL, | 160 NULL, |
| 161 NULL, | 161 NULL, |
| 162 &dummy_recorder_), | 162 &dummy_recorder_), |
| 163 connect_result_(net::ERR_UNEXPECTED), | 163 connect_result_(net::ERR_UNEXPECTED), |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 EXPECT_NE(retry_time, factory()->NextRetryAttempt()); | 504 EXPECT_NE(retry_time, factory()->NextRetryAttempt()); |
| 505 retry_time = factory()->NextRetryAttempt(); | 505 retry_time = factory()->NextRetryAttempt(); |
| 506 EXPECT_FALSE(retry_time.is_null()); | 506 EXPECT_FALSE(retry_time.is_null()); |
| 507 EXPECT_GE((retry_time - connect_time).InMilliseconds(), | 507 EXPECT_GE((retry_time - connect_time).InMilliseconds(), |
| 508 CalculateBackoff(3)); | 508 CalculateBackoff(3)); |
| 509 EXPECT_FALSE(factory()->IsEndpointReachable()); | 509 EXPECT_FALSE(factory()->IsEndpointReachable()); |
| 510 } | 510 } |
| 511 | 511 |
| 512 } // namespace | 512 } // namespace |
| 513 } // namespace gcm | 513 } // namespace gcm |
| OLD | NEW |