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 "base/memory/weak_ptr.h" | |
mmenke
2015/10/07 18:43:33
Not needed
xunjieli
2015/10/19 21:07:46
Done.
| |
10 #include "net/base/net_export.h" | |
11 #include "net/base/request_priority.h" | |
12 #include "net/http/http_request_info.h" | |
13 #include "net/spdy/spdy_session.h" | |
14 #include "net/spdy/spdy_stream.h" | |
15 | |
16 namespace net { | |
17 | |
18 struct HttpRequestInfo; | |
19 class IOBuffer; | |
20 class BoundNetLog; | |
21 | |
22 class NET_EXPORT BidirectionalStream { | |
23 public: | |
24 // Delegate to handle BidirectionalStream events. | |
25 class Delegate { | |
26 public: | |
27 Delegate() {} | |
mmenke
2015/10/07 18:43:33
nit: Blank line after constructor.
xunjieli
2015/10/19 21:07:46
Done.
| |
28 // Called when an error occurs. E.g. when an 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; | |
mmenke
2015/10/07 18:43:33
This is called when all data from the last SendDat
xunjieli
2015/10/19 21:07:46
I think it is called for every SendData.
mmenke
2015/10/19 21:27:53
Right...But it's called when *all* of the data is
xunjieli
2015/10/19 21:34:31
Ah, I see! I will modify the comment to reflect th
| |
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. | |
mef
2015/10/07 23:44:56
Add a comment about values of |status|.
xunjieli
2015/10/19 21:07:46
Done.
| |
50 virtual void OnClose(int status) = 0; | |
51 | |
52 protected: | |
53 virtual ~Delegate() {} | |
54 | |
55 private: | |
56 DISALLOW_COPY_AND_ASSIGN(Delegate); | |
57 }; | |
58 | |
59 BidirectionalStream() {} | |
60 virtual ~BidirectionalStream() {} | |
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. | |
73 virtual void SendData(IOBuffer* data, int length, bool end_stream) = 0; | |
mmenke
2015/10/07 18:43:33
I assume it's not legal to call again until OnData
xunjieli
2015/10/19 21:07:46
Yes, that's my understanding too. I added a commen
| |
74 | |
75 // TODO(xunjieli): implement a method to do flow control. | |
mef
2015/10/07 23:44:56
Do we also need a method to explicitly close / can
xunjieli
2015/10/19 21:07:46
Done.
| |
76 private: | |
77 DISALLOW_COPY_AND_ASSIGN(BidirectionalStream); | |
78 }; | |
79 | |
80 } // namespace net | |
81 | |
82 #endif // NET_HTTP_BIDIRECTIONAL_STREAM_H_ | |
OLD | NEW |