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 // A helper class to create a net::BidirectionalStream. Embedder should use | |
28 // the Delegate interface to get notified of success or failure. | |
mmenke
2015/10/21 22:40:16
Should mention that both the BidirectionalStreamCr
xunjieli
2015/10/22 20:01:41
Done.
| |
29 class NET_EXPORT BidirectionalStreamCreateHelper | |
30 : public HttpStreamRequest::Delegate { | |
31 public: | |
32 class NET_EXPORT Delegate { | |
mmenke
2015/10/21 22:40:16
Should document this - in particular, are callback
xunjieli
2015/10/22 20:01:41
Done.
| |
33 public: | |
34 Delegate() {} | |
35 | |
36 virtual void OnStreamCreated() = 0; | |
37 // |error| is a net error. | |
38 virtual void OnStreamFailed(int error) = 0; | |
39 | |
40 protected: | |
41 virtual ~Delegate() {} | |
42 | |
43 private: | |
44 DISALLOW_COPY_AND_ASSIGN(Delegate); | |
45 }; | |
46 | |
47 BidirectionalStreamCreateHelper(const HttpRequestInfo* request_info, | |
mmenke
2015/10/21 22:40:16
Worth mentioning that parts of request_info are ig
mmenke
2015/10/21 22:40:16
const HttpRequestInfo& request_info?
xunjieli
2015/10/22 20:01:41
Done.
xunjieli
2015/10/22 20:01:41
Done.
| |
48 RequestPriority priority, | |
49 const URLRequestContext* context, | |
mmenke
2015/10/21 22:40:16
Maybe just take an HTTP network session? That all
mmenke
2015/10/21 22:40:16
"const" is kinda weird here - by making a request,
xunjieli
2015/10/22 20:01:41
Done.
xunjieli
2015/10/22 20:01:41
Done.
| |
50 Delegate* delegate); | |
51 | |
52 ~BidirectionalStreamCreateHelper() override; | |
mmenke
2015/10/21 22:40:16
Should mention somewhere that destroying it cancel
xunjieli
2015/10/22 20:01:41
Done.
| |
53 | |
54 // Starts a HttpStreamRequest to create a BidirectionalStream. | |
55 void CreateBidirectionalStream(); | |
mmenke
2015/10/21 22:40:16
Should we do this automatically on creation? Save
xunjieli
2015/10/22 20:01:41
Done. Good idea
| |
56 | |
57 // HttpStreamRequest::Delegate methods: | |
58 void OnStreamReady(const SSLConfig& used_ssl_config, | |
59 const ProxyInfo& used_proxy_info, | |
60 HttpStream* stream) override; | |
61 void OnBidirectionalStreamReady(const SSLConfig& used_ssl_config, | |
62 const ProxyInfo& used_proxy_info, | |
63 BidirectionalStream* stream) override; | |
64 void OnWebSocketHandshakeStreamReady( | |
65 const SSLConfig& used_ssl_config, | |
66 const ProxyInfo& used_proxy_info, | |
67 WebSocketHandshakeStreamBase* stream) override; | |
68 void OnStreamFailed(int status, | |
69 const SSLConfig& used_ssl_config, | |
70 SSLFailureState ssl_failure_state) override; | |
71 void OnCertificateError(int status, | |
72 const SSLConfig& used_ssl_config, | |
73 const SSLInfo& ssl_info) override; | |
74 void OnNeedsProxyAuth(const HttpResponseInfo& response_info, | |
75 const SSLConfig& used_ssl_config, | |
76 const ProxyInfo& used_proxy_info, | |
77 HttpAuthController* auth_controller) override; | |
78 void OnNeedsClientAuth(const SSLConfig& used_ssl_config, | |
79 SSLCertRequestInfo* cert_info) override; | |
80 void OnHttpsProxyTunnelResponse(const HttpResponseInfo& response_info, | |
81 const SSLConfig& used_ssl_config, | |
82 const ProxyInfo& used_proxy_info, | |
83 HttpStream* stream) override; | |
84 | |
85 private: | |
86 const HttpRequestInfo* request_info_; | |
87 RequestPriority priority_; | |
88 Delegate* delegate_; | |
89 BoundNetLog net_log_; | |
90 HttpNetworkSession* session_; | |
91 SSLConfig server_ssl_config_; | |
92 SSLConfig proxy_ssl_config_; | |
93 | |
94 scoped_ptr<HttpStreamRequest> stream_request_; | |
95 scoped_ptr<BidirectionalStream> stream_; | |
96 | |
97 DISALLOW_COPY_AND_ASSIGN(BidirectionalStreamCreateHelper); | |
98 }; | |
99 | |
100 } // namespace net | |
101 | |
102 #endif // NET_HTTP_BIDIRECTIONAL_STREAM_CREATE_HELPER_H_ | |
OLD | NEW |