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/memory/ptr_util.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/metrics/sparse_histogram.h" | 12 #include "base/metrics/sparse_histogram.h" |
13 #include "base/profiler/scoped_tracker.h" | 13 #include "base/profiler/scoped_tracker.h" |
14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
15 #include "google_apis/gcm/engine/connection_handler_impl.h" | 15 #include "google_apis/gcm/engine/connection_handler_impl.h" |
16 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 16 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
17 #include "google_apis/gcm/protocol/mcs.pb.h" | 17 #include "google_apis/gcm/protocol/mcs.pb.h" |
18 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
19 #include "net/http/http_network_session.h" | 19 #include "net/http/http_network_session.h" |
20 #include "net/http/http_request_headers.h" | 20 #include "net/http/http_request_headers.h" |
21 #include "net/log/net_log.h" | 21 #include "net/log/net_log.h" |
| 22 #include "net/log/net_log_source_type.h" |
22 #include "net/proxy/proxy_info.h" | 23 #include "net/proxy/proxy_info.h" |
23 #include "net/socket/client_socket_handle.h" | 24 #include "net/socket/client_socket_handle.h" |
24 #include "net/socket/client_socket_pool_manager.h" | 25 #include "net/socket/client_socket_pool_manager.h" |
25 #include "net/ssl/ssl_config_service.h" | 26 #include "net/ssl/ssl_config_service.h" |
26 | 27 |
27 namespace gcm { | 28 namespace gcm { |
28 | 29 |
29 namespace { | 30 namespace { |
30 | 31 |
31 // The amount of time a Socket read should wait before timing out. | 32 // The amount of time a Socket read should wait before timing out. |
(...skipping 15 matching lines...) Expand all Loading... |
47 | 48 |
48 } // namespace | 49 } // namespace |
49 | 50 |
50 ConnectionFactoryImpl::ConnectionFactoryImpl( | 51 ConnectionFactoryImpl::ConnectionFactoryImpl( |
51 const std::vector<GURL>& mcs_endpoints, | 52 const std::vector<GURL>& mcs_endpoints, |
52 const net::BackoffEntry::Policy& backoff_policy, | 53 const net::BackoffEntry::Policy& backoff_policy, |
53 net::HttpNetworkSession* gcm_network_session, | 54 net::HttpNetworkSession* gcm_network_session, |
54 net::HttpNetworkSession* http_network_session, | 55 net::HttpNetworkSession* http_network_session, |
55 net::NetLog* net_log, | 56 net::NetLog* net_log, |
56 GCMStatsRecorder* recorder) | 57 GCMStatsRecorder* recorder) |
57 : mcs_endpoints_(mcs_endpoints), | 58 : mcs_endpoints_(mcs_endpoints), |
58 next_endpoint_(0), | 59 next_endpoint_(0), |
59 last_successful_endpoint_(0), | 60 last_successful_endpoint_(0), |
60 backoff_policy_(backoff_policy), | 61 backoff_policy_(backoff_policy), |
61 gcm_network_session_(gcm_network_session), | 62 gcm_network_session_(gcm_network_session), |
62 http_network_session_(http_network_session), | 63 http_network_session_(http_network_session), |
63 bound_net_log_( | 64 bound_net_log_( |
64 net::BoundNetLog::Make(net_log, net::NetLog::SOURCE_SOCKET)), | 65 net::BoundNetLog::Make(net_log, net::NetLogSourceType::SOCKET)), |
65 pac_request_(NULL), | 66 pac_request_(NULL), |
66 connecting_(false), | 67 connecting_(false), |
67 waiting_for_backoff_(false), | 68 waiting_for_backoff_(false), |
68 waiting_for_network_online_(false), | 69 waiting_for_network_online_(false), |
69 logging_in_(false), | 70 logging_in_(false), |
70 recorder_(recorder), | 71 recorder_(recorder), |
71 listener_(NULL), | 72 listener_(NULL), |
72 weak_ptr_factory_(this) { | 73 weak_ptr_factory_(this) { |
73 DCHECK_GE(mcs_endpoints_.size(), 1U); | 74 DCHECK_GE(mcs_endpoints_.size(), 1U); |
74 DCHECK(!http_network_session_ || | 75 DCHECK(!http_network_session_ || |
75 (gcm_network_session_ != http_network_session_)); | 76 (gcm_network_session_ != http_network_session_)); |
76 } | 77 } |
77 | 78 |
78 ConnectionFactoryImpl::~ConnectionFactoryImpl() { | 79 ConnectionFactoryImpl::~ConnectionFactoryImpl() { |
79 CloseSocket(); | 80 CloseSocket(); |
80 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); | 81 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); |
81 if (pac_request_) { | 82 if (pac_request_) { |
82 gcm_network_session_->proxy_service()->CancelPacRequest(pac_request_); | 83 gcm_network_session_->proxy_service()->CancelPacRequest(pac_request_); |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 | 574 |
574 void ConnectionFactoryImpl::RebuildNetworkSessionAuthCache() { | 575 void ConnectionFactoryImpl::RebuildNetworkSessionAuthCache() { |
575 if (!http_network_session_ || !http_network_session_->http_auth_cache()) | 576 if (!http_network_session_ || !http_network_session_->http_auth_cache()) |
576 return; | 577 return; |
577 | 578 |
578 gcm_network_session_->http_auth_cache()->UpdateAllFrom( | 579 gcm_network_session_->http_auth_cache()->UpdateAllFrom( |
579 *http_network_session_->http_auth_cache()); | 580 *http_network_session_->http_auth_cache()); |
580 } | 581 } |
581 | 582 |
582 } // namespace gcm | 583 } // namespace gcm |
OLD | NEW |