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

Side by Side Diff: third_party/WebKit/Source/core/mojo/Mojo.cpp

Issue 2720873002: Implements JS bindings for mojo shared buffer. (Closed)
Patch Set: rebaseline2 Created 3 years, 9 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #include "core/mojo/Mojo.h" 5 #include "core/mojo/Mojo.h"
6 6
7 #include "core/mojo/MojoCreateMessagePipeResult.h" 7 #include "core/mojo/MojoCreateMessagePipeResult.h"
8 #include "core/mojo/MojoCreateSharedBufferResult.h"
8 #include "core/mojo/MojoHandle.h" 9 #include "core/mojo/MojoHandle.h"
9 10
10 namespace blink { 11 namespace blink {
11 12
12 // static 13 // static
13 void Mojo::createMessagePipe(MojoCreateMessagePipeResult& resultDict) { 14 void Mojo::createMessagePipe(MojoCreateMessagePipeResult& resultDict) {
14 MojoCreateMessagePipeOptions options = {0}; 15 MojoCreateMessagePipeOptions options = {0};
15 options.struct_size = sizeof(::MojoCreateMessagePipeOptions); 16 options.struct_size = sizeof(::MojoCreateMessagePipeOptions);
16 options.flags = MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_NONE; 17 options.flags = MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_NONE;
17 18
18 mojo::ScopedMessagePipeHandle handle0, handle1; 19 mojo::ScopedMessagePipeHandle handle0, handle1;
19 MojoResult result = mojo::CreateMessagePipe(&options, &handle0, &handle1); 20 MojoResult result = mojo::CreateMessagePipe(&options, &handle0, &handle1);
20 21
21 resultDict.setResult(result); 22 resultDict.setResult(result);
22 if (result == MOJO_RESULT_OK) { 23 if (result == MOJO_RESULT_OK) {
23 resultDict.setHandle0( 24 resultDict.setHandle0(
24 MojoHandle::create(mojo::ScopedHandle::From(std::move(handle0)))); 25 MojoHandle::create(mojo::ScopedHandle::From(std::move(handle0))));
25 resultDict.setHandle1( 26 resultDict.setHandle1(
26 MojoHandle::create(mojo::ScopedHandle::From(std::move(handle1)))); 27 MojoHandle::create(mojo::ScopedHandle::From(std::move(handle1))));
27 } 28 }
28 } 29 }
29 30
31 // static
32 void Mojo::createSharedBuffer(unsigned numBytes,
33 MojoCreateSharedBufferResult& resultDict) {
34 MojoCreateSharedBufferOptions* options = nullptr;
35 mojo::Handle handle;
36 MojoResult result =
37 MojoCreateSharedBuffer(options, numBytes, handle.mutable_value());
38
39 resultDict.setResult(result);
40 if (result == MOJO_RESULT_OK) {
41 resultDict.setHandle(MojoHandle::create(mojo::MakeScopedHandle(handle)));
42 }
43 }
44
30 } // namespace blink 45 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/mojo/Mojo.h ('k') | third_party/WebKit/Source/core/mojo/Mojo.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698