summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/module_args/mojo.gni3
-rw-r--r--mojo/services/html_viewer/blink_input_events_type_converters.cc91
-rw-r--r--third_party/mojo/src/mojo/public/VERSION2
-rw-r--r--third_party/mojo/src/mojo/public/cpp/bindings/binding.h12
-rw-r--r--third_party/mojo/src/mojo/public/cpp/bindings/tests/BUILD.gn1
-rw-r--r--third_party/mojo/src/mojo/public/cpp/bindings/tests/binding_unittest.cc116
-rw-r--r--third_party/mojo/src/mojo/public/dart/BUILD.gn33
-rw-r--r--third_party/mojo/src/mojo/public/dart/application.dart10
-rw-r--r--third_party/mojo/src/mojo/public/dart/bindings.dart3
-rw-r--r--third_party/mojo/src/mojo/public/dart/core.dart3
-rw-r--r--third_party/mojo/src/mojo/public/dart/internal.dart14
-rw-r--r--third_party/mojo/src/mojo/public/dart/rules.gni46
-rw-r--r--third_party/mojo/src/mojo/public/dart/src/buffer.dart35
-rw-r--r--third_party/mojo/src/mojo/public/dart/src/data_pipe.dart39
-rw-r--r--third_party/mojo/src/mojo/public/dart/src/event_stream.dart30
-rw-r--r--third_party/mojo/src/mojo/public/dart/src/handle.dart29
-rw-r--r--third_party/mojo/src/mojo/public/dart/src/handle_watcher.dart148
-rw-r--r--third_party/mojo/src/mojo/public/dart/src/message_pipe.dart16
-rw-r--r--third_party/mojo/src/mojo/public/dart/src/natives.dart70
-rw-r--r--third_party/mojo/src/mojo/public/dart/src/proxy.dart15
-rw-r--r--third_party/mojo/src/mojo/public/dart/src/stub.dart36
-rw-r--r--third_party/mojo/src/mojo/public/dart/src/timer_queue.dart6
-rw-r--r--third_party/mojo/src/mojo/public/interfaces/application/BUILD.gn5
-rw-r--r--third_party/mojo/src/mojo/public/tools/NETWORK_SERVICE_VERSION2
-rw-r--r--third_party/mojo/src/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl8
-rw-r--r--third_party/mojo/src/mojo/public/tools/bindings/generators/dart_templates/module.lib.tmpl5
-rw-r--r--third_party/mojo/src/mojo/public/tools/bindings/mojom.gni9
-rw-r--r--third_party/mojo_services/src/accessibility/public/interfaces/BUILD.gn2
-rw-r--r--third_party/mojo_services/src/clipboard/public/interfaces/BUILD.gn2
-rw-r--r--third_party/mojo_services/src/content_handler/public/interfaces/BUILD.gn2
-rw-r--r--third_party/mojo_services/src/geometry/public/cpp/BUILD.gn2
-rw-r--r--third_party/mojo_services/src/geometry/public/interfaces/BUILD.gn2
-rw-r--r--third_party/mojo_services/src/gpu/public/interfaces/BUILD.gn4
-rw-r--r--third_party/mojo_services/src/http_server/public/cpp/BUILD.gn2
-rw-r--r--third_party/mojo_services/src/http_server/public/interfaces/BUILD.gn2
-rw-r--r--third_party/mojo_services/src/input_events/public/interfaces/BUILD.gn4
-rw-r--r--third_party/mojo_services/src/input_events/public/interfaces/input_event_constants.mojom51
-rw-r--r--third_party/mojo_services/src/input_events/public/interfaces/input_events.mojom58
-rw-r--r--third_party/mojo_services/src/native_viewport/public/cpp/BUILD.gn4
-rw-r--r--third_party/mojo_services/src/native_viewport/public/interfaces/BUILD.gn2
-rw-r--r--third_party/mojo_services/src/navigation/public/interfaces/BUILD.gn2
-rw-r--r--third_party/mojo_services/src/surfaces/public/cpp/BUILD.gn2
-rw-r--r--third_party/mojo_services/src/surfaces/public/interfaces/BUILD.gn2
-rw-r--r--third_party/mojo_services/src/view_manager/public/cpp/BUILD.gn2
-rw-r--r--third_party/mojo_services/src/view_manager/public/interfaces/BUILD.gn2
-rw-r--r--third_party/mojo_services/src/window_manager/public/interfaces/BUILD.gn2
46 files changed, 529 insertions, 407 deletions
diff --git a/build/module_args/mojo.gni b/build/module_args/mojo.gni
index d370cfa..c834325 100644
--- a/build/module_args/mojo.gni
+++ b/build/module_args/mojo.gni
@@ -13,6 +13,9 @@ build_network_service_from_source = true
# depend on the apptest framework.
disable_dart_apptest_framework = true
+# Points to the directory network_service is built from.
+network_service_root = "//mojo/services"
+
declare_args() {
# Specify prebuilt network service mojo file location rather than download
# from gs://mojo.
diff --git a/mojo/services/html_viewer/blink_input_events_type_converters.cc b/mojo/services/html_viewer/blink_input_events_type_converters.cc
index 11434b5..3599df6 100644
--- a/mojo/services/html_viewer/blink_input_events_type_converters.cc
+++ b/mojo/services/html_viewer/blink_input_events_type_converters.cc
@@ -15,6 +15,10 @@ namespace {
// Used for scrolling. This matches Firefox behavior.
const int kPixelsPerTick = 53;
+double EventTimeToWebEventTime(const EventPtr& event) {
+ return base::TimeDelta::FromInternalValue(event->time_stamp).InSecondsF();
+}
+
int EventFlagsToWebEventModifiers(int flags) {
int modifiers = 0;
@@ -57,24 +61,21 @@ int GetClickCount(int flags) {
return 1;
}
+void SetWebMouseEventLocation(const mojo::PointerData& pointer_data,
+ blink::WebMouseEvent* web_event) {
+ web_event->x = static_cast<int>(pointer_data.x);
+ web_event->y = static_cast<int>(pointer_data.y);
+ web_event->globalX = static_cast<int>(pointer_data.screen_x);
+ web_event->globalY = static_cast<int>(pointer_data.screen_y);
+}
+
scoped_ptr<blink::WebInputEvent> BuildWebMouseEventFrom(const EventPtr& event) {
scoped_ptr<blink::WebMouseEvent> web_event(new blink::WebMouseEvent);
- web_event->x = event->location_data->in_view_location->x;
- web_event->y = event->location_data->in_view_location->y;
-
- // TODO(erg): Remove this if check once we can rely on screen_location
- // actually being passed to us. As written today, getting the screen
- // location from ui::Event objects can only be done by querying the
- // underlying native events, so all synthesized events don't have screen
- // locations.
- if (!event->location_data->screen_location.is_null()) {
- web_event->globalX = event->location_data->screen_location->x;
- web_event->globalY = event->location_data->screen_location->y;
- }
+
+ SetWebMouseEventLocation(*(event->pointer_data), web_event.get());
web_event->modifiers = EventFlagsToWebEventModifiers(event->flags);
- web_event->timeStampSeconds =
- base::TimeDelta::FromInternalValue(event->time_stamp).InSecondsF();
+ web_event->timeStampSeconds = EventTimeToWebEventTime(event);
web_event->button = blink::WebMouseEvent::ButtonNone;
if (event->flags & mojo::EVENT_FLAGS_LEFT_MOUSE_BUTTON)
@@ -85,19 +86,13 @@ scoped_ptr<blink::WebInputEvent> BuildWebMouseEventFrom(const EventPtr& event) {
web_event->button = blink::WebMouseEvent::ButtonRight;
switch (event->action) {
- case EVENT_TYPE_MOUSE_PRESSED:
+ case mojo::EVENT_TYPE_POINTER_DOWN:
web_event->type = blink::WebInputEvent::MouseDown;
break;
- case EVENT_TYPE_MOUSE_RELEASED:
+ case mojo::EVENT_TYPE_POINTER_UP:
web_event->type = blink::WebInputEvent::MouseUp;
break;
- case EVENT_TYPE_MOUSE_ENTERED:
- web_event->type = blink::WebInputEvent::MouseLeave;
- web_event->button = blink::WebMouseEvent::ButtonNone;
- break;
- case EVENT_TYPE_MOUSE_EXITED:
- case EVENT_TYPE_MOUSE_MOVED:
- case EVENT_TYPE_MOUSE_DRAGGED:
+ case mojo::EVENT_TYPE_POINTER_MOVE:
web_event->type = blink::WebInputEvent::MouseMove;
break;
default:
@@ -115,8 +110,7 @@ scoped_ptr<blink::WebInputEvent> BuildWebKeyboardEvent(
scoped_ptr<blink::WebKeyboardEvent> web_event(new blink::WebKeyboardEvent);
web_event->modifiers = EventFlagsToWebInputEventModifiers(event->flags);
- web_event->timeStampSeconds =
- base::TimeDelta::FromInternalValue(event->time_stamp).InSecondsF();
+ web_event->timeStampSeconds = EventTimeToWebEventTime(event);
switch (event->action) {
case EVENT_TYPE_KEY_PRESSED:
@@ -149,27 +143,20 @@ scoped_ptr<blink::WebInputEvent> BuildWebMouseWheelEventFrom(
web_event->type = blink::WebInputEvent::MouseWheel;
web_event->button = blink::WebMouseEvent::ButtonNone;
web_event->modifiers = EventFlagsToWebEventModifiers(event->flags);
- web_event->timeStampSeconds =
- base::TimeDelta::FromInternalValue(event->time_stamp).InSecondsF();
+ web_event->timeStampSeconds = EventTimeToWebEventTime(event);
- web_event->x = event->location_data->in_view_location->x;
- web_event->y = event->location_data->in_view_location->y;
-
- // TODO(erg): Remove this null check as parallel to above.
- if (!event->location_data->screen_location.is_null()) {
- web_event->globalX = event->location_data->screen_location->x;
- web_event->globalY = event->location_data->screen_location->y;
- }
+ SetWebMouseEventLocation(*(event->pointer_data), web_event.get());
if ((event->flags & mojo::EVENT_FLAGS_SHIFT_DOWN) != 0 &&
- event->wheel_data->x_offset == 0) {
- web_event->deltaX = event->wheel_data->y_offset;
+ event->pointer_data->horizontal_wheel == 0) {
+ web_event->deltaX = event->pointer_data->horizontal_wheel;
web_event->deltaY = 0;
} else {
- web_event->deltaX = event->wheel_data->x_offset;
- web_event->deltaY = event->wheel_data->y_offset;
+ web_event->deltaX = event->pointer_data->horizontal_wheel;
+ web_event->deltaY = event->pointer_data->vertical_wheel;
}
+ // TODO(sky): resole this, doesn't work for desktop.
web_event->wheelTicksX = web_event->deltaX / kPixelsPerTick;
web_event->wheelTicksY = web_event->deltaY / kPixelsPerTick;
@@ -182,22 +169,22 @@ scoped_ptr<blink::WebInputEvent> BuildWebMouseWheelEventFrom(
scoped_ptr<blink::WebInputEvent>
TypeConverter<scoped_ptr<blink::WebInputEvent>, EventPtr>::Convert(
const EventPtr& event) {
- if (event->action == EVENT_TYPE_MOUSE_PRESSED ||
- event->action == EVENT_TYPE_MOUSE_RELEASED ||
- event->action == EVENT_TYPE_MOUSE_ENTERED ||
- event->action == EVENT_TYPE_MOUSE_EXITED ||
- event->action == EVENT_TYPE_MOUSE_MOVED ||
- event->action == EVENT_TYPE_MOUSE_DRAGGED) {
- return BuildWebMouseEventFrom(event);
- } else if ((event->action == EVENT_TYPE_KEY_PRESSED ||
- event->action == EVENT_TYPE_KEY_RELEASED) &&
+ if (event->action == mojo::EVENT_TYPE_POINTER_DOWN ||
+ event->action == mojo::EVENT_TYPE_POINTER_UP ||
+ event->action == mojo::EVENT_TYPE_POINTER_CANCEL ||
+ event->action == mojo::EVENT_TYPE_POINTER_MOVE) {
+ if (event->pointer_data->horizontal_wheel != 0 ||
+ event->pointer_data->vertical_wheel != 0) {
+ return BuildWebMouseWheelEventFrom(event);
+ }
+ if (event->pointer_data->kind == mojo::POINTER_KIND_MOUSE)
+ return BuildWebMouseEventFrom(event);
+ } else if ((event->action == mojo::EVENT_TYPE_KEY_PRESSED ||
+ event->action == mojo::EVENT_TYPE_KEY_RELEASED) &&
event->key_data) {
return BuildWebKeyboardEvent(event);
- } else if (event->action == EVENT_TYPE_MOUSEWHEEL) {
- return BuildWebMouseWheelEventFrom(event);
}
-
- return scoped_ptr<blink::WebInputEvent>();
+ return nullptr;
}
} // namespace mojo
diff --git a/third_party/mojo/src/mojo/public/VERSION b/third_party/mojo/src/mojo/public/VERSION
index 627bf07..8c8c28b0 100644
--- a/third_party/mojo/src/mojo/public/VERSION
+++ b/third_party/mojo/src/mojo/public/VERSION
@@ -1 +1 @@
-7214b7ec7d27563b2666afad86cf1c5895c56c18 \ No newline at end of file
+cb6c5abfadfea0ca73dca466e2894554ac1ae144 \ No newline at end of file
diff --git a/third_party/mojo/src/mojo/public/cpp/bindings/binding.h b/third_party/mojo/src/mojo/public/cpp/bindings/binding.h
index a982bdb..05a162e 100644
--- a/third_party/mojo/src/mojo/public/cpp/bindings/binding.h
+++ b/third_party/mojo/src/mojo/public/cpp/bindings/binding.h
@@ -50,11 +50,11 @@ namespace mojo {
// waiting for calls to arrive. Normally it is fine to use the default waiter.
// However, the caller may provide their own implementation if needed. The
// |Binding| will not take ownership of the waiter, and the waiter must outlive
-// the |Binding|.
-//
-// TODO(ggowan): Find out under what circumstances the caller may need to
-// provide their own implementation of MojoAsyncWaiter, and then describe those
-// circumstances.
+// the |Binding|. The provided waiter must be able to signal the implementation
+// which generally means it needs to be able to schedule work on the thread the
+// implementation runs on. If writing library code that has to work on different
+// types of threads callers may need to provide different waiter
+// implementations.
template <typename Interface>
class Binding : public ErrorHandler {
public:
@@ -106,7 +106,7 @@ class Binding : public ErrorHandler {
}
// Completes a binding that was constructed with only an interface
- // implementation. Takes ownership of |handle| and binds it to the previously
+ // implementation. Takes ownership of |handle| and binds it to the previously
// specified implementation. See class comment for definition of |waiter|.
void Bind(
ScopedMessagePipeHandle handle,
diff --git a/third_party/mojo/src/mojo/public/cpp/bindings/tests/BUILD.gn b/third_party/mojo/src/mojo/public/cpp/bindings/tests/BUILD.gn
index efd0b38..6d09151 100644
--- a/third_party/mojo/src/mojo/public/cpp/bindings/tests/BUILD.gn
+++ b/third_party/mojo/src/mojo/public/cpp/bindings/tests/BUILD.gn
@@ -9,6 +9,7 @@ mojo_sdk_source_set("tests") {
sources = [
"array_unittest.cc",
+ "binding_unittest.cc",
"bounds_checker_unittest.cc",
"buffer_unittest.cc",
"callback_unittest.cc",
diff --git a/third_party/mojo/src/mojo/public/cpp/bindings/tests/binding_unittest.cc b/third_party/mojo/src/mojo/public/cpp/bindings/tests/binding_unittest.cc
new file mode 100644
index 0000000..2e38f13
--- /dev/null
+++ b/third_party/mojo/src/mojo/public/cpp/bindings/tests/binding_unittest.cc
@@ -0,0 +1,116 @@
+// Copyright 2015 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.
+
+#include "mojo/public/cpp/bindings/binding.h"
+#include "mojo/public/cpp/environment/environment.h"
+#include "mojo/public/cpp/utility/run_loop.h"
+#include "mojo/public/interfaces/bindings/tests/sample_service.mojom.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace mojo {
+namespace {
+
+class ServiceImpl : public sample::Service {
+ public:
+ ServiceImpl() {}
+ ~ServiceImpl() override {}
+
+ private:
+ // sample::Service implementation
+ void Frobinate(sample::FooPtr foo,
+ BazOptions options,
+ sample::PortPtr port,
+ const FrobinateCallback& callback) override {
+ callback.Run(1);
+ }
+ void GetPort(InterfaceRequest<sample::Port> port) override {}
+};
+
+class RecordingErrorHandler : public ErrorHandler {
+ public:
+ RecordingErrorHandler() : error_(false) {}
+ ~RecordingErrorHandler() override {}
+
+ bool encountered_error() const { return error_; }
+
+ private:
+ // ErrorHandler implementation.
+ void OnConnectionError() override { error_ = true; }
+
+ bool error_;
+};
+
+class BindingTest : public testing::Test {
+ public:
+ BindingTest() {}
+ ~BindingTest() override {}
+
+ protected:
+ RecordingErrorHandler handler_;
+ ServiceImpl impl_;
+ Environment env_;
+ RunLoop loop_;
+};
+
+// Tests that destroying a mojo::Binding closes the bound message pipe handle.
+TEST_F(BindingTest, DestroyClosesMessagePipe) {
+ sample::ServicePtr ptr;
+ auto request = GetProxy(&ptr);
+ ptr.set_error_handler(&handler_);
+ bool called = false;
+ auto called_cb = [&called](int32_t result) { called = true; };
+ {
+ Binding<sample::Service> binding(&impl_, request.Pass());
+ ptr->Frobinate(nullptr, sample::Service::BAZ_OPTIONS_REGULAR, nullptr,
+ called_cb);
+ loop_.RunUntilIdle();
+ EXPECT_TRUE(called);
+ EXPECT_FALSE(handler_.encountered_error());
+ }
+ // Now that the Binding is out of scope we should detect an error on the other
+ // end of the pipe.
+ loop_.RunUntilIdle();
+ EXPECT_TRUE(handler_.encountered_error());
+
+ // And calls should fail.
+ called = false;
+ ptr->Frobinate(nullptr, sample::Service::BAZ_OPTIONS_REGULAR, nullptr,
+ called_cb);
+ loop_.RunUntilIdle();
+ EXPECT_FALSE(called);
+}
+
+// Tests that explicitly calling Unbind followed by rebinding works.
+TEST_F(BindingTest, Unbind) {
+ sample::ServicePtr ptr;
+ Binding<sample::Service> binding(&impl_, GetProxy(&ptr));
+
+ bool called = false;
+ auto called_cb = [&called](int32_t result) { called = true; };
+ ptr->Frobinate(nullptr, sample::Service::BAZ_OPTIONS_REGULAR, nullptr,
+ called_cb);
+ loop_.RunUntilIdle();
+ EXPECT_TRUE(called);
+
+ called = false;
+ auto request = binding.Unbind();
+ EXPECT_FALSE(binding.is_bound());
+ // All calls should fail when not bound...
+ ptr->Frobinate(nullptr, sample::Service::BAZ_OPTIONS_REGULAR, nullptr,
+ called_cb);
+ loop_.RunUntilIdle();
+ EXPECT_FALSE(called);
+
+ called = false;
+ binding.Bind(request.Pass());
+ EXPECT_TRUE(binding.is_bound());
+ // ...and should succeed again when the rebound.
+ ptr->Frobinate(nullptr, sample::Service::BAZ_OPTIONS_REGULAR, nullptr,
+ called_cb);
+ loop_.RunUntilIdle();
+ EXPECT_TRUE(called);
+}
+
+} // namespace
+} // mojo
diff --git a/third_party/mojo/src/mojo/public/dart/BUILD.gn b/third_party/mojo/src/mojo/public/dart/BUILD.gn
new file mode 100644
index 0000000..711eee3
--- /dev/null
+++ b/third_party/mojo/src/mojo/public/dart/BUILD.gn
@@ -0,0 +1,33 @@
+import("../mojo_sdk.gni")
+import("rules.gni")
+
+dart_mojo_sdk_sources = [
+ "application.dart",
+ "bindings.dart",
+ "core.dart",
+ "src/application_connection.dart",
+ "src/application.dart",
+ "src/buffer.dart",
+ "src/codec.dart",
+ "src/data_pipe.dart",
+ "src/drain_data.dart",
+ "src/event_stream.dart",
+ "src/handle.dart",
+ "src/message.dart",
+ "src/message_pipe.dart",
+ "src/proxy.dart",
+ "src/struct.dart",
+ "src/stub.dart",
+ "src/types.dart",
+]
+
+dart_package("dart") {
+ # This base dir ensures that Dart's Mojo SDK can be imported with, e.g.,
+ # import 'package:mojo/public/dart/core.dart' even when the Mojo SDK lives
+ # somewhere else in the source tree.
+ base_dir = rebase_path("../../$mojo_root", ".", ".")
+ sources = dart_mojo_sdk_sources
+ deps = [
+ "../interfaces/application",
+ ]
+}
diff --git a/third_party/mojo/src/mojo/public/dart/application.dart b/third_party/mojo/src/mojo/public/dart/application.dart
index ed3bf24..13f7c0b 100644
--- a/third_party/mojo/src/mojo/public/dart/application.dart
+++ b/third_party/mojo/src/mojo/public/dart/application.dart
@@ -7,12 +7,14 @@ library application;
import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';
-import 'dart:mojo.bindings' as bindings;
-import 'dart:mojo.core' as core;
-import 'package:mojo/public/interfaces/application/application.mojom.dart' as application_mojom;
+import 'package:mojo/public/dart/bindings.dart' as bindings;
+import 'package:mojo/public/dart/core.dart' as core;
+import 'package:mojo/public/interfaces/application/application.mojom.dart'
+ as application_mojom;
import 'package:mojo/public/interfaces/application/service_provider.mojom.dart';
-import 'package:mojo/public/interfaces/application/shell.mojom.dart' as shell_mojom;
+import 'package:mojo/public/interfaces/application/shell.mojom.dart'
+ as shell_mojom;
part 'src/application.dart';
part 'src/application_connection.dart';
diff --git a/third_party/mojo/src/mojo/public/dart/bindings.dart b/third_party/mojo/src/mojo/public/dart/bindings.dart
index 642744f..e68afec 100644
--- a/third_party/mojo/src/mojo/public/dart/bindings.dart
+++ b/third_party/mojo/src/mojo/public/dart/bindings.dart
@@ -7,7 +7,8 @@ library bindings;
import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';
-import 'dart:mojo.core' as core;
+
+import 'package:mojo/public/dart/core.dart' as core;
part 'src/codec.dart';
part 'src/message.dart';
diff --git a/third_party/mojo/src/mojo/public/dart/core.dart b/third_party/mojo/src/mojo/public/dart/core.dart
index 6cdbe26..e72da3f 100644
--- a/third_party/mojo/src/mojo/public/dart/core.dart
+++ b/third_party/mojo/src/mojo/public/dart/core.dart
@@ -7,6 +7,7 @@ library core;
import 'dart:async';
import 'dart:collection';
import 'dart:isolate';
+import 'dart:mojo.internal';
import 'dart:typed_data';
part 'src/buffer.dart';
@@ -14,7 +15,5 @@ part 'src/data_pipe.dart';
part 'src/drain_data.dart';
part 'src/event_stream.dart';
part 'src/handle.dart';
-part 'src/handle_watcher.dart';
part 'src/message_pipe.dart';
-part 'src/timer_queue.dart';
part 'src/types.dart';
diff --git a/third_party/mojo/src/mojo/public/dart/internal.dart b/third_party/mojo/src/mojo/public/dart/internal.dart
new file mode 100644
index 0000000..4239df2
--- /dev/null
+++ b/third_party/mojo/src/mojo/public/dart/internal.dart
@@ -0,0 +1,14 @@
+// Copyright 2015 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.
+
+library internal;
+
+import 'dart:async';
+import 'dart:collection';
+import 'dart:isolate';
+import 'dart:typed_data';
+
+part 'src/handle_watcher.dart';
+part 'src/natives.dart';
+part 'src/timer_queue.dart';
diff --git a/third_party/mojo/src/mojo/public/dart/rules.gni b/third_party/mojo/src/mojo/public/dart/rules.gni
index 56c502a..120a738 100644
--- a/third_party/mojo/src/mojo/public/dart/rules.gni
+++ b/third_party/mojo/src/mojo/public/dart/rules.gni
@@ -35,6 +35,9 @@ template("dart_package") {
rebase_base_dir =
rebase_path(get_label_info(":$target_name", "dir"), root_build_dir)
+ if (defined(invoker.base_dir)) {
+ rebase_base_dir = invoker.base_dir
+ }
rebase_inputs = rebase_path(inputs, root_build_dir)
rebase_zip_inputs = rebase_path(zip_inputs, root_build_dir)
rebase_output = rebase_path(output, root_build_dir)
@@ -74,50 +77,9 @@ template("dart_packaged_application") {
rebase_path(package_output),
rebase_path("$target_gen_dir/${target_name}_analyze.stamp"),
"--no-hints",
-
- # The dart bindings refer to the autogenerated application interface in
- # their source code; since that code is then packaged into the image, we
- # need to manually resolve these package urls to the autogenerated code.
- "--url-mapping=package:mojo/public/interfaces/application/application.mojom.dart,/" + rebase_path(
- "mojo/public/interfaces/application/application.mojom.dart",
- "/",
- root_gen_dir + mojo_root),
- "--url-mapping=package:mojo/public/interfaces/application/service_provider.mojom.dart,/" + rebase_path(
- "mojo/public/interfaces/application/service_provider.mojom.dart",
- "/",
- root_gen_dir + mojo_root),
- "--url-mapping=package:mojo/public/interfaces/application/shell.mojom.dart,/" + rebase_path(
- "mojo/public/interfaces/application/shell.mojom.dart",
- "/",
- root_gen_dir + mojo_root),
-
- # If you are trying to use the mojo sdk in another repository, you'll
- # probably also need these url mapping overrides. Users are currently
- # referring to these files with these third_party/mojo/ URLs.
- #
- # (This means that we're referring to the same files through two different
- # URLs, depending on which part of the system we're referring to them from.
- # This is not a good idea.)
- "--url-mapping=package:third_party/mojo/src/mojo/public/interfaces/application/application.mojom.dart,/" + rebase_path(
- "mojo/public/interfaces/application/application.mojom.dart",
- "/",
- root_gen_dir + mojo_root),
- "--url-mapping=package:third_party/mojo/src/mojo/public/interfaces/application/service_provider.mojom.dart,/" + rebase_path(
- "mojo/public/interfaces/application/service_provider.mojom.dart",
- "/",
- root_gen_dir + mojo_root),
- "--url-mapping=package:third_party/mojo/src/mojo/public/interfaces/application/shell.mojom.dart,/" + rebase_path(
- "mojo/public/interfaces/application/shell.mojom.dart",
- "/",
- root_gen_dir + mojo_root),
]
- # Because the standard 'mojo:*' packages depend on the application mojom
- # interface, we must depend on their existence, even though we don't depend
- # directly on them.
- deps = [
- rebase_path("mojo/public/interfaces/application", ".", mojo_root),
- ]
+ deps = []
if (defined(invoker.deps)) {
deps += invoker.deps
}
diff --git a/third_party/mojo/src/mojo/public/dart/src/buffer.dart b/third_party/mojo/src/mojo/public/dart/src/buffer.dart
index 4467315..5e153be 100644
--- a/third_party/mojo/src/mojo/public/dart/src/buffer.dart
+++ b/third_party/mojo/src/mojo/public/dart/src/buffer.dart
@@ -4,25 +4,6 @@
part of core;
-class _MojoSharedBufferNatives {
- static List Create(int numBytes, int flags)
- native "MojoSharedBuffer_Create";
-
- static List Duplicate(int bufferHandle, int flags)
- native "MojoSharedBuffer_Duplicate";
-
- static List Map(MojoSharedBuffer buffer,
- int bufferHandle,
- int offset,
- int numBytes,
- int flags)
- native "MojoSharedBuffer_Map";
-
- static int Unmap(ByteData buffer)
- native "MojoSharedBuffer_Unmap";
-}
-
-
class MojoSharedBuffer {
static const int CREATE_FLAG_NONE = 0;
static const int DUPLICATE_FLAG_NONE = 0;
@@ -32,11 +13,11 @@ class MojoSharedBuffer {
MojoResult status;
ByteData mapping;
- MojoSharedBuffer(
- this.handle, [this.status = MojoResult.OK, this.mapping = null]);
+ MojoSharedBuffer(this.handle,
+ [this.status = MojoResult.OK, this.mapping = null]);
factory MojoSharedBuffer.create(int numBytes, [int flags = 0]) {
- List result = _MojoSharedBufferNatives.Create(numBytes, flags);
+ List result = MojoSharedBufferNatives.Create(numBytes, flags);
if (result == null) {
return null;
}
@@ -52,13 +33,13 @@ class MojoSharedBuffer {
}
factory MojoSharedBuffer.duplicate(MojoSharedBuffer msb, [int flags = 0]) {
- List result = _MojoSharedBufferNatives.Duplicate(msb.handle.h, flags);
+ List result = MojoSharedBufferNatives.Duplicate(msb.handle.h, flags);
if (result == null) {
return null;
}
assert((result is List) && (result.length == 2));
var r = new MojoResult(result[0]);
- if(!r.isOk) {
+ if (!r.isOk) {
return null;
}
@@ -83,8 +64,8 @@ class MojoSharedBuffer {
status = MojoResult.INVALID_ARGUMENT;
return status;
}
- List result = _MojoSharedBufferNatives.Map(
- this, handle.h, offset, numBytes, flags);
+ List result =
+ MojoSharedBufferNatives.Map(this, handle.h, offset, numBytes, flags);
if (result == null) {
status = MojoResult.INVALID_ARGUMENT;
return status;
@@ -96,7 +77,7 @@ class MojoSharedBuffer {
}
MojoResult unmap() {
- int r = _MojoSharedBufferNatives.Unmap(mapping);
+ int r = MojoSharedBufferNatives.Unmap(mapping);
status = new MojoResult(r);
mapping = null;
return status;
diff --git a/third_party/mojo/src/mojo/public/dart/src/data_pipe.dart b/third_party/mojo/src/mojo/public/dart/src/data_pipe.dart
index 7f1666d..884bbcb 100644
--- a/third_party/mojo/src/mojo/public/dart/src/data_pipe.dart
+++ b/third_party/mojo/src/mojo/public/dart/src/data_pipe.dart
@@ -4,29 +4,6 @@
part of core;
-class _MojoDataPipeNatives {
- static List MojoCreateDataPipe(int elementBytes, int capacityBytes,
- int flags) native "MojoDataPipe_Create";
-
- static List MojoWriteData(int handle, ByteData data, int numBytes,
- int flags) native "MojoDataPipe_WriteData";
-
- static List MojoBeginWriteData(int handle, int bufferBytes,
- int flags) native "MojoDataPipe_BeginWriteData";
-
- static int MojoEndWriteData(
- int handle, int bytesWritten) native "MojoDataPipe_EndWriteData";
-
- static List MojoReadData(int handle, ByteData data, int numBytes,
- int flags) native "MojoDataPipe_ReadData";
-
- static List MojoBeginReadData(int handle, int bufferBytes,
- int flags) native "MojoDataPipe_BeginReadData";
-
- static int MojoEndReadData(
- int handle, int bytesRead) native "MojoDataPipe_EndReadData";
-}
-
class MojoDataPipeProducer {
static const int FLAG_NONE = 0;
static const int FLAG_ALL_OR_NONE = 1 << 0;
@@ -45,8 +22,8 @@ class MojoDataPipeProducer {
}
int data_numBytes = (numBytes == -1) ? data.lengthInBytes : numBytes;
- List result = _MojoDataPipeNatives.MojoWriteData(
- handle.h, data, data_numBytes, flags);
+ List result =
+ MojoDataPipeNatives.MojoWriteData(handle.h, data, data_numBytes, flags);
if (result == null) {
status = MojoResult.INVALID_ARGUMENT;
return 0;
@@ -64,7 +41,7 @@ class MojoDataPipeProducer {
}
List result =
- _MojoDataPipeNatives.MojoBeginWriteData(handle.h, bufferBytes, flags);
+ MojoDataPipeNatives.MojoBeginWriteData(handle.h, bufferBytes, flags);
if (result == null) {
status = MojoResult.INVALID_ARGUMENT;
return null;
@@ -80,7 +57,7 @@ class MojoDataPipeProducer {
status = MojoResult.INVALID_ARGUMENT;
return status;
}
- int result = _MojoDataPipeNatives.MojoEndWriteData(handle.h, bytesWritten);
+ int result = MojoDataPipeNatives.MojoEndWriteData(handle.h, bytesWritten);
status = new MojoResult(result);
return status;
}
@@ -110,7 +87,7 @@ class MojoDataPipeConsumer {
int data_numBytes = (numBytes == -1) ? data.lengthInBytes : numBytes;
List result =
- _MojoDataPipeNatives.MojoReadData(handle.h, data, data_numBytes, flags);
+ MojoDataPipeNatives.MojoReadData(handle.h, data, data_numBytes, flags);
if (result == null) {
status = MojoResult.INVALID_ARGUMENT;
return 0;
@@ -127,7 +104,7 @@ class MojoDataPipeConsumer {
}
List result =
- _MojoDataPipeNatives.MojoBeginReadData(handle.h, bufferBytes, flags);
+ MojoDataPipeNatives.MojoBeginReadData(handle.h, bufferBytes, flags);
if (result == null) {
status = MojoResult.INVALID_ARGUMENT;
return null;
@@ -143,7 +120,7 @@ class MojoDataPipeConsumer {
status = MojoResult.INVALID_ARGUMENT;
return status;
}
- int result = _MojoDataPipeNatives.MojoEndReadData(handle.h, bytesRead);
+ int result = MojoDataPipeNatives.MojoEndReadData(handle.h, bytesRead);
status = new MojoResult(result);
return status;
}
@@ -171,7 +148,7 @@ class MojoDataPipe {
factory MojoDataPipe([int elementBytes = DEFAULT_ELEMENT_SIZE,
int capacityBytes = DEFAULT_CAPACITY, int flags = FLAG_NONE]) {
- List result = _MojoDataPipeNatives.MojoCreateDataPipe(
+ List result = MojoDataPipeNatives.MojoCreateDataPipe(
elementBytes, capacityBytes, flags);
if (result == null) {
return null;
diff --git a/third_party/mojo/src/mojo/public/dart/src/event_stream.dart b/third_party/mojo/src/mojo/public/dart/src/event_stream.dart
index 645334e..712d0259 100644
--- a/third_party/mojo/src/mojo/public/dart/src/event_stream.dart
+++ b/third_party/mojo/src/mojo/public/dart/src/event_stream.dart
@@ -64,7 +64,8 @@ class MojoEventStream extends Stream<List<int>> {
_controller.addStream(_receivePort).whenComplete(_controller.close);
if (_signals != MojoHandleSignals.NONE) {
- var res = MojoHandleWatcher.add(_handle, _sendPort, _signals.value);
+ var res = new MojoResult(
+ MojoHandleWatcher.add(_handle.h, _sendPort, _signals.value));
if (!res.isOk) {
throw "MojoHandleWatcher add failed: $res";
}
@@ -78,7 +79,8 @@ class MojoEventStream extends Stream<List<int>> {
void enableSignals(MojoHandleSignals signals) {
_signals = signals;
if (_isListening) {
- var res = MojoHandleWatcher.add(_handle, _sendPort, signals.value);
+ var res = new MojoResult(
+ MojoHandleWatcher.add(_handle.h, _sendPort, signals.value));
if (!res.isOk) {
throw "MojoHandleWatcher add failed: $res";
}
@@ -92,11 +94,13 @@ class MojoEventStream extends Stream<List<int>> {
Future _handleWatcherClose() {
assert(_handle != null);
- return MojoHandleWatcher.close(_handle, wait: true).then((_) {
+ assert(MojoHandle._removeUnclosedHandle(_handle));
+ return MojoHandleWatcher.close(_handle.h, wait: true).then((r) {
if (_receivePort != null) {
_receivePort.close();
_receivePort = null;
}
+ return new MojoResult(r);
});
}
@@ -118,12 +122,13 @@ class MojoEventStream extends Stream<List<int>> {
void _onPauseStateChange() {
if (_controller.isPaused) {
- var res = MojoHandleWatcher.remove(_handle);
+ var res = new MojoResult(MojoHandleWatcher.remove(_handle.h));
if (!res.isOk) {
throw "MojoHandleWatcher add failed: $res";
}
} else {
- var res = MojoHandleWatcher.add(_handle, _sendPort, _signals.value);
+ var res = new MojoResult(
+ MojoHandleWatcher.add(_handle.h, _sendPort, _signals.value));
if (!res.isOk) {
throw "MojoHandleWatcher add failed: $res";
}
@@ -200,21 +205,24 @@ class MojoEventStreamListener {
assert(_eventStream.readyWrite);
handleWrite();
}
- if (_isOpen) {
+ if (!signalsReceived.isPeerClosed) {
_eventStream.enableSignals(signalsWatched);
}
_isInHandler = false;
if (signalsReceived.isPeerClosed) {
- if (onError != null) {
- onError();
- }
- close();
+ // nodefer is true here because there is no need to wait to close until
+ // outstanding messages are sent. The other side is gone.
+ close(nodefer: true).then((_) {
+ if (onError != null) {
+ onError();
+ }
+ });
}
}, onDone: close);
return subscription;
}
- Future close() {
+ Future close({bool nodefer: false}) {
var result;
_isOpen = false;
_endpoint = null;
diff --git a/third_party/mojo/src/mojo/public/dart/src/handle.dart b/third_party/mojo/src/mojo/public/dart/src/handle.dart
index 6b99ed8..e7ac3eb 100644
--- a/third_party/mojo/src/mojo/public/dart/src/handle.dart
+++ b/third_party/mojo/src/mojo/public/dart/src/handle.dart
@@ -4,15 +4,6 @@
part of core;
-class _MojoHandleNatives {
- static int register(MojoEventStream eventStream) native "MojoHandle_Register";
- static int close(int handle) native "MojoHandle_Close";
- static List wait(
- int handle, int signals, int deadline) native "MojoHandle_Wait";
- static List waitMany(List<int> handles, List<int> signals,
- int deadline) native "MojoHandle_WaitMany";
-}
-
class _HandleCreationRecord {
final MojoHandle handle;
final StackTrace stack;
@@ -36,7 +27,7 @@ class MojoHandle {
MojoResult close() {
assert(_removeUnclosedHandle(this));
- int result = _MojoHandleNatives.close(_h);
+ int result = MojoHandleNatives.close(_h);
_h = INVALID;
return new MojoResult(result);
}
@@ -47,8 +38,11 @@ class MojoHandle {
}
MojoWaitResult wait(int signals, int deadline) {
- List result = _MojoHandleNatives.wait(h, signals, deadline);
- return new MojoWaitResult(new MojoResult(result[0]), result[1]);
+ List result = MojoHandleNatives.wait(h, signals, deadline);
+ var state = result[1] != null
+ ? new MojoHandleSignalsState(result[1][0], result[1][1])
+ : null;
+ return new MojoWaitResult(new MojoResult(result[0]), state);
}
bool _ready(MojoHandleSignals signal) {
@@ -89,13 +83,16 @@ class MojoHandle {
static MojoWaitManyResult waitMany(
List<int> handles, List<int> signals, int deadline) {
- List result = _MojoHandleNatives.waitMany(handles, signals, deadline);
- return new MojoWaitManyResult(
- new MojoResult(result[0]), result[1], result[2]);
+ List result = MojoHandleNatives.waitMany(handles, signals, deadline);
+ List states = result[2] != null
+ ? result[2].map((l) => new MojoHandleSignalsState(l[0], l[1])).toList()
+ : null;
+ return new MojoWaitManyResult(new MojoResult(result[0]), result[1], states);
}
static MojoResult register(MojoEventStream eventStream) {
- return new MojoResult(_MojoHandleNatives.register(eventStream));
+ return new MojoResult(
+ MojoHandleNatives.register(eventStream, eventStream._handle.h));
}
static HashMap<int, _HandleCreationRecord> _unclosedHandles = new HashMap();
diff --git a/third_party/mojo/src/mojo/public/dart/src/handle_watcher.dart b/third_party/mojo/src/mojo/public/dart/src/handle_watcher.dart
index 198a9f6..70cc297 100644
--- a/third_party/mojo/src/mojo/public/dart/src/handle_watcher.dart
+++ b/third_party/mojo/src/mojo/public/dart/src/handle_watcher.dart
@@ -2,17 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-part of core;
-
-class _MojoHandleWatcherNatives {
- static int sendControlData(int controlHandle, int mojoHandle, SendPort port,
- int data) native "MojoHandleWatcher_SendControlData";
- static List recvControlData(
- int controlHandle) native "MojoHandleWatcher_RecvControlData";
- static int setControlHandle(
- int controlHandle) native "MojoHandleWatcher_SetControlHandle";
- static int getControlHandle() native "MojoHandleWatcher_GetControlHandle";
-}
+part of internal;
// The MojoHandleWatcher sends a stream of events to application isolates that
// register Mojo handles with it. Application isolates make the following calls:
@@ -36,14 +26,27 @@ class MojoHandleWatcher {
static const int TIMER = 3;
static const int SHUTDOWN = 4;
+ static const int kMojoHandleInvalid = 0;
+ static const int kDeadlineIndefinite = -1;
+
+ static const int kMojoResultOk = 0;
+ static const int kMojoResultDeadlineExceeded = -4;
+ static const int kMojoResultFailedPrecondition = -9;
+
+ static const int kMojoSignalsReadable = (1 << 0);
+ static const int kMojoSignalsWritable = (1 << 1);
+ static const int kMojoSignalsPeerClosed = (1 << 2);
+ static const int kMojoSignalsAll =
+ kMojoSignalsReadable | kMojoSignalsWritable | kMojoSignalsPeerClosed;
+
static int _encodeCommand(int cmd, [int signals = 0]) =>
- (cmd << 3) | (signals & MojoHandleSignals.kAll);
+ (cmd << 3) | (signals & kMojoSignalsAll);
static int _decodeCommand(int cmd) {
- assert(MojoHandleSignals.kAll < 1 << 3);
+ assert(kMojoSignalsAll < 1 << 3);
return cmd >> 3;
}
- static MojoHandleSignals _decodeSignals(int cmd) {
- return new MojoHandleSignals(cmd & MojoHandleSignals.kAll);
+ static int _decodeSignals(int cmd) {
+ return cmd & kMojoSignalsAll;
}
// The Mojo handle over which control messages are sent.
@@ -66,10 +69,6 @@ class MojoHandleWatcher {
// A mapping from Mojo handles to their indices in _handles.
Map<int, int> _handleIndices;
- // Since we are not storing wrapped handles, a dummy handle for when we need
- // a MojoHandle.
- MojoHandle _tempHandle;
-
// Priority queue of timers registered with the watcher.
TimerQueue _timerQueue;
@@ -80,12 +79,11 @@ class MojoHandleWatcher {
_signals = new List<int>(),
_handleIndices = new Map<int, int>(),
_handleCount = 1,
- _tempHandle = new MojoHandle(MojoHandle.INVALID),
_timerQueue = new TimerQueue() {
// Setup control handle.
_handles.add(_controlHandle);
_ports.add(null); // There is no port for the control handle.
- _signals.add(MojoHandleSignals.kReadable);
+ _signals.add(kMojoSignalsReadable);
_handleIndices[_controlHandle] = 0;
}
@@ -93,22 +91,22 @@ class MojoHandleWatcher {
MojoHandleWatcher watcher = new MojoHandleWatcher(consumerHandle);
while (!watcher._shutdown) {
int deadline = watcher._processTimerDeadlines();
- MojoWaitManyResult mwmr =
- MojoHandle.waitMany(watcher._handles, watcher._signals, deadline);
- if (mwmr.result.isOk && mwmr.index == 0) {
+ // mwmr[0]: result, mwmr[1]: index, mwmr[2]: list of signal states.
+ List mwmr = MojoHandleNatives.waitMany(
+ watcher._handles, watcher._signals, deadline);
+ if ((mwmr[0] == kMojoResultOk) && (mwmr[1] == 0)) {
watcher._handleControlMessage();
- } else if (mwmr.result.isOk && (mwmr.index > 0)) {
- int handle = watcher._handles[mwmr.index];
+ } else if ((mwmr[0] == kMojoResultOk) && (mwmr[1] > 0)) {
+ int handle = watcher._handles[mwmr[1]];
// Route event.
- watcher._routeEvent(
- mwmr.states[mwmr.index].satisfied_signals, mwmr.index);
+ watcher._routeEvent(mwmr[2][mwmr[1]][0], mwmr[1]);
// Remove the handle from the list.
watcher._removeHandle(handle);
- } else if (!mwmr.result.isDeadlineExceeded) {
+ } else if (mwmr[0] != kMojoResultDeadlineExceeded) {
// Some handle was closed, but not by us.
// Find it and close it on our side.
- watcher._pruneClosedHandles(mwmr.states);
+ watcher._pruneClosedHandles(mwmr[2]);
}
}
}
@@ -118,7 +116,7 @@ class MojoHandleWatcher {
}
void _handleControlMessage() {
- List result = _MojoHandleWatcherNatives.recvControlData(_controlHandle);
+ List result = MojoHandleWatcherNatives.recvControlData(_controlHandle);
// result[0] = mojo handle if any, or a timer deadline in milliseconds.
// result[1] = SendPort if any.
// result[2] = command << 2 | WRITABLE | READABLE
@@ -147,18 +145,18 @@ class MojoHandleWatcher {
}
}
- void _addHandle(int mojoHandle, SendPort port, MojoHandleSignals signals) {
+ void _addHandle(int mojoHandle, SendPort port, int signals) {
int idx = _handleIndices[mojoHandle];
if (idx == null) {
_handles.add(mojoHandle);
_ports.add(port);
- _signals.add(signals.value);
+ _signals.add(signals);
_handleIndices[mojoHandle] = _handleCount;
_handleCount++;
} else {
assert(_ports[idx] == port);
assert(_handles[idx] == mojoHandle);
- _signals[idx] |= signals.value;
+ _signals[idx] |= signals;
}
}
@@ -200,21 +198,19 @@ class MojoHandleWatcher {
// has already been pruned. This happens when the app isolate has not yet
// received the PEER_CLOSED event. The app isolate will not close the
// handle, so we must do so here.
- _tempHandle._set(mojoHandle);
- _tempHandle.close();
+ MojoHandleNatives.close(mojoHandle);
if (port != null) port.send(null); // Notify that close is done.
return;
}
if (idx == 0) {
throw "The control handle (idx = 0) cannot be closed.";
}
- _tempHandle._set(_handles[idx]);
- _tempHandle.close();
+ MojoHandleNatives.close(_handles[idx]);
if (port != null) port.send(null); // Notify that close is done.
if (pruning) {
// If this handle is being pruned, notify the application isolate
// by sending MojoHandleSignals.PEER_CLOSED.
- _ports[idx].send([_signals[idx], MojoHandleSignals.kPeerClosed]);
+ _ports[idx].send([_signals[idx], kMojoSignalsPeerClosed]);
}
_removeHandle(mojoHandle);
}
@@ -229,28 +225,27 @@ class MojoHandleWatcher {
}
return _timerQueue.hasTimer
? (_timerQueue.currentTimeout - now) * 1000
- : MojoHandle.DEADLINE_INDEFINITE;
+ : kDeadlineIndefinite;
}
void _timer(SendPort port, int deadline) {
_timerQueue.updateTimer(port, deadline);
}
- void _pruneClosedHandles(List<MojoHandleSignalsState> states) {
+ void _pruneClosedHandles(List<List<int>> states) {
List<int> closed = new List();
for (var i = 0; i < _handles.length; i++) {
if (states != null) {
- var signals = new MojoHandleSignals(states[i].satisfied_signals);
- if (signals.isPeerClosed) {
+ int signals = states[i][0];
+ if ((signals & kMojoSignalsPeerClosed) != 0) {
closed.add(_handles[i]);
}
} else {
- _tempHandle._set(_handles[i]);
- MojoWaitResult mwr = _tempHandle.wait(MojoHandleSignals.kAll, 0);
- if ((!mwr.result.isOk) && (!mwr.result.isDeadlineExceeded)) {
+ List mwr = MojoHandleNatives.wait(_handles[i], kMojoSignalsAll, 0);
+ if ((mwr[0] != kMojoResultOk) &&
+ (mwr[0] != kMojoResultDeadlineExceeded)) {
closed.add(_handles[i]);
}
- _tempHandle._set(MojoHandle.INVALID);
}
}
for (var h in closed) {
@@ -262,38 +257,36 @@ class MojoHandleWatcher {
void _shutdownHandleWatcher(SendPort shutdownSendPort) {
_shutdown = true;
- _tempHandle._set(_controlHandle);
- _tempHandle.close();
+ MojoHandleNatives.close(_controlHandle);
shutdownSendPort.send(null);
}
- static MojoResult _sendControlData(
- MojoHandle mojoHandle, SendPort port, int data) {
- int controlHandle = _MojoHandleWatcherNatives.getControlHandle();
- if (controlHandle == MojoHandle.INVALID) {
- return MojoResult.FAILED_PRECONDITION;
+ static int _sendControlData(int rawHandle, SendPort port, int data) {
+ int controlHandle = MojoHandleWatcherNatives.getControlHandle();
+ if (controlHandle == kMojoHandleInvalid) {
+ return kMojoResultFailedPrecondition;
}
- int rawHandle = MojoHandle.INVALID;
- if (mojoHandle != null) {
- rawHandle = mojoHandle.h;
- }
- var result = _MojoHandleWatcherNatives.sendControlData(
+ var result = MojoHandleWatcherNatives.sendControlData(
controlHandle, rawHandle, port, data);
- return new MojoResult(result);
+ return result;
}
// Starts up the MojoHandleWatcher isolate. Should be called only once
// per VM process.
static Future<Isolate> _start() {
// Make a control message pipe,
- MojoMessagePipe pipe = new MojoMessagePipe();
- int consumerHandle = pipe.endpoints[0].handle.h;
- int producerHandle = pipe.endpoints[1].handle.h;
+ List pipeEndpoints = MojoMessagePipeNatives.MojoCreateMessagePipe(0);
+ assert(pipeEndpoints != null);
+ assert((pipeEndpoints is List) && (pipeEndpoints.length == 3));
+ assert(pipeEndpoints[0] == kMojoResultOk);
+
+ int consumerHandle = pipeEndpoints[1];
+ int producerHandle = pipeEndpoints[2];
// Call setControlHandle with the other end.
- assert(producerHandle != MojoHandle.INVALID);
- _MojoHandleWatcherNatives.setControlHandle(producerHandle);
+ assert(producerHandle != kMojoHandleInvalid);
+ MojoHandleWatcherNatives.setControlHandle(producerHandle);
// Spawn the handle watcher isolate with the MojoHandleWatcher,
return Isolate.spawn(_handleWatcherIsolate, consumerHandle);
@@ -307,15 +300,15 @@ class MojoHandleWatcher {
var shutdownSendPort = shutdownReceivePort.sendPort;
// Send the shutdown command.
- _sendControlData(null, shutdownSendPort, _encodeCommand(SHUTDOWN));
+ _sendControlData(
+ kMojoHandleInvalid, shutdownSendPort, _encodeCommand(SHUTDOWN));
// Close the control handle.
- int controlHandle = _MojoHandleWatcherNatives.getControlHandle();
- var handle = new MojoHandle(controlHandle);
- handle.close();
+ int controlHandle = MojoHandleWatcherNatives.getControlHandle();
+ MojoHandleNatives.close(controlHandle);
// Invalidate the control handle.
- _MojoHandleWatcherNatives.setControlHandle(MojoHandle.INVALID);
+ MojoHandleWatcherNatives.setControlHandle(kMojoHandleInvalid);
// Wait for the handle watcher isolate to exit.
shutdownReceivePort.first.then((_) {
@@ -326,13 +319,13 @@ class MojoHandleWatcher {
// If wait is true, returns a future that resolves only after the handle
// has actually been closed by the handle watcher. Otherwise, returns a
// future that resolves immediately.
- static Future<MojoResult> close(MojoHandle mojoHandle, {bool wait: false}) {
- assert(MojoHandle._removeUnclosedHandle(mojoHandle));
+ static Future<int> close(int mojoHandle, {bool wait: false}) {
+ //assert(MojoHandle._removeUnclosedHandle(mojoHandle));
if (!wait) {
return new Future.value(
_sendControlData(mojoHandle, null, _encodeCommand(CLOSE)));
}
- MojoResult result;
+ int result;
var completer = new Completer();
var rawPort = new RawReceivePort((_) {
completer.complete(result);
@@ -345,17 +338,16 @@ class MojoHandleWatcher {
});
}
- static MojoResult add(MojoHandle mojoHandle, SendPort port, int signals) {
+ static int add(int mojoHandle, SendPort port, int signals) {
return _sendControlData(mojoHandle, port, _encodeCommand(ADD, signals));
}
- static MojoResult remove(MojoHandle mojoHandle) {
+ static int remove(int mojoHandle) {
return _sendControlData(mojoHandle, null, _encodeCommand(REMOVE));
}
- static MojoResult timer(Object ignored, SendPort port, int deadline) {
+ static int timer(Object ignored, SendPort port, int deadline) {
// The deadline will be unwrapped before sending to the handle watcher.
- return _sendControlData(
- new MojoHandle._internal(deadline), port, _encodeCommand(TIMER));
+ return _sendControlData(deadline, port, _encodeCommand(TIMER));
}
}
diff --git a/third_party/mojo/src/mojo/public/dart/src/message_pipe.dart b/third_party/mojo/src/mojo/public/dart/src/message_pipe.dart
index 5021c78..29ae078 100644
--- a/third_party/mojo/src/mojo/public/dart/src/message_pipe.dart
+++ b/third_party/mojo/src/mojo/public/dart/src/message_pipe.dart
@@ -4,16 +4,6 @@
part of core;
-class _MojoMessagePipeNatives {
- static List MojoCreateMessagePipe(int flags) native "MojoMessagePipe_Create";
-
- static int MojoWriteMessage(int handle, ByteData data, int numBytes,
- List<int> handles, int flags) native "MojoMessagePipe_Write";
-
- static List MojoReadMessage(int handle, ByteData data, int numBytes,
- List<int> handles, int flags) native "MojoMessagePipe_Read";
-}
-
class MojoMessagePipeReadResult {
final MojoResult status;
final int bytesRead;
@@ -60,7 +50,7 @@ class MojoMessagePipeEndpoint {
(handles != null) ? handles.map((h) => h.h).toList() : null;
// Do the call.
- int result = _MojoMessagePipeNatives.MojoWriteMessage(
+ int result = MojoMessagePipeNatives.MojoWriteMessage(
handle.h, data, dataNumBytes, mojoHandles, flags);
status = new MojoResult(result);
@@ -95,7 +85,7 @@ class MojoMessagePipeEndpoint {
}
// Do the call.
- List result = _MojoMessagePipeNatives.MojoReadMessage(
+ List result = MojoMessagePipeNatives.MojoReadMessage(
handle.h, data, dataNumBytes, mojoHandles, flags);
if (result == null) {
@@ -140,7 +130,7 @@ class MojoMessagePipe {
}
factory MojoMessagePipe([int flags = FLAG_NONE]) {
- List result = _MojoMessagePipeNatives.MojoCreateMessagePipe(flags);
+ List result = MojoMessagePipeNatives.MojoCreateMessagePipe(flags);
if (result == null) {
return null;
}
diff --git a/third_party/mojo/src/mojo/public/dart/src/natives.dart b/third_party/mojo/src/mojo/public/dart/src/natives.dart
new file mode 100644
index 0000000..a46ddd6
--- /dev/null
+++ b/third_party/mojo/src/mojo/public/dart/src/natives.dart
@@ -0,0 +1,70 @@
+// Copyright 2015 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.
+
+part of internal;
+
+class MojoHandleNatives {
+ static int register(
+ Object eventStream, int handle) native "MojoHandle_Register";
+ static int close(int handle) native "MojoHandle_Close";
+ static List wait(
+ int handle, int signals, int deadline) native "MojoHandle_Wait";
+ static List waitMany(List<int> handles, List<int> signals,
+ int deadline) native "MojoHandle_WaitMany";
+}
+
+class MojoHandleWatcherNatives {
+ static int sendControlData(int controlHandle, int mojoHandle, SendPort port,
+ int data) native "MojoHandleWatcher_SendControlData";
+ static List recvControlData(
+ int controlHandle) native "MojoHandleWatcher_RecvControlData";
+ static int setControlHandle(
+ int controlHandle) native "MojoHandleWatcher_SetControlHandle";
+ static int getControlHandle() native "MojoHandleWatcher_GetControlHandle";
+}
+
+class MojoMessagePipeNatives {
+ static List MojoCreateMessagePipe(int flags) native "MojoMessagePipe_Create";
+
+ static int MojoWriteMessage(int handle, ByteData data, int numBytes,
+ List<int> handles, int flags) native "MojoMessagePipe_Write";
+
+ static List MojoReadMessage(int handle, ByteData data, int numBytes,
+ List<int> handles, int flags) native "MojoMessagePipe_Read";
+}
+
+class MojoDataPipeNatives {
+ static List MojoCreateDataPipe(int elementBytes, int capacityBytes,
+ int flags) native "MojoDataPipe_Create";
+
+ static List MojoWriteData(int handle, ByteData data, int numBytes,
+ int flags) native "MojoDataPipe_WriteData";
+
+ static List MojoBeginWriteData(int handle, int bufferBytes,
+ int flags) native "MojoDataPipe_BeginWriteData";
+
+ static int MojoEndWriteData(
+ int handle, int bytesWritten) native "MojoDataPipe_EndWriteData";
+
+ static List MojoReadData(int handle, ByteData data, int numBytes,
+ int flags) native "MojoDataPipe_ReadData";
+
+ static List MojoBeginReadData(int handle, int bufferBytes,
+ int flags) native "MojoDataPipe_BeginReadData";
+
+ static int MojoEndReadData(
+ int handle, int bytesRead) native "MojoDataPipe_EndReadData";
+}
+
+class MojoSharedBufferNatives {
+ static List Create(int numBytes, int flags) native "MojoSharedBuffer_Create";
+
+ static List Duplicate(
+ int bufferHandle, int flags) native "MojoSharedBuffer_Duplicate";
+
+ static List Map(Object buffer, int bufferHandle, int offset, int numBytes,
+ int flags) native "MojoSharedBuffer_Map";
+
+ static int Unmap(ByteData buffer) native "MojoSharedBuffer_Unmap";
+}
diff --git a/third_party/mojo/src/mojo/public/dart/src/proxy.dart b/third_party/mojo/src/mojo/public/dart/src/proxy.dart
index 5317e56..a84ca3e 100644
--- a/third_party/mojo/src/mojo/public/dart/src/proxy.dart
+++ b/third_party/mojo/src/mojo/public/dart/src/proxy.dart
@@ -4,6 +4,12 @@
part of bindings;
+class ProxyCloseException {
+ final String message;
+ ProxyCloseException(this.message);
+ String toString() => message;
+}
+
abstract class Proxy extends core.MojoEventStreamListener {
Map<int, Completer> _completerMap;
int _nextId = 0;
@@ -40,6 +46,15 @@ abstract class Proxy extends core.MojoEventStreamListener {
throw 'Unexpected write signal in proxy.';
}
+ @override
+ Future close({bool nodefer: false}) {
+ for (var completer in _completerMap.values) {
+ completer.completeError(new ProxyCloseException('Proxy closed'));
+ }
+ _completerMap.clear();
+ return super.close(nodefer: nodefer);
+ }
+
void sendMessage(Struct message, int name) {
if (!isOpen) {
listen();
diff --git a/third_party/mojo/src/mojo/public/dart/src/stub.dart b/third_party/mojo/src/mojo/public/dart/src/stub.dart
index 6695f07..9008f55 100644
--- a/third_party/mojo/src/mojo/public/dart/src/stub.dart
+++ b/third_party/mojo/src/mojo/public/dart/src/stub.dart
@@ -44,26 +44,29 @@ abstract class Stub extends core.MojoEventStreamListener {
if (isOpen) {
endpoint.write(
response.buffer, response.buffer.lengthInBytes, response.handles);
- if (!endpoint.status.isOk) {
- throw 'message pipe write failed: ${endpoint.status}';
- }
+ // FailedPrecondition is only used to indicate that the other end of
+ // the pipe has been closed. We can ignore the close here and wait for
+ // the PeerClosed signal on the event stream.
+ assert(endpoint.status.isOk || endpoint.status.isFailedPrecondition);
if (_isClosing && (_outstandingResponseFutures == 0)) {
// This was the final response future for which we needed to send
// a response. It is safe to close.
- super.close();
- _isClosing = false;
- _closeCompleter.complete(null);
- _closeCompleter = null;
+ super.close().then((_) {
+ _isClosing = false;
+ _closeCompleter.complete(null);
+ _closeCompleter = null;
+ });
}
}
});
} else if (_isClosing && (_outstandingResponseFutures == 0)) {
// We are closing, there is no response to send for this message, and
// there are no outstanding response futures. Do the close now.
- super.close();
- _isClosing = false;
- _closeCompleter.complete(null);
- _closeCompleter = null;
+ super.close().then((_) {
+ _isClosing = false;
+ _closeCompleter.complete(null);
+ _closeCompleter = null;
+ });
}
}
@@ -73,7 +76,8 @@ abstract class Stub extends core.MojoEventStreamListener {
// NB: |nodefer| should only be true when calling close() while handling an
// exception thrown from handleRead(), e.g. when we receive a malformed
- // message.
+ // message, or when we have received the PEER_CLOSED event.
+ @override
Future close({bool nodefer: false}) {
if (isOpen &&
!nodefer &&
@@ -86,7 +90,13 @@ abstract class Stub extends core.MojoEventStreamListener {
_closeCompleter = new Completer();
return _closeCompleter.future;
} else {
- return super.close();
+ return super.close(nodefer: nodefer).then((_) {
+ if (_isClosing) {
+ _isClosing = false;
+ _closeCompleter.complete(null);
+ _closeCompleter = null;
+ }
+ });
}
}
diff --git a/third_party/mojo/src/mojo/public/dart/src/timer_queue.dart b/third_party/mojo/src/mojo/public/dart/src/timer_queue.dart
index 8f9936b..01c2493 100644
--- a/third_party/mojo/src/mojo/public/dart/src/timer_queue.dart
+++ b/third_party/mojo/src/mojo/public/dart/src/timer_queue.dart
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-part of core;
+part of internal;
class Timeout implements Comparable<Timeout> {
- int deadline; // milliseconds since the Unix epoch.
+ int deadline; // milliseconds since the Unix epoch.
SendPort port;
Timeout(this.port, this.deadline);
- int compareTo(Timeout other) => other.deadline - deadline;
+ int compareTo(Timeout other) => deadline - other.deadline;
}
class TimerQueue {
diff --git a/third_party/mojo/src/mojo/public/interfaces/application/BUILD.gn b/third_party/mojo/src/mojo/public/interfaces/application/BUILD.gn
index 463df55..5b15344 100644
--- a/third_party/mojo/src/mojo/public/interfaces/application/BUILD.gn
+++ b/third_party/mojo/src/mojo/public/interfaces/application/BUILD.gn
@@ -11,4 +11,9 @@ mojom("application") {
"service_provider.mojom",
"shell.mojom",
]
+
+ # This base dir ensures that Dart's Mojo SDK can be imported with, e.g.,
+ # import 'package:mojo/public/dart/core.dart' even when the Mojo SDK lives
+ # somewhere else in the source tree.
+ base_dir = mojo_root
}
diff --git a/third_party/mojo/src/mojo/public/tools/NETWORK_SERVICE_VERSION b/third_party/mojo/src/mojo/public/tools/NETWORK_SERVICE_VERSION
index fd7a713..611dc8b 100644
--- a/third_party/mojo/src/mojo/public/tools/NETWORK_SERVICE_VERSION
+++ b/third_party/mojo/src/mojo/public/tools/NETWORK_SERVICE_VERSION
@@ -1 +1 @@
-custom_build_0cf4c5c1ad031c67b48d76cb599122be6f7e0709_issue1013183003_patchset1 \ No newline at end of file
+fed9cc4ee48bf831f52127f56c2d442ddedff4a1 \ No newline at end of file
diff --git a/third_party/mojo/src/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl b/third_party/mojo/src/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl
index cca521d..30463b2 100644
--- a/third_party/mojo/src/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl
+++ b/third_party/mojo/src/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl
@@ -63,7 +63,11 @@ class {{interface|name}}ProxyImpl extends bindings.Proxy {
throw 'Expected a message with a valid request Id.';
}
Completer c = completerMap[message.header.requestId];
- completerMap[message.header.requestId] = null;
+ if (c == null) {
+ throw 'Message had unknown request Id: ${message.header.requestId}';
+ }
+ completerMap.remove(message.header.requestId);
+ assert(!c.isCompleted);
c.complete(r);
break;
{%- endif %}
@@ -154,7 +158,7 @@ class {{interface|name}}Proxy implements bindings.ProxyBase {
core.MojoMessagePipeEndpoint endpoint) =>
new {{interface|name}}Proxy.fromEndpoint(endpoint);
- Future close() => impl.close();
+ Future close({bool nodefer: false}) => impl.close(nodefer: nodefer);
String toString() {
return "{{interface|name}}Proxy($impl)";
diff --git a/third_party/mojo/src/mojo/public/tools/bindings/generators/dart_templates/module.lib.tmpl b/third_party/mojo/src/mojo/public/tools/bindings/generators/dart_templates/module.lib.tmpl
index c3b0558..21b643e 100644
--- a/third_party/mojo/src/mojo/public/tools/bindings/generators/dart_templates/module.lib.tmpl
+++ b/third_party/mojo/src/mojo/public/tools/bindings/generators/dart_templates/module.lib.tmpl
@@ -5,8 +5,9 @@
library {{module.name}};
import 'dart:async';
-import 'dart:mojo.bindings' as bindings;
-import 'dart:mojo.core' as core;
+
+import 'package:mojo/public/dart/bindings.dart' as bindings;
+import 'package:mojo/public/dart/core.dart' as core;
{%- for import in imports %}
import 'package:{{import.module.path}}.dart' as {{import.unique_name}};
diff --git a/third_party/mojo/src/mojo/public/tools/bindings/mojom.gni b/third_party/mojo/src/mojo/public/tools/bindings/mojom.gni
index 5cfd5cd..dd68501 100644
--- a/third_party/mojo/src/mojo/public/tools/bindings/mojom.gni
+++ b/third_party/mojo/src/mojo/public/tools/bindings/mojom.gni
@@ -334,7 +334,14 @@ template("mojom") {
output,
]
- rebase_base_dir = rebase_path("$root_build_dir/gen/", root_build_dir)
+ invoker_base_dir = ""
+ if (defined(invoker.base_dir)) {
+ invoker_base_dir =
+ rebase_path(invoker.base_dir, "$root_build_dir/../../", ".")
+ }
+
+ rebase_base_dir =
+ rebase_path("$root_build_dir/gen/$invoker_base_dir", root_build_dir)
if (defined(invoker.sources)) {
rebase_inputs = rebase_path(inputs, root_build_dir)
}
diff --git a/third_party/mojo_services/src/accessibility/public/interfaces/BUILD.gn b/third_party/mojo_services/src/accessibility/public/interfaces/BUILD.gn
index 7997908c..2b29c1a 100644
--- a/third_party/mojo_services/src/accessibility/public/interfaces/BUILD.gn
+++ b/third_party/mojo_services/src/accessibility/public/interfaces/BUILD.gn
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import("../../../mojo_sdk_root.gni")
+import("//build/module_args/mojo.gni")
import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni")
mojom("interfaces") {
diff --git a/third_party/mojo_services/src/clipboard/public/interfaces/BUILD.gn b/third_party/mojo_services/src/clipboard/public/interfaces/BUILD.gn
index 7ac21d2..16fe33b 100644
--- a/third_party/mojo_services/src/clipboard/public/interfaces/BUILD.gn
+++ b/third_party/mojo_services/src/clipboard/public/interfaces/BUILD.gn
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import("../../../mojo_sdk_root.gni")
+import("//build/module_args/mojo.gni")
import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni")
mojom("interfaces") {
diff --git a/third_party/mojo_services/src/content_handler/public/interfaces/BUILD.gn b/third_party/mojo_services/src/content_handler/public/interfaces/BUILD.gn
index 5016c65..77798ea 100644
--- a/third_party/mojo_services/src/content_handler/public/interfaces/BUILD.gn
+++ b/third_party/mojo_services/src/content_handler/public/interfaces/BUILD.gn
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import("../../../mojo_sdk_root.gni")
+import("//build/module_args/mojo.gni")
import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni")
mojom("interfaces") {
diff --git a/third_party/mojo_services/src/geometry/public/cpp/BUILD.gn b/third_party/mojo_services/src/geometry/public/cpp/BUILD.gn
index c05b8d3..c527c93 100644
--- a/third_party/mojo_services/src/geometry/public/cpp/BUILD.gn
+++ b/third_party/mojo_services/src/geometry/public/cpp/BUILD.gn
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import("../../../mojo_sdk_root.gni")
+import("//build/module_args/mojo.gni")
import("$mojo_sdk_root/mojo/public/mojo_sdk.gni")
mojo_sdk_source_set("cpp") {
diff --git a/third_party/mojo_services/src/geometry/public/interfaces/BUILD.gn b/third_party/mojo_services/src/geometry/public/interfaces/BUILD.gn
index 4896add..9047ee2 100644
--- a/third_party/mojo_services/src/geometry/public/interfaces/BUILD.gn
+++ b/third_party/mojo_services/src/geometry/public/interfaces/BUILD.gn
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import("../../../mojo_sdk_root.gni")
+import("//build/module_args/mojo.gni")
import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni")
mojom("interfaces") {
diff --git a/third_party/mojo_services/src/gpu/public/interfaces/BUILD.gn b/third_party/mojo_services/src/gpu/public/interfaces/BUILD.gn
index 865f73e..ec061df 100644
--- a/third_party/mojo_services/src/gpu/public/interfaces/BUILD.gn
+++ b/third_party/mojo_services/src/gpu/public/interfaces/BUILD.gn
@@ -2,13 +2,13 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import("../../../mojo_sdk_root.gni")
+import("//build/module_args/mojo.gni")
import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni")
mojom("interfaces") {
sources = [
- "context_provider.mojom",
"command_buffer.mojom",
+ "context_provider.mojom",
"gpu.mojom",
"gpu_capabilities.mojom",
"viewport_parameter_listener.mojom",
diff --git a/third_party/mojo_services/src/http_server/public/cpp/BUILD.gn b/third_party/mojo_services/src/http_server/public/cpp/BUILD.gn
index a24f006..4fca6c7 100644
--- a/third_party/mojo_services/src/http_server/public/cpp/BUILD.gn
+++ b/third_party/mojo_services/src/http_server/public/cpp/BUILD.gn
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import("../../../mojo_sdk_root.gni")
+import("//build/module_args/mojo.gni")
import("$mojo_sdk_root/mojo/public/mojo_sdk.gni")
mojo_sdk_source_set("cpp") {
diff --git a/third_party/mojo_services/src/http_server/public/interfaces/BUILD.gn b/third_party/mojo_services/src/http_server/public/interfaces/BUILD.gn
index 05eee62a..7fde891 100644
--- a/third_party/mojo_services/src/http_server/public/interfaces/BUILD.gn
+++ b/third_party/mojo_services/src/http_server/public/interfaces/BUILD.gn
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import("../../../mojo_sdk_root.gni")
+import("//build/module_args/mojo.gni")
import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni")
mojom("interfaces") {
diff --git a/third_party/mojo_services/src/input_events/public/interfaces/BUILD.gn b/third_party/mojo_services/src/input_events/public/interfaces/BUILD.gn
index e7a75f2..5ef09eb 100644
--- a/third_party/mojo_services/src/input_events/public/interfaces/BUILD.gn
+++ b/third_party/mojo_services/src/input_events/public/interfaces/BUILD.gn
@@ -2,13 +2,13 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import("../../../mojo_sdk_root.gni")
+import("//build/module_args/mojo.gni")
import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni")
mojom("interfaces") {
sources = [
- "input_events.mojom",
"input_event_constants.mojom",
+ "input_events.mojom",
"input_key_codes.mojom",
]
diff --git a/third_party/mojo_services/src/input_events/public/interfaces/input_event_constants.mojom b/third_party/mojo_services/src/input_events/public/interfaces/input_event_constants.mojom
index f137fb3..b3e0ea1 100644
--- a/third_party/mojo_services/src/input_events/public/interfaces/input_event_constants.mojom
+++ b/third_party/mojo_services/src/input_events/public/interfaces/input_event_constants.mojom
@@ -4,50 +4,14 @@
module mojo;
-// This mirrors ui::EventType
enum EventType {
- UNKNOWN ,
- MOUSE_PRESSED,
- MOUSE_DRAGGED,
- MOUSE_RELEASED,
- MOUSE_MOVED,
- MOUSE_ENTERED,
- MOUSE_EXITED,
+ UNKNOWN,
KEY_PRESSED,
KEY_RELEASED,
- MOUSEWHEEL,
- MOUSE_CAPTURE_CHANGED,
- TOUCH_RELEASED,
- TOUCH_PRESSED,
- TOUCH_MOVED,
- TOUCH_CANCELLED,
- DROP_TARGET_EVENT,
- TRANSLATED_KEY_PRESS,
- TRANSLATED_KEY_RELEASE,
- GESTURE_SCROLL_BEGIN,
- GESTURE_SCROLL_END,
- GESTURE_SCROLL_UPDATE,
- GESTURE_TAP,
- GESTURE_TAP_DOWN,
- GESTURE_TAP_CANCEL,
- GESTURE_TAP_UNCONFIRMED,
- GESTURE_DOUBLE_TAP,
- GESTURE_BEGIN,
- GESTURE_END,
- GESTURE_TWO_FINGER_TAP,
- GESTURE_PINCH_BEGIN,
- GESTURE_PINCH_END,
- GESTURE_PINCH_UPDATE,
- GESTURE_LONG_PRESS,
- GESTURE_LONG_TAP,
- GESTURE_SWIPE,
- GESTURE_SHOW_PRESS,
- GESTURE_WIN8_EDGE_SWIPE,
- SCROLL,
- SCROLL_FLING_START,
- SCROLL_FLING_CANCEL,
- CANCEL_MODE,
- UMA_DATA
+ POINTER_CANCEL,
+ POINTER_DOWN,
+ POINTER_MOVE,
+ POINTER_UP,
};
// This mirrors ui::EventFlags
@@ -75,3 +39,8 @@ enum MouseEventFlags {
// TODO(erg): Move accessibility flags and maybe synthetic touch events here.
};
+
+enum PointerKind {
+ TOUCH,
+ MOUSE,
+};
diff --git a/third_party/mojo_services/src/input_events/public/interfaces/input_events.mojom b/third_party/mojo_services/src/input_events/public/interfaces/input_events.mojom
index 1cab579..0086265 100644
--- a/third_party/mojo_services/src/input_events/public/interfaces/input_events.mojom
+++ b/third_party/mojo_services/src/input_events/public/interfaces/input_events.mojom
@@ -8,11 +8,6 @@ import "geometry/public/interfaces/geometry.mojom";
import "input_events/public/interfaces/input_event_constants.mojom";
import "input_events/public/interfaces/input_key_codes.mojom";
-struct LocationData {
- Point? in_view_location;
- Point? screen_location;
-};
-
struct KeyData {
// The chromium event key code; these values are from the ui/ KeyCode enum,
// which has the fun property of being neither consistently the Windows key
@@ -52,47 +47,30 @@ struct KeyData {
uint16 unmodified_text;
};
-struct TouchData {
+struct PointerData {
int32 pointer_id;
-};
-
-struct GestureData {
- // A bounding box for all the input events that contributed to this gesture.
- RectF? bounding_box;
-
- // GESTURE_SCROLL_UPDATE
- float scroll_x;
- float scroll_y;
-
- // SCROLL_FLING_START
- float velocity_x;
- float velocity_y;
-
- // GESTURE_PINCH_UPDATE
- float scale;
-
- // GESTURE_SWIPE
- bool swipe_left;
- bool swipe_right;
- bool swipe_up;
- bool swipe_down;
-
- // GESTURE_TAP and GESTURE_TAP_UNCONFIRMED and GESTURE_DOUBLE_TAP
- int32 tap_count;
-};
-
-struct MouseWheelData {
- int32 x_offset;
- int32 y_offset;
+ PointerKind kind;
+ // |x| and |y| are in the coordinate system of the View.
+ float x;
+ float y;
+ // |screen_x| and |screen_y| are in screen coordinates.
+ float screen_x;
+ float screen_y;
+ float pressure;
+ float radius_major;
+ float radius_minor;
+ float orientation;
+ // Used for devices that support wheels. Ranges from -1 to 1.
+ float horizontal_wheel;
+ float vertical_wheel;
};
struct Event {
+ // TODO(sky): rename to type.
EventType action;
+ // TODO(sky): parts of this should move to PointerData.
EventFlags flags;
int64 time_stamp;
- LocationData? location_data;
KeyData? key_data;
- TouchData? touch_data;
- GestureData? gesture_data;
- MouseWheelData? wheel_data;
+ PointerData? pointer_data;
};
diff --git a/third_party/mojo_services/src/native_viewport/public/cpp/BUILD.gn b/third_party/mojo_services/src/native_viewport/public/cpp/BUILD.gn
index 035ddfa..855de71 100644
--- a/third_party/mojo_services/src/native_viewport/public/cpp/BUILD.gn
+++ b/third_party/mojo_services/src/native_viewport/public/cpp/BUILD.gn
@@ -2,13 +2,13 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import("../../../mojo_sdk_root.gni")
+import("//build/module_args/mojo.gni")
import("$mojo_sdk_root/mojo/public/mojo_sdk.gni")
mojo_sdk_source_set("args") {
public_configs = [ "../../../public/build/config:mojo_services" ]
sources = [
- "lib/args.cc",
"args.h",
+ "lib/args.cc",
]
}
diff --git a/third_party/mojo_services/src/native_viewport/public/interfaces/BUILD.gn b/third_party/mojo_services/src/native_viewport/public/interfaces/BUILD.gn
index 0311564..86ff870 100644
--- a/third_party/mojo_services/src/native_viewport/public/interfaces/BUILD.gn
+++ b/third_party/mojo_services/src/native_viewport/public/interfaces/BUILD.gn
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import("../../../mojo_sdk_root.gni")
+import("//build/module_args/mojo.gni")
import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni")
mojom("interfaces") {
diff --git a/third_party/mojo_services/src/navigation/public/interfaces/BUILD.gn b/third_party/mojo_services/src/navigation/public/interfaces/BUILD.gn
index da9fc70..5141680 100644
--- a/third_party/mojo_services/src/navigation/public/interfaces/BUILD.gn
+++ b/third_party/mojo_services/src/navigation/public/interfaces/BUILD.gn
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import("../../../mojo_sdk_root.gni")
+import("//build/module_args/mojo.gni")
import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni")
mojom("interfaces") {
diff --git a/third_party/mojo_services/src/surfaces/public/cpp/BUILD.gn b/third_party/mojo_services/src/surfaces/public/cpp/BUILD.gn
index ddac4f3..9cf48b33 100644
--- a/third_party/mojo_services/src/surfaces/public/cpp/BUILD.gn
+++ b/third_party/mojo_services/src/surfaces/public/cpp/BUILD.gn
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import("../../../mojo_sdk_root.gni")
+import("//build/module_args/mojo.gni")
import("$mojo_sdk_root/mojo/public/mojo_sdk.gni")
mojo_sdk_source_set("cpp") {
diff --git a/third_party/mojo_services/src/surfaces/public/interfaces/BUILD.gn b/third_party/mojo_services/src/surfaces/public/interfaces/BUILD.gn
index 8350df8..7902a7a 100644
--- a/third_party/mojo_services/src/surfaces/public/interfaces/BUILD.gn
+++ b/third_party/mojo_services/src/surfaces/public/interfaces/BUILD.gn
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import("../../../mojo_sdk_root.gni")
+import("//build/module_args/mojo.gni")
import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni")
mojom("interfaces") {
diff --git a/third_party/mojo_services/src/view_manager/public/cpp/BUILD.gn b/third_party/mojo_services/src/view_manager/public/cpp/BUILD.gn
index d121021..189e827 100644
--- a/third_party/mojo_services/src/view_manager/public/cpp/BUILD.gn
+++ b/third_party/mojo_services/src/view_manager/public/cpp/BUILD.gn
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import("../../../mojo_sdk_root.gni")
+import("//build/module_args/mojo.gni")
import("$mojo_sdk_root/mojo/public/mojo_sdk.gni")
mojo_sdk_source_set("cpp") {
diff --git a/third_party/mojo_services/src/view_manager/public/interfaces/BUILD.gn b/third_party/mojo_services/src/view_manager/public/interfaces/BUILD.gn
index 69a454b..177066b 100644
--- a/third_party/mojo_services/src/view_manager/public/interfaces/BUILD.gn
+++ b/third_party/mojo_services/src/view_manager/public/interfaces/BUILD.gn
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import("../../../mojo_sdk_root.gni")
+import("//build/module_args/mojo.gni")
import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni")
mojom("interfaces") {
diff --git a/third_party/mojo_services/src/window_manager/public/interfaces/BUILD.gn b/third_party/mojo_services/src/window_manager/public/interfaces/BUILD.gn
index 14b7d2c..b97f069 100644
--- a/third_party/mojo_services/src/window_manager/public/interfaces/BUILD.gn
+++ b/third_party/mojo_services/src/window_manager/public/interfaces/BUILD.gn
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import("../../../mojo_sdk_root.gni")
+import("//build/module_args/mojo.gni")
import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni")
mojom("interfaces") {