Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / net / tools / quic / quic_spdy_client_stream.h
blobdd2f9d29c62e5b7b4135722930bfd1c5e4f800d9
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.
5 #ifndef NET_TOOLS_QUIC_QUIC_SPDY_CLIENT_STREAM_H_
6 #define NET_TOOLS_QUIC_QUIC_SPDY_CLIENT_STREAM_H_
8 #include <sys/types.h>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "base/strings/string_piece.h"
13 #include "net/quic/quic_data_stream.h"
14 #include "net/quic/quic_protocol.h"
15 #include "net/spdy/spdy_framer.h"
17 namespace net {
18 namespace tools {
20 class QuicClientSession;
22 // All this does right now is send an SPDY request, and aggregate the
23 // SPDY response.
24 class QuicSpdyClientStream : public QuicDataStream {
25 public:
26 QuicSpdyClientStream(QuicStreamId id, QuicClientSession* session);
27 ~QuicSpdyClientStream() override;
29 // Override the base class to close the write side as soon as we get a
30 // response.
31 // SPDY/HTTP does not support bidirectional streaming.
32 void OnStreamFrame(const QuicStreamFrame& frame) override;
34 // Override the base class to store the size of the headers.
35 void OnStreamHeadersComplete(bool fin, size_t frame_len) override;
37 // ReliableQuicStream implementation called by the session when there's
38 // data for us.
39 uint32 ProcessData(const char* data, uint32 data_len) override;
41 // Serializes the headers and body, sends it to the server, and
42 // returns the number of bytes sent.
43 size_t SendRequest(const SpdyHeaderBlock& headers,
44 base::StringPiece body,
45 bool fin);
47 // Sends body data to the server, or buffers if it can't be sent immediately.
48 void SendBody(const std::string& data, bool fin);
49 // As above, but |delegate| will be notified once |data| is ACKed.
50 void SendBody(const std::string& data,
51 bool fin,
52 QuicAckNotifier::DelegateInterface* delegate);
54 // Returns the response data.
55 const std::string& data() { return data_; }
57 // Returns whatever headers have been received for this stream.
58 const SpdyHeaderBlock& headers() { return response_headers_; }
60 size_t header_bytes_read() const { return header_bytes_read_; }
62 size_t header_bytes_written() const { return header_bytes_written_; }
64 int response_code() const { return response_code_; }
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.
68 using QuicDataStream::set_priority;
70 private:
71 bool ParseResponseHeaders(const char* data, uint32 data_len);
73 // The parsed headers received from the server.
74 SpdyHeaderBlock response_headers_;
75 // The parsed content-length, or -1 if none is specified.
76 int content_length_;
77 int response_code_;
78 std::string data_;
79 size_t header_bytes_read_;
80 size_t header_bytes_written_;
82 DISALLOW_COPY_AND_ASSIGN(QuicSpdyClientStream);
85 } // namespace tools
86 } // namespace net
88 #endif // NET_TOOLS_QUIC_QUIC_SPDY_CLIENT_STREAM_H_