| OLD | NEW |
| 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_PACKET_WRITER_H_ | 5 #ifndef BLIMP_NET_PACKET_WRITER_H_ |
| 6 #define BLIMP_NET_PACKET_WRITER_H_ | 6 #define BLIMP_NET_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 "blimp/net/blimp_net_export.h" | 11 #include "blimp/net/blimp_net_export.h" |
| 12 #include "net/base/completion_callback.h" | 12 #include "net/base/completion_callback.h" |
| 13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
| 14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 15 | 15 |
| 16 namespace blimp { | 16 namespace blimp { |
| 17 | 17 |
| 18 class BlimpConnectionDetails; |
| 19 |
| 18 // Interface to describe a writer which can write variable-length data packets | 20 // Interface to describe a writer which can write variable-length data packets |
| 19 // to a connection. | 21 // to a connection. |
| 20 class BLIMP_NET_EXPORT PacketWriter { | 22 class BLIMP_NET_EXPORT PacketWriter { |
| 21 public: | 23 public: |
| 22 virtual ~PacketWriter() {} | 24 virtual ~PacketWriter() {} |
| 23 | 25 |
| 24 // Invokes |cb| with net::OK if the write operation executed successfully. | 26 // Invokes |cb| with net::OK if the write operation executed successfully. |
| 25 // All other values indicate unrecoverable errors. | 27 // All other values indicate unrecoverable errors. |
| 26 // |callback| must not be invoked if |this| is deleted. | 28 // |callback| must not be invoked if |this| is deleted. |
| 27 virtual void WritePacket(const scoped_refptr<net::DrainableIOBuffer>& data, | 29 virtual void WritePacket(const scoped_refptr<net::DrainableIOBuffer>& data, |
| 28 const net::CompletionCallback& callback) = 0; | 30 const net::CompletionCallback& callback) = 0; |
| 31 |
| 32 void SetBlimpConnectionDetails(BlimpConnectionDetails* details) { |
| 33 connection_details_ = details; |
| 34 } |
| 35 |
| 36 protected: |
| 37 BlimpConnectionDetails* connection_details_ = nullptr; |
| 29 }; | 38 }; |
| 30 | 39 |
| 31 } // namespace blimp | 40 } // namespace blimp |
| 32 | 41 |
| 33 #endif // BLIMP_NET_PACKET_WRITER_H_ | 42 #endif // BLIMP_NET_PACKET_WRITER_H_ |
| OLD | NEW |