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

Side by Side Diff: mojo/public/cpp/bindings/lib/fixed_buffer.h

Issue 1524613002: [mojo] Use base::Pickle for Message storage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: happy compiler happy robots Created 5 years 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
« no previous file with comments | « mojo/public/cpp/bindings/lib/buffer.h ('k') | mojo/public/cpp/bindings/lib/fixed_buffer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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_FIXED_BUFFER_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_FIXED_BUFFER_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_FIXED_BUFFER_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_FIXED_BUFFER_H_
7 7
8 #include "mojo/public/cpp/bindings/lib/buffer.h" 8 #include "mojo/public/cpp/bindings/lib/buffer.h"
9 #include "mojo/public/cpp/system/macros.h" 9 #include "mojo/public/cpp/system/macros.h"
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // |size| should be aligned using internal::Align. 42 // |size| should be aligned using internal::Align.
43 void Initialize(void* memory, size_t size); 43 void Initialize(void* memory, size_t size);
44 44
45 size_t size() const { return size_; } 45 size_t size() const { return size_; }
46 46
47 // Grows the buffer by |num_bytes| and returns a pointer to the start of the 47 // Grows the buffer by |num_bytes| and returns a pointer to the start of the
48 // addition. The resulting address is 8-byte aligned, and the content of the 48 // addition. The resulting address is 8-byte aligned, and the content of the
49 // memory is zero-filled. 49 // memory is zero-filled.
50 void* Allocate(size_t num_bytes) override; 50 void* Allocate(size_t num_bytes) override;
51 51
52 PickleBuffer* AsPickleBuffer() override;
53
52 protected: 54 protected:
53 char* ptr_; 55 char* ptr_;
54 size_t cursor_; 56 size_t cursor_;
55 size_t size_; 57 size_t size_;
56 58
57 MOJO_DISALLOW_COPY_AND_ASSIGN(FixedBuffer); 59 MOJO_DISALLOW_COPY_AND_ASSIGN(FixedBuffer);
58 }; 60 };
59 61
60 class FixedBufferForTesting : public FixedBuffer { 62 class FixedBufferForTesting : public FixedBuffer {
61 public: 63 public:
62 explicit FixedBufferForTesting(size_t size); 64 explicit FixedBufferForTesting(size_t size);
63 ~FixedBufferForTesting() override; 65 ~FixedBufferForTesting() override;
64 66
65 // Returns the internal memory owned by the Buffer to the caller. The Buffer 67 // Returns the internal memory owned by the Buffer to the caller. The Buffer
66 // relinquishes its pointer, effectively resetting the state of the Buffer 68 // relinquishes its pointer, effectively resetting the state of the Buffer
67 // and leaving the caller responsible for freeing the returned memory address 69 // and leaving the caller responsible for freeing the returned memory address
68 // when no longer needed. 70 // when no longer needed.
69 void* Leak(); 71 void* Leak();
70 72
71 private: 73 private:
72 MOJO_DISALLOW_COPY_AND_ASSIGN(FixedBufferForTesting); 74 MOJO_DISALLOW_COPY_AND_ASSIGN(FixedBufferForTesting);
73 }; 75 };
74 76
75 } // namespace internal 77 } // namespace internal
76 } // namespace mojo 78 } // namespace mojo
77 79
78 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_FIXED_BUFFER_H_ 80 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_FIXED_BUFFER_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/buffer.h ('k') | mojo/public/cpp/bindings/lib/fixed_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698