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

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

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 fix 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.h
===================================================================
--- jingle/notifier/base/chrome_async_socket.h (revision 81429)
+++ jingle/notifier/base/chrome_async_socket.h (working copy)
@@ -19,27 +19,33 @@
#include "base/memory/scoped_ptr.h"
#include "base/task.h"
#include "net/base/completion_callback.h"
+#include "net/base/host_port_pair.h"
#include "net/base/net_errors.h"
#include "net/base/net_log.h"
#include "net/base/ssl_config_service.h"
+#include "net/proxy/proxy_info.h"
+#include "net/proxy/proxy_service.h"
#include "talk/xmpp/asyncsocket.h"
namespace net {
-class CertVerifier;
class ClientSocket;
+class ClientSocketHandle;
class ClientSocketFactory;
+class HttpNetworkSession;
class IOBufferWithSize;
+class URLRequestContextGetter;
} // namespace net
namespace notifier {
class ChromeAsyncSocket : public buzz::AsyncSocket {
public:
- // Takes ownership of |client_socket_factory| but not |cert_verifier| nor
- // |net_log|. |cert_verifier| may not be NULL. |net_log| may be NULL.
- ChromeAsyncSocket(net::ClientSocketFactory* client_socket_factory,
- const net::SSLConfig& ssl_config,
- net::CertVerifier* cert_verifier,
+ // Does not take ownership of |net_log|. |net_log| may be NULL.
+ // The transport socket is created from the client socket pool.
+ ChromeAsyncSocket(const net::SSLConfig& ssl_config,
+ const scoped_refptr<net::URLRequestContextGetter>&
+ request_context_getter,
+ bool use_fake_ssl_client_socket,
size_t read_buf_size,
size_t write_buf_size,
net::NetLog* net_log);
@@ -67,10 +73,10 @@
// If state() is not STATE_CLOSED, sets error to ERROR_WRONGSTATE
// and returns false.
//
- // If |address| is not resolved, sets error to ERROR_DNS and returns
- // false.
//
- // Otherwise, starts the connection process and returns true.
+ // Otherwise, starts the connection process and returns true. The connection
+ // process involves resolving proxy servers to use for the connection and
+ // then connecting using the client socket pool.
// SignalConnected will be raised when the connection is successful;
// otherwise, SignalClosed will be raised with a net error set.
virtual bool Connect(const talk_base::SocketAddress& address);
@@ -145,6 +151,15 @@
//
// SignalError: not used.
+#if defined(UNIT_TEST)
+ // Used to override the socket used in unit-tests. Takes ownership of
+ // |client_socket_factory|.
+ void set_client_socket_factory(
+ net::ClientSocketFactory* client_socket_factory) {
+ client_socket_factory_.reset(client_socket_factory);
+ }
+#endif // defined(UNIT_TEST)
+
private:
enum AsyncIOState {
// An I/O op is not in progress.
@@ -155,6 +170,11 @@
PENDING,
};
+ // A version of Connect that uses the passed in ClientSocketFactory to
+ // create a connection rather than use the client socket pool. Used for
+ // unit-tests.
+ bool ConnectUsingFactory(const talk_base::SocketAddress& address);
+
bool IsOpen() const;
// Error functions.
@@ -162,8 +182,11 @@
void DoNetError(net::Error net_error);
void DoNetErrorFromStatus(int status);
- // Connection functions.
+ // Proxy resolution and connection functions.
+ void ProcessProxyResolveDone(int status);
+ int ReconsiderProxyAfterError(int error);
void ProcessConnectDone(int status);
+ void ProcessFakeSSLHandshakeDone(int status);
// Read loop functions.
void PostDoRead();
@@ -181,16 +204,21 @@
// Close functions.
void DoClose();
- // Callbacks passed to |transport_socket_|.
+ // Callbacks passed to net APIs.
+ net::CompletionCallbackImpl<ChromeAsyncSocket> proxy_resolve_callback_;
net::CompletionCallbackImpl<ChromeAsyncSocket> connect_callback_;
net::CompletionCallbackImpl<ChromeAsyncSocket> read_callback_;
net::CompletionCallbackImpl<ChromeAsyncSocket> write_callback_;
net::CompletionCallbackImpl<ChromeAsyncSocket> ssl_connect_callback_;
+ net::CompletionCallbackImpl<ChromeAsyncSocket> fake_ssl_handshake_callback_;
+ // Used for unit-tests.
scoped_ptr<net::ClientSocketFactory> client_socket_factory_;
const net::SSLConfig ssl_config_;
- net::CertVerifier* const cert_verifier_;
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
+ bool use_fake_ssl_client_socket_;
net::BoundNetLog bound_net_log_;
+ scoped_refptr<net::HttpNetworkSession> network_session_;
// buzz::AsyncSocket state.
buzz::AsyncSocket::State state_;
@@ -203,8 +231,12 @@
// NULL iff state() == STATE_CLOSED.
//
- // TODO(akalin): Use ClientSocketPool.
- scoped_ptr<net::ClientSocket> transport_socket_;
+ // The transport socket.
+ scoped_ptr<net::ClientSocketHandle> connection_;
+ net::ProxyService::PacRequest* pac_request_;
+ net::ProxyInfo proxy_info_;
+ net::HostPortPair dest_host_port_pair_;
+ bool tried_direct_connect_fallback_;
// State for the read loop. |read_start_| <= |read_end_| <=
// |read_buf_->size()|. There's a read in flight (i.e.,

Powered by Google App Engine
This is Rietveld 408576698