Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / net / quic / quic_reliable_client_stream.h
bloba3301d50b227d1bf7c4603875f4ac9d68350e239
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
3 // found in the LICENSE file.
4 //
5 // NOTE: This code is not shared between Google and Chrome.
7 #ifndef NET_QUIC_QUIC_RELIABLE_CLIENT_STREAM_H_
8 #define NET_QUIC_QUIC_RELIABLE_CLIENT_STREAM_H_
10 #include "net/base/ip_endpoint.h"
11 #include "net/base/upload_data_stream.h"
12 #include "net/http/http_request_info.h"
13 #include "net/http/http_response_info.h"
14 #include "net/http/http_stream.h"
15 #include "net/quic/quic_data_stream.h"
17 namespace net {
19 class QuicSpdySession;
21 // A client-initiated ReliableQuicStream. Instances of this class
22 // are owned by the QuicClientSession which created them.
23 class NET_EXPORT_PRIVATE QuicReliableClientStream : public QuicDataStream {
24 public:
25 // Delegate handles protocol specific behavior of a quic stream.
26 class NET_EXPORT_PRIVATE Delegate {
27 public:
28 Delegate() {}
30 // Called when headers are available.
31 virtual void OnHeadersAvailable(const SpdyHeaderBlock& headers) = 0;
33 // Called when data is available to be read.
34 virtual void OnDataAvailable() = 0;
36 // Called when the stream is closed by the peer.
37 virtual void OnClose(QuicErrorCode error) = 0;
39 // Called when the stream is closed because of an error.
40 virtual void OnError(int error) = 0;
42 // Returns true if sending of headers has completed.
43 virtual bool HasSendHeadersComplete() = 0;
45 protected:
46 virtual ~Delegate() {}
48 private:
49 DISALLOW_COPY_AND_ASSIGN(Delegate);
52 QuicReliableClientStream(QuicStreamId id,
53 QuicSpdySession* session,
54 const BoundNetLog& net_log);
56 ~QuicReliableClientStream() override;
58 // QuicDataStream
59 void OnStreamHeadersComplete(bool fin, size_t frame_len) override;
60 void OnDataAvailable() override;
61 void OnClose() override;
62 void OnCanWrite() override;
63 QuicPriority EffectivePriority() const override;
65 // While the server's set_priority shouldn't be called externally, the creator
66 // of client-side streams should be able to set the priority.
67 using QuicDataStream::set_priority;
69 int WriteStreamData(base::StringPiece data,
70 bool fin,
71 const CompletionCallback& callback);
72 // Set new |delegate|. |delegate| must not be NULL.
73 // If this stream has already received data, OnDataReceived() will be
74 // called on the delegate.
75 void SetDelegate(Delegate* delegate);
76 Delegate* GetDelegate() { return delegate_; }
77 void OnError(int error);
79 // Reads at most |buf_len| bytes into |buf|. Returns the number of bytes read.
80 int Read(IOBuffer* buf, int buf_len);
82 // Returns true if the stream can possible write data. (The socket may
83 // turn out to be write blocked, of course). If the stream can not write,
84 // this method returns false, and |callback| will be invoked when
85 // it becomes writable.
86 bool CanWrite(const CompletionCallback& callback);
88 const BoundNetLog& net_log() const { return net_log_; }
90 using QuicDataStream::HasBufferedData;
92 private:
93 void NotifyDelegateOfHeadersCompleteLater();
94 void NotifyDelegateOfHeadersComplete();
95 void NotifyDelegateOfDataAvailableLater();
96 void NotifyDelegateOfDataAvailable();
98 BoundNetLog net_log_;
99 Delegate* delegate_;
101 bool headers_delivered_;
103 CompletionCallback callback_;
105 base::WeakPtrFactory<QuicReliableClientStream> weak_factory_;
107 DISALLOW_COPY_AND_ASSIGN(QuicReliableClientStream);
110 } // namespace net
112 #endif // NET_QUIC_QUIC_RELIABLE_CLIENT_STREAM_H_