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

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

Issue 1962393004: Added a debug info UI for Blimp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added empty implementation for linux client 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;
24 25
25 // Writes opaque length-prefixed packets to a StreamSocket. 26 // Writes opaque length-prefixed packets to a StreamSocket.
26 // The header segment is 32-bit, encoded in network byte order. 27 // The header segment is 32-bit, encoded in network byte order.
27 // The body segment length is specified in the header (should be capped at 28 // The body segment length is specified in the header (should be capped at
28 // kMaxPacketPayloadSizeBytes). 29 // kMaxPacketPayloadSizeBytes).
29 class BLIMP_NET_EXPORT StreamPacketWriter : public PacketWriter { 30 class BLIMP_NET_EXPORT StreamPacketWriter : public PacketWriter {
30 public: 31 public:
31 // |socket|: The socket to write packets to. The caller must ensure |socket| 32 // |socket|: The socket to write packets to. The caller must ensure |socket|
32 // is valid while the reader is in-use (see ReadPacket below). 33 // is valid while the reader is in-use (see ReadPacket below).
33 explicit StreamPacketWriter(net::StreamSocket* socket); 34 // |statistics|: Statistics collector which keeps track of number of bytes
35 // written. |statistics| is expected to outlive |this|.
36 StreamPacketWriter(net::StreamSocket* socket,
37 BlimpConnectionStatistics* statistics);
34 38
35 ~StreamPacketWriter() override; 39 ~StreamPacketWriter() override;
36 40
37 // PacketWriter implementation. 41 // PacketWriter implementation.
38 void WritePacket(const scoped_refptr<net::DrainableIOBuffer>& data, 42 void WritePacket(const scoped_refptr<net::DrainableIOBuffer>& data,
39 const net::CompletionCallback& callback) override; 43 const net::CompletionCallback& callback) override;
40 44
41 private: 45 private:
42 enum class WriteState { 46 enum class WriteState {
43 IDLE, 47 IDLE,
(...skipping 16 matching lines...) Expand all
60 // Invokes |callback_| on packet write completion or on error. 64 // Invokes |callback_| on packet write completion or on error.
61 void OnWriteComplete(int result); 65 void OnWriteComplete(int result);
62 66
63 WriteState write_state_; 67 WriteState write_state_;
64 68
65 net::StreamSocket* socket_; 69 net::StreamSocket* socket_;
66 70
67 scoped_refptr<net::DrainableIOBuffer> payload_buffer_; 71 scoped_refptr<net::DrainableIOBuffer> payload_buffer_;
68 scoped_refptr<net::DrainableIOBuffer> header_buffer_; 72 scoped_refptr<net::DrainableIOBuffer> header_buffer_;
69 net::CompletionCallback callback_; 73 net::CompletionCallback callback_;
74 BlimpConnectionStatistics* statistics_;
70 75
71 base::WeakPtrFactory<StreamPacketWriter> weak_factory_; 76 base::WeakPtrFactory<StreamPacketWriter> weak_factory_;
72 77
73 DISALLOW_COPY_AND_ASSIGN(StreamPacketWriter); 78 DISALLOW_COPY_AND_ASSIGN(StreamPacketWriter);
74 }; 79 };
75 80
76 } // namespace blimp 81 } // namespace blimp
77 82
78 #endif // BLIMP_NET_STREAM_PACKET_WRITER_H_ 83 #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