summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/mojo
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/core/mojo')
-rw-r--r--chromium/third_party/blink/renderer/core/mojo/DEPS4
-rw-r--r--chromium/third_party/blink/renderer/core/mojo/mojo.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/mojo/mojo_handle.cc29
-rw-r--r--chromium/third_party/blink/renderer/core/mojo/mojo_watcher.cc10
-rw-r--r--chromium/third_party/blink/renderer/core/mojo/test/mojo_interface_interceptor.cc6
5 files changed, 31 insertions, 21 deletions
diff --git a/chromium/third_party/blink/renderer/core/mojo/DEPS b/chromium/third_party/blink/renderer/core/mojo/DEPS
index a3ad46964e4..a3bebdc81a8 100644
--- a/chromium/third_party/blink/renderer/core/mojo/DEPS
+++ b/chromium/third_party/blink/renderer/core/mojo/DEPS
@@ -1,3 +1,5 @@
include_rules = [
- "+mojo/public/cpp/system",
+ "+base/numerics/safe_math.h",
+
+ "+mojo/public",
]
diff --git a/chromium/third_party/blink/renderer/core/mojo/mojo.cc b/chromium/third_party/blink/renderer/core/mojo/mojo.cc
index 4f0e56320fd..ecb71fb76ce 100644
--- a/chromium/third_party/blink/renderer/core/mojo/mojo.cc
+++ b/chromium/third_party/blink/renderer/core/mojo/mojo.cc
@@ -100,8 +100,7 @@ void Mojo::bindInterface(ScriptState* script_state,
const String& interface_name,
MojoHandle* request_handle,
const String& scope) {
- std::string name =
- StringUTF8Adaptor(interface_name).AsStringPiece().as_string();
+ std::string name = interface_name.Utf8();
auto handle =
mojo::ScopedMessagePipeHandle::From(request_handle->TakeHandle());
diff --git a/chromium/third_party/blink/renderer/core/mojo/mojo_handle.cc b/chromium/third_party/blink/renderer/core/mojo/mojo_handle.cc
index b74bf25779e..a2491fcdd63 100644
--- a/chromium/third_party/blink/renderer/core/mojo/mojo_handle.cc
+++ b/chromium/third_party/blink/renderer/core/mojo/mojo_handle.cc
@@ -4,6 +4,9 @@
#include "third_party/blink/renderer/core/mojo/mojo_handle.h"
+#include "base/numerics/safe_math.h"
+#include "mojo/public/c/system/message_pipe.h"
+#include "mojo/public/cpp/bindings/message.h"
#include "mojo/public/cpp/system/message_pipe.h"
#include "third_party/blink/renderer/bindings/core/v8/array_buffer_or_array_buffer_view.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
@@ -50,11 +53,17 @@ MojoWatcher* MojoHandle::watch(ScriptState* script_state,
MojoResult MojoHandle::writeMessage(
ArrayBufferOrArrayBufferView& buffer,
const HeapVector<Member<MojoHandle>>& handles) {
- // mojo::WriteMessageRaw takes ownership of the handles, so release them here.
- Vector<::MojoHandle, kHandleVectorInlineCapacity> raw_handles(handles.size());
- std::transform(
- handles.begin(), handles.end(), raw_handles.begin(),
- [](MojoHandle* handle) { return handle->handle_.release().value(); });
+ Vector<mojo::ScopedHandle, kHandleVectorInlineCapacity> scoped_handles;
+ scoped_handles.ReserveCapacity(handles.size());
+ bool has_invalid_handles = false;
+ for (auto& handle : handles) {
+ if (!handle->handle_.is_valid())
+ has_invalid_handles = true;
+ else
+ scoped_handles.emplace_back(std::move(handle->handle_));
+ }
+ if (has_invalid_handles)
+ return MOJO_RESULT_INVALID_ARGUMENT;
const void* bytes = nullptr;
size_t num_bytes = 0;
@@ -68,9 +77,13 @@ MojoResult MojoHandle::writeMessage(
num_bytes = view->byteLength();
}
- return mojo::WriteMessageRaw(
- mojo::MessagePipeHandle(handle_.get().value()), bytes, num_bytes,
- raw_handles.data(), raw_handles.size(), MOJO_WRITE_MESSAGE_FLAG_NONE);
+ auto message = mojo::Message(
+ base::make_span(static_cast<const uint8_t*>(bytes), num_bytes),
+ base::make_span(scoped_handles));
+ DCHECK(!message.IsNull());
+ return mojo::WriteMessageNew(mojo::MessagePipeHandle(handle_.get().value()),
+ message.TakeMojoMessage(),
+ MOJO_WRITE_MESSAGE_FLAG_NONE);
}
MojoReadMessageResult* MojoHandle::readMessage(
diff --git a/chromium/third_party/blink/renderer/core/mojo/mojo_watcher.cc b/chromium/third_party/blink/renderer/core/mojo/mojo_watcher.cc
index a5ab3f8660a..d4e0652b39d 100644
--- a/chromium/third_party/blink/renderer/core/mojo/mojo_watcher.cc
+++ b/chromium/third_party/blink/renderer/core/mojo/mojo_watcher.cc
@@ -9,8 +9,8 @@
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/mojo/mojo_handle_signals.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
-#include "third_party/blink/renderer/platform/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
+#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
namespace blink {
@@ -25,17 +25,15 @@ MojoWatcher* MojoWatcher::Create(mojo::Handle handle,
// Current clients expect to recieve the initial error returned by MojoWatch
// via watch callback.
//
- // Note that the usage of wrapPersistent is intentional so that the intial
+ // Note that the usage of WrapPersistent is intentional so that the initial
// error is guaranteed to be reported to the client in case where the given
// handle is invalid and garbage collection happens before the callback
// is scheduled.
if (result != MOJO_RESULT_OK) {
watcher->task_runner_->PostTask(
FROM_HERE,
- WTF::Bind(&V8PersistentCallbackFunction<
- V8MojoWatchCallback>::InvokeAndReportException,
- WrapPersistent(ToV8PersistentCallbackFunction(callback)),
- WrapPersistent(watcher), result));
+ WTF::Bind(&V8MojoWatchCallback::InvokeAndReportException,
+ WrapPersistent(callback), WrapPersistent(watcher), result));
}
return watcher;
}
diff --git a/chromium/third_party/blink/renderer/core/mojo/test/mojo_interface_interceptor.cc b/chromium/third_party/blink/renderer/core/mojo/test/mojo_interface_interceptor.cc
index 05ed60bccad..d3868722230 100644
--- a/chromium/third_party/blink/renderer/core/mojo/test/mojo_interface_interceptor.cc
+++ b/chromium/third_party/blink/renderer/core/mojo/test/mojo_interface_interceptor.cc
@@ -55,8 +55,7 @@ void MojoInterfaceInterceptor::start(ExceptionState& exception_state) {
return;
}
- std::string interface_name =
- StringUTF8Adaptor(interface_name_).AsStringPiece().as_string();
+ std::string interface_name = interface_name_.Utf8();
if (process_scope_) {
service_manager::Connector* connector = Platform::Current()->GetConnector();
@@ -100,8 +99,7 @@ void MojoInterfaceInterceptor::stop() {
return;
started_ = false;
- std::string interface_name =
- StringUTF8Adaptor(interface_name_).AsStringPiece().as_string();
+ std::string interface_name = interface_name_.Utf8();
if (process_scope_) {
auto filter = service_manager::ServiceFilter::ByName(