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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/memory/ptr_util.h" |
10 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
11 #include "base/metrics/sparse_histogram.h" | 12 #include "base/metrics/sparse_histogram.h" |
12 #include "base/profiler/scoped_tracker.h" | 13 #include "base/profiler/scoped_tracker.h" |
13 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
14 #include "google_apis/gcm/engine/connection_handler_impl.h" | 15 #include "google_apis/gcm/engine/connection_handler_impl.h" |
15 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 16 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
16 #include "google_apis/gcm/protocol/mcs.pb.h" | 17 #include "google_apis/gcm/protocol/mcs.pb.h" |
17 #include "net/base/load_flags.h" | 18 #include "net/base/load_flags.h" |
18 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
19 #include "net/http/http_network_session.h" | 20 #include "net/http/http_network_session.h" |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 // May be null in tests. | 326 // May be null in tests. |
326 mcs_proto::LoginRequest login_request; | 327 mcs_proto::LoginRequest login_request; |
327 if (!request_builder_.is_null()) { | 328 if (!request_builder_.is_null()) { |
328 request_builder_.Run(&login_request); | 329 request_builder_.Run(&login_request); |
329 DCHECK(login_request.IsInitialized()); | 330 DCHECK(login_request.IsInitialized()); |
330 } | 331 } |
331 | 332 |
332 connection_handler_->Init(login_request, socket_handle_.socket()); | 333 connection_handler_->Init(login_request, socket_handle_.socket()); |
333 } | 334 } |
334 | 335 |
335 scoped_ptr<net::BackoffEntry> ConnectionFactoryImpl::CreateBackoffEntry( | 336 std::unique_ptr<net::BackoffEntry> ConnectionFactoryImpl::CreateBackoffEntry( |
336 const net::BackoffEntry::Policy* const policy) { | 337 const net::BackoffEntry::Policy* const policy) { |
337 return scoped_ptr<net::BackoffEntry>(new net::BackoffEntry(policy)); | 338 return std::unique_ptr<net::BackoffEntry>(new net::BackoffEntry(policy)); |
338 } | 339 } |
339 | 340 |
340 scoped_ptr<ConnectionHandler> ConnectionFactoryImpl::CreateConnectionHandler( | 341 std::unique_ptr<ConnectionHandler> |
| 342 ConnectionFactoryImpl::CreateConnectionHandler( |
341 base::TimeDelta read_timeout, | 343 base::TimeDelta read_timeout, |
342 const ConnectionHandler::ProtoReceivedCallback& read_callback, | 344 const ConnectionHandler::ProtoReceivedCallback& read_callback, |
343 const ConnectionHandler::ProtoSentCallback& write_callback, | 345 const ConnectionHandler::ProtoSentCallback& write_callback, |
344 const ConnectionHandler::ConnectionChangedCallback& connection_callback) { | 346 const ConnectionHandler::ConnectionChangedCallback& connection_callback) { |
345 return make_scoped_ptr<ConnectionHandler>( | 347 return base::WrapUnique<ConnectionHandler>(new ConnectionHandlerImpl( |
346 new ConnectionHandlerImpl(read_timeout, | 348 read_timeout, read_callback, write_callback, connection_callback)); |
347 read_callback, | |
348 write_callback, | |
349 connection_callback)); | |
350 } | 349 } |
351 | 350 |
352 base::TimeTicks ConnectionFactoryImpl::NowTicks() { | 351 base::TimeTicks ConnectionFactoryImpl::NowTicks() { |
353 return base::TimeTicks::Now(); | 352 return base::TimeTicks::Now(); |
354 } | 353 } |
355 | 354 |
356 void ConnectionFactoryImpl::OnConnectDone(int result) { | 355 void ConnectionFactoryImpl::OnConnectDone(int result) { |
357 // TODO(zea): Remove ScopedTracker below once crbug.com/455884 is fixed. | 356 // TODO(zea): Remove ScopedTracker below once crbug.com/455884 is fixed. |
358 tracked_objects::ScopedTracker tracking_profile( | 357 tracked_objects::ScopedTracker tracking_profile( |
359 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 358 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 | 578 |
580 void ConnectionFactoryImpl::RebuildNetworkSessionAuthCache() { | 579 void ConnectionFactoryImpl::RebuildNetworkSessionAuthCache() { |
581 if (!http_network_session_ || !http_network_session_->http_auth_cache()) | 580 if (!http_network_session_ || !http_network_session_->http_auth_cache()) |
582 return; | 581 return; |
583 | 582 |
584 gcm_network_session_->http_auth_cache()->UpdateAllFrom( | 583 gcm_network_session_->http_auth_cache()->UpdateAllFrom( |
585 *http_network_session_->http_auth_cache()); | 584 *http_network_session_->http_auth_cache()); |
586 } | 585 } |
587 | 586 |
588 } // namespace gcm | 587 } // namespace gcm |
OLD | NEW |