| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/chrome_async_socket.h" | 5 #include "jingle/notifier/base/chrome_async_socket.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <winsock2.h> | 8 #include <winsock2.h> |
| 9 #elif defined(OS_POSIX) | 9 #elif defined(OS_POSIX) |
| 10 #include <arpa/inet.h> | 10 #include <arpa/inet.h> |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #include <algorithm> | 13 #include <algorithm> |
| 14 #include <cstring> | 14 #include <cstring> |
| 15 #include <cstdlib> | 15 #include <cstdlib> |
| 16 | 16 |
| 17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
| 18 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
| 19 #include "base/logging.h" | 19 #include "base/logging.h" |
| 20 #include "net/base/address_list.h" | 20 #include "net/base/address_list.h" |
| 21 #include "net/base/host_port_pair.h" |
| 21 #include "net/base/io_buffer.h" | 22 #include "net/base/io_buffer.h" |
| 22 #include "net/base/net_util.h" | 23 #include "net/base/net_util.h" |
| 23 #include "net/base/ssl_config_service.h" | 24 #include "net/base/ssl_config_service.h" |
| 24 #include "net/base/sys_addrinfo.h" | 25 #include "net/base/sys_addrinfo.h" |
| 25 #include "net/socket/client_socket_factory.h" | 26 #include "net/socket/client_socket_factory.h" |
| 26 #include "net/socket/ssl_client_socket.h" | 27 #include "net/socket/ssl_client_socket.h" |
| 27 #include "net/socket/tcp_client_socket.h" | 28 #include "net/socket/tcp_client_socket.h" |
| 28 #include "talk/base/socketaddress.h" | 29 #include "talk/base/socketaddress.h" |
| 29 | 30 |
| 30 namespace notifier { | 31 namespace notifier { |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 read_start_ = 0U; | 429 read_start_ = 0U; |
| 429 read_end_ = 0U; | 430 read_end_ = 0U; |
| 430 DCHECK_EQ(write_end_, 0U); | 431 DCHECK_EQ(write_end_, 0U); |
| 431 | 432 |
| 432 // Clear out any posted DoRead() tasks. | 433 // Clear out any posted DoRead() tasks. |
| 433 scoped_runnable_method_factory_.RevokeAll(); | 434 scoped_runnable_method_factory_.RevokeAll(); |
| 434 | 435 |
| 435 DCHECK(transport_socket_.get()); | 436 DCHECK(transport_socket_.get()); |
| 436 transport_socket_.reset( | 437 transport_socket_.reset( |
| 437 client_socket_factory_->CreateSSLClientSocket( | 438 client_socket_factory_->CreateSSLClientSocket( |
| 438 transport_socket_.release(), domain_name, ssl_config_, | 439 transport_socket_.release(), net::HostPortPair(domain_name, 443), |
| 439 NULL /* ssl_host_info */)); | 440 ssl_config_, NULL /* ssl_host_info */)); |
| 440 int status = transport_socket_->Connect(&ssl_connect_callback_); | 441 int status = transport_socket_->Connect(&ssl_connect_callback_); |
| 441 if (status != net::ERR_IO_PENDING) { | 442 if (status != net::ERR_IO_PENDING) { |
| 442 MessageLoop* message_loop = MessageLoop::current(); | 443 MessageLoop* message_loop = MessageLoop::current(); |
| 443 CHECK(message_loop); | 444 CHECK(message_loop); |
| 444 message_loop->PostTask( | 445 message_loop->PostTask( |
| 445 FROM_HERE, | 446 FROM_HERE, |
| 446 scoped_runnable_method_factory_.NewRunnableMethod( | 447 scoped_runnable_method_factory_.NewRunnableMethod( |
| 447 &ChromeAsyncSocket::ProcessSSLConnectDone, status)); | 448 &ChromeAsyncSocket::ProcessSSLConnectDone, status)); |
| 448 } | 449 } |
| 449 return true; | 450 return true; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 468 } | 469 } |
| 469 state_ = STATE_TLS_OPEN; | 470 state_ = STATE_TLS_OPEN; |
| 470 PostDoRead(); | 471 PostDoRead(); |
| 471 if (write_end_ > 0U) { | 472 if (write_end_ > 0U) { |
| 472 PostDoWrite(); | 473 PostDoWrite(); |
| 473 } | 474 } |
| 474 SignalSSLConnected(); | 475 SignalSSLConnected(); |
| 475 } | 476 } |
| 476 | 477 |
| 477 } // namespace notifier | 478 } // namespace notifier |
| OLD | NEW |