| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 LIBRARIES_NACL_IO_SOCKET_PACKET_H_ | 5 #ifndef LIBRARIES_NACL_IO_SOCKET_PACKET_H_ |
| 6 #define LIBRARIES_NACL_IO_SOCKET_PACKET_H_ | 6 #define LIBRARIES_NACL_IO_SOCKET_PACKET_H_ |
| 7 | 7 |
| 8 #include "nacl_io/fifo_interface.h" | 8 #include "nacl_io/fifo_interface.h" |
| 9 #include "ppapi/c/pp_resource.h" | 9 #include "ppapi/c/pp_resource.h" |
| 10 | 10 |
| 11 #include "sdk_util/macros.h" | 11 #include "sdk_util/macros.h" |
| 12 | 12 |
| 13 namespace nacl_io { | 13 namespace nacl_io { |
| 14 | 14 |
| 15 class PepperInterface; | 15 class PepperInterface; |
| 16 | 16 |
| 17 // NOTE: The Packet class always owns the buffer and address, either by 'Copy' | 17 // NOTE: The Packet class always owns the buffer and address. |
| 18 // or by 'Take' ownership. | |
| 19 class Packet { | 18 class Packet { |
| 20 public: | 19 public: |
| 21 explicit Packet(PepperInterface* ppapi); | 20 explicit Packet(PepperInterface* ppapi); |
| 22 ~Packet(); | 21 ~Packet(); |
| 23 | 22 |
| 24 // Copy the buffer, and address reference | 23 // Copy the buffer, and address reference |
| 25 void Copy(const void* buffer, size_t len, PP_Resource addr); | 24 void Copy(const void* buffer, size_t len, PP_Resource addr); |
| 26 | 25 |
| 27 // Take ownership the buffer, and address reference | |
| 28 void Take(const void* buffer, size_t len, PP_Resource addr); | |
| 29 | |
| 30 char* buffer() { return buffer_; } | 26 char* buffer() { return buffer_; } |
| 31 PP_Resource addr() { return addr_; } | 27 PP_Resource addr() { return addr_; } |
| 32 size_t len() { return len_; } | 28 size_t len() { return len_; } |
| 33 | 29 |
| 34 private: | 30 private: |
| 35 PepperInterface* ppapi_; | 31 PepperInterface* ppapi_; |
| 36 PP_Resource addr_; | 32 PP_Resource addr_; |
| 37 char* buffer_; | 33 char* buffer_; |
| 38 size_t len_; | 34 size_t len_; |
| 39 | 35 |
| 40 DISALLOW_COPY_AND_ASSIGN(Packet); | 36 DISALLOW_COPY_AND_ASSIGN(Packet); |
| 41 }; | 37 }; |
| 42 | 38 |
| 43 } // namespace nacl_io | 39 } // namespace nacl_io |
| 44 | 40 |
| 45 #endif // LIBRARIES_NACL_IO_SOCKET_PACKET_H_ | 41 #endif // LIBRARIES_NACL_IO_SOCKET_PACKET_H_ |
| OLD | NEW |