We started redesigning GpuMemoryBuffer interface to handle multiple buffers [0].
[chromium-blink-merge.git] / jingle / glue / proxy_resolving_client_socket.h
blob696a097d68fadba542a49396b289d7f0ff3fcae7
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/log/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 ~ProxyResolvingClientSocket() override;
50 // net::StreamSocket implementation.
51 int Read(net::IOBuffer* buf,
52 int buf_len,
53 const net::CompletionCallback& callback) override;
54 int Write(net::IOBuffer* buf,
55 int buf_len,
56 const net::CompletionCallback& callback) override;
57 int SetReceiveBufferSize(int32 size) override;
58 int SetSendBufferSize(int32 size) override;
59 int Connect(const net::CompletionCallback& callback) override;
60 void Disconnect() override;
61 bool IsConnected() const override;
62 bool IsConnectedAndIdle() const override;
63 int GetPeerAddress(net::IPEndPoint* address) const override;
64 int GetLocalAddress(net::IPEndPoint* address) const override;
65 const net::BoundNetLog& NetLog() const override;
66 void SetSubresourceSpeculation() override;
67 void SetOmniboxSpeculation() override;
68 bool WasEverUsed() const override;
69 bool UsingTCPFastOpen() const override;
70 bool WasNpnNegotiated() const override;
71 net::NextProto GetNegotiatedProtocol() const override;
72 bool GetSSLInfo(net::SSLInfo* ssl_info) override;
74 private:
75 // Proxy resolution and connection functions.
76 void ProcessProxyResolveDone(int status);
77 void ProcessConnectDone(int status);
79 void CloseTransportSocket();
80 void RunUserConnectCallback(int status);
81 int ReconsiderProxyAfterError(int error);
82 void ReportSuccessfulProxyConnection();
84 // Callbacks passed to net APIs.
85 net::CompletionCallback proxy_resolve_callback_;
86 net::CompletionCallback connect_callback_;
88 scoped_refptr<net::HttpNetworkSession> network_session_;
90 // The transport socket.
91 scoped_ptr<net::ClientSocketHandle> transport_;
93 const net::SSLConfig ssl_config_;
94 net::ProxyService::PacRequest* pac_request_;
95 net::ProxyInfo proxy_info_;
96 const net::HostPortPair dest_host_port_pair_;
97 const GURL proxy_url_;
98 bool tried_direct_connect_fallback_;
99 net::BoundNetLog bound_net_log_;
101 // The callback passed to Connect().
102 net::CompletionCallback user_connect_callback_;
104 base::WeakPtrFactory<ProxyResolvingClientSocket> weak_factory_;
106 DISALLOW_COPY_AND_ASSIGN(ProxyResolvingClientSocket);
109 } // namespace jingle_glue
111 #endif // JINGLE_GLUE_PROXY_RESOLVING_CLIENT_SOCKET_H_