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

Side by Side Diff: jingle/glue/proxy_resolving_client_socket.cc

Issue 332313003: Add Finch experiment for selectively bypassing proxies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bengr's nit Created 6 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/glue/proxy_resolving_client_socket.h" 5 #include "jingle/glue/proxy_resolving_client_socket.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "net/base/io_buffer.h" 12 #include "net/base/io_buffer.h"
13 #include "net/base/load_flags.h"
13 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
14 #include "net/http/http_network_session.h" 15 #include "net/http/http_network_session.h"
15 #include "net/socket/client_socket_handle.h" 16 #include "net/socket/client_socket_handle.h"
16 #include "net/socket/client_socket_pool_manager.h" 17 #include "net/socket/client_socket_pool_manager.h"
17 #include "net/url_request/url_request_context.h" 18 #include "net/url_request/url_request_context.h"
18 #include "net/url_request/url_request_context_getter.h" 19 #include "net/url_request/url_request_context_getter.h"
19 20
20 namespace jingle_glue { 21 namespace jingle_glue {
21 22
22 ProxyResolvingClientSocket::ProxyResolvingClientSocket( 23 ProxyResolvingClientSocket::ProxyResolvingClientSocket(
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 131
131 int ProxyResolvingClientSocket::Connect( 132 int ProxyResolvingClientSocket::Connect(
132 const net::CompletionCallback& callback) { 133 const net::CompletionCallback& callback) {
133 DCHECK(user_connect_callback_.is_null()); 134 DCHECK(user_connect_callback_.is_null());
134 135
135 tried_direct_connect_fallback_ = false; 136 tried_direct_connect_fallback_ = false;
136 137
137 // First we try and resolve the proxy. 138 // First we try and resolve the proxy.
138 int status = network_session_->proxy_service()->ResolveProxy( 139 int status = network_session_->proxy_service()->ResolveProxy(
139 proxy_url_, 140 proxy_url_,
141 net::LOAD_NORMAL,
140 &proxy_info_, 142 &proxy_info_,
141 proxy_resolve_callback_, 143 proxy_resolve_callback_,
142 &pac_request_, 144 &pac_request_,
145 NULL,
143 bound_net_log_); 146 bound_net_log_);
144 if (status != net::ERR_IO_PENDING) { 147 if (status != net::ERR_IO_PENDING) {
145 // We defer execution of ProcessProxyResolveDone instead of calling it 148 // We defer execution of ProcessProxyResolveDone instead of calling it
146 // directly here for simplicity. From the caller's point of view, 149 // directly here for simplicity. From the caller's point of view,
147 // the connect always happens asynchronously. 150 // the connect always happens asynchronously.
148 base::MessageLoop* message_loop = base::MessageLoop::current(); 151 base::MessageLoop* message_loop = base::MessageLoop::current();
149 CHECK(message_loop); 152 CHECK(message_loop);
150 message_loop->PostTask( 153 message_loop->PostTask(
151 FROM_HERE, 154 FROM_HERE,
152 base::Bind(&ProxyResolvingClientSocket::ProcessProxyResolveDone, 155 base::Bind(&ProxyResolvingClientSocket::ProcessProxyResolveDone,
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 default: 273 default:
271 return error; 274 return error;
272 } 275 }
273 276
274 if (proxy_info_.is_https() && ssl_config_.send_client_cert) { 277 if (proxy_info_.is_https() && ssl_config_.send_client_cert) {
275 network_session_->ssl_client_auth_cache()->Remove( 278 network_session_->ssl_client_auth_cache()->Remove(
276 proxy_info_.proxy_server().host_port_pair()); 279 proxy_info_.proxy_server().host_port_pair());
277 } 280 }
278 281
279 int rv = network_session_->proxy_service()->ReconsiderProxyAfterError( 282 int rv = network_session_->proxy_service()->ReconsiderProxyAfterError(
280 proxy_url_, error, &proxy_info_, proxy_resolve_callback_, &pac_request_, 283 proxy_url_, net::LOAD_NORMAL, error, &proxy_info_,
281 bound_net_log_); 284 proxy_resolve_callback_, &pac_request_, NULL, bound_net_log_);
282 if (rv == net::OK || rv == net::ERR_IO_PENDING) { 285 if (rv == net::OK || rv == net::ERR_IO_PENDING) {
283 CloseTransportSocket(); 286 CloseTransportSocket();
284 } else { 287 } else {
285 // If ReconsiderProxyAfterError() failed synchronously, it means 288 // If ReconsiderProxyAfterError() failed synchronously, it means
286 // there was nothing left to fall-back to, so fail the transaction 289 // there was nothing left to fall-back to, so fail the transaction
287 // with the last connection error we got. 290 // with the last connection error we got.
288 rv = error; 291 rv = error;
289 } 292 }
290 293
291 // We either have new proxy info or there was an error in falling back. 294 // We either have new proxy info or there was an error in falling back.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 return false; 399 return false;
397 } 400 }
398 401
399 void ProxyResolvingClientSocket::CloseTransportSocket() { 402 void ProxyResolvingClientSocket::CloseTransportSocket() {
400 if (transport_.get() && transport_->socket()) 403 if (transport_.get() && transport_->socket())
401 transport_->socket()->Disconnect(); 404 transport_->socket()->Disconnect();
402 transport_.reset(); 405 transport_.reset();
403 } 406 }
404 407
405 } // namespace jingle_glue 408 } // namespace jingle_glue
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698