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

Side by Side Diff: mojo/public/cpp/bindings/lib/message_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
« no previous file with comments | « mojo/public/cpp/bindings/lib/message.cc ('k') | mojo/public/cpp/bindings/lib/message_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
(Empty)
1 // Copyright 2016 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_MESSAGE_LIB_MESSAGE_BUFFER_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_LIB_MESSAGE_BUFFER_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include <utility>
12
13 #include "base/macros.h"
14 #include "mojo/public/cpp/bindings/lib/buffer.h"
15 #include "mojo/public/cpp/system/message.h"
16
17 namespace mojo {
18 namespace internal {
19
20 // A fixed-size Buffer implementation using a Mojo message object for storage.
21 class MessageBuffer : public Buffer {
22 public:
23 // Initializes this buffer to carry a fixed byte capacity and no handles.
24 MessageBuffer(size_t capacity, bool zero_initialized);
25
26 // Initializes this buffer from an existing Mojo MessageHandle.
27 MessageBuffer(ScopedMessageHandle message, uint32_t num_bytes);
28
29 ~MessageBuffer() override;
30
31 void* data() const { return buffer_; }
32 uint32_t data_num_bytes() const { return data_num_bytes_; }
33
34 // Buffer:
35 void* Allocate(size_t delta) override;
36
37 ScopedMessageHandle TakeMessage() { return std::move(message_); }
38
39 private:
40 uint32_t data_num_bytes_ = 0;
41 ScopedMessageHandle message_;
42 void* buffer_;
43
44 uint32_t bytes_claimed_ = 0;
45
46 DISALLOW_COPY_AND_ASSIGN(MessageBuffer);
47 };
48
49 } // namespace internal
50 } // namespace mojo
51
52 #endif // MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_LIB_MESSAGE_BUFFER_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/message.cc ('k') | mojo/public/cpp/bindings/lib/message_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698