1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_FIXED_BUFFER_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_FIXED_BUFFER_H_ 7 8 #include <stddef.h> 9 10 #include "base/compiler_specific.h" 11 #include "base/macros.h" 12 #include "mojo/public/cpp/bindings/bindings_export.h" 13 #include "mojo/public/cpp/bindings/lib/buffer.h" 14 15 namespace mojo { 16 namespace internal { 17 18 // FixedBufferForTesting owns its buffer. The Leak method may be used to steal 19 // the underlying memory. 20 class MOJO_CPP_BINDINGS_EXPORT FixedBufferForTesting NON_EXPORTED_BASE(public Buffer)21 : NON_EXPORTED_BASE(public Buffer) { 22 public: 23 explicit FixedBufferForTesting(size_t size); 24 ~FixedBufferForTesting(); 25 26 // Returns the internal memory owned by the Buffer to the caller. The Buffer 27 // relinquishes its pointer, effectively resetting the state of the Buffer 28 // and leaving the caller responsible for freeing the returned memory address 29 // when no longer needed. 30 void* Leak(); 31 32 private: 33 DISALLOW_COPY_AND_ASSIGN(FixedBufferForTesting); 34 }; 35 36 } // namespace internal 37 } // namespace mojo 38 39 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_FIXED_BUFFER_H_ 40