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

Side by Side Diff: jingle/notifier/base/proxy_resolving_client_socket.cc

Issue 7532011: Only mark a proxy as bad if we have confirmation that another proxy succeeded for the same request. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Better names Created 9 years, 4 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "jingle/notifier/base/proxy_resolving_client_socket.h" 5 #include "jingle/notifier/base/proxy_resolving_client_socket.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // If the connection fails, try another proxy. 183 // If the connection fails, try another proxy.
184 status = ReconsiderProxyAfterError(status); 184 status = ReconsiderProxyAfterError(status);
185 // ReconsiderProxyAfterError either returns an error (in which case it is 185 // ReconsiderProxyAfterError either returns an error (in which case it is
186 // not reconsidering a proxy) or returns ERR_IO_PENDING if it is considering 186 // not reconsidering a proxy) or returns ERR_IO_PENDING if it is considering
187 // another proxy. 187 // another proxy.
188 DCHECK_NE(status, net::OK); 188 DCHECK_NE(status, net::OK);
189 if (status == net::ERR_IO_PENDING) 189 if (status == net::ERR_IO_PENDING)
190 // Proxy reconsideration pending. Return. 190 // Proxy reconsideration pending. Return.
191 return; 191 return;
192 CloseTransportSocket(); 192 CloseTransportSocket();
193 } else {
194 ReportSuccessfulProxyConnection();
193 } 195 }
194 RunUserConnectCallback(status); 196 RunUserConnectCallback(status);
195 } 197 }
196 198
197 // TODO(sanjeevr): This has largely been copied from 199 // TODO(sanjeevr): This has largely been copied from
198 // HttpStreamFactoryImpl::Job::ReconsiderProxyAfterError. This should be 200 // HttpStreamFactoryImpl::Job::ReconsiderProxyAfterError. This should be
199 // refactored into some common place. 201 // refactored into some common place.
200 // This method reconsiders the proxy on certain errors. If it does reconsider 202 // This method reconsiders the proxy on certain errors. If it does reconsider
201 // a proxy it always returns ERR_IO_PENDING and posts a call to 203 // a proxy it always returns ERR_IO_PENDING and posts a call to
202 // ProcessProxyResolveDone with the result of the reconsideration. 204 // ProcessProxyResolveDone with the result of the reconsideration.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 FROM_HERE, 269 FROM_HERE,
268 scoped_runnable_method_factory_.NewRunnableMethod( 270 scoped_runnable_method_factory_.NewRunnableMethod(
269 &ProxyResolvingClientSocket::ProcessProxyResolveDone, rv)); 271 &ProxyResolvingClientSocket::ProcessProxyResolveDone, rv));
270 // Since we potentially have another try to go (trying the direct connect) 272 // Since we potentially have another try to go (trying the direct connect)
271 // set the return code code to ERR_IO_PENDING. 273 // set the return code code to ERR_IO_PENDING.
272 rv = net::ERR_IO_PENDING; 274 rv = net::ERR_IO_PENDING;
273 } 275 }
274 return rv; 276 return rv;
275 } 277 }
276 278
279 void ProxyResolvingClientSocket::ReportSuccessfulProxyConnection() {
280 network_session_->proxy_service()->ReportSuccess(proxy_info_);
281 }
282
277 void ProxyResolvingClientSocket::Disconnect() { 283 void ProxyResolvingClientSocket::Disconnect() {
278 CloseTransportSocket(); 284 CloseTransportSocket();
279 if (pac_request_) 285 if (pac_request_)
280 network_session_->proxy_service()->CancelPacRequest(pac_request_); 286 network_session_->proxy_service()->CancelPacRequest(pac_request_);
281 user_connect_callback_ = NULL; 287 user_connect_callback_ = NULL;
282 } 288 }
283 289
284 bool ProxyResolvingClientSocket::IsConnected() const { 290 bool ProxyResolvingClientSocket::IsConnected() const {
285 if (!transport_.get() || !transport_->socket()) 291 if (!transport_.get() || !transport_->socket())
286 return false; 292 return false;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 return base::TimeDelta::FromMicroseconds(-1); 364 return base::TimeDelta::FromMicroseconds(-1);
359 } 365 }
360 366
361 void ProxyResolvingClientSocket::CloseTransportSocket() { 367 void ProxyResolvingClientSocket::CloseTransportSocket() {
362 if (transport_.get() && transport_->socket()) 368 if (transport_.get() && transport_->socket())
363 transport_->socket()->Disconnect(); 369 transport_->socket()->Disconnect();
364 transport_.reset(); 370 transport_.reset();
365 } 371 }
366 372
367 } // namespace notifier 373 } // namespace notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698