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 #include <utility> |
8 | 9 |
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/test/simple_test_tick_clock.h" | 12 #include "base/test/simple_test_tick_clock.h" |
12 #include "google_apis/gcm/base/mcs_util.h" | 13 #include "google_apis/gcm/base/mcs_util.h" |
13 #include "google_apis/gcm/engine/fake_connection_handler.h" | 14 #include "google_apis/gcm/engine/fake_connection_handler.h" |
14 #include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h" | 15 #include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h" |
15 #include "net/base/backoff_entry.h" | 16 #include "net/base/backoff_entry.h" |
16 #include "net/http/http_network_session.h" | 17 #include "net/http/http_network_session.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 return make_scoped_ptr(new net::BackoffEntry(&kTestBackoffPolicy, | 195 return make_scoped_ptr(new net::BackoffEntry(&kTestBackoffPolicy, |
195 &tick_clock_)); | 196 &tick_clock_)); |
196 } | 197 } |
197 | 198 |
198 scoped_ptr<ConnectionHandler> | 199 scoped_ptr<ConnectionHandler> |
199 TestConnectionFactoryImpl::CreateConnectionHandler( | 200 TestConnectionFactoryImpl::CreateConnectionHandler( |
200 base::TimeDelta read_timeout, | 201 base::TimeDelta read_timeout, |
201 const ConnectionHandler::ProtoReceivedCallback& read_callback, | 202 const ConnectionHandler::ProtoReceivedCallback& read_callback, |
202 const ConnectionHandler::ProtoSentCallback& write_callback, | 203 const ConnectionHandler::ProtoSentCallback& write_callback, |
203 const ConnectionHandler::ConnectionChangedCallback& connection_callback) { | 204 const ConnectionHandler::ConnectionChangedCallback& connection_callback) { |
204 return scoped_handler_.Pass(); | 205 return std::move(scoped_handler_); |
205 } | 206 } |
206 | 207 |
207 base::TimeTicks TestConnectionFactoryImpl::NowTicks() { | 208 base::TimeTicks TestConnectionFactoryImpl::NowTicks() { |
208 return tick_clock_.NowTicks(); | 209 return tick_clock_.NowTicks(); |
209 } | 210 } |
210 | 211 |
211 void TestConnectionFactoryImpl::SetConnectResult(int connect_result) { | 212 void TestConnectionFactoryImpl::SetConnectResult(int connect_result) { |
212 DCHECK_NE(connect_result, net::ERR_UNEXPECTED); | 213 DCHECK_NE(connect_result, net::ERR_UNEXPECTED); |
213 ASSERT_EQ(0, num_expected_attempts_); | 214 ASSERT_EQ(0, num_expected_attempts_); |
214 connections_fulfilled_ = false; | 215 connections_fulfilled_ = false; |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 // Now trigger force a re-connection. | 564 // Now trigger force a re-connection. |
564 factory()->SetConnectResult(net::OK); | 565 factory()->SetConnectResult(net::OK); |
565 factory()->Connect(); | 566 factory()->Connect(); |
566 WaitForConnections(); | 567 WaitForConnections(); |
567 | 568 |
568 // Re-connection should succeed. | 569 // Re-connection should succeed. |
569 EXPECT_TRUE(factory()->IsEndpointReachable()); | 570 EXPECT_TRUE(factory()->IsEndpointReachable()); |
570 } | 571 } |
571 | 572 |
572 } // namespace gcm | 573 } // namespace gcm |
OLD | NEW |