| 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 MOJO_PUBLIC_CPP_BINDINGS_LIB_PICKLE_BUFFER_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_PICKLE_BUFFER_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_PICKLE_BUFFER_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_PICKLE_BUFFER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 10 #include "mojo/public/cpp/bindings/lib/buffer.h" | 10 #include "mojo/public/cpp/bindings/lib/buffer.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 } | 31 } |
| 32 | 32 |
| 33 size_t data_num_bytes() const { return payload_size(); } | 33 size_t data_num_bytes() const { return payload_size(); } |
| 34 | 34 |
| 35 // Resizes and zeroes the underlying Pickle's capacity. | 35 // Resizes and zeroes the underlying Pickle's capacity. |
| 36 void AllocData(uint32_t num_bytes); | 36 void AllocData(uint32_t num_bytes); |
| 37 | 37 |
| 38 // Resizes the underlying Pickle's capacity without zeroing. | 38 // Resizes the underlying Pickle's capacity without zeroing. |
| 39 void AllocUninitializedData(uint32_t num_bytes); | 39 void AllocUninitializedData(uint32_t num_bytes); |
| 40 | 40 |
| 41 // Buffer: |
| 42 PickleBuffer* AsPickleBuffer() override; |
| 43 |
| 41 private: | 44 private: |
| 42 // Buffer implementation. Note that this may grow the Pickle's capacity if | 45 // Buffer implementation. Note that this may grow the Pickle's capacity if |
| 43 // necessary, but you can avoid this by calling AllocData to preallocate when | 46 // necessary, but you can avoid this by calling AllocData to preallocate when |
| 44 // the final buffer size is known in advance. | 47 // the final buffer size is known in advance. |
| 45 // | 48 // |
| 46 // This guarantees that the returned data is aligned on an 8-byte boundary. | 49 // This guarantees that the returned data is aligned on an 8-byte boundary. |
| 47 void* Allocate(size_t num_bytes) override; | 50 void* Allocate(size_t num_bytes) override; |
| 48 | 51 |
| 49 // TODO(rockot): Stop wasting 8 bytes per buffer. | 52 // TODO(rockot): Stop wasting 8 bytes per buffer. |
| 50 // | 53 // |
| (...skipping 19 matching lines...) Expand all Loading... |
| 70 // claim memory. | 73 // claim memory. |
| 71 size_t allocation_cursor_ = 0; | 74 size_t allocation_cursor_ = 0; |
| 72 | 75 |
| 73 DISALLOW_COPY_AND_ASSIGN(PickleBuffer); | 76 DISALLOW_COPY_AND_ASSIGN(PickleBuffer); |
| 74 }; | 77 }; |
| 75 | 78 |
| 76 } // namespace internal | 79 } // namespace internal |
| 77 } // namespace mojo | 80 } // namespace mojo |
| 78 | 81 |
| 79 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_PICKLE_BUFFER_H_ | 82 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_PICKLE_BUFFER_H_ |
| OLD | NEW |