Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(614)

Side by Side Diff: google_apis/gcm/engine/connection_factory_impl.cc

Issue 132193003: [GCM] Support actual check-in in mcs_probe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comment Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | google_apis/gcm/tools/mcs_probe.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.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 "google_apis/gcm/engine/connection_handler_impl.h" 10 #include "google_apis/gcm/engine/connection_handler_impl.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 base::Bind(&ConnectionFactoryImpl::ConnectionHandlerCallback, 92 base::Bind(&ConnectionFactoryImpl::ConnectionHandlerCallback,
93 weak_ptr_factory_.GetWeakPtr()))); 93 weak_ptr_factory_.GetWeakPtr())));
94 } 94 }
95 95
96 ConnectionHandler* ConnectionFactoryImpl::GetConnectionHandler() const { 96 ConnectionHandler* ConnectionFactoryImpl::GetConnectionHandler() const {
97 return connection_handler_.get(); 97 return connection_handler_.get();
98 } 98 }
99 99
100 void ConnectionFactoryImpl::Connect() { 100 void ConnectionFactoryImpl::Connect() {
101 DCHECK(connection_handler_); 101 DCHECK(connection_handler_);
102 DCHECK(!IsEndpointReachable());
103 102
104 connecting_ = true; 103 connecting_ = true;
105 if (backoff_entry_->ShouldRejectRequest()) { 104 if (backoff_entry_->ShouldRejectRequest()) {
106 DVLOG(1) << "Delaying MCS endpoint connection for " 105 DVLOG(1) << "Delaying MCS endpoint connection for "
107 << backoff_entry_->GetTimeUntilRelease().InMilliseconds() 106 << backoff_entry_->GetTimeUntilRelease().InMilliseconds()
108 << " milliseconds."; 107 << " milliseconds.";
109 base::MessageLoop::current()->PostDelayedTask( 108 base::MessageLoop::current()->PostDelayedTask(
110 FROM_HERE, 109 FROM_HERE,
111 base::Bind(&ConnectionFactoryImpl::Connect, 110 base::Bind(&ConnectionFactoryImpl::Connect,
112 weak_ptr_factory_.GetWeakPtr()), 111 weak_ptr_factory_.GetWeakPtr()),
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 158 }
160 159
161 void ConnectionFactoryImpl::OnIPAddressChanged() { 160 void ConnectionFactoryImpl::OnIPAddressChanged() {
162 DVLOG(1) << "IP Address changed, resetting backoff."; 161 DVLOG(1) << "IP Address changed, resetting backoff.";
163 backoff_entry_->Reset(); 162 backoff_entry_->Reset();
164 // Connect(..) should be retrying with backoff already if a connection is 163 // Connect(..) should be retrying with backoff already if a connection is
165 // necessary, so no need to call again. 164 // necessary, so no need to call again.
166 } 165 }
167 166
168 void ConnectionFactoryImpl::ConnectImpl() { 167 void ConnectionFactoryImpl::ConnectImpl() {
169 DCHECK(!IsEndpointReachable());
170
171 if (socket_handle_.socket() && socket_handle_.socket()->IsConnected()) 168 if (socket_handle_.socket() && socket_handle_.socket()->IsConnected())
172 socket_handle_.socket()->Disconnect(); 169 socket_handle_.socket()->Disconnect();
173 socket_handle_.Reset(); 170 socket_handle_.Reset();
174 171
175 // TODO(zea): resolve proxies. 172 // TODO(zea): resolve proxies.
176 net::ProxyInfo proxy_info; 173 net::ProxyInfo proxy_info;
177 proxy_info.UseDirect(); 174 proxy_info.UseDirect();
178 net::SSLConfig ssl_config; 175 net::SSLConfig ssl_config;
179 network_session_->ssl_config_service()->GetSSLConfig(&ssl_config); 176 network_session_->ssl_config_service()->GetSSLConfig(&ssl_config);
180 177
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 UMA_HISTOGRAM_SPARSE_SLOWLY("GCM.ConnectionDisconnectErrorCode", result); 233 UMA_HISTOGRAM_SPARSE_SLOWLY("GCM.ConnectionDisconnectErrorCode", result);
237 234
238 // TODO(zea): Consider how to handle errors that may require some sort of 235 // TODO(zea): Consider how to handle errors that may require some sort of
239 // user intervention (login page, etc.). 236 // user intervention (login page, etc.).
240 LOG(ERROR) << "Connection reset with error " << result; 237 LOG(ERROR) << "Connection reset with error " << result;
241 backoff_entry_->InformOfRequest(false); 238 backoff_entry_->InformOfRequest(false);
242 Connect(); 239 Connect();
243 } 240 }
244 241
245 } // namespace gcm 242 } // namespace gcm
OLDNEW
« no previous file with comments | « no previous file | google_apis/gcm/tools/mcs_probe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698