Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: blimp/net/stream_packet_writer.h

Issue 2008283004: Revert of Added a debug info UI for Blimp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « blimp/net/stream_packet_reader_unittest.cc ('k') | blimp/net/stream_packet_writer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 #ifndef BLIMP_NET_STREAM_PACKET_WRITER_H_ 5 #ifndef BLIMP_NET_STREAM_PACKET_WRITER_H_
6 #define BLIMP_NET_STREAM_PACKET_WRITER_H_ 6 #define BLIMP_NET_STREAM_PACKET_WRITER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/threading/thread_checker.h" 12 #include "base/threading/thread_checker.h"
13 #include "blimp/net/blimp_net_export.h" 13 #include "blimp/net/blimp_net_export.h"
14 #include "blimp/net/packet_writer.h" 14 #include "blimp/net/packet_writer.h"
15 #include "net/base/completion_callback.h" 15 #include "net/base/completion_callback.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 17
18 namespace net { 18 namespace net {
19 class DrainableIOBuffer; 19 class DrainableIOBuffer;
20 class StreamSocket; 20 class StreamSocket;
21 } // namespace net 21 } // namespace net
22 22
23 namespace blimp { 23 namespace blimp {
24 class BlimpConnectionStatistics;
25 24
26 // Writes opaque length-prefixed packets to a StreamSocket. 25 // Writes opaque length-prefixed packets to a StreamSocket.
27 // The header segment is 32-bit, encoded in network byte order. 26 // The header segment is 32-bit, encoded in network byte order.
28 // The body segment length is specified in the header (should be capped at 27 // The body segment length is specified in the header (should be capped at
29 // kMaxPacketPayloadSizeBytes). 28 // kMaxPacketPayloadSizeBytes).
30 class BLIMP_NET_EXPORT StreamPacketWriter : public PacketWriter { 29 class BLIMP_NET_EXPORT StreamPacketWriter : public PacketWriter {
31 public: 30 public:
32 // |socket|: The socket to write packets to. The caller must ensure |socket| 31 // |socket|: The socket to write packets to. The caller must ensure |socket|
33 // is valid while the reader is in-use (see ReadPacket below). 32 // is valid while the reader is in-use (see ReadPacket below).
34 // |statistics|: Statistics collector which keeps track of number of bytes 33 explicit StreamPacketWriter(net::StreamSocket* socket);
35 // written. |statistics| is expected to outlive |this|.
36 StreamPacketWriter(net::StreamSocket* socket,
37 BlimpConnectionStatistics* statistics);
38 34
39 ~StreamPacketWriter() override; 35 ~StreamPacketWriter() override;
40 36
41 // PacketWriter implementation. 37 // PacketWriter implementation.
42 void WritePacket(const scoped_refptr<net::DrainableIOBuffer>& data, 38 void WritePacket(const scoped_refptr<net::DrainableIOBuffer>& data,
43 const net::CompletionCallback& callback) override; 39 const net::CompletionCallback& callback) override;
44 40
45 private: 41 private:
46 enum class WriteState { 42 enum class WriteState {
47 IDLE, 43 IDLE,
(...skipping 16 matching lines...) Expand all
64 // Invokes |callback_| on packet write completion or on error. 60 // Invokes |callback_| on packet write completion or on error.
65 void OnWriteComplete(int result); 61 void OnWriteComplete(int result);
66 62
67 WriteState write_state_; 63 WriteState write_state_;
68 64
69 net::StreamSocket* socket_; 65 net::StreamSocket* socket_;
70 66
71 scoped_refptr<net::DrainableIOBuffer> payload_buffer_; 67 scoped_refptr<net::DrainableIOBuffer> payload_buffer_;
72 scoped_refptr<net::DrainableIOBuffer> header_buffer_; 68 scoped_refptr<net::DrainableIOBuffer> header_buffer_;
73 net::CompletionCallback callback_; 69 net::CompletionCallback callback_;
74 BlimpConnectionStatistics* statistics_;
75 70
76 base::WeakPtrFactory<StreamPacketWriter> weak_factory_; 71 base::WeakPtrFactory<StreamPacketWriter> weak_factory_;
77 72
78 DISALLOW_COPY_AND_ASSIGN(StreamPacketWriter); 73 DISALLOW_COPY_AND_ASSIGN(StreamPacketWriter);
79 }; 74 };
80 75
81 } // namespace blimp 76 } // namespace blimp
82 77
83 #endif // BLIMP_NET_STREAM_PACKET_WRITER_H_ 78 #endif // BLIMP_NET_STREAM_PACKET_WRITER_H_
OLDNEW
« no previous file with comments | « blimp/net/stream_packet_reader_unittest.cc ('k') | blimp/net/stream_packet_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698