Chromium Code Reviews| 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_H_ | |
| 6 #define NET_HTTP_BIDIRECTIONAL_STREAM_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "net/base/net_export.h" | |
| 10 #include "net/base/request_priority.h" | |
| 11 #include "net/http/http_request_info.h" | |
| 12 #include "net/spdy/spdy_session.h" | |
| 13 #include "net/spdy/spdy_stream.h" | |
| 14 | |
| 15 namespace net { | |
| 16 | |
| 17 struct HttpRequestInfo; | |
| 18 class IOBuffer; | |
| 19 class BoundNetLog; | |
| 20 | |
| 21 class NET_EXPORT BidirectionalStream { | |
|
mmenke
2015/10/21 18:05:52
Need some class level docs.
xunjieli
2015/10/21 19:35:36
Done.
| |
| 22 public: | |
| 23 // Delegate to handle BidirectionalStream events. | |
| 24 class Delegate { | |
| 25 public: | |
| 26 Delegate() {} | |
| 27 | |
| 28 // Called when an error occurs. E.g. when a connection to the server cannot | |
| 29 // be established. | |
| 30 virtual void OnFailed(int error) = 0; | |
| 31 | |
| 32 // Called when the request headers have been sent. | |
| 33 virtual void OnRequestHeadersSent() = 0; | |
| 34 | |
| 35 // Called when response headers are received. | |
| 36 virtual void OnHeaders(const SpdyHeaderBlock& response_headers) = 0; | |
| 37 | |
| 38 // Called when read is completed asynchronously. |bytes_read| specifies how | |
| 39 // much data is available. | |
| 40 virtual void OnReadCompleted(int bytes_read) = 0; | |
| 41 | |
| 42 // Called when data is sent. | |
| 43 virtual void OnDataSent() = 0; | |
| 44 | |
| 45 // Called when trailers are received. | |
| 46 virtual void OnTrailers(const SpdyHeaderBlock& trailers) = 0; | |
| 47 | |
| 48 // Called when the stream is closed. No other delegate functions will be | |
| 49 // called after this. |status| is an error code or OK. | |
| 50 virtual void OnClose(int status) = 0; | |
|
mef
2015/10/20 21:56:35
Will there be distinction between OnClose and OnCa
xunjieli
2015/10/21 19:35:36
Not in the underlying implementation. But I think
| |
| 51 | |
| 52 protected: | |
| 53 virtual ~Delegate() {} | |
| 54 | |
| 55 private: | |
| 56 DISALLOW_COPY_AND_ASSIGN(Delegate); | |
| 57 }; | |
| 58 | |
| 59 BidirectionalStream() {} | |
| 60 virtual ~BidirectionalStream() {} | |
|
mmenke
2015/10/21 18:05:52
Don't think we should inline anything in this file
xunjieli
2015/10/21 19:35:36
What do you mean by inlining? Sorry, I am still a
mmenke
2015/10/21 19:46:14
Put method bodies with the declaration. You shoul
xunjieli
2015/10/21 20:22:19
I see! Done. Thanks
| |
| 61 | |
| 62 // Starts the BidirectionalStream and sends request headers. | |
| 63 virtual void Start(const HttpRequestInfo* request_info, | |
| 64 RequestPriority priority, | |
| 65 const BoundNetLog& net_log, | |
| 66 Delegate* delegate) = 0; | |
| 67 | |
| 68 // Reads at most |buf_len| bytes into |buf|. Returns the number of bytes read, | |
| 69 // or ERR_IO_PENDING if the read is to be completed asynchronously. | |
| 70 virtual int ReadData(IOBuffer* buf, int buf_len) = 0; | |
| 71 | |
| 72 // Sends data. This should not be called again util OnDataSent is invoked. | |
|
mef
2015/10/20 21:56:34
until. Is OnDataSent invoked when entire buffer is
xunjieli
2015/10/21 19:35:36
Done. Yes, OnDataSent is invoked when the entire b
| |
| 73 virtual void SendData(IOBuffer* data, int length, bool end_stream) = 0; | |
| 74 | |
| 75 // Cancels the stream. Delegate::OnClose will be invoked if the stream is | |
| 76 // canceled. | |
|
mmenke
2015/10/21 18:05:52
I'd recommend against this behavior - we've run in
xunjieli
2015/10/21 19:35:36
Done. Good idea! That makes it easier to reason.
| |
| 77 virtual void Cancel() = 0; | |
| 78 | |
| 79 // TODO(xunjieli): implement a method to do flow control. | |
| 80 private: | |
|
mmenke
2015/10/21 18:05:52
nit: Blank line before private.
xunjieli
2015/10/21 19:35:36
Done.
| |
| 81 DISALLOW_COPY_AND_ASSIGN(BidirectionalStream); | |
| 82 }; | |
| 83 | |
| 84 } // namespace net | |
| 85 | |
| 86 #endif // NET_HTTP_BIDIRECTIONAL_STREAM_H_ | |
| OLD | NEW |