OLD | NEW |
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 | |
9 #include <algorithm> | 8 #include <algorithm> |
10 #include <cstdlib> | 9 #include <cstdlib> |
11 #include <cstring> | 10 #include <cstring> |
| 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 "jingle/glue/resolving_client_socket_factory.h" | 17 #include "jingle/glue/resolving_client_socket_factory.h" |
18 #include "net/base/address_list.h" | 18 #include "net/base/address_list.h" |
19 #include "net/base/host_port_pair.h" | 19 #include "net/base/host_port_pair.h" |
20 #include "net/base/io_buffer.h" | 20 #include "net/base/io_buffer.h" |
21 #include "net/base/net_util.h" | 21 #include "net/base/net_util.h" |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 read_start_ = 0U; | 398 read_start_ = 0U; |
399 read_end_ = 0U; | 399 read_end_ = 0U; |
400 DCHECK_EQ(write_end_, 0U); | 400 DCHECK_EQ(write_end_, 0U); |
401 | 401 |
402 // Clear out any posted DoRead() tasks. | 402 // Clear out any posted DoRead() tasks. |
403 weak_ptr_factory_.InvalidateWeakPtrs(); | 403 weak_ptr_factory_.InvalidateWeakPtrs(); |
404 | 404 |
405 DCHECK(transport_socket_.get()); | 405 DCHECK(transport_socket_.get()); |
406 scoped_ptr<net::ClientSocketHandle> socket_handle( | 406 scoped_ptr<net::ClientSocketHandle> socket_handle( |
407 new net::ClientSocketHandle()); | 407 new net::ClientSocketHandle()); |
408 socket_handle->SetSocket(transport_socket_.Pass()); | 408 socket_handle->SetSocket(std::move(transport_socket_)); |
409 transport_socket_ = | 409 transport_socket_ = resolving_client_socket_factory_->CreateSSLClientSocket( |
410 resolving_client_socket_factory_->CreateSSLClientSocket( | 410 std::move(socket_handle), net::HostPortPair(domain_name, 443)); |
411 socket_handle.Pass(), net::HostPortPair(domain_name, 443)); | |
412 int status = transport_socket_->Connect( | 411 int status = transport_socket_->Connect( |
413 base::Bind(&ChromeAsyncSocket::ProcessSSLConnectDone, | 412 base::Bind(&ChromeAsyncSocket::ProcessSSLConnectDone, |
414 weak_ptr_factory_.GetWeakPtr())); | 413 weak_ptr_factory_.GetWeakPtr())); |
415 if (status != net::ERR_IO_PENDING) { | 414 if (status != net::ERR_IO_PENDING) { |
416 base::MessageLoop* message_loop = base::MessageLoop::current(); | 415 base::MessageLoop* message_loop = base::MessageLoop::current(); |
417 CHECK(message_loop); | 416 CHECK(message_loop); |
418 message_loop->PostTask( | 417 message_loop->PostTask( |
419 FROM_HERE, | 418 FROM_HERE, |
420 base::Bind(&ChromeAsyncSocket::ProcessSSLConnectDone, | 419 base::Bind(&ChromeAsyncSocket::ProcessSSLConnectDone, |
421 weak_ptr_factory_.GetWeakPtr(), status)); | 420 weak_ptr_factory_.GetWeakPtr(), status)); |
(...skipping 20 matching lines...) Expand all Loading... |
442 } | 441 } |
443 state_ = STATE_TLS_OPEN; | 442 state_ = STATE_TLS_OPEN; |
444 PostDoRead(); | 443 PostDoRead(); |
445 if (write_end_ > 0U) { | 444 if (write_end_ > 0U) { |
446 PostDoWrite(); | 445 PostDoWrite(); |
447 } | 446 } |
448 SignalSSLConnected(); | 447 SignalSSLConnected(); |
449 } | 448 } |
450 | 449 |
451 } // namespace jingle_glue | 450 } // namespace jingle_glue |
OLD | NEW |