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

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

Issue 1932083002: Mojo: Use new message APIs to reduce copying (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 7 months 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_PICKLE_BUFFER_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_PICKLE_BUFFER_H_
7
8 #include <stddef.h>
9
10 #include <memory>
11
12 #include "base/macros.h"
13 #include "base/pickle.h"
14 #include "mojo/public/cpp/bindings/lib/buffer.h"
15
16 namespace mojo {
17 namespace internal {
18
19 // An implementation of Buffer which uses base::Pickle for its backing. Note
20 // that this does not use Pickle's header structure at all, instead storing
21 // the complete Message (including header) in the Pickle's payload.
22 class PickleBuffer : public Buffer {
23 public:
24 PickleBuffer(size_t num_bytes, bool zero_initialized);
25 ~PickleBuffer() override;
26
27 const void* data() const;
28
29 void* data() {
30 return const_cast<void*>(static_cast<const PickleBuffer*>(this)->data());
31 }
32
33 size_t data_num_bytes() const;
34
35 base::Pickle* pickle() const;
36
37 private:
38 class Storage;
39
40 // Buffer implementation. Note that this cannot grow the Pickle's capacity and
41 // it is an error to Allocate() more bytes in total than have been
42 // pre-allocated using ReserveCapacity() or ReserveUninitializedCapacity().
43 //
44 // This guarantees that the returned data is aligned on an 8-byte boundary.
45 void* Allocate(size_t num_bytes) override;
46 PickleBuffer* AsPickleBuffer() override;
47
48 std::unique_ptr<Storage> storage_;
49
50 DISALLOW_COPY_AND_ASSIGN(PickleBuffer);
51 };
52
53 } // namespace internal
54 } // namespace mojo
55
56 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_PICKLE_BUFFER_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/native_struct_serialization.h ('k') | mojo/public/cpp/bindings/lib/pickle_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698