Disable rei.com on oopif benchmarks.
[chromium-blink-merge.git] / net / quic / p2p / quic_p2p_stream.h
blob5a1abcccdef3a37d6bbc2a5c95c3011583860c39
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.
5 #ifndef NET_QUIC_P2P_QUIC_P2P_STREAM_H_
6 #define NET_QUIC_P2P_QUIC_P2P_STREAM_H_
8 #include "net/base/completion_callback.h"
9 #include "net/base/net_export.h"
10 #include "net/quic/reliable_quic_stream.h"
12 namespace net {
14 // Streams created by QuicP2PSession.
15 class NET_EXPORT QuicP2PStream : public ReliableQuicStream {
16 public:
17 // Delegate handles protocol specific behavior of a quic stream.
18 class NET_EXPORT Delegate {
19 public:
20 Delegate() {}
22 // Called when data is received.
23 virtual void OnDataReceived(const char* data, int length) = 0;
25 // Called when the stream is closed by the peer.
26 virtual void OnClose(QuicErrorCode error) = 0;
28 protected:
29 virtual ~Delegate() {}
31 private:
32 DISALLOW_COPY_AND_ASSIGN(Delegate);
35 QuicP2PStream(QuicStreamId id, QuicSession* session);
37 ~QuicP2PStream() override;
39 // ReliableQuicStream overrides.
40 void OnDataAvailable() override;
41 void OnClose() override;
42 void OnCanWrite() override;
43 QuicPriority EffectivePriority() const override;
45 void WriteHeader(base::StringPiece data);
47 int Write(base::StringPiece data, const CompletionCallback& callback);
49 void SetDelegate(Delegate* delegate);
50 Delegate* GetDelegate() { return delegate_; }
52 private:
53 Delegate* delegate_ = nullptr;
55 QuicPriority priority_ = 0;
57 CompletionCallback write_callback_;
58 int last_write_size_ = 0;
60 DISALLOW_COPY_AND_ASSIGN(QuicP2PStream);
63 } // namespace net
65 #endif // NET_QUIC_P2P_QUIC_P2P_STREAM_H_