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

Unified Diff: third_party/WebKit/Source/core/mojo/Mojo.cpp

Issue 2732163002: Implements JS bindings for mojo data pipe. (Closed)
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/mojo/Mojo.cpp
diff --git a/third_party/WebKit/Source/core/mojo/Mojo.cpp b/third_party/WebKit/Source/core/mojo/Mojo.cpp
index f06dc11939b90f6c1bec17ae4f74b19623573478..5e5d4f24b5f9e63e16c655ebf2882f08268f5116 100644
--- a/third_party/WebKit/Source/core/mojo/Mojo.cpp
+++ b/third_party/WebKit/Source/core/mojo/Mojo.cpp
@@ -4,6 +4,8 @@
#include "core/mojo/Mojo.h"
+#include "core/mojo/MojoCreateDataPipeOptions.h"
+#include "core/mojo/MojoCreateDataPipeResult.h"
#include "core/mojo/MojoCreateMessagePipeResult.h"
#include "core/mojo/MojoCreateSharedBufferResult.h"
#include "core/mojo/MojoHandle.h"
@@ -29,6 +31,27 @@ void Mojo::createMessagePipe(MojoCreateMessagePipeResult& resultDict) {
}
// static
+void Mojo::createDataPipe(const MojoCreateDataPipeOptions& optionsDict,
+ MojoCreateDataPipeResult& resultDict) {
+ ::MojoCreateDataPipeOptions options = {0};
+ options.struct_size = sizeof(options);
+ options.flags = MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE;
+ options.element_num_bytes = optionsDict.elementNumBytes();
+ options.capacity_num_bytes = optionsDict.capacityNumBytes();
+
+ mojo::ScopedDataPipeProducerHandle producer;
+ mojo::ScopedDataPipeConsumerHandle consumer;
+ MojoResult result = mojo::CreateDataPipe(&options, &producer, &consumer);
+ resultDict.setResult(result);
+ if (result == MOJO_RESULT_OK) {
+ resultDict.setProducer(
+ MojoHandle::create(mojo::ScopedHandle::From(std::move(producer))));
+ resultDict.setConsumer(
+ MojoHandle::create(mojo::ScopedHandle::From(std::move(consumer))));
+ }
+}
+
+// static
void Mojo::createSharedBuffer(unsigned numBytes,
MojoCreateSharedBufferResult& resultDict) {
MojoCreateSharedBufferOptions* options = nullptr;
« 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