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 "base/location.h" | 7 #include "base/location.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/metrics/sparse_histogram.h" | 9 #include "base/metrics/sparse_histogram.h" |
10 #include "base/profiler/scoped_tracker.h" | 10 #include "base/profiler/scoped_tracker.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 waiting_for_network_online_ = net::NetworkChangeNotifier::IsOffline(); | 100 waiting_for_network_online_ = net::NetworkChangeNotifier::IsOffline(); |
101 } | 101 } |
102 | 102 |
103 ConnectionHandler* ConnectionFactoryImpl::GetConnectionHandler() const { | 103 ConnectionHandler* ConnectionFactoryImpl::GetConnectionHandler() const { |
104 return connection_handler_.get(); | 104 return connection_handler_.get(); |
105 } | 105 } |
106 | 106 |
107 void ConnectionFactoryImpl::Connect() { | 107 void ConnectionFactoryImpl::Connect() { |
108 if (!connection_handler_) { | 108 if (!connection_handler_) { |
109 connection_handler_ = CreateConnectionHandler( | 109 connection_handler_ = CreateConnectionHandler( |
110 base::TimeDelta::FromMilliseconds(kReadTimeoutMs), | 110 base::TimeDelta::FromMilliseconds(kReadTimeoutMs), read_callback_, |
111 read_callback_, | |
112 write_callback_, | 111 write_callback_, |
113 base::Bind(&ConnectionFactoryImpl::ConnectionHandlerCallback, | 112 base::Bind(&ConnectionFactoryImpl::ConnectionHandlerCallback, |
114 weak_ptr_factory_.GetWeakPtr())).Pass(); | 113 weak_ptr_factory_.GetWeakPtr())); |
115 } | 114 } |
116 | 115 |
117 if (connecting_ || waiting_for_backoff_) | 116 if (connecting_ || waiting_for_backoff_) |
118 return; // Connection attempt already in progress or pending. | 117 return; // Connection attempt already in progress or pending. |
119 | 118 |
120 if (IsEndpointReachable()) | 119 if (IsEndpointReachable()) |
121 return; // Already connected. | 120 return; // Already connected. |
122 | 121 |
123 ConnectWithBackoff(); | 122 ConnectWithBackoff(); |
124 } | 123 } |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 | 575 |
577 void ConnectionFactoryImpl::RebuildNetworkSessionAuthCache() { | 576 void ConnectionFactoryImpl::RebuildNetworkSessionAuthCache() { |
578 if (!http_network_session_ || !http_network_session_->http_auth_cache()) | 577 if (!http_network_session_ || !http_network_session_->http_auth_cache()) |
579 return; | 578 return; |
580 | 579 |
581 gcm_network_session_->http_auth_cache()->UpdateAllFrom( | 580 gcm_network_session_->http_auth_cache()->UpdateAllFrom( |
582 *http_network_session_->http_auth_cache()); | 581 *http_network_session_->http_auth_cache()); |
583 } | 582 } |
584 | 583 |
585 } // namespace gcm | 584 } // namespace gcm |
OLD | NEW |