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

Side by Side Diff: mojo/public/cpp/system/buffer.cc

Issue 2036053002: Mojo: Add a C++-style SharedBuffer API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/system/buffer.h ('k') | mojo/public/cpp/system/handle.h » ('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 #include "mojo/public/cpp/system/buffer.h"
6
7 namespace mojo {
8
9 ScopedSharedBufferHandle SharedBufferHandle::Clone(bool read_only) const {
Ken Rockot(use gerrit already) 2016/06/03 20:14:35 optional nit: Maybe add an enum in SharedBufferHan
Sam McNally 2016/06/05 23:49:20 Done.
10 ScopedSharedBufferHandle result;
11 if (!is_valid())
12 return result;
13
14 MojoDuplicateBufferHandleOptions options = {
15 sizeof(options), MOJO_DUPLICATE_BUFFER_HANDLE_OPTIONS_FLAG_NONE};
16 if (read_only)
17 options.flags |= MOJO_DUPLICATE_BUFFER_HANDLE_OPTIONS_FLAG_READ_ONLY;
18 SharedBufferHandle result_handle;
19 MojoDuplicateBufferHandle(value(), &options, result_handle.mutable_value());
20 result.reset(result_handle);
21 return result;
22 }
23
24 ScopedSharedBufferMapping SharedBufferHandle::Map(uint64_t size) const {
25 return MapAtOffset(size, 0);
26 }
27
28 ScopedSharedBufferMapping SharedBufferHandle::MapAtOffset(
29 uint64_t size,
30 uint64_t offset) const {
31 void* buffer = nullptr;
32 MojoMapBuffer(value(), offset, size, &buffer, MOJO_MAP_BUFFER_FLAG_NONE);
33 return ScopedSharedBufferMapping(buffer);
34 }
35
36 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/system/buffer.h ('k') | mojo/public/cpp/system/handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698