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

Unified Diff: jingle/notifier/base/chrome_async_socket.cc

Issue 6833031: Changed the jingle network code in ChromeAsyncSocket to use the client socket pool. This also all... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Lint fixes Created 9 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: jingle/notifier/base/chrome_async_socket.cc
===================================================================
--- jingle/notifier/base/chrome_async_socket.cc (revision 81535)
+++ jingle/notifier/base/chrome_async_socket.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -18,6 +18,7 @@
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/message_loop.h"
+#include "jingle/notifier/base/resolving_client_socket_factory.h"
#include "net/base/address_list.h"
#include "net/base/host_port_pair.h"
#include "net/base/io_buffer.h"
@@ -25,6 +26,7 @@
#include "net/base/ssl_config_service.h"
#include "net/base/sys_addrinfo.h"
#include "net/socket/client_socket_factory.h"
+#include "net/socket/client_socket_handle.h"
#include "net/socket/ssl_client_socket.h"
#include "net/socket/tcp_client_socket.h"
#include "talk/base/socketaddress.h"
@@ -32,9 +34,7 @@
namespace notifier {
ChromeAsyncSocket::ChromeAsyncSocket(
- net::ClientSocketFactory* client_socket_factory,
- const net::SSLConfig& ssl_config,
- net::CertVerifier* cert_verifier,
+ ResolvingClientSocketFactory* client_socket_factory,
size_t read_buf_size,
size_t write_buf_size,
net::NetLog* net_log)
@@ -47,8 +47,6 @@
ssl_connect_callback_(ALLOW_THIS_IN_INITIALIZER_LIST(this),
&ChromeAsyncSocket::ProcessSSLConnectDone),
client_socket_factory_(client_socket_factory),
- ssl_config_(ssl_config),
- cert_verifier_(cert_verifier),
bound_net_log_(
net::BoundNetLog::Make(net_log, net::NetLog::SOURCE_SOCKET)),
state_(STATE_CLOSED),
@@ -103,26 +101,6 @@
DoNetError(static_cast<net::Error>(status));
}
-namespace {
-
-// Takes a 32-bit integer in host byte order and converts it to a
-// net::IPAddressNumber.
-net::IPAddressNumber Uint32ToIPAddressNumber(uint32 ip) {
- uint32 ip_nbo = htonl(ip);
- const unsigned char* const ip_start =
- reinterpret_cast<const unsigned char*>(&ip_nbo);
- return net::IPAddressNumber(ip_start, ip_start + (sizeof ip_nbo));
-}
-
-net::AddressList SocketAddressToAddressList(
- const talk_base::SocketAddress& address) {
- DCHECK_NE(address.ip(), 0U);
- return net::AddressList(Uint32ToIPAddressNumber(address.ip()),
- address.port(), false);
-}
-
-} // namespace
-
// STATE_CLOSED -> STATE_CONNECTING
bool ChromeAsyncSocket::Connect(const talk_base::SocketAddress& address) {
@@ -131,7 +109,8 @@
DoNonNetError(ERROR_WRONGSTATE);
return false;
}
- if (address.ip() == 0) {
+ // We can't work with an empty hostname and IP address.
+ if (address.hostname().empty() && (address.ip() == 0)) {
DoNonNetError(ERROR_DNS);
return false;
}
@@ -145,10 +124,11 @@
DCHECK(scoped_runnable_method_factory_.empty());
scoped_runnable_method_factory_.RevokeAll();
- net::AddressList address_list = SocketAddressToAddressList(address);
+ net::HostPortPair dest_host_port_pair(address.IPAsString(), address.port());
+
transport_socket_.reset(
client_socket_factory_->CreateTransportClientSocket(
- address_list, bound_net_log_.net_log(), net::NetLog::Source()));
+ dest_host_port_pair, bound_net_log_.net_log()));
int status = transport_socket_->Connect(&connect_callback_);
if (status != net::ERR_IO_PENDING) {
// We defer execution of ProcessConnectDone instead of calling it
@@ -436,11 +416,11 @@
scoped_runnable_method_factory_.RevokeAll();
DCHECK(transport_socket_.get());
+ net::ClientSocketHandle* socket_handle = new net::ClientSocketHandle();
+ socket_handle->set_socket(transport_socket_.release());
transport_socket_.reset(
client_socket_factory_->CreateSSLClientSocket(
- transport_socket_.release(), net::HostPortPair(domain_name, 443),
- ssl_config_, NULL /* ssl_host_info */,
- cert_verifier_));
+ socket_handle, net::HostPortPair(domain_name, 443)));
int status = transport_socket_->Connect(&ssl_connect_callback_);
if (status != net::ERR_IO_PENDING) {
MessageLoop* message_loop = MessageLoop::current();

Powered by Google App Engine
This is Rietveld 408576698