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

Unified Diff: net/http/bidirectional_stream_create_helper.h

Issue 1326503003: Added a net::BidirectionalStream to expose a bidirectional streaming interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avoid inlining Created 5 years, 2 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: net/http/bidirectional_stream_create_helper.h
diff --git a/net/http/bidirectional_stream_create_helper.h b/net/http/bidirectional_stream_create_helper.h
new file mode 100644
index 0000000000000000000000000000000000000000..514bb712e560a952a3708d46cc63eb611d3e068a
--- /dev/null
+++ b/net/http/bidirectional_stream_create_helper.h
@@ -0,0 +1,102 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_HTTP_BIDIRECTIONAL_STREAM_CREATE_HELPER_H_
+#define NET_HTTP_BIDIRECTIONAL_STREAM_CREATE_HELPER_H_
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "net/base/request_priority.h"
+#include "net/http/http_stream_factory.h"
+#include "net/log/net_log.h"
+#include "net/ssl/ssl_config.h"
+
+namespace net {
+
+class BidirectionalStream;
+class ClientSocketHandle;
+class HttpAuthController;
+class HttpNetworkSession;
+class HttpStream;
+class HttpStreamRequest;
+class IOBuffer;
+class ProxyInfo;
+struct HttpRequestInfo;
+
+// A helper class to create a net::BidirectionalStream. Embedder should use
+// 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.
+class NET_EXPORT BidirectionalStreamCreateHelper
+ : public HttpStreamRequest::Delegate {
+ public:
+ 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.
+ public:
+ Delegate() {}
+
+ virtual void OnStreamCreated() = 0;
+ // |error| is a net error.
+ virtual void OnStreamFailed(int error) = 0;
+
+ protected:
+ virtual ~Delegate() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Delegate);
+ };
+
+ 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.
+ RequestPriority priority,
+ 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.
+ Delegate* delegate);
+
+ ~BidirectionalStreamCreateHelper() override;
mmenke 2015/10/21 22:40:16 Should mention somewhere that destroying it cancel
xunjieli 2015/10/22 20:01:41 Done.
+
+ // Starts a HttpStreamRequest to create a BidirectionalStream.
+ 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
+
+ // HttpStreamRequest::Delegate methods:
+ void OnStreamReady(const SSLConfig& used_ssl_config,
+ const ProxyInfo& used_proxy_info,
+ HttpStream* stream) override;
+ void OnBidirectionalStreamReady(const SSLConfig& used_ssl_config,
+ const ProxyInfo& used_proxy_info,
+ BidirectionalStream* stream) override;
+ void OnWebSocketHandshakeStreamReady(
+ const SSLConfig& used_ssl_config,
+ const ProxyInfo& used_proxy_info,
+ WebSocketHandshakeStreamBase* stream) override;
+ void OnStreamFailed(int status,
+ const SSLConfig& used_ssl_config,
+ SSLFailureState ssl_failure_state) override;
+ void OnCertificateError(int status,
+ const SSLConfig& used_ssl_config,
+ const SSLInfo& ssl_info) override;
+ void OnNeedsProxyAuth(const HttpResponseInfo& response_info,
+ const SSLConfig& used_ssl_config,
+ const ProxyInfo& used_proxy_info,
+ HttpAuthController* auth_controller) override;
+ void OnNeedsClientAuth(const SSLConfig& used_ssl_config,
+ SSLCertRequestInfo* cert_info) override;
+ void OnHttpsProxyTunnelResponse(const HttpResponseInfo& response_info,
+ const SSLConfig& used_ssl_config,
+ const ProxyInfo& used_proxy_info,
+ HttpStream* stream) override;
+
+ private:
+ const HttpRequestInfo* request_info_;
+ RequestPriority priority_;
+ Delegate* delegate_;
+ BoundNetLog net_log_;
+ HttpNetworkSession* session_;
+ SSLConfig server_ssl_config_;
+ SSLConfig proxy_ssl_config_;
+
+ scoped_ptr<HttpStreamRequest> stream_request_;
+ scoped_ptr<BidirectionalStream> stream_;
+
+ DISALLOW_COPY_AND_ASSIGN(BidirectionalStreamCreateHelper);
+};
+
+} // namespace net
+
+#endif // NET_HTTP_BIDIRECTIONAL_STREAM_CREATE_HELPER_H_

Powered by Google App Engine
This is Rietveld 408576698