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

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

Issue 2088433002: Remove calls to MessageLoop::current() in jingle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR Created 4 years, 6 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
« no previous file with comments | « no previous file | jingle/notifier/base/xmpp_connection.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) 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 <stdint.h> 7 #include <stdint.h>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/threading/thread_task_runner_handle.h"
14 #include "net/base/io_buffer.h" 15 #include "net/base/io_buffer.h"
15 #include "net/base/ip_address.h" 16 #include "net/base/ip_address.h"
16 #include "net/base/load_flags.h" 17 #include "net/base/load_flags.h"
17 #include "net/base/net_errors.h" 18 #include "net/base/net_errors.h"
18 #include "net/http/http_auth_controller.h" 19 #include "net/http/http_auth_controller.h"
19 #include "net/http/http_network_session.h" 20 #include "net/http/http_network_session.h"
20 #include "net/http/proxy_client_socket.h" 21 #include "net/http/proxy_client_socket.h"
21 #include "net/socket/client_socket_handle.h" 22 #include "net/socket/client_socket_handle.h"
22 #include "net/socket/client_socket_pool_manager.h" 23 #include "net/socket/client_socket_pool_manager.h"
23 #include "net/url_request/url_request_context.h" 24 #include "net/url_request/url_request_context.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 net::LOAD_NORMAL, 143 net::LOAD_NORMAL,
143 &proxy_info_, 144 &proxy_info_,
144 proxy_resolve_callback_, 145 proxy_resolve_callback_,
145 &pac_request_, 146 &pac_request_,
146 NULL, 147 NULL,
147 bound_net_log_); 148 bound_net_log_);
148 if (status != net::ERR_IO_PENDING) { 149 if (status != net::ERR_IO_PENDING) {
149 // We defer execution of ProcessProxyResolveDone instead of calling it 150 // We defer execution of ProcessProxyResolveDone instead of calling it
150 // directly here for simplicity. From the caller's point of view, 151 // directly here for simplicity. From the caller's point of view,
151 // the connect always happens asynchronously. 152 // the connect always happens asynchronously.
152 base::MessageLoop* message_loop = base::MessageLoop::current(); 153 base::ThreadTaskRunnerHandle::Get()->PostTask(
153 CHECK(message_loop);
154 message_loop->PostTask(
155 FROM_HERE, 154 FROM_HERE,
156 base::Bind(&ProxyResolvingClientSocket::ProcessProxyResolveDone, 155 base::Bind(&ProxyResolvingClientSocket::ProcessProxyResolveDone,
157 weak_factory_.GetWeakPtr(), status)); 156 weak_factory_.GetWeakPtr(), status));
158 } 157 }
159 user_connect_callback_ = callback; 158 user_connect_callback_ = callback;
160 return net::ERR_IO_PENDING; 159 return net::ERR_IO_PENDING;
161 } 160 }
162 161
163 void ProxyResolvingClientSocket::RunUserConnectCallback(int status) { 162 void ProxyResolvingClientSocket::RunUserConnectCallback(int status) {
164 DCHECK_LE(status, net::OK); 163 DCHECK_LE(status, net::OK);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // If ReconsiderProxyAfterError() failed synchronously, it means 297 // If ReconsiderProxyAfterError() failed synchronously, it means
299 // there was nothing left to fall-back to, so fail the transaction 298 // there was nothing left to fall-back to, so fail the transaction
300 // with the last connection error we got. 299 // with the last connection error we got.
301 rv = error; 300 rv = error;
302 } 301 }
303 302
304 // We either have new proxy info or there was an error in falling back. 303 // We either have new proxy info or there was an error in falling back.
305 // In both cases we want to post ProcessProxyResolveDone (in the error case 304 // In both cases we want to post ProcessProxyResolveDone (in the error case
306 // we might still want to fall back a direct connection). 305 // we might still want to fall back a direct connection).
307 if (rv != net::ERR_IO_PENDING) { 306 if (rv != net::ERR_IO_PENDING) {
308 base::MessageLoop* message_loop = base::MessageLoop::current(); 307 base::ThreadTaskRunnerHandle::Get()->PostTask(
309 CHECK(message_loop);
310 message_loop->PostTask(
311 FROM_HERE, 308 FROM_HERE,
312 base::Bind(&ProxyResolvingClientSocket::ProcessProxyResolveDone, 309 base::Bind(&ProxyResolvingClientSocket::ProcessProxyResolveDone,
313 weak_factory_.GetWeakPtr(), rv)); 310 weak_factory_.GetWeakPtr(), rv));
314 // Since we potentially have another try to go (trying the direct connect) 311 // Since we potentially have another try to go (trying the direct connect)
315 // set the return code code to ERR_IO_PENDING. 312 // set the return code code to ERR_IO_PENDING.
316 rv = net::ERR_IO_PENDING; 313 rv = net::ERR_IO_PENDING;
317 } 314 }
318 return rv; 315 return rv;
319 } 316 }
320 317
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 return 0; 421 return 0;
425 } 422 }
426 423
427 void ProxyResolvingClientSocket::CloseTransportSocket() { 424 void ProxyResolvingClientSocket::CloseTransportSocket() {
428 if (transport_.get() && transport_->socket()) 425 if (transport_.get() && transport_->socket())
429 transport_->socket()->Disconnect(); 426 transport_->socket()->Disconnect();
430 transport_.reset(); 427 transport_.reset();
431 } 428 }
432 429
433 } // namespace jingle_glue 430 } // namespace jingle_glue
OLDNEW
« no previous file with comments | « no previous file | jingle/notifier/base/xmpp_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698