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

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: Addressed Kevin's comments 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
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).
Kevin M 2016/05/24 21:49:00 Document |statistics| and lifetime requirements
33 explicit StreamPacketWriter(net::StreamSocket* socket); 34 explicit StreamPacketWriter(net::StreamSocket* socket,
Kevin M 2016/05/24 21:49:01 Remove "explicit" for >1 arg constructors, in here
shaktisahu 2016/05/24 22:42:14 Done.
35 BlimpConnectionStatistics* statistics);
34 36
35 ~StreamPacketWriter() override; 37 ~StreamPacketWriter() override;
36 38
37 // PacketWriter implementation. 39 // PacketWriter implementation.
38 void WritePacket(const scoped_refptr<net::DrainableIOBuffer>& data, 40 void WritePacket(const scoped_refptr<net::DrainableIOBuffer>& data,
39 const net::CompletionCallback& callback) override; 41 const net::CompletionCallback& callback) override;
40 42
41 private: 43 private:
42 enum class WriteState { 44 enum class WriteState {
43 IDLE, 45 IDLE,
(...skipping 16 matching lines...) Expand all
60 // Invokes |callback_| on packet write completion or on error. 62 // Invokes |callback_| on packet write completion or on error.
61 void OnWriteComplete(int result); 63 void OnWriteComplete(int result);
62 64
63 WriteState write_state_; 65 WriteState write_state_;
64 66
65 net::StreamSocket* socket_; 67 net::StreamSocket* socket_;
66 68
67 scoped_refptr<net::DrainableIOBuffer> payload_buffer_; 69 scoped_refptr<net::DrainableIOBuffer> payload_buffer_;
68 scoped_refptr<net::DrainableIOBuffer> header_buffer_; 70 scoped_refptr<net::DrainableIOBuffer> header_buffer_;
69 net::CompletionCallback callback_; 71 net::CompletionCallback callback_;
72 BlimpConnectionStatistics* statistics_;
70 73
71 base::WeakPtrFactory<StreamPacketWriter> weak_factory_; 74 base::WeakPtrFactory<StreamPacketWriter> weak_factory_;
72 75
73 DISALLOW_COPY_AND_ASSIGN(StreamPacketWriter); 76 DISALLOW_COPY_AND_ASSIGN(StreamPacketWriter);
74 }; 77 };
75 78
76 } // namespace blimp 79 } // namespace blimp
77 80
78 #endif // BLIMP_NET_STREAM_PACKET_WRITER_H_ 81 #endif // BLIMP_NET_STREAM_PACKET_WRITER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698