Add reset button for each preference in gesture config UI
[chromium-blink-merge.git] / net / quic / quic_reliable_client_stream.h
blob77ac787f10df8dfc69530d06970e10ed7c13abac
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/reliable_quic_stream.h"
17 namespace net {
19 class QuicClientSession;
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 ReliableQuicStream {
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 stream is ready to send data.
31 // Returns network error code. OK when it successfully sent data.
32 // ERR_IO_PENDING when performing operation asynchronously.
33 virtual int OnSendData() = 0;
35 // Called when data has been sent. |status| indicates network error
36 // or number of bytes that has been sent. On return, |eof| is set to true
37 // if no more data is available to send.
38 // Returns network error code. OK when it successfully sent data.
39 virtual int OnSendDataComplete(int status, bool* eof) = 0;
41 // Called when data is received.
42 // Returns network error code. OK when it successfully receives data.
43 virtual int OnDataReceived(const char* data, int length) = 0;
45 // Called when the stream is closed by the peer.
46 virtual void OnClose(QuicErrorCode error) = 0;
48 // Called when the stream is closed because of an error.
49 virtual void OnError(int error) = 0;
51 protected:
52 virtual ~Delegate() {}
54 private:
55 DISALLOW_COPY_AND_ASSIGN(Delegate);
58 QuicReliableClientStream(QuicStreamId id,
59 QuicSession* session,
60 const BoundNetLog& net_log);
62 virtual ~QuicReliableClientStream();
64 // ReliableQuicStream
65 virtual uint32 ProcessData(const char* data, uint32 data_len) OVERRIDE;
66 virtual void TerminateFromPeer(bool half_close) OVERRIDE;
67 using ReliableQuicStream::WriteData;
69 // Set new |delegate|. |delegate| must not be NULL.
70 // If this stream has already received data, OnDataReceived() will be
71 // called on the delegate.
72 void SetDelegate(Delegate* delegate);
73 Delegate* GetDelegate() { return delegate_; }
74 void OnError(int error);
76 const BoundNetLog& net_log() const { return net_log_; }
78 private:
79 BoundNetLog net_log_;
80 Delegate* delegate_;
82 DISALLOW_COPY_AND_ASSIGN(QuicReliableClientStream);
85 } // namespace net
87 #endif // NET_QUIC_QUIC_RELIABLE_CLIENT_STREAM_H_