OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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 #ifndef NET_HTTP_BIDIRECTIONAL_STREAM_CREATE_HELPER_H_ | |
6 #define NET_HTTP_BIDIRECTIONAL_STREAM_CREATE_HELPER_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "net/base/request_priority.h" | |
11 #include "net/http/http_stream_factory.h" | |
12 #include "net/log/net_log.h" | |
13 #include "net/ssl/ssl_config.h" | |
14 | |
15 namespace net { | |
16 | |
17 class BidirectionalStream; | |
18 class ClientSocketHandle; | |
19 class HttpAuthController; | |
20 class HttpNetworkSession; | |
21 class HttpStream; | |
22 class HttpStreamRequest; | |
23 class IOBuffer; | |
24 class ProxyInfo; | |
25 struct HttpRequestInfo; | |
26 | |
27 /** | |
28 * A helper class to create a net::BidirectionalStream. Embedder should use | |
xunjieli
2015/10/21 19:38:21
Oops. I used Javadoc syntax. Will change in the ne
xunjieli
2015/10/21 20:22:19
Done.
| |
29 * the Delegate interface to get notified of success or failure. | |
30 */ | |
31 class NET_EXPORT BidirectionalStreamCreateHelper | |
32 : public HttpStreamRequest::Delegate { | |
33 public: | |
34 class NET_EXPORT Delegate { | |
35 public: | |
36 Delegate() {} | |
37 | |
38 virtual void OnStreamCreated() = 0; | |
39 // |error| is a net error. | |
40 virtual void OnStreamFailed(int error) = 0; | |
41 | |
42 protected: | |
43 virtual ~Delegate() {} | |
44 | |
45 private: | |
46 DISALLOW_COPY_AND_ASSIGN(Delegate); | |
47 }; | |
48 | |
49 BidirectionalStreamCreateHelper(const HttpRequestInfo* request_info, | |
50 RequestPriority priority, | |
51 const URLRequestContext* context, | |
52 Delegate* delegate); | |
53 | |
54 ~BidirectionalStreamCreateHelper() override; | |
55 | |
56 // Starts a HttpStreamRequest to create a BidirectionalStream. | |
57 void CreateBidirectionalStream(); | |
58 | |
59 // HttpStreamRequest::Delegate methods: | |
60 void OnStreamReady(const SSLConfig& used_ssl_config, | |
61 const ProxyInfo& used_proxy_info, | |
62 HttpStream* stream) override; | |
63 void OnBidirectionalStreamReady(const SSLConfig& used_ssl_config, | |
64 const ProxyInfo& used_proxy_info, | |
65 BidirectionalStream* stream) override; | |
66 void OnWebSocketHandshakeStreamReady( | |
67 const SSLConfig& used_ssl_config, | |
68 const ProxyInfo& used_proxy_info, | |
69 WebSocketHandshakeStreamBase* stream) override; | |
70 void OnStreamFailed(int status, | |
71 const SSLConfig& used_ssl_config, | |
72 SSLFailureState ssl_failure_state) override; | |
73 void OnCertificateError(int status, | |
74 const SSLConfig& used_ssl_config, | |
75 const SSLInfo& ssl_info) override; | |
76 void OnNeedsProxyAuth(const HttpResponseInfo& response_info, | |
77 const SSLConfig& used_ssl_config, | |
78 const ProxyInfo& used_proxy_info, | |
79 HttpAuthController* auth_controller) override; | |
80 void OnNeedsClientAuth(const SSLConfig& used_ssl_config, | |
81 SSLCertRequestInfo* cert_info) override; | |
82 void OnHttpsProxyTunnelResponse(const HttpResponseInfo& response_info, | |
83 const SSLConfig& used_ssl_config, | |
84 const ProxyInfo& used_proxy_info, | |
85 HttpStream* stream) override; | |
86 | |
87 private: | |
88 const HttpRequestInfo* request_info_; | |
89 RequestPriority priority_; | |
90 Delegate* delegate_; | |
91 BoundNetLog net_log_; | |
92 HttpNetworkSession* session_; | |
93 SSLConfig server_ssl_config_; | |
94 SSLConfig proxy_ssl_config_; | |
95 | |
96 scoped_ptr<HttpStreamRequest> stream_request_; | |
97 scoped_ptr<BidirectionalStream> stream_; | |
98 | |
99 DISALLOW_COPY_AND_ASSIGN(BidirectionalStreamCreateHelper); | |
100 }; | |
101 | |
102 } // namespace net | |
103 | |
104 #endif // NET_HTTP_BIDIRECTIONAL_STREAM_CREATE_HELPER_H_ | |
OLD | NEW |