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

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

Issue 2082353002: Remove calls to deprecated MessageLoop methods in jingle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/glue/proxy_resolving_client_socket_unittest.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/chrome_async_socket.h" 5 #include "jingle/glue/chrome_async_socket.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <cstdlib> 9 #include <cstdlib>
10 #include <cstring> 10 #include <cstring>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/single_thread_task_runner.h"
17 #include "jingle/glue/resolving_client_socket_factory.h" 18 #include "jingle/glue/resolving_client_socket_factory.h"
18 #include "net/base/address_list.h" 19 #include "net/base/address_list.h"
19 #include "net/base/host_port_pair.h" 20 #include "net/base/host_port_pair.h"
20 #include "net/base/io_buffer.h" 21 #include "net/base/io_buffer.h"
21 #include "net/socket/client_socket_handle.h" 22 #include "net/socket/client_socket_handle.h"
22 #include "net/socket/ssl_client_socket.h" 23 #include "net/socket/ssl_client_socket.h"
23 #include "net/socket/tcp_client_socket.h" 24 #include "net/socket/tcp_client_socket.h"
24 #include "net/ssl/ssl_config_service.h" 25 #include "net/ssl/ssl_config_service.h"
25 #include "third_party/webrtc/base/socketaddress.h" 26 #include "third_party/webrtc/base/socketaddress.h"
26 27
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 int status = transport_socket_->Connect( 113 int status = transport_socket_->Connect(
113 base::Bind(&ChromeAsyncSocket::ProcessConnectDone, 114 base::Bind(&ChromeAsyncSocket::ProcessConnectDone,
114 weak_ptr_factory_.GetWeakPtr())); 115 weak_ptr_factory_.GetWeakPtr()));
115 if (status != net::ERR_IO_PENDING) { 116 if (status != net::ERR_IO_PENDING) {
116 // We defer execution of ProcessConnectDone instead of calling it 117 // We defer execution of ProcessConnectDone instead of calling it
117 // directly here as the caller may not expect an error/close to 118 // directly here as the caller may not expect an error/close to
118 // happen here. This is okay, as from the caller's point of view, 119 // happen here. This is okay, as from the caller's point of view,
119 // the connect always happens asynchronously. 120 // the connect always happens asynchronously.
120 base::MessageLoop* message_loop = base::MessageLoop::current(); 121 base::MessageLoop* message_loop = base::MessageLoop::current();
121 CHECK(message_loop); 122 CHECK(message_loop);
122 message_loop->PostTask( 123 message_loop->task_runner()->PostTask(
Sergey Ulanov 2016/06/22 17:42:29 Shouldn't this be ThreadTaskRunnerHandle::get()->P
fdoray 2016/06/22 17:48:06 Done. My script wasn't smart enough for this :)
123 FROM_HERE, 124 FROM_HERE, base::Bind(&ChromeAsyncSocket::ProcessConnectDone,
124 base::Bind(&ChromeAsyncSocket::ProcessConnectDone, 125 weak_ptr_factory_.GetWeakPtr(), status));
125 weak_ptr_factory_.GetWeakPtr(), status));
126 } 126 }
127 return true; 127 return true;
128 } 128 }
129 129
130 // STATE_CONNECTING -> STATE_OPEN 130 // STATE_CONNECTING -> STATE_OPEN
131 // read_state_ == IDLE -> read_state_ == POSTED (via PostDoRead()) 131 // read_state_ == IDLE -> read_state_ == POSTED (via PostDoRead())
132 132
133 void ChromeAsyncSocket::ProcessConnectDone(int status) { 133 void ChromeAsyncSocket::ProcessConnectDone(int status) {
134 DCHECK_NE(status, net::ERR_IO_PENDING); 134 DCHECK_NE(status, net::ERR_IO_PENDING);
135 DCHECK_EQ(read_state_, IDLE); 135 DCHECK_EQ(read_state_, IDLE);
(...skipping 13 matching lines...) Expand all
149 149
150 // read_state_ == IDLE -> read_state_ == POSTED 150 // read_state_ == IDLE -> read_state_ == POSTED
151 151
152 void ChromeAsyncSocket::PostDoRead() { 152 void ChromeAsyncSocket::PostDoRead() {
153 DCHECK(IsOpen()); 153 DCHECK(IsOpen());
154 DCHECK_EQ(read_state_, IDLE); 154 DCHECK_EQ(read_state_, IDLE);
155 DCHECK_EQ(read_start_, 0U); 155 DCHECK_EQ(read_start_, 0U);
156 DCHECK_EQ(read_end_, 0U); 156 DCHECK_EQ(read_end_, 0U);
157 base::MessageLoop* message_loop = base::MessageLoop::current(); 157 base::MessageLoop* message_loop = base::MessageLoop::current();
158 CHECK(message_loop); 158 CHECK(message_loop);
159 message_loop->PostTask( 159 message_loop->task_runner()->PostTask(
160 FROM_HERE, 160 FROM_HERE,
161 base::Bind(&ChromeAsyncSocket::DoRead, 161 base::Bind(&ChromeAsyncSocket::DoRead, weak_ptr_factory_.GetWeakPtr()));
162 weak_ptr_factory_.GetWeakPtr()));
163 read_state_ = POSTED; 162 read_state_ = POSTED;
164 } 163 }
165 164
166 // read_state_ == POSTED -> read_state_ == PENDING 165 // read_state_ == POSTED -> read_state_ == PENDING
167 166
168 void ChromeAsyncSocket::DoRead() { 167 void ChromeAsyncSocket::DoRead() {
169 DCHECK(IsOpen()); 168 DCHECK(IsOpen());
170 DCHECK_EQ(read_state_, POSTED); 169 DCHECK_EQ(read_state_, POSTED);
171 DCHECK_EQ(read_start_, 0U); 170 DCHECK_EQ(read_start_, 0U);
172 DCHECK_EQ(read_end_, 0U); 171 DCHECK_EQ(read_end_, 0U);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 282 }
284 283
285 // write_state_ == IDLE -> write_state_ == POSTED 284 // write_state_ == IDLE -> write_state_ == POSTED
286 285
287 void ChromeAsyncSocket::PostDoWrite() { 286 void ChromeAsyncSocket::PostDoWrite() {
288 DCHECK(IsOpen()); 287 DCHECK(IsOpen());
289 DCHECK_EQ(write_state_, IDLE); 288 DCHECK_EQ(write_state_, IDLE);
290 DCHECK_GT(write_end_, 0U); 289 DCHECK_GT(write_end_, 0U);
291 base::MessageLoop* message_loop = base::MessageLoop::current(); 290 base::MessageLoop* message_loop = base::MessageLoop::current();
292 CHECK(message_loop); 291 CHECK(message_loop);
293 message_loop->PostTask( 292 message_loop->task_runner()->PostTask(
294 FROM_HERE, 293 FROM_HERE,
295 base::Bind(&ChromeAsyncSocket::DoWrite, 294 base::Bind(&ChromeAsyncSocket::DoWrite, weak_ptr_factory_.GetWeakPtr()));
296 weak_ptr_factory_.GetWeakPtr()));
297 write_state_ = POSTED; 295 write_state_ = POSTED;
298 } 296 }
299 297
300 // write_state_ == POSTED -> write_state_ == PENDING 298 // write_state_ == POSTED -> write_state_ == PENDING
301 299
302 void ChromeAsyncSocket::DoWrite() { 300 void ChromeAsyncSocket::DoWrite() {
303 DCHECK(IsOpen()); 301 DCHECK(IsOpen());
304 DCHECK_EQ(write_state_, POSTED); 302 DCHECK_EQ(write_state_, POSTED);
305 DCHECK_GT(write_end_, 0U); 303 DCHECK_GT(write_end_, 0U);
306 // Once we call Write(), we cannot call StartTls() until the write 304 // Once we call Write(), we cannot call StartTls() until the write
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 new net::ClientSocketHandle()); 404 new net::ClientSocketHandle());
407 socket_handle->SetSocket(std::move(transport_socket_)); 405 socket_handle->SetSocket(std::move(transport_socket_));
408 transport_socket_ = resolving_client_socket_factory_->CreateSSLClientSocket( 406 transport_socket_ = resolving_client_socket_factory_->CreateSSLClientSocket(
409 std::move(socket_handle), net::HostPortPair(domain_name, 443)); 407 std::move(socket_handle), net::HostPortPair(domain_name, 443));
410 int status = transport_socket_->Connect( 408 int status = transport_socket_->Connect(
411 base::Bind(&ChromeAsyncSocket::ProcessSSLConnectDone, 409 base::Bind(&ChromeAsyncSocket::ProcessSSLConnectDone,
412 weak_ptr_factory_.GetWeakPtr())); 410 weak_ptr_factory_.GetWeakPtr()));
413 if (status != net::ERR_IO_PENDING) { 411 if (status != net::ERR_IO_PENDING) {
414 base::MessageLoop* message_loop = base::MessageLoop::current(); 412 base::MessageLoop* message_loop = base::MessageLoop::current();
415 CHECK(message_loop); 413 CHECK(message_loop);
416 message_loop->PostTask( 414 message_loop->task_runner()->PostTask(
417 FROM_HERE, 415 FROM_HERE, base::Bind(&ChromeAsyncSocket::ProcessSSLConnectDone,
418 base::Bind(&ChromeAsyncSocket::ProcessSSLConnectDone, 416 weak_ptr_factory_.GetWeakPtr(), status));
419 weak_ptr_factory_.GetWeakPtr(), status));
420 } 417 }
421 return true; 418 return true;
422 } 419 }
423 420
424 // STATE_TLS_CONNECTING -> STATE_TLS_OPEN 421 // STATE_TLS_CONNECTING -> STATE_TLS_OPEN
425 // read_state_ == IDLE -> read_state_ == POSTED (via PostDoRead()) 422 // read_state_ == IDLE -> read_state_ == POSTED (via PostDoRead())
426 // (maybe) write_state_ == IDLE -> write_state_ == POSTED (via 423 // (maybe) write_state_ == IDLE -> write_state_ == POSTED (via
427 // PostDoWrite()) 424 // PostDoWrite())
428 425
429 void ChromeAsyncSocket::ProcessSSLConnectDone(int status) { 426 void ChromeAsyncSocket::ProcessSSLConnectDone(int status) {
(...skipping 10 matching lines...) Expand all
440 } 437 }
441 state_ = STATE_TLS_OPEN; 438 state_ = STATE_TLS_OPEN;
442 PostDoRead(); 439 PostDoRead();
443 if (write_end_ > 0U) { 440 if (write_end_ > 0U) {
444 PostDoWrite(); 441 PostDoWrite();
445 } 442 }
446 SignalSSLConnected(); 443 SignalSSLConnected();
447 } 444 }
448 445
449 } // namespace jingle_glue 446 } // namespace jingle_glue
OLDNEW
« no previous file with comments | « no previous file | jingle/glue/proxy_resolving_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698