Disable TouchActionBrowserTest.DefaultAuto under ThreadSanitizer
[chromium-blink-merge.git] / jingle / glue / proxy_resolving_client_socket.h
blob99824d09e596103beda7763ae9e3caf158dfc27b
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
3 // found in the LICENSE file.
4 //
5 // This StreamSocket implementation wraps a ClientSocketHandle that is created
6 // from the client socket pool after resolving proxies.
8 #ifndef JINGLE_GLUE_PROXY_RESOLVING_CLIENT_SOCKET_H_
9 #define JINGLE_GLUE_PROXY_RESOLVING_CLIENT_SOCKET_H_
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h"
15 #include "net/base/completion_callback.h"
16 #include "net/base/host_port_pair.h"
17 #include "net/base/net_errors.h"
18 #include "net/base/net_log.h"
19 #include "net/proxy/proxy_info.h"
20 #include "net/proxy/proxy_service.h"
21 #include "net/socket/stream_socket.h"
22 #include "net/ssl/ssl_config_service.h"
23 #include "url/gurl.h"
25 namespace net {
26 class ClientSocketFactory;
27 class ClientSocketHandle;
28 class HttpNetworkSession;
29 class URLRequestContextGetter;
30 } // namespace net
32 // TODO(sanjeevr): Move this to net/
33 namespace jingle_glue {
35 class ProxyResolvingClientSocket : public net::StreamSocket {
36 public:
37 // Constructs a new ProxyResolvingClientSocket. |socket_factory| is
38 // the ClientSocketFactory that will be used by the underlying
39 // HttpNetworkSession. If |socket_factory| is NULL, the default
40 // socket factory (net::ClientSocketFactory::GetDefaultFactory())
41 // will be used. |dest_host_port_pair| is the destination for this
42 // socket. The hostname must be non-empty and the port must be > 0.
43 ProxyResolvingClientSocket(
44 net::ClientSocketFactory* socket_factory,
45 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter,
46 const net::SSLConfig& ssl_config,
47 const net::HostPortPair& dest_host_port_pair);
48 virtual ~ProxyResolvingClientSocket();
50 // net::StreamSocket implementation.
51 virtual int Read(net::IOBuffer* buf, int buf_len,
52 const net::CompletionCallback& callback) OVERRIDE;
53 virtual int Write(net::IOBuffer* buf, int buf_len,
54 const net::CompletionCallback& callback) OVERRIDE;
55 virtual bool SetReceiveBufferSize(int32 size) OVERRIDE;
56 virtual bool SetSendBufferSize(int32 size) OVERRIDE;
57 virtual int Connect(const net::CompletionCallback& callback) OVERRIDE;
58 virtual void Disconnect() OVERRIDE;
59 virtual bool IsConnected() const OVERRIDE;
60 virtual bool IsConnectedAndIdle() const OVERRIDE;
61 virtual int GetPeerAddress(net::IPEndPoint* address) const OVERRIDE;
62 virtual int GetLocalAddress(net::IPEndPoint* address) const OVERRIDE;
63 virtual const net::BoundNetLog& NetLog() const OVERRIDE;
64 virtual void SetSubresourceSpeculation() OVERRIDE;
65 virtual void SetOmniboxSpeculation() OVERRIDE;
66 virtual bool WasEverUsed() const OVERRIDE;
67 virtual bool UsingTCPFastOpen() const OVERRIDE;
68 virtual bool WasNpnNegotiated() const OVERRIDE;
69 virtual net::NextProto GetNegotiatedProtocol() const OVERRIDE;
70 virtual bool GetSSLInfo(net::SSLInfo* ssl_info) OVERRIDE;
72 private:
73 // Proxy resolution and connection functions.
74 void ProcessProxyResolveDone(int status);
75 void ProcessConnectDone(int status);
77 void CloseTransportSocket();
78 void RunUserConnectCallback(int status);
79 int ReconsiderProxyAfterError(int error);
80 void ReportSuccessfulProxyConnection();
82 // Callbacks passed to net APIs.
83 net::CompletionCallback proxy_resolve_callback_;
84 net::CompletionCallback connect_callback_;
86 scoped_refptr<net::HttpNetworkSession> network_session_;
88 // The transport socket.
89 scoped_ptr<net::ClientSocketHandle> transport_;
91 const net::SSLConfig ssl_config_;
92 net::ProxyService::PacRequest* pac_request_;
93 net::ProxyInfo proxy_info_;
94 const net::HostPortPair dest_host_port_pair_;
95 const GURL proxy_url_;
96 bool tried_direct_connect_fallback_;
97 net::BoundNetLog bound_net_log_;
99 // The callback passed to Connect().
100 net::CompletionCallback user_connect_callback_;
102 base::WeakPtrFactory<ProxyResolvingClientSocket> weak_factory_;
104 DISALLOW_COPY_AND_ASSIGN(ProxyResolvingClientSocket);
107 } // namespace jingle_glue
109 #endif // JINGLE_GLUE_PROXY_RESOLVING_CLIENT_SOCKET_H_