OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // NOTE: This code is not shared between Google and Chrome. | 5 // NOTE: This code is not shared between Google and Chrome. |
6 | 6 |
7 #ifndef NET_QUIC_QUIC_RELIABLE_CLIENT_STREAM_H_ | 7 #ifndef NET_QUIC_QUIC_RELIABLE_CLIENT_STREAM_H_ |
8 #define NET_QUIC_QUIC_RELIABLE_CLIENT_STREAM_H_ | 8 #define NET_QUIC_QUIC_RELIABLE_CLIENT_STREAM_H_ |
9 | 9 |
10 #include "net/base/ip_endpoint.h" | 10 #include "net/base/ip_endpoint.h" |
11 #include "net/base/upload_data_stream.h" | 11 #include "net/base/upload_data_stream.h" |
12 #include "net/http/http_request_info.h" | 12 #include "net/http/http_request_info.h" |
13 #include "net/http/http_response_info.h" | 13 #include "net/http/http_response_info.h" |
14 #include "net/http/http_stream.h" | 14 #include "net/http/http_stream.h" |
15 #include "net/quic/quic_data_stream.h" | 15 #include "net/quic/quic_spdy_stream.h" |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 | 18 |
19 class QuicSpdySession; | 19 class QuicSpdySession; |
20 | 20 |
21 // A client-initiated ReliableQuicStream. Instances of this class | 21 // A client-initiated ReliableQuicStream. Instances of this class |
22 // are owned by the QuicClientSession which created them. | 22 // are owned by the QuicClientSession which created them. |
23 class NET_EXPORT_PRIVATE QuicReliableClientStream : public QuicDataStream { | 23 class NET_EXPORT_PRIVATE QuicReliableClientStream : public QuicSpdyStream { |
24 public: | 24 public: |
25 // Delegate handles protocol specific behavior of a quic stream. | 25 // Delegate handles protocol specific behavior of a quic stream. |
26 class NET_EXPORT_PRIVATE Delegate { | 26 class NET_EXPORT_PRIVATE Delegate { |
27 public: | 27 public: |
28 Delegate() {} | 28 Delegate() {} |
29 | 29 |
30 // Called when headers are available. | 30 // Called when headers are available. |
31 virtual void OnHeadersAvailable(const SpdyHeaderBlock& headers, | 31 virtual void OnHeadersAvailable(const SpdyHeaderBlock& headers, |
32 size_t frame_len) = 0; | 32 size_t frame_len) = 0; |
33 | 33 |
(...skipping 15 matching lines...) Expand all Loading... |
49 private: | 49 private: |
50 DISALLOW_COPY_AND_ASSIGN(Delegate); | 50 DISALLOW_COPY_AND_ASSIGN(Delegate); |
51 }; | 51 }; |
52 | 52 |
53 QuicReliableClientStream(QuicStreamId id, | 53 QuicReliableClientStream(QuicStreamId id, |
54 QuicSpdySession* session, | 54 QuicSpdySession* session, |
55 const BoundNetLog& net_log); | 55 const BoundNetLog& net_log); |
56 | 56 |
57 ~QuicReliableClientStream() override; | 57 ~QuicReliableClientStream() override; |
58 | 58 |
59 // QuicDataStream | 59 // QuicSpdyStream |
60 void OnStreamHeadersComplete(bool fin, size_t frame_len) override; | 60 void OnStreamHeadersComplete(bool fin, size_t frame_len) override; |
61 void OnDataAvailable() override; | 61 void OnDataAvailable() override; |
62 void OnClose() override; | 62 void OnClose() override; |
63 void OnCanWrite() override; | 63 void OnCanWrite() override; |
64 QuicPriority EffectivePriority() const override; | 64 QuicPriority EffectivePriority() const override; |
65 | 65 |
66 // While the server's set_priority shouldn't be called externally, the creator | 66 // While the server's set_priority shouldn't be called externally, the creator |
67 // of client-side streams should be able to set the priority. | 67 // of client-side streams should be able to set the priority. |
68 using QuicDataStream::set_priority; | 68 using QuicSpdyStream::set_priority; |
69 | 69 |
70 int WriteStreamData(base::StringPiece data, | 70 int WriteStreamData(base::StringPiece data, |
71 bool fin, | 71 bool fin, |
72 const CompletionCallback& callback); | 72 const CompletionCallback& callback); |
73 // Set new |delegate|. |delegate| must not be NULL. | 73 // Set new |delegate|. |delegate| must not be NULL. |
74 // If this stream has already received data, OnDataReceived() will be | 74 // If this stream has already received data, OnDataReceived() will be |
75 // called on the delegate. | 75 // called on the delegate. |
76 void SetDelegate(Delegate* delegate); | 76 void SetDelegate(Delegate* delegate); |
77 Delegate* GetDelegate() { return delegate_; } | 77 Delegate* GetDelegate() { return delegate_; } |
78 void OnError(int error); | 78 void OnError(int error); |
79 | 79 |
80 // Reads at most |buf_len| bytes into |buf|. Returns the number of bytes read. | 80 // Reads at most |buf_len| bytes into |buf|. Returns the number of bytes read. |
81 int Read(IOBuffer* buf, int buf_len); | 81 int Read(IOBuffer* buf, int buf_len); |
82 | 82 |
83 // Returns true if the stream can possible write data. (The socket may | 83 // Returns true if the stream can possible write data. (The socket may |
84 // turn out to be write blocked, of course). If the stream can not write, | 84 // turn out to be write blocked, of course). If the stream can not write, |
85 // this method returns false, and |callback| will be invoked when | 85 // this method returns false, and |callback| will be invoked when |
86 // it becomes writable. | 86 // it becomes writable. |
87 bool CanWrite(const CompletionCallback& callback); | 87 bool CanWrite(const CompletionCallback& callback); |
88 | 88 |
89 const BoundNetLog& net_log() const { return net_log_; } | 89 const BoundNetLog& net_log() const { return net_log_; } |
90 | 90 |
91 using QuicDataStream::HasBufferedData; | 91 using QuicSpdyStream::HasBufferedData; |
92 | 92 |
93 private: | 93 private: |
94 void NotifyDelegateOfHeadersCompleteLater(size_t frame_len); | 94 void NotifyDelegateOfHeadersCompleteLater(size_t frame_len); |
95 void NotifyDelegateOfHeadersComplete(size_t frame_len); | 95 void NotifyDelegateOfHeadersComplete(size_t frame_len); |
96 void NotifyDelegateOfDataAvailableLater(); | 96 void NotifyDelegateOfDataAvailableLater(); |
97 void NotifyDelegateOfDataAvailable(); | 97 void NotifyDelegateOfDataAvailable(); |
98 | 98 |
99 BoundNetLog net_log_; | 99 BoundNetLog net_log_; |
100 Delegate* delegate_; | 100 Delegate* delegate_; |
101 | 101 |
102 bool headers_delivered_; | 102 bool headers_delivered_; |
103 | 103 |
104 CompletionCallback callback_; | 104 CompletionCallback callback_; |
105 | 105 |
106 base::WeakPtrFactory<QuicReliableClientStream> weak_factory_; | 106 base::WeakPtrFactory<QuicReliableClientStream> weak_factory_; |
107 | 107 |
108 DISALLOW_COPY_AND_ASSIGN(QuicReliableClientStream); | 108 DISALLOW_COPY_AND_ASSIGN(QuicReliableClientStream); |
109 }; | 109 }; |
110 | 110 |
111 } // namespace net | 111 } // namespace net |
112 | 112 |
113 #endif // NET_QUIC_QUIC_RELIABLE_CLIENT_STREAM_H_ | 113 #endif // NET_QUIC_QUIC_RELIABLE_CLIENT_STREAM_H_ |
OLD | NEW |