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/BUILD.gn38
-rw-r--r--chromium/third_party/blink/renderer/core/mojo/DIR_METADATA3
-rw-r--r--chromium/third_party/blink/renderer/core/mojo/OWNERS1
-rw-r--r--chromium/third_party/blink/renderer/core/mojo/mojo.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/mojo/mojo_handle.cc6
-rw-r--r--chromium/third_party/blink/renderer/core/mojo/mojo_watcher.cc13
-rw-r--r--chromium/third_party/blink/renderer/core/mojo/mojo_watcher.h6
-rw-r--r--chromium/third_party/blink/renderer/core/mojo/test/mojo_interface_interceptor.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/mojo/test/mojo_interface_interceptor.h2
-rw-r--r--chromium/third_party/blink/renderer/core/mojo/tests/js_to_cpp.mojom61
10 files changed, 26 insertions, 110 deletions
diff --git a/chromium/third_party/blink/renderer/core/mojo/BUILD.gn b/chromium/third_party/blink/renderer/core/mojo/BUILD.gn
deleted file mode 100644
index ecbb304b5fa..00000000000
--- a/chromium/third_party/blink/renderer/core/mojo/BUILD.gn
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import("//mojo/public/tools/bindings/mojom.gni")
-import("//third_party/blink/renderer/core/core.gni")
-
-source_set("unit_tests") {
- testonly = true
- sources = [ "tests/js_to_cpp_test.cc" ]
-
- data = [ "tests/JsToCppTest.js" ]
-
- configs += [
- "//third_party/blink/renderer/core:blink_core_pch",
- "//third_party/blink/renderer:config",
- "//third_party/blink/renderer:inside_blink",
- ]
-
- deps = [
- ":test_bindings_blink",
- "//mojo/public/cpp/bindings",
- "//testing/gtest",
- "//third_party/blink/renderer/controller:blink_bindings_test_sources",
- "//third_party/blink/renderer/core:core",
- "//third_party/blink/renderer/core:testing",
- "//third_party/blink/renderer/platform:test_support",
- ]
-
- data_deps = [
- ":test_bindings_js_data_deps",
- "//mojo/public/js:bindings",
- ]
-}
-
-mojom("test_bindings") {
- sources = [ "tests/js_to_cpp.mojom" ]
-}
diff --git a/chromium/third_party/blink/renderer/core/mojo/DIR_METADATA b/chromium/third_party/blink/renderer/core/mojo/DIR_METADATA
new file mode 100644
index 00000000000..92214b2320a
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/mojo/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "Internals>Mojo"
+}
diff --git a/chromium/third_party/blink/renderer/core/mojo/OWNERS b/chromium/third_party/blink/renderer/core/mojo/OWNERS
index 8df388c3640..e69de29bb2d 100644
--- a/chromium/third_party/blink/renderer/core/mojo/OWNERS
+++ b/chromium/third_party/blink/renderer/core/mojo/OWNERS
@@ -1 +0,0 @@
-# COMPONENT: Internals>Mojo
diff --git a/chromium/third_party/blink/renderer/core/mojo/mojo.cc b/chromium/third_party/blink/renderer/core/mojo/mojo.cc
index 28de5f1938d..5a25af41c61 100644
--- a/chromium/third_party/blink/renderer/core/mojo/mojo.cc
+++ b/chromium/third_party/blink/renderer/core/mojo/mojo.cc
@@ -65,7 +65,7 @@ MojoCreateDataPipeResult* Mojo::createDataPipe(
mojo::ScopedDataPipeProducerHandle producer;
mojo::ScopedDataPipeConsumerHandle consumer;
- MojoResult result = mojo::CreateDataPipe(&options, &producer, &consumer);
+ MojoResult result = mojo::CreateDataPipe(&options, producer, consumer);
result_dict->setResult(result);
if (result == MOJO_RESULT_OK) {
result_dict->setProducer(MakeGarbageCollected<MojoHandle>(
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 8f61701fd46..a6bb3032531 100644
--- a/chromium/third_party/blink/renderer/core/mojo/mojo_handle.cc
+++ b/chromium/third_party/blink/renderer/core/mojo/mojo_handle.cc
@@ -72,7 +72,7 @@ MojoResult MojoHandle::writeMessage(
bytes = array->Data();
num_bytes = array->ByteLength();
} else {
- DOMArrayBufferView* view = buffer.GetAsArrayBufferView().View();
+ DOMArrayBufferView* view = buffer.GetAsArrayBufferView().Get();
bytes = view->BaseAddress();
num_bytes = view->byteLength();
}
@@ -156,7 +156,7 @@ MojoWriteDataResult* MojoHandle::writeData(
elements = array->Data();
checked_num_bytes = array->ByteLength();
} else {
- DOMArrayBufferView* view = buffer.GetAsArrayBufferView().View();
+ DOMArrayBufferView* view = buffer.GetAsArrayBufferView().Get();
elements = view->BaseAddress();
checked_num_bytes = view->byteLength();
}
@@ -222,7 +222,7 @@ MojoReadDataResult* MojoHandle::readData(
elements = array->Data();
checked_num_bytes = array->ByteLength();
} else {
- DOMArrayBufferView* view = buffer.GetAsArrayBufferView().View();
+ DOMArrayBufferView* view = buffer.GetAsArrayBufferView().Get();
elements = view->BaseAddress();
checked_num_bytes = view->byteLength();
}
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 c7bd5290b8c..b22586872e3 100644
--- a/chromium/third_party/blink/renderer/core/mojo/mojo_watcher.cc
+++ b/chromium/third_party/blink/renderer/core/mojo/mojo_watcher.cc
@@ -89,6 +89,11 @@ MojoResult MojoWatcher::Watch(mojo::Handle handle,
if (result != MOJO_RESULT_OK)
return result;
+ // If MojoAddTrigger succeeded above, we need this object to stay alive at
+ // least until OnHandleReady is invoked with MOJO_RESULT_CANCELLED, which
+ // signals the final invocation by the trap.
+ keep_alive_ = this;
+
handle_ = handle;
MojoResult ready_result;
@@ -137,10 +142,9 @@ MojoResult MojoWatcher::Arm(MojoResult* ready_result) {
// static
void MojoWatcher::OnHandleReady(const MojoTrapEvent* event) {
- // It is safe to assume the MojoWathcer still exists. It stays alive at least
- // as long as |handle_| is valid, and |handle_| is only reset after we
- // dispatch a |MOJO_RESULT_CANCELLED| notification. That is always the last
- // notification received by this callback.
+ // It is safe to assume the MojoWathcer still exists, because we keep it alive
+ // until we've dispatched MOJO_RESULT_CANCELLED from here to RunReadyCallback,
+ // and that is always the last notification we'll dispatch.
MojoWatcher* watcher = reinterpret_cast<MojoWatcher*>(event->trigger_context);
PostCrossThreadTask(
*watcher->task_runner_, FROM_HERE,
@@ -152,6 +156,7 @@ void MojoWatcher::OnHandleReady(const MojoTrapEvent* event) {
void MojoWatcher::RunReadyCallback(MojoResult result) {
if (result == MOJO_RESULT_CANCELLED) {
// Last notification.
+ keep_alive_.Clear();
handle_ = mojo::Handle();
// Only dispatch to the callback if this cancellation was implicit due to
diff --git a/chromium/third_party/blink/renderer/core/mojo/mojo_watcher.h b/chromium/third_party/blink/renderer/core/mojo/mojo_watcher.h
index c1ce045f924..a83e72da10e 100644
--- a/chromium/third_party/blink/renderer/core/mojo/mojo_watcher.h
+++ b/chromium/third_party/blink/renderer/core/mojo/mojo_watcher.h
@@ -10,6 +10,11 @@
#include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h"
#include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_observer.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
+#include "third_party/blink/renderer/platform/heap/self_keep_alive.h"
+
+namespace base {
+class SingleThreadTaskRunner;
+} // namespace base
namespace blink {
@@ -50,6 +55,7 @@ class MojoWatcher final : public ScriptWrappable,
static void OnHandleReady(const MojoTrapEvent*);
void RunReadyCallback(MojoResult);
+ SelfKeepAlive<MojoWatcher> keep_alive_{PERSISTENT_FROM_HERE};
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
Member<V8MojoWatchCallback> callback_;
mojo::ScopedTrapHandle trap_handle_;
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 5d669b90821..2c7d62b61ff 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
@@ -4,6 +4,8 @@
#include "third_party/blink/renderer/core/mojo/test/mojo_interface_interceptor.h"
+#include <utility>
+
#include "third_party/blink/public/common/browser_interface_broker_proxy.h"
#include "third_party/blink/public/common/thread_safe_browser_interface_broker_proxy.h"
#include "third_party/blink/public/platform/platform.h"
@@ -140,7 +142,7 @@ void MojoInterfaceInterceptor::OnInterfaceRequest(
->PostTask(
FROM_HERE,
WTF::Bind(&MojoInterfaceInterceptor::DispatchInterfaceRequestEvent,
- WrapPersistent(this), WTF::Passed(std::move(handle))));
+ WrapPersistent(this), std::move(handle)));
}
void MojoInterfaceInterceptor::DispatchInterfaceRequestEvent(
diff --git a/chromium/third_party/blink/renderer/core/mojo/test/mojo_interface_interceptor.h b/chromium/third_party/blink/renderer/core/mojo/test/mojo_interface_interceptor.h
index c4f96747bd8..100c08641cd 100644
--- a/chromium/third_party/blink/renderer/core/mojo/test/mojo_interface_interceptor.h
+++ b/chromium/third_party/blink/renderer/core/mojo/test/mojo_interface_interceptor.h
@@ -5,7 +5,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_MOJO_TEST_MOJO_INTERFACE_INTERCEPTOR_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_MOJO_TEST_MOJO_INTERFACE_INTERCEPTOR_H_
-#include "base/util/type_safety/strong_alias.h"
+#include "base/types/strong_alias.h"
#include "mojo/public/cpp/system/message_pipe.h"
#include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h"
#include "third_party/blink/renderer/core/dom/events/event_listener.h"
diff --git a/chromium/third_party/blink/renderer/core/mojo/tests/js_to_cpp.mojom b/chromium/third_party/blink/renderer/core/mojo/tests/js_to_cpp.mojom
deleted file mode 100644
index ca63916cc4b..00000000000
--- a/chromium/third_party/blink/renderer/core/mojo/tests/js_to_cpp.mojom
+++ /dev/null
@@ -1,61 +0,0 @@
-module js_to_cpp;
-
-// This struct encompasses all of the basic types, so that they
-// may be sent from C++ to JS and back for validation.
-struct EchoArgs {
- int64 si64;
- int32 si32;
- int16 si16;
- int8 si8;
- uint64 ui64;
- uint32 ui32;
- uint16 ui16;
- uint8 ui8;
- float float_val;
- float float_inf;
- float float_nan;
- double double_val;
- double double_inf;
- double double_nan;
- string? name;
- array<string>? string_array;
- handle<message_pipe>? message_handle;
- handle<data_pipe_consumer>? data_handle;
-};
-
-struct EchoArgsList {
- EchoArgsList? next;
- EchoArgs? item;
-};
-
-interface ForTesting {};
-
-// Note: For messages which control test flow, pick numbers that are unlikely
-// to be hit as a result of our deliberate corruption of response messages.
-interface CppSide {
- // Sent for all tests to notify that the JS side is now ready.
- StartTest@88888888();
-
- // Indicates end for echo, bit-flip, and back-pointer tests.
- TestFinished@99999999();
-
- // Responses from specific tests.
- PingResponse();
- EchoResponse(EchoArgsList list);
-
- // Having an associated remote in the message makes sure the message header
- // version 2 is tested.
- BitFlipResponse(EchoArgsList arg,
- pending_associated_remote<ForTesting>? not_used);
-
- BackPointerResponse(EchoArgsList arg);
-};
-
-interface JsSide {
- SetCppSide(pending_remote<CppSide> cpp);
-
- Ping();
- Echo(int32 numIterations, EchoArgs arg);
- BitFlip(EchoArgs arg);
- BackPointer(EchoArgs arg);
-};