summaryrefslogtreecommitdiff
path: root/chromium/mojo
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-04-05 14:08:31 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-04-11 07:46:53 +0000
commit6a4cabb866f66d4128a97cdc6d9d08ce074f1247 (patch)
treeab00f70a5e89278d6a0d16ff0c42578dc4d84a2d /chromium/mojo
parente733310db58160074f574c429d48f8308c0afe17 (diff)
downloadqtwebengine-chromium-6a4cabb866f66d4128a97cdc6d9d08ce074f1247.tar.gz
BASELINE: Update Chromium to 57.0.2987.144
Change-Id: I29db402ff696c71a04c4dbaec822c2e53efe0267 Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'chromium/mojo')
-rw-r--r--chromium/mojo/BUILD.gn1
-rw-r--r--chromium/mojo/android/BUILD.gn4
-rw-r--r--chromium/mojo/android/system/watcher_impl.cc61
-rw-r--r--chromium/mojo/common/BUILD.gn19
-rw-r--r--chromium/mojo/common/DEPS10
-rw-r--r--chromium/mojo/common/OWNERS2
-rw-r--r--chromium/mojo/common/common_custom_types.mojom42
-rw-r--r--chromium/mojo/common/common_custom_types_struct_traits.cc54
-rw-r--r--chromium/mojo/common/common_custom_types_struct_traits.h27
-rw-r--r--chromium/mojo/common/common_custom_types_unittest.cc227
-rw-r--r--chromium/mojo/common/common_type_converters.cc84
-rw-r--r--chromium/mojo/common/common_type_converters.h67
-rw-r--r--chromium/mojo/common/common_type_converters_unittest.cc130
-rw-r--r--chromium/mojo/common/data_pipe_file_utils.cc81
-rw-r--r--chromium/mojo/common/data_pipe_utils.cc36
-rw-r--r--chromium/mojo/common/data_pipe_utils.h36
-rw-r--r--chromium/mojo/common/file.mojom10
-rw-r--r--chromium/mojo/common/file.typemap13
-rw-r--r--chromium/mojo/common/file_path.mojom8
-rw-r--r--chromium/mojo/common/file_path.typemap12
-rw-r--r--chromium/mojo/common/string16.mojom12
-rw-r--r--chromium/mojo/common/string16.typemap12
-rw-r--r--chromium/mojo/common/test_common_custom_types.mojom25
-rw-r--r--chromium/mojo/common/text_direction.mojom12
-rw-r--r--chromium/mojo/common/text_direction.typemap12
-rw-r--r--chromium/mojo/common/time.mojom15
-rw-r--r--chromium/mojo/common/time.typemap (renamed from chromium/mojo/common/common_custom_types.typemap)17
-rw-r--r--chromium/mojo/common/traits_test_service.mojom2
-rw-r--r--chromium/mojo/common/typemaps.gni11
-rw-r--r--chromium/mojo/common/unguessable_token.mojom11
-rw-r--r--chromium/mojo/common/unguessable_token.typemap12
-rw-r--r--chromium/mojo/common/user_agent.cc25
-rw-r--r--chromium/mojo/common/user_agent.h20
-rw-r--r--chromium/mojo/common/values.mojom32
-rw-r--r--chromium/mojo/common/values.typemap25
-rw-r--r--chromium/mojo/common/values_struct_traits.cc102
-rw-r--r--chromium/mojo/common/values_struct_traits.h250
-rw-r--r--chromium/mojo/common/version.mojom10
-rw-r--r--chromium/mojo/common/version.typemap12
-rw-r--r--chromium/mojo/edk/embedder/BUILD.gn21
-rw-r--r--chromium/mojo/edk/embedder/embedder.cc24
-rw-r--r--chromium/mojo/edk/embedder/embedder.h22
-rw-r--r--chromium/mojo/edk/embedder/embedder_unittest.cc28
-rw-r--r--chromium/mojo/edk/embedder/named_platform_handle_utils.h9
-rw-r--r--chromium/mojo/edk/embedder/named_platform_handle_utils_posix.cc6
-rw-r--r--chromium/mojo/edk/embedder/platform_channel_pair.h1
-rw-r--r--chromium/mojo/edk/embedder/platform_channel_pair_posix.cc27
-rw-r--r--chromium/mojo/edk/embedder/platform_channel_utils_posix.cc5
-rw-r--r--chromium/mojo/edk/embedder/platform_channel_utils_posix.h6
-rw-r--r--chromium/mojo/edk/embedder/process_delegate.h31
-rw-r--r--chromium/mojo/edk/embedder/scoped_ipc_support.cc62
-rw-r--r--chromium/mojo/edk/embedder/scoped_ipc_support.h102
-rw-r--r--chromium/mojo/edk/js/drain_data.cc4
-rw-r--r--chromium/mojo/edk/js/drain_data.h6
-rw-r--r--chromium/mojo/edk/js/tests/BUILD.gn2
-rw-r--r--chromium/mojo/edk/system/BUILD.gn1
-rw-r--r--chromium/mojo/edk/system/channel_posix.cc20
-rw-r--r--chromium/mojo/edk/system/core.cc20
-rw-r--r--chromium/mojo/edk/system/core.h5
-rw-r--r--chromium/mojo/edk/system/data_pipe_consumer_dispatcher.h1
-rw-r--r--chromium/mojo/edk/system/data_pipe_control_message.h1
-rw-r--r--chromium/mojo/edk/system/message_pipe_dispatcher.h1
-rw-r--r--chromium/mojo/edk/system/message_pipe_unittest.cc11
-rw-r--r--chromium/mojo/edk/system/multiprocess_message_pipe_unittest.cc17
-rw-r--r--chromium/mojo/edk/system/node_controller.cc17
-rw-r--r--chromium/mojo/edk/system/ports/name.cc4
-rw-r--r--chromium/mojo/edk/system/ports/name.h4
-rw-r--r--chromium/mojo/edk/system/ports/node.cc6
-rw-r--r--chromium/mojo/edk/system/shared_buffer_dispatcher.h1
-rw-r--r--chromium/mojo/edk/test/BUILD.gn2
-rw-r--r--chromium/mojo/gpu/BUILD.gn18
-rw-r--r--chromium/mojo/gpu/DEPS4
-rw-r--r--chromium/mojo/gpu/OWNERS5
-rw-r--r--chromium/mojo/gpu/mojo_gles2_impl_autogen.cc1899
-rw-r--r--chromium/mojo/gpu/mojo_gles2_impl_autogen.h890
-rw-r--r--chromium/mojo/public/BUILD.gn1
-rw-r--r--chromium/mojo/public/cpp/bindings/BUILD.gn12
-rw-r--r--chromium/mojo/public/cpp/bindings/array.h289
-rw-r--r--chromium/mojo/public/cpp/bindings/array_traits_standard.h43
-rw-r--r--chromium/mojo/public/cpp/bindings/array_traits_wtf.h40
-rw-r--r--chromium/mojo/public/cpp/bindings/associated_interface_ptr.h68
-rw-r--r--chromium/mojo/public/cpp/bindings/binding.h2
-rw-r--r--chromium/mojo/public/cpp/bindings/binding_set.h7
-rw-r--r--chromium/mojo/public/cpp/bindings/interface_endpoint_client.h9
-rw-r--r--chromium/mojo/public/cpp/bindings/interface_ptr.h6
-rw-r--r--chromium/mojo/public/cpp/bindings/interface_request.h26
-rw-r--r--chromium/mojo/public/cpp/bindings/lib/array_serialization.h1
-rw-r--r--chromium/mojo/public/cpp/bindings/lib/binding_state.cc100
-rw-r--r--chromium/mojo/public/cpp/bindings/lib/binding_state.h117
-rw-r--r--chromium/mojo/public/cpp/bindings/lib/hash_util.h11
-rw-r--r--chromium/mojo/public/cpp/bindings/lib/interface_endpoint_client.cc17
-rw-r--r--chromium/mojo/public/cpp/bindings/lib/interface_ptr_state.h174
-rw-r--r--chromium/mojo/public/cpp/bindings/lib/multiplex_router.cc12
-rw-r--r--chromium/mojo/public/cpp/bindings/lib/multiplex_router.h2
-rw-r--r--chromium/mojo/public/cpp/bindings/lib/native_struct.cc6
-rw-r--r--chromium/mojo/public/cpp/bindings/lib/native_struct_data.h1
-rw-r--r--chromium/mojo/public/cpp/bindings/lib/router.cc347
-rw-r--r--chromium/mojo/public/cpp/bindings/lib/router.h206
-rw-r--r--chromium/mojo/public/cpp/bindings/lib/serialization.h11
-rw-r--r--chromium/mojo/public/cpp/bindings/lib/sync_handle_registry.cc10
-rw-r--r--chromium/mojo/public/cpp/bindings/lib/wtf_serialization.h2
-rw-r--r--chromium/mojo/public/cpp/bindings/map.h312
-rw-r--r--chromium/mojo/public/cpp/bindings/map_traits_standard.h53
-rw-r--r--chromium/mojo/public/cpp/bindings/map_traits_wtf.h62
-rw-r--r--chromium/mojo/public/cpp/bindings/native_struct.h6
-rw-r--r--chromium/mojo/public/cpp/bindings/stl_converters.h245
-rw-r--r--chromium/mojo/public/cpp/bindings/string.h209
-rw-r--r--chromium/mojo/public/cpp/bindings/string_traits_standard.h31
-rw-r--r--chromium/mojo/public/cpp/bindings/strong_associated_binding.h5
-rw-r--r--chromium/mojo/public/cpp/bindings/strong_binding.h8
-rw-r--r--chromium/mojo/public/cpp/bindings/struct_traits.h9
-rw-r--r--chromium/mojo/public/cpp/bindings/sync_call_restrictions.h9
-rw-r--r--chromium/mojo/public/cpp/bindings/tests/BUILD.gn16
-rw-r--r--chromium/mojo/public/cpp/bindings/thread_safe_interface_ptr.h68
-rw-r--r--chromium/mojo/public/cpp/bindings/type_converter.h17
-rw-r--r--chromium/mojo/public/cpp/bindings/wtf_array.h197
-rw-r--r--chromium/mojo/public/cpp/bindings/wtf_map.h200
-rw-r--r--chromium/mojo/public/cpp/system/platform_handle.cc49
-rw-r--r--chromium/mojo/public/cpp/system/platform_handle.h11
-rw-r--r--chromium/mojo/public/cpp/system/watcher.cc39
-rw-r--r--chromium/mojo/public/cpp/system/watcher.h12
-rw-r--r--chromium/mojo/public/interfaces/bindings/BUILD.gn1
-rw-r--r--chromium/mojo/public/interfaces/bindings/tests/BUILD.gn36
-rw-r--r--chromium/mojo/public/interfaces/bindings/tests/test_constants.mojom4
-rw-r--r--chromium/mojo/public/interfaces/bindings/tests/test_export.mojom2
-rw-r--r--chromium/mojo/public/interfaces/bindings/tests/test_import.mojom11
-rw-r--r--chromium/mojo/public/js/BUILD.gn2
-rw-r--r--chromium/mojo/public/js/bindings.js314
-rw-r--r--chromium/mojo/public/js/codec.js58
-rw-r--r--chromium/mojo/public/js/connection.js196
-rw-r--r--chromium/mojo/public/js/connector.js27
-rw-r--r--chromium/mojo/public/js/constants.cc4
-rw-r--r--chromium/mojo/public/js/constants.h4
-rw-r--r--chromium/mojo/public/js/interface_types.js52
-rw-r--r--chromium/mojo/public/js/router.js65
-rw-r--r--chromium/mojo/public/js/validation_unittests.js43
-rw-r--r--chromium/mojo/public/js/validator.js47
-rw-r--r--chromium/mojo/public/tools/bindings/chromium_bindings_configuration.gni7
-rw-r--r--chromium/mojo/public/tools/bindings/generators/cpp_templates/enum_macros.tmpl2
-rw-r--r--chromium/mojo/public/tools/bindings/generators/cpp_templates/interface_declaration.tmpl23
-rw-r--r--chromium/mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl27
-rw-r--r--chromium/mojo/public/tools/bindings/generators/cpp_templates/interface_macros.tmpl28
-rw-r--r--chromium/mojo/public/tools/bindings/generators/cpp_templates/interface_proxy_declaration.tmpl2
-rw-r--r--chromium/mojo/public/tools/bindings/generators/cpp_templates/module-shared-internal.h.tmpl2
-rw-r--r--chromium/mojo/public/tools/bindings/generators/cpp_templates/module-shared.h.tmpl4
-rw-r--r--chromium/mojo/public/tools/bindings/generators/cpp_templates/module.cc.tmpl10
-rw-r--r--chromium/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl17
-rw-r--r--chromium/mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl2
-rw-r--r--chromium/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl10
-rw-r--r--chromium/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl22
-rw-r--r--chromium/mojo/public/tools/bindings/generators/js_templates/module.amd.tmpl3
-rw-r--r--chromium/mojo/public/tools/bindings/generators/js_templates/module_definition.tmpl1
-rw-r--r--chromium/mojo/public/tools/bindings/generators/js_templates/validation_macros.tmpl12
-rw-r--r--chromium/mojo/public/tools/bindings/generators/mojom_cpp_generator.py70
-rw-r--r--chromium/mojo/public/tools/bindings/generators/mojom_js_generator.py70
-rw-r--r--chromium/mojo/public/tools/bindings/mojom.gni141
-rwxr-xr-xchromium/mojo/public/tools/bindings/mojom_bindings_generator.py9
-rw-r--r--chromium/mojo/public/tools/bindings/pylib/mojom/generate/generator.py4
158 files changed, 2219 insertions, 7015 deletions
diff --git a/chromium/mojo/BUILD.gn b/chromium/mojo/BUILD.gn
index 9440e669df5..4a4ed288892 100644
--- a/chromium/mojo/BUILD.gn
+++ b/chromium/mojo/BUILD.gn
@@ -37,7 +37,6 @@ group("tests") {
"//mojo/edk/test:mojo_public_system_perftests",
"//mojo/edk/test:mojo_public_system_unittests",
"//services/service_manager/public/cpp/tests:mojo_public_application_unittests",
- "//services/service_manager/runner/host:mojo_runner_host_unittests",
"//services/service_manager/tests",
]
}
diff --git a/chromium/mojo/android/BUILD.gn b/chromium/mojo/android/BUILD.gn
index e09fb353fff..1a8cdbdb3c7 100644
--- a/chromium/mojo/android/BUILD.gn
+++ b/chromium/mojo/android/BUILD.gn
@@ -107,6 +107,7 @@ android_library("mojo_javatests") {
"//mojo/public/interfaces/bindings/tests:test_mojom_import_java",
"//mojo/public/java:bindings_java",
"//mojo/public/java:system_java",
+ "//third_party/android_support_test_runner:runner_java",
]
data = [
@@ -130,7 +131,7 @@ shared_library("mojo_java_unittests") {
":libsystem_java",
":system_java_jni_headers",
"//base",
- "//base/test/:test_support",
+ "//base/test:test_support",
"//build/config/sanitizers:deps",
"//mojo/edk/system",
"//mojo/public/cpp/bindings/tests:mojo_public_bindings_test_utils",
@@ -146,6 +147,7 @@ instrumentation_test_apk("mojo_test_apk") {
"//base:base_java",
"//mojo/public/interfaces/bindings/tests:test_interfaces",
"//mojo/public/java:bindings_java",
+ "//third_party/android_support_test_runner:runner_java",
]
shared_libraries = [ ":mojo_java_unittests" ]
apk_name = "MojoTest"
diff --git a/chromium/mojo/android/system/watcher_impl.cc b/chromium/mojo/android/system/watcher_impl.cc
index a363a595bed..ba212955e56 100644
--- a/chromium/mojo/android/system/watcher_impl.cc
+++ b/chromium/mojo/android/system/watcher_impl.cc
@@ -24,25 +24,60 @@ using base::android::JavaParamRef;
namespace {
-class JavaWatcherCallback {
+class WatcherImpl {
public:
- JavaWatcherCallback(JNIEnv* env, const JavaParamRef<jobject>& java_watcher) {
- java_watcher_.Reset(env, java_watcher);
+ WatcherImpl() {}
+
+ ~WatcherImpl() = default;
+
+ jint Start(JNIEnv* env,
+ const JavaParamRef<jobject>& jcaller,
+ jint mojo_handle,
+ jint signals) {
+ java_watcher_.Reset(env, jcaller);
+
+ auto ready_callback =
+ base::Bind(&WatcherImpl::OnHandleReady, base::Unretained(this));
+
+ MojoResult result =
+ watcher_.Start(mojo::Handle(static_cast<MojoHandle>(mojo_handle)),
+ static_cast<MojoHandleSignals>(signals), ready_callback);
+
+ if (result != MOJO_RESULT_OK)
+ java_watcher_.Reset();
+
+ return result;
}
- void OnHandleReady(MojoResult result) {
- Java_WatcherImpl_onHandleReady(base::android::AttachCurrentThread(),
- java_watcher_, result);
+ void Cancel() {
+ java_watcher_.Reset();
+ watcher_.Cancel();
}
private:
+ void OnHandleReady(MojoResult result) {
+ DCHECK(!java_watcher_.is_null());
+
+ base::android::ScopedJavaGlobalRef<jobject> java_watcher_preserver;
+ if (result == MOJO_RESULT_CANCELLED)
+ java_watcher_preserver = std::move(java_watcher_);
+
+ Java_WatcherImpl_onHandleReady(
+ base::android::AttachCurrentThread(),
+ java_watcher_.is_null() ? java_watcher_preserver : java_watcher_,
+ result);
+ }
+
+ Watcher watcher_;
base::android::ScopedJavaGlobalRef<jobject> java_watcher_;
+
+ DISALLOW_COPY_AND_ASSIGN(WatcherImpl);
};
} // namespace
static jlong CreateWatcher(JNIEnv* env, const JavaParamRef<jobject>& jcaller) {
- return reinterpret_cast<jlong>(new Watcher);
+ return reinterpret_cast<jlong>(new WatcherImpl);
}
static jint Start(JNIEnv* env,
@@ -50,24 +85,20 @@ static jint Start(JNIEnv* env,
jlong watcher_ptr,
jint mojo_handle,
jint signals) {
- Watcher* watcher = reinterpret_cast<Watcher*>(watcher_ptr);
- return watcher->Start(
- mojo::Handle(static_cast<MojoHandle>(mojo_handle)),
- static_cast<MojoHandleSignals>(signals),
- base::Bind(&JavaWatcherCallback::OnHandleReady,
- base::Owned(new JavaWatcherCallback(env, jcaller))));
+ auto watcher = reinterpret_cast<WatcherImpl*>(watcher_ptr);
+ return watcher->Start(env, jcaller, mojo_handle, signals);
}
static void Cancel(JNIEnv* env,
const JavaParamRef<jobject>& jcaller,
jlong watcher_ptr) {
- reinterpret_cast<Watcher*>(watcher_ptr)->Cancel();
+ reinterpret_cast<WatcherImpl*>(watcher_ptr)->Cancel();
}
static void Delete(JNIEnv* env,
const JavaParamRef<jobject>& jcaller,
jlong watcher_ptr) {
- delete reinterpret_cast<Watcher*>(watcher_ptr);
+ delete reinterpret_cast<WatcherImpl*>(watcher_ptr);
}
bool RegisterWatcherImpl(JNIEnv* env) {
diff --git a/chromium/mojo/common/BUILD.gn b/chromium/mojo/common/BUILD.gn
index 278d9ee2fb2..e0f18add8ef 100644
--- a/chromium/mojo/common/BUILD.gn
+++ b/chromium/mojo/common/BUILD.gn
@@ -14,7 +14,14 @@ group("common") {
mojom("common_custom_types") {
sources = [
- "common_custom_types.mojom",
+ "file.mojom",
+ "file_path.mojom",
+ "string16.mojom",
+ "text_direction.mojom",
+ "time.mojom",
+ "unguessable_token.mojom",
+ "values.mojom",
+ "version.mojom",
]
}
@@ -22,15 +29,10 @@ component("common_base") {
output_name = "mojo_common_lib"
sources = [
- "common_type_converters.cc",
- "common_type_converters.h",
"data_pipe_drainer.cc",
"data_pipe_drainer.h",
- "data_pipe_file_utils.cc",
"data_pipe_utils.cc",
"data_pipe_utils.h",
- "user_agent.cc",
- "user_agent.h",
]
defines = [ "MOJO_COMMON_IMPLEMENTATION" ]
@@ -71,7 +73,6 @@ test("mojo_common_unittests") {
sources = [
"common_custom_types_unittest.cc",
- "common_type_converters_unittest.cc",
"struct_traits_unittest.cc",
]
}
@@ -94,5 +95,9 @@ source_set("struct_traits") {
deps = [
":common_custom_types_shared_cpp_sources",
"//base:base",
+ "//mojo/public/cpp/system",
+ ]
+ public_deps = [
+ "//base:i18n",
]
}
diff --git a/chromium/mojo/common/DEPS b/chromium/mojo/common/DEPS
index f3e298ffc22..e8ac42887d1 100644
--- a/chromium/mojo/common/DEPS
+++ b/chromium/mojo/common/DEPS
@@ -1,16 +1,6 @@
include_rules = [
# common must not depend on embedder.
"-mojo",
- "+services/service_manager/public/cpp",
"+mojo/common",
"+mojo/public",
]
-
-specific_include_rules = {
- "trace_controller_impl\.h": [
- "+services/tracing/public/interfaces/tracing.mojom.h"
- ],
- "tracing_impl\.h": [
- "+services/tracing/public/interfaces/tracing.mojom.h"
- ],
-}
diff --git a/chromium/mojo/common/OWNERS b/chromium/mojo/common/OWNERS
index b567079e0a9..154435234ea 100644
--- a/chromium/mojo/common/OWNERS
+++ b/chromium/mojo/common/OWNERS
@@ -1,5 +1,3 @@
-per-file *_type_converter*.*=set noparent
-per-file *_type_converter*.*=file://ipc/SECURITY_OWNERS
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
per-file *_struct_traits*.*=set noparent
diff --git a/chromium/mojo/common/common_custom_types.mojom b/chromium/mojo/common/common_custom_types.mojom
deleted file mode 100644
index 203fa3c844d..00000000000
--- a/chromium/mojo/common/common_custom_types.mojom
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2016 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.
-
-module mojo.common.mojom;
-
-[Native]
-struct FilePath;
-
-[Native]
-struct ListValue;
-
-[Native]
-struct DictionaryValue;
-
-[Native]
-struct Time;
-
-struct TimeDelta {
- int64 microseconds;
-};
-
-[Native]
-struct TimeTicks;
-
-// Corresponds to |base::string16| in base/strings/string16.h
-// Corresponds to |WTF::String| in
-// third_party/WebKit/Source/wtf/text/WTFString.h.
-struct String16 {
- array<uint16> data;
-};
-
-// Corresponds to |base::UnguessableToken| in base/unguessable_token.h
-struct UnguessableToken {
- uint64 high;
- uint64 low;
-};
-
-// Corresponds to |base::Version| in base/version.h
-struct Version {
- array<uint32> components;
-};
diff --git a/chromium/mojo/common/common_custom_types_struct_traits.cc b/chromium/mojo/common/common_custom_types_struct_traits.cc
index c3b7ef20008..62895048ad2 100644
--- a/chromium/mojo/common/common_custom_types_struct_traits.cc
+++ b/chromium/mojo/common/common_custom_types_struct_traits.cc
@@ -4,7 +4,7 @@
#include "mojo/common/common_custom_types_struct_traits.h"
-#include <iterator>
+#include "mojo/public/cpp/system/platform_handle.h"
namespace mojo {
@@ -53,4 +53,56 @@ bool StructTraits<
return true;
}
+mojo::ScopedHandle StructTraits<common::mojom::FileDataView, base::File>::fd(
+ base::File& file) {
+ DCHECK(file.IsValid());
+ return mojo::WrapPlatformFile(file.TakePlatformFile());
+}
+
+bool StructTraits<common::mojom::FileDataView, base::File>::Read(
+ common::mojom::FileDataView data,
+ base::File* file) {
+ base::PlatformFile platform_handle = base::kInvalidPlatformFile;
+ if (mojo::UnwrapPlatformFile(data.TakeFd(), &platform_handle) !=
+ MOJO_RESULT_OK) {
+ return false;
+ }
+ *file = base::File(platform_handle);
+ return true;
+}
+
+// static
+common::mojom::TextDirection
+EnumTraits<common::mojom::TextDirection, base::i18n::TextDirection>::ToMojom(
+ base::i18n::TextDirection text_direction) {
+ switch (text_direction) {
+ case base::i18n::UNKNOWN_DIRECTION:
+ return common::mojom::TextDirection::UNKNOWN_DIRECTION;
+ case base::i18n::RIGHT_TO_LEFT:
+ return common::mojom::TextDirection::RIGHT_TO_LEFT;
+ case base::i18n::LEFT_TO_RIGHT:
+ return common::mojom::TextDirection::LEFT_TO_RIGHT;
+ }
+ NOTREACHED();
+ return common::mojom::TextDirection::UNKNOWN_DIRECTION;
+}
+
+// static
+bool EnumTraits<common::mojom::TextDirection, base::i18n::TextDirection>::
+ FromMojom(common::mojom::TextDirection input,
+ base::i18n::TextDirection* out) {
+ switch (input) {
+ case common::mojom::TextDirection::UNKNOWN_DIRECTION:
+ *out = base::i18n::UNKNOWN_DIRECTION;
+ return true;
+ case common::mojom::TextDirection::RIGHT_TO_LEFT:
+ *out = base::i18n::RIGHT_TO_LEFT;
+ return true;
+ case common::mojom::TextDirection::LEFT_TO_RIGHT:
+ *out = base::i18n::LEFT_TO_RIGHT;
+ return true;
+ }
+ return false;
+}
+
} // namespace mojo
diff --git a/chromium/mojo/common/common_custom_types_struct_traits.h b/chromium/mojo/common/common_custom_types_struct_traits.h
index b99e15ffc9d..b20c795b965 100644
--- a/chromium/mojo/common/common_custom_types_struct_traits.h
+++ b/chromium/mojo/common/common_custom_types_struct_traits.h
@@ -5,11 +5,18 @@
#ifndef MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_
#define MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_
+#include "base/files/file.h"
+#include "base/i18n/rtl.h"
#include "base/strings/utf_string_conversions.h"
#include "base/unguessable_token.h"
#include "base/version.h"
-#include "mojo/common/common_custom_types.mojom-shared.h"
+#include "mojo/common/file.mojom-shared.h"
#include "mojo/common/mojo_common_export.h"
+#include "mojo/common/string16.mojom-shared.h"
+#include "mojo/common/text_direction.mojom-shared.h"
+#include "mojo/common/time.mojom-shared.h"
+#include "mojo/common/unguessable_token.mojom-shared.h"
+#include "mojo/common/version.mojom-shared.h"
namespace mojo {
@@ -68,6 +75,24 @@ struct StructTraits<common::mojom::TimeDeltaDataView, base::TimeDelta> {
}
};
+template <>
+struct StructTraits<common::mojom::FileDataView, base::File> {
+ static bool IsNull(const base::File& file) { return !file.IsValid(); }
+
+ static void SetToNull(base::File* file) { *file = base::File(); }
+
+ static mojo::ScopedHandle fd(base::File& file);
+ static bool Read(common::mojom::FileDataView data, base::File* file);
+};
+
+template <>
+struct EnumTraits<common::mojom::TextDirection, base::i18n::TextDirection> {
+ static common::mojom::TextDirection ToMojom(
+ base::i18n::TextDirection text_direction);
+ static bool FromMojom(common::mojom::TextDirection input,
+ base::i18n::TextDirection* out);
+};
+
} // namespace mojo
#endif // MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_
diff --git a/chromium/mojo/common/common_custom_types_unittest.cc b/chromium/mojo/common/common_custom_types_unittest.cc
index 520f82a9a00..17478d1c681 100644
--- a/chromium/mojo/common/common_custom_types_unittest.cc
+++ b/chromium/mojo/common/common_custom_types_unittest.cc
@@ -3,11 +3,13 @@
// found in the LICENSE file.
#include "base/files/file_path.h"
+#include "base/files/scoped_temp_dir.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
+#include "base/numerics/safe_math.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
-#include "mojo/common/common_custom_types.mojom.h"
#include "mojo/common/test_common_custom_types.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -24,22 +26,6 @@ struct BounceTestTraits {
}
};
-template <>
-struct BounceTestTraits<base::DictionaryValue> {
- static void ExpectEquality(const base::DictionaryValue& a,
- const base::DictionaryValue& b) {
- EXPECT_TRUE(a.Equals(&b));
- }
-};
-
-template <>
-struct BounceTestTraits<base::ListValue> {
- static void ExpectEquality(const base::ListValue& a,
- const base::ListValue& b) {
- EXPECT_TRUE(a.Equals(&b));
- }
-};
-
template <typename T>
struct PassTraits {
using Type = const T&;
@@ -136,13 +122,19 @@ class TestValueImpl : public TestValue {
// TestValue implementation:
void BounceDictionaryValue(
- const base::DictionaryValue& in,
+ std::unique_ptr<base::DictionaryValue> in,
const BounceDictionaryValueCallback& callback) override {
- callback.Run(in);
+ callback.Run(std::move(in));
}
- void BounceListValue(const base::ListValue& in,
+
+ void BounceListValue(std::unique_ptr<base::ListValue> in,
const BounceListValueCallback& callback) override {
- callback.Run(in);
+ callback.Run(std::move(in));
+ }
+
+ void BounceValue(std::unique_ptr<base::Value> in,
+ const BounceValueCallback& callback) override {
+ callback.Run(std::move(in));
}
private:
@@ -164,6 +156,36 @@ class TestString16Impl : public TestString16 {
mojo::Binding<TestString16> binding_;
};
+class TestFileImpl : public TestFile {
+ public:
+ explicit TestFileImpl(TestFileRequest request)
+ : binding_(this, std::move(request)) {}
+
+ // TestFile implementation:
+ void BounceFile(base::File in, const BounceFileCallback& callback) override {
+ callback.Run(std::move(in));
+ }
+
+ private:
+ mojo::Binding<TestFile> binding_;
+};
+
+class TestTextDirectionImpl : public TestTextDirection {
+ public:
+ explicit TestTextDirectionImpl(TestTextDirectionRequest request)
+ : binding_(this, std::move(request)) {}
+
+ // TestTextDirection:
+ void BounceTextDirection(
+ base::i18n::TextDirection in,
+ const BounceTextDirectionCallback& callback) override {
+ callback.Run(in);
+ }
+
+ private:
+ mojo::Binding<TestTextDirection> binding_;
+};
+
class CommonCustomTypesTest : public testing::Test {
protected:
CommonCustomTypesTest() {}
@@ -181,7 +203,7 @@ TEST_F(CommonCustomTypesTest, FilePath) {
base::RunLoop run_loop;
TestFilePathPtr ptr;
- TestFilePathImpl impl(GetProxy(&ptr));
+ TestFilePathImpl impl(MakeRequest(&ptr));
base::FilePath dir(FILE_PATH_LITERAL("hello"));
base::FilePath file = dir.Append(FILE_PATH_LITERAL("world"));
@@ -195,7 +217,7 @@ TEST_F(CommonCustomTypesTest, UnguessableToken) {
base::RunLoop run_loop;
TestUnguessableTokenPtr ptr;
- TestUnguessableTokenImpl impl(GetProxy(&ptr));
+ TestUnguessableTokenImpl impl(MakeRequest(&ptr));
base::UnguessableToken token = base::UnguessableToken::Create();
@@ -208,7 +230,7 @@ TEST_F(CommonCustomTypesTest, Time) {
base::RunLoop run_loop;
TestTimePtr ptr;
- TestTimeImpl impl(GetProxy(&ptr));
+ TestTimeImpl impl(MakeRequest(&ptr));
base::Time t = base::Time::Now();
@@ -221,7 +243,7 @@ TEST_F(CommonCustomTypesTest, TimeDelta) {
base::RunLoop run_loop;
TestTimePtr ptr;
- TestTimeImpl impl(GetProxy(&ptr));
+ TestTimeImpl impl(MakeRequest(&ptr));
base::TimeDelta t = base::TimeDelta::FromDays(123);
@@ -234,7 +256,7 @@ TEST_F(CommonCustomTypesTest, TimeTicks) {
base::RunLoop run_loop;
TestTimePtr ptr;
- TestTimeImpl impl(GetProxy(&ptr));
+ TestTimeImpl impl(MakeRequest(&ptr));
base::TimeTicks t = base::TimeTicks::Now();
@@ -245,51 +267,88 @@ TEST_F(CommonCustomTypesTest, TimeTicks) {
TEST_F(CommonCustomTypesTest, Value) {
TestValuePtr ptr;
- TestValueImpl impl(GetProxy(&ptr));
-
- base::DictionaryValue dict;
- dict.SetBoolean("bool", false);
- dict.SetInteger("int", 2);
- dict.SetString("string", "some string");
- dict.SetBoolean("nested.bool", true);
- dict.SetInteger("nested.int", 9);
- dict.Set("some_binary", base::BinaryValue::CreateWithCopiedBuffer("mojo", 4));
+ TestValueImpl impl(MakeRequest(&ptr));
+
+ std::unique_ptr<base::Value> output;
+
+ ASSERT_TRUE(ptr->BounceValue(nullptr, &output));
+ EXPECT_FALSE(output);
+
+ std::unique_ptr<base::Value> input = base::Value::CreateNullValue();
+ ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output));
+ EXPECT_TRUE(base::Value::Equals(input.get(), output.get()));
+
+ input = base::MakeUnique<base::FundamentalValue>(123);
+ ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output));
+ EXPECT_TRUE(base::Value::Equals(input.get(), output.get()));
+
+ input = base::MakeUnique<base::FundamentalValue>(1.23);
+ ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output));
+ EXPECT_TRUE(base::Value::Equals(input.get(), output.get()));
+
+ input = base::MakeUnique<base::FundamentalValue>(false);
+ ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output));
+ EXPECT_TRUE(base::Value::Equals(input.get(), output.get()));
+
+ input = base::MakeUnique<base::StringValue>("test string");
+ ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output));
+ EXPECT_TRUE(base::Value::Equals(input.get(), output.get()));
+
+ input = base::BinaryValue::CreateWithCopiedBuffer("mojo", 4);
+ ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output));
+ EXPECT_TRUE(base::Value::Equals(input.get(), output.get()));
+
+ auto dict = base::MakeUnique<base::DictionaryValue>();
+ dict->SetBoolean("bool", false);
+ dict->SetInteger("int", 2);
+ dict->SetString("string", "some string");
+ dict->SetBoolean("nested.bool", true);
+ dict->SetInteger("nested.int", 9);
+ dict->Set("some_binary",
+ base::BinaryValue::CreateWithCopiedBuffer("mojo", 4));
+ dict->Set("null_value", base::Value::CreateNullValue());
+ dict->SetIntegerWithoutPathExpansion("non_nested.int", 10);
{
std::unique_ptr<base::ListValue> dict_list(new base::ListValue());
dict_list->AppendString("string");
dict_list->AppendBoolean(true);
- dict.Set("list", std::move(dict_list));
- }
- {
- base::RunLoop run_loop;
- ptr->BounceDictionaryValue(
- dict, ExpectResponse(&dict, run_loop.QuitClosure()));
- run_loop.Run();
+ dict->Set("list", std::move(dict_list));
}
- base::ListValue list;
- list.AppendString("string");
- list.AppendDouble(42.1);
- list.AppendBoolean(true);
- list.Append(base::BinaryValue::CreateWithCopiedBuffer("mojo", 4));
+ std::unique_ptr<base::DictionaryValue> dict_output;
+ ASSERT_TRUE(ptr->BounceDictionaryValue(dict->CreateDeepCopy(), &dict_output));
+ EXPECT_TRUE(base::Value::Equals(dict.get(), dict_output.get()));
+
+ input = std::move(dict);
+ ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output));
+ EXPECT_TRUE(base::Value::Equals(input.get(), output.get()));
+
+ auto list = base::MakeUnique<base::ListValue>();
+ list->AppendString("string");
+ list->AppendDouble(42.1);
+ list->AppendBoolean(true);
+ list->Append(base::BinaryValue::CreateWithCopiedBuffer("mojo", 4));
+ list->Append(base::Value::CreateNullValue());
{
std::unique_ptr<base::DictionaryValue> list_dict(
new base::DictionaryValue());
list_dict->SetString("string", "str");
- list.Append(std::move(list_dict));
- }
- {
- base::RunLoop run_loop;
- ptr->BounceListValue(list, ExpectResponse(&list, run_loop.QuitClosure()));
- run_loop.Run();
+ list->Append(std::move(list_dict));
}
+ std::unique_ptr<base::ListValue> list_output;
+ ASSERT_TRUE(ptr->BounceListValue(list->CreateDeepCopy(), &list_output));
+ EXPECT_TRUE(base::Value::Equals(list.get(), list_output.get()));
+
+ input = std::move(list);
+ ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output));
+ ASSERT_TRUE(base::Value::Equals(input.get(), output.get()));
}
TEST_F(CommonCustomTypesTest, String16) {
base::RunLoop run_loop;
TestString16Ptr ptr;
- TestString16Impl impl(GetProxy(&ptr));
+ TestString16Impl impl(MakeRequest(&ptr));
base::string16 str16 = base::ASCIIToUTF16("hello world");
@@ -302,7 +361,7 @@ TEST_F(CommonCustomTypesTest, EmptyString16) {
base::RunLoop run_loop;
TestString16Ptr ptr;
- TestString16Impl impl(GetProxy(&ptr));
+ TestString16Impl impl(MakeRequest(&ptr));
base::string16 str16;
@@ -311,6 +370,64 @@ TEST_F(CommonCustomTypesTest, EmptyString16) {
run_loop.Run();
}
+TEST_F(CommonCustomTypesTest, File) {
+ base::ScopedTempDir temp_dir;
+ ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
+
+ TestFilePtr ptr;
+ TestFileImpl impl(MakeRequest(&ptr));
+
+ base::File file(
+ temp_dir.GetPath().AppendASCII("test_file.txt"),
+ base::File::FLAG_CREATE | base::File::FLAG_WRITE | base::File::FLAG_READ);
+ const base::StringPiece test_content =
+ "A test string to be stored in a test file";
+ file.WriteAtCurrentPos(
+ test_content.data(),
+ base::CheckedNumeric<int>(test_content.size()).ValueOrDie());
+
+ base::File file_out;
+ ASSERT_TRUE(ptr->BounceFile(std::move(file), &file_out));
+ std::vector<char> content(test_content.size());
+ ASSERT_TRUE(file_out.IsValid());
+ ASSERT_EQ(static_cast<int>(test_content.size()),
+ file_out.Read(
+ 0, content.data(),
+ base::CheckedNumeric<int>(test_content.size()).ValueOrDie()));
+ EXPECT_EQ(test_content,
+ base::StringPiece(content.data(), test_content.size()));
+}
+
+TEST_F(CommonCustomTypesTest, InvalidFile) {
+ TestFilePtr ptr;
+ TestFileImpl impl(MakeRequest(&ptr));
+
+ base::ScopedTempDir temp_dir;
+ ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
+ // Test that |file_out| is set to an invalid file.
+ base::File file_out(
+ temp_dir.GetPath().AppendASCII("test_file.txt"),
+ base::File::FLAG_CREATE | base::File::FLAG_WRITE | base::File::FLAG_READ);
+
+ ASSERT_TRUE(ptr->BounceFile(base::File(), &file_out));
+ EXPECT_FALSE(file_out.IsValid());
+}
+
+TEST_F(CommonCustomTypesTest, TextDirection) {
+ base::i18n::TextDirection kTestDirections[] = {base::i18n::LEFT_TO_RIGHT,
+ base::i18n::RIGHT_TO_LEFT,
+ base::i18n::UNKNOWN_DIRECTION};
+
+ TestTextDirectionPtr ptr;
+ TestTextDirectionImpl impl(MakeRequest(&ptr));
+
+ for (size_t i = 0; i < arraysize(kTestDirections); i++) {
+ base::i18n::TextDirection direction_out;
+ ASSERT_TRUE(ptr->BounceTextDirection(kTestDirections[i], &direction_out));
+ EXPECT_EQ(kTestDirections[i], direction_out);
+ }
+}
+
} // namespace test
} // namespace common
} // namespace mojo
diff --git a/chromium/mojo/common/common_type_converters.cc b/chromium/mojo/common/common_type_converters.cc
deleted file mode 100644
index 92ae3e26820..00000000000
--- a/chromium/mojo/common/common_type_converters.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 2013 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/common/common_type_converters.h"
-
-#include <stdint.h>
-
-#include <string>
-
-#include "base/strings/utf_string_conversions.h"
-
-namespace mojo {
-
-// static
-String TypeConverter<String, base::StringPiece>::Convert(
- const base::StringPiece& input) {
- if (input.empty()) {
- char c = 0;
- return String(&c, 0);
- }
- return String(input.data(), input.size());
-}
-// static
-base::StringPiece TypeConverter<base::StringPiece, String>::Convert(
- const String& input) {
- return input.get();
-}
-
-// static
-String TypeConverter<String, base::string16>::Convert(
- const base::string16& input) {
- return TypeConverter<String, base::StringPiece>::Convert(
- base::UTF16ToUTF8(input));
-}
-// static
-base::string16 TypeConverter<base::string16, String>::Convert(
- const String& input) {
- return base::UTF8ToUTF16(input.To<base::StringPiece>());
-}
-
-std::string TypeConverter<std::string, Array<uint8_t>>::Convert(
- const Array<uint8_t>& input) {
- if (input.is_null() || input.empty())
- return std::string();
-
- return std::string(reinterpret_cast<const char*>(&input.front()),
- input.size());
-}
-
-Array<uint8_t> TypeConverter<Array<uint8_t>, std::string>::Convert(
- const std::string& input) {
- Array<uint8_t> result(input.size());
- if (!input.empty())
- memcpy(&result.front(), input.c_str(), input.size());
- return result;
-}
-
-Array<uint8_t> TypeConverter<Array<uint8_t>, base::StringPiece>::Convert(
- const base::StringPiece& input) {
- Array<uint8_t> result(input.size());
- if (!input.empty())
- memcpy(&result.front(), input.data(), input.size());
- return result;
-}
-
-base::string16 TypeConverter<base::string16, Array<uint8_t>>::Convert(
- const Array<uint8_t>& input) {
- if (input.is_null() || input.empty())
- return base::string16();
-
- return base::string16(reinterpret_cast<const base::char16*>(&input.front()),
- input.size() / sizeof(base::char16));
-}
-
-Array<uint8_t> TypeConverter<Array<uint8_t>, base::string16>::Convert(
- const base::string16& input) {
- Array<uint8_t> result(input.size() * sizeof(base::char16));
- if (!input.empty())
- memcpy(&result.front(), input.c_str(), input.size() * sizeof(base::char16));
- return result;
-}
-
-} // namespace mojo
diff --git a/chromium/mojo/common/common_type_converters.h b/chromium/mojo/common/common_type_converters.h
deleted file mode 100644
index bf1e723b84d..00000000000
--- a/chromium/mojo/common/common_type_converters.h
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright 2013 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.
-
-#ifndef MOJO_COMMON_COMMON_TYPE_CONVERTERS_H_
-#define MOJO_COMMON_COMMON_TYPE_CONVERTERS_H_
-
-#include <stdint.h>
-#include <vector>
-
-#include "base/strings/string16.h"
-#include "base/strings/string_piece.h"
-#include "mojo/common/mojo_common_export.h"
-#include "mojo/public/cpp/bindings/array.h"
-#include "mojo/public/cpp/bindings/string.h"
-#include "mojo/public/cpp/bindings/type_converter.h"
-
-namespace mojo {
-
-template <>
-struct MOJO_COMMON_EXPORT TypeConverter<String, base::StringPiece> {
- static String Convert(const base::StringPiece& input);
-};
-
-template <>
-struct MOJO_COMMON_EXPORT TypeConverter<base::StringPiece, String> {
- static base::StringPiece Convert(const String& input);
-};
-
-template <>
-struct MOJO_COMMON_EXPORT TypeConverter<String, base::string16> {
- static String Convert(const base::string16& input);
-};
-
-template <>
-struct MOJO_COMMON_EXPORT TypeConverter<base::string16, String> {
- static base::string16 Convert(const String& input);
-};
-
-template <>
-struct MOJO_COMMON_EXPORT TypeConverter<std::string, Array<uint8_t>> {
- static std::string Convert(const Array<uint8_t>& input);
-};
-
-template <>
-struct MOJO_COMMON_EXPORT TypeConverter<Array<uint8_t>, std::string> {
- static Array<uint8_t> Convert(const std::string& input);
-};
-
-template <>
-struct MOJO_COMMON_EXPORT TypeConverter<Array<uint8_t>, base::StringPiece> {
- static Array<uint8_t> Convert(const base::StringPiece& input);
-};
-
-template <>
-struct MOJO_COMMON_EXPORT TypeConverter<base::string16, Array<uint8_t>> {
- static base::string16 Convert(const Array<uint8_t>& input);
-};
-
-template <>
-struct MOJO_COMMON_EXPORT TypeConverter<Array<uint8_t>, base::string16> {
- static Array<uint8_t> Convert(const base::string16& input);
-};
-
-} // namespace mojo
-
-#endif // MOJO_COMMON_COMMON_TYPE_CONVERTERS_H_
diff --git a/chromium/mojo/common/common_type_converters_unittest.cc b/chromium/mojo/common/common_type_converters_unittest.cc
deleted file mode 100644
index 1740d06a71f..00000000000
--- a/chromium/mojo/common/common_type_converters_unittest.cc
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright 2013 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/common/common_type_converters.h"
-
-#include <stdint.h>
-
-#include "base/strings/utf_string_conversions.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "url/gurl.h"
-
-namespace mojo {
-namespace common {
-namespace test {
-namespace {
-
-void ExpectEqualsStringPiece(const std::string& expected,
- const base::StringPiece& str) {
- EXPECT_EQ(expected, str.as_string());
-}
-
-void ExpectEqualsMojoString(const std::string& expected,
- const String& str) {
- EXPECT_EQ(expected, str.get());
-}
-
-void ExpectEqualsString16(const base::string16& expected,
- const base::string16& actual) {
- EXPECT_EQ(expected, actual);
-}
-
-void ExpectEqualsMojoString(const base::string16& expected,
- const String& str) {
- EXPECT_EQ(expected, str.To<base::string16>());
-}
-
-} // namespace
-
-TEST(CommonTypeConvertersTest, StringPiece) {
- std::string kText("hello world");
-
- base::StringPiece string_piece(kText);
- String mojo_string(String::From(string_piece));
-
- ExpectEqualsMojoString(kText, mojo_string);
- ExpectEqualsStringPiece(kText, mojo_string.To<base::StringPiece>());
-
- // Test implicit construction and conversion:
- ExpectEqualsMojoString(kText, String::From(string_piece));
- ExpectEqualsStringPiece(kText, mojo_string.To<base::StringPiece>());
-
- // Test null String:
- base::StringPiece empty_string_piece = String().To<base::StringPiece>();
- EXPECT_TRUE(empty_string_piece.empty());
-}
-
-TEST(CommonTypeConvertersTest, String16) {
- const base::string16 string16(base::ASCIIToUTF16("hello world"));
- const String mojo_string(String::From(string16));
-
- ExpectEqualsMojoString(string16, mojo_string);
- EXPECT_EQ(string16, mojo_string.To<base::string16>());
-
- // Test implicit construction and conversion:
- ExpectEqualsMojoString(string16, String::From(string16));
- ExpectEqualsString16(string16, mojo_string.To<base::string16>());
-
- // Test empty string conversion.
- ExpectEqualsMojoString(base::string16(), String::From(base::string16()));
-}
-
-TEST(CommonTypeConvertersTest, ArrayUint8ToStdString) {
- Array<uint8_t> data(4);
- data[0] = 'd';
- data[1] = 'a';
- data[2] = 't';
- data[3] = 'a';
-
- EXPECT_EQ("data", data.To<std::string>());
-}
-
-TEST(CommonTypeConvertersTest, StdStringToArrayUint8) {
- std::string input("data");
- Array<uint8_t> data = Array<uint8_t>::From(input);
-
- ASSERT_EQ(4ul, data.size());
- EXPECT_EQ('d', data[0]);
- EXPECT_EQ('a', data[1]);
- EXPECT_EQ('t', data[2]);
- EXPECT_EQ('a', data[3]);
-}
-
-TEST(CommonTypeConvertersTest, ArrayUint8ToString16) {
- Array<uint8_t> data(8);
- data[0] = 'd';
- data[2] = 'a';
- data[4] = 't';
- data[6] = 'a';
-
- EXPECT_EQ(base::ASCIIToUTF16("data"), data.To<base::string16>());
-}
-
-TEST(CommonTypeConvertersTest, String16ToArrayUint8) {
- base::string16 input(base::ASCIIToUTF16("data"));
- Array<uint8_t> data = Array<uint8_t>::From(input);
-
- ASSERT_EQ(8ul, data.size());
- EXPECT_EQ('d', data[0]);
- EXPECT_EQ('a', data[2]);
- EXPECT_EQ('t', data[4]);
- EXPECT_EQ('a', data[6]);
-}
-
-TEST(CommonTypeConvertersTest, String16ToArrayUint8AndBack) {
- base::string16 input(base::ASCIIToUTF16("data"));
- Array<uint8_t> data = Array<uint8_t>::From(input);
- EXPECT_EQ(input, data.To<base::string16>());
-}
-
-TEST(CommonTypeConvertersTest, EmptyStringToArrayUint8) {
- Array<uint8_t> data = Array<uint8_t>::From(std::string());
-
- ASSERT_EQ(0ul, data.size());
- EXPECT_FALSE(data.is_null());
-}
-
-} // namespace test
-} // namespace common
-} // namespace mojo
diff --git a/chromium/mojo/common/data_pipe_file_utils.cc b/chromium/mojo/common/data_pipe_file_utils.cc
deleted file mode 100644
index 841dfde9618..00000000000
--- a/chromium/mojo/common/data_pipe_file_utils.cc
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright 2014 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/common/data_pipe_utils.h"
-
-#include <stdint.h>
-
-#include "base/files/file_path.h"
-#include "base/files/file_util.h"
-#include "base/files/scoped_file.h"
-#include "base/location.h"
-#include "base/task_runner_util.h"
-
-namespace mojo {
-namespace common {
-namespace {
-
-bool BlockingCopyFromFile(const base::FilePath& source,
- ScopedDataPipeProducerHandle destination,
- uint32_t skip) {
- base::File file(source, base::File::FLAG_OPEN | base::File::FLAG_READ);
- if (!file.IsValid())
- return false;
- if (file.Seek(base::File::FROM_BEGIN, skip) != skip) {
- LOG(ERROR) << "Seek of " << skip << " in " << source.value() << " failed";
- return false;
- }
- for (;;) {
- void* buffer = nullptr;
- uint32_t buffer_num_bytes = 0;
- MojoResult result =
- BeginWriteDataRaw(destination.get(), &buffer, &buffer_num_bytes,
- MOJO_WRITE_DATA_FLAG_NONE);
- if (result == MOJO_RESULT_OK) {
- int bytes_read =
- file.ReadAtCurrentPos(static_cast<char*>(buffer), buffer_num_bytes);
- if (bytes_read >= 0) {
- EndWriteDataRaw(destination.get(), bytes_read);
- if (bytes_read == 0) {
- // eof
- return true;
- }
- } else {
- // error
- EndWriteDataRaw(destination.get(), 0);
- return false;
- }
- } else if (result == MOJO_RESULT_SHOULD_WAIT) {
- result = Wait(destination.get(), MOJO_HANDLE_SIGNAL_WRITABLE,
- MOJO_DEADLINE_INDEFINITE, nullptr);
- if (result != MOJO_RESULT_OK) {
- // If the consumer handle was closed, then treat as EOF.
- return result == MOJO_RESULT_FAILED_PRECONDITION;
- }
- } else {
- // If the consumer handle was closed, then treat as EOF.
- return result == MOJO_RESULT_FAILED_PRECONDITION;
- }
- }
-#if !defined(OS_WIN)
- NOTREACHED();
- return false;
-#endif
-}
-
-} // namespace
-
-void CopyFromFile(const base::FilePath& source,
- ScopedDataPipeProducerHandle destination,
- uint32_t skip,
- base::TaskRunner* task_runner,
- const base::Callback<void(bool)>& callback) {
- base::PostTaskAndReplyWithResult(task_runner, FROM_HERE,
- base::Bind(&BlockingCopyFromFile, source,
- base::Passed(&destination), skip),
- callback);
-}
-
-} // namespace common
-} // namespace mojo
diff --git a/chromium/mojo/common/data_pipe_utils.cc b/chromium/mojo/common/data_pipe_utils.cc
index 8540ac63473..bed5e858fc0 100644
--- a/chromium/mojo/common/data_pipe_utils.cc
+++ b/chromium/mojo/common/data_pipe_utils.cc
@@ -4,16 +4,9 @@
#include "mojo/common/data_pipe_utils.h"
-#include <stddef.h>
-#include <stdint.h>
-#include <stdio.h>
#include <utility>
-#include "base/files/file_path.h"
-#include "base/files/file_util.h"
-#include "base/files/scoped_file.h"
-#include "base/message_loop/message_loop.h"
-#include "base/task_runner_util.h"
+#include "base/bind.h"
namespace mojo {
namespace common {
@@ -58,12 +51,7 @@ size_t CopyToStringHelper(
return num_bytes;
}
-size_t CopyToFileHelper(FILE* fp, const void* buffer, uint32_t num_bytes) {
- return fwrite(buffer, 1, num_bytes, fp);
-}
-
-} // namespace
-
+} // namespace
// TODO(hansmuller): Add a max_size parameter.
bool BlockingCopyToString(ScopedDataPipeConsumerHandle source,
@@ -107,25 +95,5 @@ bool MOJO_COMMON_EXPORT BlockingCopyFromString(
}
}
-bool BlockingCopyToFile(ScopedDataPipeConsumerHandle source,
- const base::FilePath& destination) {
- base::ScopedFILE fp(base::OpenFile(destination, "wb"));
- if (!fp)
- return false;
- return BlockingCopyHelper(std::move(source),
- base::Bind(&CopyToFileHelper, fp.get()));
-}
-
-void CopyToFile(ScopedDataPipeConsumerHandle source,
- const base::FilePath& destination,
- base::TaskRunner* task_runner,
- const base::Callback<void(bool)>& callback) {
- base::PostTaskAndReplyWithResult(
- task_runner,
- FROM_HERE,
- base::Bind(&BlockingCopyToFile, base::Passed(&source), destination),
- callback);
-}
-
} // namespace common
} // namespace mojo
diff --git a/chromium/mojo/common/data_pipe_utils.h b/chromium/mojo/common/data_pipe_utils.h
index 426912c95b4..a3f7c093e47 100644
--- a/chromium/mojo/common/data_pipe_utils.h
+++ b/chromium/mojo/common/data_pipe_utils.h
@@ -2,41 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef MOJO_SHELL_DATA_PIPE_UTILS_H_
-#define MOJO_SHELL_DATA_PIPE_UTILS_H_
+#ifndef MOJO_COMMON_DATA_PIPE_UTILS_H_
+#define MOJO_COMMON_DATA_PIPE_UTILS_H_
#include <stdint.h>
#include <string>
-#include "base/callback_forward.h"
#include "mojo/common/mojo_common_export.h"
-#include "mojo/public/cpp/system/core.h"
-
-namespace base {
-class FilePath;
-class TaskRunner;
-}
+#include "mojo/public/cpp/system/data_pipe.h"
namespace mojo {
namespace common {
-// Asynchronously copies data from source to the destination file. The given
-// |callback| is run upon completion. File writes will be scheduled to the
-// given |task_runner|.
-void MOJO_COMMON_EXPORT CopyToFile(
- ScopedDataPipeConsumerHandle source,
- const base::FilePath& destination,
- base::TaskRunner* task_runner,
- const base::Callback<void(bool /*success*/)>& callback);
-
-void MOJO_COMMON_EXPORT
-CopyFromFile(const base::FilePath& source,
- ScopedDataPipeProducerHandle destination,
- uint32_t skip,
- base::TaskRunner* task_runner,
- const base::Callback<void(bool /*success*/)>& callback);
-
// Copies the data from |source| into |contents| and returns true on success and
// false on error. In case of I/O error, |contents| holds the data that could
// be read from source before the error occurred.
@@ -48,13 +26,7 @@ bool MOJO_COMMON_EXPORT BlockingCopyFromString(
const std::string& source,
const ScopedDataPipeProducerHandle& destination);
-// Synchronously copies data from source to the destination file returning true
-// on success and false on error. In case of an error, |destination| holds the
-// data that could be read from the source before the error occured.
-bool MOJO_COMMON_EXPORT BlockingCopyToFile(ScopedDataPipeConsumerHandle source,
- const base::FilePath& destination);
-
} // namespace common
} // namespace mojo
-#endif // MOJO_SHELL_DATA_PIPE_UTILS_H_
+#endif // MOJO_COMMON_DATA_PIPE_UTILS_H_
diff --git a/chromium/mojo/common/file.mojom b/chromium/mojo/common/file.mojom
new file mode 100644
index 00000000000..fe224734d94
--- /dev/null
+++ b/chromium/mojo/common/file.mojom
@@ -0,0 +1,10 @@
+// Copyright 2016 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.
+
+module mojo.common.mojom;
+
+// Corresponds to |base::File| in base/files/file.h
+struct File {
+ handle fd;
+};
diff --git a/chromium/mojo/common/file.typemap b/chromium/mojo/common/file.typemap
new file mode 100644
index 00000000000..26d494139e8
--- /dev/null
+++ b/chromium/mojo/common/file.typemap
@@ -0,0 +1,13 @@
+# Copyright 2016 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.
+
+mojom = "//mojo/common/file.mojom"
+public_headers = [ "//base/files/file.h" ]
+traits_headers = [ "//mojo/common/common_custom_types_struct_traits.h" ]
+public_deps = [
+ "//mojo/common:struct_traits",
+]
+
+type_mappings =
+ [ "mojo.common.mojom.File=base::File[move_only,nullable_is_same_type]" ]
diff --git a/chromium/mojo/common/file_path.mojom b/chromium/mojo/common/file_path.mojom
new file mode 100644
index 00000000000..10ebe058be8
--- /dev/null
+++ b/chromium/mojo/common/file_path.mojom
@@ -0,0 +1,8 @@
+// Copyright 2016 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.
+
+module mojo.common.mojom;
+
+[Native]
+struct FilePath;
diff --git a/chromium/mojo/common/file_path.typemap b/chromium/mojo/common/file_path.typemap
new file mode 100644
index 00000000000..66d8c54da8a
--- /dev/null
+++ b/chromium/mojo/common/file_path.typemap
@@ -0,0 +1,12 @@
+# Copyright 2016 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.
+
+mojom = "//mojo/common/file_path.mojom"
+public_headers = [ "//base/files/file_path.h" ]
+traits_headers = [ "//ipc/ipc_message_utils.h" ]
+public_deps = [
+ "//ipc",
+]
+
+type_mappings = [ "mojo.common.mojom.FilePath=base::FilePath" ]
diff --git a/chromium/mojo/common/string16.mojom b/chromium/mojo/common/string16.mojom
new file mode 100644
index 00000000000..173c8670cd1
--- /dev/null
+++ b/chromium/mojo/common/string16.mojom
@@ -0,0 +1,12 @@
+// Copyright 2016 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.
+
+module mojo.common.mojom;
+
+// Corresponds to |base::string16| in base/strings/string16.h
+// Corresponds to |WTF::String| in
+// third_party/WebKit/Source/wtf/text/WTFString.h.
+struct String16 {
+ array<uint16> data;
+};
diff --git a/chromium/mojo/common/string16.typemap b/chromium/mojo/common/string16.typemap
new file mode 100644
index 00000000000..223de29c0da
--- /dev/null
+++ b/chromium/mojo/common/string16.typemap
@@ -0,0 +1,12 @@
+# Copyright 2016 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.
+
+mojom = "//mojo/common/string16.mojom"
+public_headers = [ "//base/strings/string16.h" ]
+traits_headers = [ "//mojo/common/common_custom_types_struct_traits.h" ]
+public_deps = [
+ "//mojo/common:struct_traits",
+]
+
+type_mappings = [ "mojo.common.mojom.String16=base::string16" ]
diff --git a/chromium/mojo/common/test_common_custom_types.mojom b/chromium/mojo/common/test_common_custom_types.mojom
index ab49cce1339..0f13680f682 100644
--- a/chromium/mojo/common/test_common_custom_types.mojom
+++ b/chromium/mojo/common/test_common_custom_types.mojom
@@ -4,7 +4,13 @@
module mojo.common.test;
-import "mojo/common/common_custom_types.mojom";
+import "mojo/common/file.mojom";
+import "mojo/common/file_path.mojom";
+import "mojo/common/string16.mojom";
+import "mojo/common/text_direction.mojom";
+import "mojo/common/time.mojom";
+import "mojo/common/unguessable_token.mojom";
+import "mojo/common/values.mojom";
interface TestFilePath {
BounceFilePath(mojo.common.mojom.FilePath in)
@@ -25,10 +31,15 @@ interface TestTime {
};
interface TestValue {
+ [Sync]
BounceDictionaryValue(mojo.common.mojom.DictionaryValue in)
=> (mojo.common.mojom.DictionaryValue out);
+ [Sync]
BounceListValue(mojo.common.mojom.ListValue in)
=> (mojo.common.mojom.ListValue out);
+ [Sync]
+ BounceValue(mojo.common.mojom.Value? in)
+ => (mojo.common.mojom.Value? out);
};
interface TestString16 {
@@ -36,3 +47,15 @@ interface TestString16 {
BounceString16(mojo.common.mojom.String16 in)
=> (mojo.common.mojom.String16 out);
};
+
+interface TestFile {
+ [Sync]
+ BounceFile(mojo.common.mojom.File? in)
+ => (mojo.common.mojom.File? out);
+};
+
+interface TestTextDirection {
+ [Sync]
+ BounceTextDirection(mojo.common.mojom.TextDirection in)
+ => (mojo.common.mojom.TextDirection out);
+};
diff --git a/chromium/mojo/common/text_direction.mojom b/chromium/mojo/common/text_direction.mojom
new file mode 100644
index 00000000000..7d651245eda
--- /dev/null
+++ b/chromium/mojo/common/text_direction.mojom
@@ -0,0 +1,12 @@
+// 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.
+
+module mojo.common.mojom;
+
+// Corresponds to |base::i18n::TextDirection| in base/i18n/rtl.h
+enum TextDirection {
+ UNKNOWN_DIRECTION,
+ RIGHT_TO_LEFT,
+ LEFT_TO_RIGHT
+};
diff --git a/chromium/mojo/common/text_direction.typemap b/chromium/mojo/common/text_direction.typemap
new file mode 100644
index 00000000000..1f5be8edbaf
--- /dev/null
+++ b/chromium/mojo/common/text_direction.typemap
@@ -0,0 +1,12 @@
+# 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.
+
+mojom = "//mojo/common/text_direction.mojom"
+public_headers = [ "//base/i18n/rtl.h" ]
+traits_headers = [ "//mojo/common/common_custom_types_struct_traits.h" ]
+public_deps = [
+ "//base:i18n",
+ "//mojo/common:struct_traits",
+]
+type_mappings = [ "mojo.common.mojom.TextDirection=base::i18n::TextDirection" ]
diff --git a/chromium/mojo/common/time.mojom b/chromium/mojo/common/time.mojom
new file mode 100644
index 00000000000..43dfcc8b3b7
--- /dev/null
+++ b/chromium/mojo/common/time.mojom
@@ -0,0 +1,15 @@
+// Copyright 2016 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.
+
+module mojo.common.mojom;
+
+[Native]
+struct Time;
+
+struct TimeDelta {
+ int64 microseconds;
+};
+
+[Native]
+struct TimeTicks;
diff --git a/chromium/mojo/common/common_custom_types.typemap b/chromium/mojo/common/time.typemap
index ecd09e87be1..99e9e3ae8d8 100644
--- a/chromium/mojo/common/common_custom_types.typemap
+++ b/chromium/mojo/common/time.typemap
@@ -2,15 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-mojom = "//mojo/common/common_custom_types.mojom"
-public_headers = [
- "//base/files/file_path.h",
- "//base/strings/string16.h",
- "//base/time/time.h",
- "//base/unguessable_token.h",
- "//base/values.h",
- "//base/version.h",
-]
+mojom = "//mojo/common/time.mojom"
+public_headers = [ "//base/time/time.h" ]
traits_headers = [
"//ipc/ipc_message_utils.h",
"//mojo/common/common_custom_types_struct_traits.h",
@@ -21,13 +14,7 @@ public_deps = [
]
type_mappings = [
- "mojo.common.mojom.FilePath=base::FilePath",
- "mojo.common.mojom.DictionaryValue=base::DictionaryValue",
- "mojo.common.mojom.ListValue=base::ListValue",
- "mojo.common.mojom.UnguessableToken=base::UnguessableToken",
- "mojo.common.mojom.String16=base::string16",
"mojo.common.mojom.Time=base::Time[copyable_pass_by_value]",
"mojo.common.mojom.TimeDelta=base::TimeDelta[copyable_pass_by_value]",
"mojo.common.mojom.TimeTicks=base::TimeTicks[copyable_pass_by_value]",
- "mojo.common.mojom.Version=base::Version",
]
diff --git a/chromium/mojo/common/traits_test_service.mojom b/chromium/mojo/common/traits_test_service.mojom
index bf508cd661a..7659eea8abb 100644
--- a/chromium/mojo/common/traits_test_service.mojom
+++ b/chromium/mojo/common/traits_test_service.mojom
@@ -4,7 +4,7 @@
module mojo.common.mojom;
-import "mojo/common/common_custom_types.mojom";
+import "mojo/common/version.mojom";
// All functions on this interface echo their arguments to test StructTraits
// serialization and deserialization.
diff --git a/chromium/mojo/common/typemaps.gni b/chromium/mojo/common/typemaps.gni
index 4c3809ddf83..ae360310f18 100644
--- a/chromium/mojo/common/typemaps.gni
+++ b/chromium/mojo/common/typemaps.gni
@@ -2,4 +2,13 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-typemaps = [ "//mojo/common/common_custom_types.typemap" ]
+typemaps = [
+ "//mojo/common/file.typemap",
+ "//mojo/common/file_path.typemap",
+ "//mojo/common/string16.typemap",
+ "//mojo/common/text_direction.typemap",
+ "//mojo/common/time.typemap",
+ "//mojo/common/unguessable_token.typemap",
+ "//mojo/common/values.typemap",
+ "//mojo/common/version.typemap",
+]
diff --git a/chromium/mojo/common/unguessable_token.mojom b/chromium/mojo/common/unguessable_token.mojom
new file mode 100644
index 00000000000..32797171caf
--- /dev/null
+++ b/chromium/mojo/common/unguessable_token.mojom
@@ -0,0 +1,11 @@
+// Copyright 2016 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.
+
+module mojo.common.mojom;
+
+// Corresponds to |base::UnguessableToken| in base/unguessable_token.h
+struct UnguessableToken {
+ uint64 high;
+ uint64 low;
+};
diff --git a/chromium/mojo/common/unguessable_token.typemap b/chromium/mojo/common/unguessable_token.typemap
new file mode 100644
index 00000000000..ec7b1942b34
--- /dev/null
+++ b/chromium/mojo/common/unguessable_token.typemap
@@ -0,0 +1,12 @@
+# Copyright 2016 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.
+
+mojom = "//mojo/common/unguessable_token.mojom"
+public_headers = [ "//base/unguessable_token.h" ]
+traits_headers = [ "//mojo/common/common_custom_types_struct_traits.h" ]
+public_deps = [
+ "//mojo/common:struct_traits",
+]
+
+type_mappings = [ "mojo.common.mojom.UnguessableToken=base::UnguessableToken" ]
diff --git a/chromium/mojo/common/user_agent.cc b/chromium/mojo/common/user_agent.cc
deleted file mode 100644
index 6055cbe5aae..00000000000
--- a/chromium/mojo/common/user_agent.cc
+++ /dev/null
@@ -1,25 +0,0 @@
-// 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/common/user_agent.h"
-
-#include "build/build_config.h"
-
-namespace mojo {
-namespace common {
-
-std::string GetUserAgent() {
- // TODO(jam): change depending on OS
-#if defined(OS_ANDROID)
- return "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 7 Build/LMY48G) "
- "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.68 "
- "Safari/537.36";
-#else
- return "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like "
- "Gecko) Chrome/42.0.2311.68 Safari/537.36";
-#endif
-}
-
-} // namespace common
-} // namespace mojo
diff --git a/chromium/mojo/common/user_agent.h b/chromium/mojo/common/user_agent.h
deleted file mode 100644
index 031b1029015..00000000000
--- a/chromium/mojo/common/user_agent.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// 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.
-
-#ifndef MOJO_COMMON_USER_AGENT_H_
-#define MOJO_COMMON_USER_AGENT_H_
-
-#include <string>
-
-#include "mojo/common/mojo_common_export.h"
-
-namespace mojo {
-namespace common {
-
-std::string MOJO_COMMON_EXPORT GetUserAgent();
-
-} // namespace common
-} // namespace mojo
-
-#endif // MOJO_COMMON_USER_AGENT_H_
diff --git a/chromium/mojo/common/values.mojom b/chromium/mojo/common/values.mojom
new file mode 100644
index 00000000000..722198c56ac
--- /dev/null
+++ b/chromium/mojo/common/values.mojom
@@ -0,0 +1,32 @@
+// Copyright 2016 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.
+
+module mojo.common.mojom;
+
+union Value {
+ NullValue? null_value;
+ bool bool_value;
+ int32 int_value;
+ double double_value;
+ string string_value;
+ array<uint8> binary_value;
+ DictionaryValue dictionary_value;
+ ListValue list_value;
+};
+
+struct ListValue {
+ array<Value> values;
+};
+
+struct DictionaryValue {
+ map<string, Value> values;
+};
+
+// An empty struct representing a null base::Value.
+struct NullValue {
+};
+
+// To avoid versioning problems for arc. TODO(sammc): Remove ASAP.
+[Native]
+struct LegacyListValue;
diff --git a/chromium/mojo/common/values.typemap b/chromium/mojo/common/values.typemap
new file mode 100644
index 00000000000..069c277940b
--- /dev/null
+++ b/chromium/mojo/common/values.typemap
@@ -0,0 +1,25 @@
+# Copyright 2016 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.
+
+mojom = "//mojo/common/values.mojom"
+public_headers = [ "//base/values.h" ]
+traits_headers = [
+ "//ipc/ipc_message_utils.h",
+ "//mojo/common/values_struct_traits.h",
+]
+public_deps = [
+ "//base",
+ "//ipc",
+]
+sources = [
+ "values_struct_traits.cc",
+ "values_struct_traits.h",
+]
+
+type_mappings = [
+ "mojo.common.mojom.DictionaryValue=std::unique_ptr<base::DictionaryValue>[move_only,nullable_is_same_type]",
+ "mojo.common.mojom.LegacyListValue=base::ListValue",
+ "mojo.common.mojom.ListValue=std::unique_ptr<base::ListValue>[move_only,nullable_is_same_type]",
+ "mojo.common.mojom.Value=std::unique_ptr<base::Value>[move_only,nullable_is_same_type]",
+]
diff --git a/chromium/mojo/common/values_struct_traits.cc b/chromium/mojo/common/values_struct_traits.cc
new file mode 100644
index 00000000000..d085906e86c
--- /dev/null
+++ b/chromium/mojo/common/values_struct_traits.cc
@@ -0,0 +1,102 @@
+// Copyright 2016 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 "base/memory/ptr_util.h"
+#include "mojo/common/values_struct_traits.h"
+
+namespace mojo {
+
+bool StructTraits<common::mojom::ListValueDataView,
+ std::unique_ptr<base::ListValue>>::
+ Read(common::mojom::ListValueDataView data,
+ std::unique_ptr<base::ListValue>* value_out) {
+ mojo::ArrayDataView<common::mojom::ValueDataView> view;
+ data.GetValuesDataView(&view);
+
+ auto list_value = base::MakeUnique<base::ListValue>();
+ for (size_t i = 0; i < view.size(); ++i) {
+ std::unique_ptr<base::Value> value;
+ if (!view.Read(i, &value))
+ return false;
+
+ list_value->Append(std::move(value));
+ }
+ *value_out = std::move(list_value);
+ return true;
+}
+
+bool StructTraits<common::mojom::DictionaryValueDataView,
+ std::unique_ptr<base::DictionaryValue>>::
+ Read(common::mojom::DictionaryValueDataView data,
+ std::unique_ptr<base::DictionaryValue>* value_out) {
+ mojo::MapDataView<mojo::StringDataView, common::mojom::ValueDataView> view;
+ data.GetValuesDataView(&view);
+ auto dictionary_value = base::MakeUnique<base::DictionaryValue>();
+ for (size_t i = 0; i < view.size(); ++i) {
+ base::StringPiece key;
+ std::unique_ptr<base::Value> value;
+ if (!view.keys().Read(i, &key) || !view.values().Read(i, &value))
+ return false;
+
+ dictionary_value->SetWithoutPathExpansion(key, std::move(value));
+ }
+ *value_out = std::move(dictionary_value);
+ return true;
+}
+
+bool UnionTraits<common::mojom::ValueDataView, std::unique_ptr<base::Value>>::
+ Read(common::mojom::ValueDataView data,
+ std::unique_ptr<base::Value>* value_out) {
+ switch (data.tag()) {
+ case common::mojom::ValueDataView::Tag::NULL_VALUE: {
+ *value_out = base::Value::CreateNullValue();
+ return true;
+ }
+ case common::mojom::ValueDataView::Tag::BOOL_VALUE: {
+ *value_out = base::MakeUnique<base::FundamentalValue>(data.bool_value());
+ return true;
+ }
+ case common::mojom::ValueDataView::Tag::INT_VALUE: {
+ *value_out = base::MakeUnique<base::FundamentalValue>(data.int_value());
+ return true;
+ }
+ case common::mojom::ValueDataView::Tag::DOUBLE_VALUE: {
+ *value_out =
+ base::MakeUnique<base::FundamentalValue>(data.double_value());
+ return true;
+ }
+ case common::mojom::ValueDataView::Tag::STRING_VALUE: {
+ base::StringPiece string_value;
+ if (!data.ReadStringValue(&string_value))
+ return false;
+ *value_out = base::MakeUnique<base::StringValue>(string_value);
+ return true;
+ }
+ case common::mojom::ValueDataView::Tag::BINARY_VALUE: {
+ mojo::ArrayDataView<uint8_t> binary_data;
+ data.GetBinaryValueDataView(&binary_data);
+ *value_out = base::BinaryValue::CreateWithCopiedBuffer(
+ reinterpret_cast<const char*>(binary_data.data()),
+ binary_data.size());
+ return true;
+ }
+ case common::mojom::ValueDataView::Tag::DICTIONARY_VALUE: {
+ std::unique_ptr<base::DictionaryValue> dictionary_value;
+ if (!data.ReadDictionaryValue(&dictionary_value))
+ return false;
+ *value_out = std::move(dictionary_value);
+ return true;
+ }
+ case common::mojom::ValueDataView::Tag::LIST_VALUE: {
+ std::unique_ptr<base::ListValue> list_value;
+ if (!data.ReadListValue(&list_value))
+ return false;
+ *value_out = std::move(list_value);
+ return true;
+ }
+ }
+ return false;
+}
+
+} // namespace mojo
diff --git a/chromium/mojo/common/values_struct_traits.h b/chromium/mojo/common/values_struct_traits.h
new file mode 100644
index 00000000000..82d5696bee6
--- /dev/null
+++ b/chromium/mojo/common/values_struct_traits.h
@@ -0,0 +1,250 @@
+// Copyright 2016 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.
+
+#ifndef MOJO_COMMON_VALUES_STRUCT_TRAITS_H_
+#define MOJO_COMMON_VALUES_STRUCT_TRAITS_H_
+
+#include "base/values.h"
+#include "mojo/common/values.mojom.h"
+#include "mojo/public/cpp/bindings/array_traits.h"
+#include "mojo/public/cpp/bindings/map_traits.h"
+#include "mojo/public/cpp/bindings/struct_traits.h"
+#include "mojo/public/cpp/bindings/union_traits.h"
+
+namespace mojo {
+
+template <>
+struct ArrayTraits<base::ListValue> {
+ using Element = std::unique_ptr<base::Value>;
+ using ConstIterator = base::ListValue::const_iterator;
+
+ static size_t GetSize(const base::ListValue& input) {
+ return input.GetSize();
+ }
+
+ static ConstIterator GetBegin(const base::ListValue& input) {
+ return input.begin();
+ }
+
+ static void AdvanceIterator(ConstIterator& iterator) { ++iterator; }
+
+ static const Element& GetValue(ConstIterator& iterator) { return *iterator; }
+};
+
+template <>
+struct StructTraits<common::mojom::ListValueDataView, base::ListValue> {
+ static const base::ListValue& values(const base::ListValue& value) {
+ return value;
+ }
+};
+
+template <>
+struct StructTraits<common::mojom::ListValueDataView,
+ std::unique_ptr<base::ListValue>> {
+ static bool IsNull(const std::unique_ptr<base::ListValue>& value) {
+ return !value;
+ }
+
+ static void SetToNull(std::unique_ptr<base::ListValue>* value) {
+ value->reset();
+ }
+
+ static const base::ListValue& values(
+ const std::unique_ptr<base::ListValue>& value) {
+ return *value;
+ }
+
+ static bool Read(common::mojom::ListValueDataView data,
+ std::unique_ptr<base::ListValue>* value);
+};
+
+template <>
+struct MapTraits<base::DictionaryValue> {
+ using Key = std::string;
+ using Value = base::Value;
+ using Iterator = base::DictionaryValue::Iterator;
+
+ static size_t GetSize(const base::DictionaryValue& input) {
+ return input.size();
+ }
+
+ static Iterator GetBegin(const base::DictionaryValue& input) {
+ return Iterator(input);
+ }
+
+ static void AdvanceIterator(Iterator& iterator) { iterator.Advance(); }
+
+ static const Key& GetKey(Iterator& iterator) { return iterator.key(); }
+
+ static const Value& GetValue(Iterator& iterator) { return iterator.value(); }
+};
+
+template <>
+struct StructTraits<common::mojom::DictionaryValueDataView,
+ base::DictionaryValue> {
+ static const base::DictionaryValue& values(
+ const base::DictionaryValue& value) {
+ return value;
+ }
+};
+
+template <>
+struct StructTraits<common::mojom::DictionaryValueDataView,
+ std::unique_ptr<base::DictionaryValue>> {
+ static bool IsNull(const std::unique_ptr<base::DictionaryValue>& value) {
+ return !value;
+ }
+
+ static void SetToNull(std::unique_ptr<base::DictionaryValue>* value) {
+ value->reset();
+ }
+
+ static const base::DictionaryValue& values(
+ const std::unique_ptr<base::DictionaryValue>& value) {
+ return *value;
+ }
+ static bool Read(common::mojom::DictionaryValueDataView data,
+ std::unique_ptr<base::DictionaryValue>* value);
+};
+
+template <>
+struct UnionTraits<common::mojom::ValueDataView, base::Value> {
+ static common::mojom::ValueDataView::Tag GetTag(const base::Value& data) {
+ switch (data.GetType()) {
+ case base::Value::Type::NONE:
+ return common::mojom::ValueDataView::Tag::NULL_VALUE;
+ case base::Value::Type::BOOLEAN:
+ return common::mojom::ValueDataView::Tag::BOOL_VALUE;
+ case base::Value::Type::INTEGER:
+ return common::mojom::ValueDataView::Tag::INT_VALUE;
+ case base::Value::Type::DOUBLE:
+ return common::mojom::ValueDataView::Tag::DOUBLE_VALUE;
+ case base::Value::Type::STRING:
+ return common::mojom::ValueDataView::Tag::STRING_VALUE;
+ case base::Value::Type::BINARY:
+ return common::mojom::ValueDataView::Tag::BINARY_VALUE;
+ case base::Value::Type::DICTIONARY:
+ return common::mojom::ValueDataView::Tag::DICTIONARY_VALUE;
+ case base::Value::Type::LIST:
+ return common::mojom::ValueDataView::Tag::LIST_VALUE;
+ }
+ NOTREACHED();
+ return common::mojom::ValueDataView::Tag::NULL_VALUE;
+ }
+
+ static common::mojom::NullValuePtr null_value(const base::Value& value) {
+ return common::mojom::NullValuePtr();
+ }
+
+ static bool bool_value(const base::Value& value) {
+ bool bool_value{};
+ if (!value.GetAsBoolean(&bool_value))
+ NOTREACHED();
+ return bool_value;
+ }
+
+ static int32_t int_value(const base::Value& value) {
+ int int_value{};
+ if (!value.GetAsInteger(&int_value))
+ NOTREACHED();
+ return int_value;
+ }
+
+ static double double_value(const base::Value& value) {
+ double double_value{};
+ if (!value.GetAsDouble(&double_value))
+ NOTREACHED();
+ return double_value;
+ }
+
+ static base::StringPiece string_value(const base::Value& value) {
+ base::StringPiece string_piece;
+ if (!value.GetAsString(&string_piece))
+ NOTREACHED();
+ return string_piece;
+ }
+
+ static mojo::ConstCArray<uint8_t> binary_value(const base::Value& value) {
+ const base::BinaryValue* binary_value = nullptr;
+ if (!value.GetAsBinary(&binary_value))
+ NOTREACHED();
+ return mojo::ConstCArray<uint8_t>(
+ binary_value->GetSize(),
+ reinterpret_cast<const uint8_t*>(binary_value->GetBuffer()));
+ }
+
+ static const base::ListValue& list_value(const base::Value& value) {
+ const base::ListValue* list_value = nullptr;
+ if (!value.GetAsList(&list_value))
+ NOTREACHED();
+ return *list_value;
+ }
+ static const base::DictionaryValue& dictionary_value(
+ const base::Value& value) {
+ const base::DictionaryValue* dictionary_value = nullptr;
+ if (!value.GetAsDictionary(&dictionary_value))
+ NOTREACHED();
+ return *dictionary_value;
+ }
+};
+
+template <>
+struct UnionTraits<common::mojom::ValueDataView, std::unique_ptr<base::Value>> {
+ static bool IsNull(const std::unique_ptr<base::Value>& value) {
+ return !value;
+ }
+
+ static void SetToNull(std::unique_ptr<base::Value>* value) { value->reset(); }
+
+ static common::mojom::ValueDataView::Tag GetTag(
+ const std::unique_ptr<base::Value>& value) {
+ return UnionTraits<common::mojom::ValueDataView, base::Value>::GetTag(
+ *value);
+ }
+
+ static common::mojom::NullValuePtr null_value(
+ const std::unique_ptr<base::Value>& value) {
+ return UnionTraits<common::mojom::ValueDataView, base::Value>::null_value(
+ *value);
+ }
+ static bool bool_value(const std::unique_ptr<base::Value>& value) {
+ return UnionTraits<common::mojom::ValueDataView, base::Value>::bool_value(
+ *value);
+ }
+ static int32_t int_value(const std::unique_ptr<base::Value>& value) {
+ return UnionTraits<common::mojom::ValueDataView, base::Value>::int_value(
+ *value);
+ }
+ static double double_value(const std::unique_ptr<base::Value>& value) {
+ return UnionTraits<common::mojom::ValueDataView, base::Value>::double_value(
+ *value);
+ }
+ static base::StringPiece string_value(
+ const std::unique_ptr<base::Value>& value) {
+ return UnionTraits<common::mojom::ValueDataView, base::Value>::string_value(
+ *value);
+ }
+ static mojo::ConstCArray<uint8_t> binary_value(
+ const std::unique_ptr<base::Value>& value) {
+ return UnionTraits<common::mojom::ValueDataView, base::Value>::binary_value(
+ *value);
+ }
+ static const base::ListValue& list_value(
+ const std::unique_ptr<base::Value>& value) {
+ return UnionTraits<common::mojom::ValueDataView, base::Value>::list_value(
+ *value);
+ }
+ static const base::DictionaryValue& dictionary_value(
+ const std::unique_ptr<base::Value>& value) {
+ return UnionTraits<common::mojom::ValueDataView,
+ base::Value>::dictionary_value(*value);
+ }
+
+ static bool Read(common::mojom::ValueDataView data,
+ std::unique_ptr<base::Value>* value);
+};
+
+} // namespace mojo
+
+#endif // MOJO_COMMON_VALUES_STRUCT_TRAITS_H_
diff --git a/chromium/mojo/common/version.mojom b/chromium/mojo/common/version.mojom
new file mode 100644
index 00000000000..6ddf6e6b8cd
--- /dev/null
+++ b/chromium/mojo/common/version.mojom
@@ -0,0 +1,10 @@
+// Copyright 2016 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.
+
+module mojo.common.mojom;
+
+// Corresponds to |base::Version| in base/version.h
+struct Version {
+ array<uint32> components;
+};
diff --git a/chromium/mojo/common/version.typemap b/chromium/mojo/common/version.typemap
new file mode 100644
index 00000000000..fa7fed9acfd
--- /dev/null
+++ b/chromium/mojo/common/version.typemap
@@ -0,0 +1,12 @@
+# Copyright 2016 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.
+
+mojom = "//mojo/common/version.mojom"
+public_headers = [ "//base/version.h" ]
+traits_headers = [ "//mojo/common/common_custom_types_struct_traits.h" ]
+public_deps = [
+ "//mojo/common:struct_traits",
+]
+
+type_mappings = [ "mojo.common.mojom.Version=base::Version" ]
diff --git a/chromium/mojo/edk/embedder/BUILD.gn b/chromium/mojo/edk/embedder/BUILD.gn
index 67a7376eb45..c652e517527 100644
--- a/chromium/mojo/edk/embedder/BUILD.gn
+++ b/chromium/mojo/edk/embedder/BUILD.gn
@@ -15,7 +15,6 @@ source_set("headers") {
"platform_channel_pair.h",
"platform_handle.h",
"platform_handle_utils.h",
- "process_delegate.h",
"scoped_platform_handle.h",
]
@@ -54,7 +53,6 @@ source_set("embedder") {
defines = [ "MOJO_SYSTEM_IMPL_IMPLEMENTATION" ]
public_deps = [
- ":delegates",
":headers",
":platform",
"//base",
@@ -121,25 +119,6 @@ source_set("platform") {
}
}
-source_set("delegates") {
- # This isn't really a standalone target; it must be linked into the
- # mojo_system_impl component.
- visibility = [
- ":embedder",
- "//mojo/edk/system",
- ]
-
- sources = [
- "process_delegate.h",
- ]
-
- defines = [ "MOJO_SYSTEM_IMPL_IMPLEMENTATION" ]
-
- public_deps = [
- "//mojo/public/cpp/system",
- ]
-}
-
source_set("embedder_unittests") {
testonly = true
diff --git a/chromium/mojo/edk/embedder/embedder.cc b/chromium/mojo/edk/embedder/embedder.cc
index 758d96c6580..41d48d4dc2e 100644
--- a/chromium/mojo/edk/embedder/embedder.cc
+++ b/chromium/mojo/edk/embedder/embedder.cc
@@ -5,6 +5,7 @@
#include "mojo/edk/embedder/embedder.h"
#include <stdint.h>
+#include <utility>
#include "base/bind.h"
#include "base/location.h"
@@ -17,8 +18,8 @@
#include "mojo/edk/embedder/embedder_internal.h"
#include "mojo/edk/embedder/entrypoints.h"
#include "mojo/edk/embedder/platform_channel_pair.h"
-#include "mojo/edk/embedder/process_delegate.h"
#include "mojo/edk/system/core.h"
+#include "mojo/edk/system/node_controller.h"
#if !defined(OS_NACL)
#include "crypto/random.h"
@@ -33,7 +34,6 @@ class PlatformSupport;
namespace internal {
Core* g_core;
-ProcessDelegate* g_process_delegate;
Core* GetCore() { return g_core; }
@@ -82,14 +82,12 @@ ScopedMessagePipeHandle ConnectToPeerProcess(ScopedPlatformHandle pipe) {
ScopedMessagePipeHandle ConnectToPeerProcess(ScopedPlatformHandle pipe,
const std::string& peer_token) {
- CHECK(internal::g_process_delegate);
DCHECK(pipe.is_valid());
DCHECK(!peer_token.empty());
return internal::g_core->ConnectToPeerProcess(std::move(pipe), peer_token);
}
void ClosePeerConnection(const std::string& peer_token) {
- CHECK(internal::g_process_delegate);
return internal::g_core->ClosePeerConnection(peer_token);
}
@@ -136,19 +134,18 @@ MojoResult PassSharedMemoryHandle(
mojo_handle, shared_memory_handle, num_bytes, read_only);
}
-void InitIPCSupport(ProcessDelegate* process_delegate,
- scoped_refptr<base::TaskRunner> io_thread_task_runner) {
+void InitIPCSupport(scoped_refptr<base::TaskRunner> io_thread_task_runner) {
CHECK(internal::g_core);
internal::g_core->SetIOTaskRunner(io_thread_task_runner);
- internal::g_process_delegate = process_delegate;
}
-void ShutdownIPCSupport() {
- CHECK(internal::g_process_delegate);
+scoped_refptr<base::TaskRunner> GetIOTaskRunner() {
+ return internal::g_core->GetNodeController()->io_task_runner();
+}
+
+void ShutdownIPCSupport(const base::Closure& callback) {
CHECK(internal::g_core);
- internal::g_core->RequestShutdown(
- base::Bind(&ProcessDelegate::OnShutdownComplete,
- base::Unretained(internal::g_process_delegate)));
+ internal::g_core->RequestShutdown(callback);
}
#if defined(OS_MACOSX) && !defined(OS_IOS)
@@ -160,18 +157,15 @@ void SetMachPortProvider(base::PortProvider* port_provider) {
ScopedMessagePipeHandle CreateMessagePipe(
ScopedPlatformHandle platform_handle) {
- CHECK(internal::g_process_delegate);
return internal::g_core->CreateMessagePipe(std::move(platform_handle));
}
ScopedMessagePipeHandle CreateParentMessagePipe(
const std::string& token, const std::string& child_token) {
- CHECK(internal::g_process_delegate);
return internal::g_core->CreateParentMessagePipe(token, child_token);
}
ScopedMessagePipeHandle CreateChildMessagePipe(const std::string& token) {
- CHECK(internal::g_process_delegate);
return internal::g_core->CreateChildMessagePipe(token);
}
diff --git a/chromium/mojo/edk/embedder/embedder.h b/chromium/mojo/edk/embedder/embedder.h
index e673aff2cd3..c0672aa8652 100644
--- a/chromium/mojo/edk/embedder/embedder.h
+++ b/chromium/mojo/edk/embedder/embedder.h
@@ -27,8 +27,6 @@ class PortProvider;
namespace mojo {
namespace edk {
-class ProcessDelegate;
-
using ProcessErrorCallback = base::Callback<void(const std::string& error)>;
// Basic configuration/initialization ------------------------------------------
@@ -150,22 +148,20 @@ PassSharedMemoryHandle(MojoHandle mojo_handle,
//
// This subsystem may be shut down using |ShutdownIPCSupport()|. None of the IPC
// functions may be called after this is called.
-
-// Initializes a process of the given type; to be called after |Init()|.
-// - |process_delegate| must be a process delegate of the appropriate type
-// corresponding to |process_type|; its methods will be called on the same
-// thread as Shutdown.
-// - |process_delegate|, and |io_thread_task_runner| should live at least
-// until |ShutdownIPCSupport()|'s callback has been run.
+//
+// |io_thread_task_runner| should live at least until |ShutdownIPCSupport()|'s
+// callback has been run.
MOJO_SYSTEM_IMPL_EXPORT void InitIPCSupport(
- ProcessDelegate* process_delegate,
scoped_refptr<base::TaskRunner> io_thread_task_runner);
+// Retrieves the TaskRunner used for IPC I/O, as set by InitIPCSupport.
+MOJO_SYSTEM_IMPL_EXPORT scoped_refptr<base::TaskRunner> GetIOTaskRunner();
+
// Shuts down the subsystem initialized by |InitIPCSupport()|. It be called from
// any thread and will attempt to complete shutdown on the I/O thread with which
-// the system was initialized. Upon completion the ProcessDelegate's
-// |OnShutdownComplete()| method is invoked.
-MOJO_SYSTEM_IMPL_EXPORT void ShutdownIPCSupport();
+// the system was initialized. Upon completion, |callback| is invoked on an
+// arbitrary thread.
+MOJO_SYSTEM_IMPL_EXPORT void ShutdownIPCSupport(const base::Closure& callback);
#if defined(OS_MACOSX) && !defined(OS_IOS)
// Set the |base::PortProvider| for this process. Can be called on any thread,
diff --git a/chromium/mojo/edk/embedder/embedder_unittest.cc b/chromium/mojo/edk/embedder/embedder_unittest.cc
index aea0f078079..f0fe44050d6 100644
--- a/chromium/mojo/edk/embedder/embedder_unittest.cc
+++ b/chromium/mojo/edk/embedder/embedder_unittest.cc
@@ -23,13 +23,13 @@
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/test_timeouts.h"
+#include "mojo/edk/embedder/embedder.h"
#include "mojo/edk/embedder/named_platform_handle.h"
#include "mojo/edk/embedder/named_platform_handle_utils.h"
#include "mojo/edk/embedder/platform_channel_pair.h"
#include "mojo/edk/embedder/test_embedder.h"
#include "mojo/edk/system/test_utils.h"
#include "mojo/edk/test/mojo_test_base.h"
-#include "mojo/edk/test/scoped_ipc_support.h"
#include "mojo/public/c/system/core.h"
#include "mojo/public/cpp/system/handle.h"
#include "mojo/public/cpp/system/message_pipe.h"
@@ -579,13 +579,7 @@ void CreateClientHandleOnIoThread(const NamedPlatformHandle& named_handle,
*output = CreateClientHandle(named_handle);
}
-#if defined(OS_ANDROID)
-// Disabled on Android as suspected source of flake. https://crbug.com/666356.
-#define MAYBE_ClosePendingPeerConnection DISABLED_ClosePendingPeerConnection
-#else
-#define MAYBE_ClosePendingPeerConnection ClosePendingPeerConnection
-#endif
-TEST_F(EmbedderTest, MAYBE_ClosePendingPeerConnection) {
+TEST_F(EmbedderTest, ClosePendingPeerConnection) {
NamedPlatformHandle named_handle = GenerateChannelName();
std::string peer_token = GenerateRandomToken();
ScopedMessagePipeHandle server_pipe =
@@ -601,7 +595,7 @@ TEST_F(EmbedderTest, MAYBE_ClosePendingPeerConnection) {
// work. By the time the local message pipe has been observerd as closed,
// that task will have been posted. Therefore, a task to create the client
// connection should be handled after the channel is closed.
- test::GetIoTaskRunner()->PostTaskAndReply(
+ GetIOTaskRunner()->PostTaskAndReply(
FROM_HERE,
base::Bind(&CreateClientHandleOnIoThread, named_handle, &client_handle),
run_loop.QuitClosure());
@@ -611,13 +605,7 @@ TEST_F(EmbedderTest, MAYBE_ClosePendingPeerConnection) {
#if !defined(OS_IOS)
-#if defined(OS_ANDROID)
-// Disabled on Android as suspected source of flake. https://crbug.com/666356.
-#define MAYBE_ClosePipeToConnectedPeer DISABLED_ClosePipeToConnectedPeer
-#else
-#define MAYBE_ClosePipeToConnectedPeer ClosePipeToConnectedPeer
-#endif
-TEST_F(EmbedderTest, MAYBE_ClosePipeToConnectedPeer) {
+TEST_F(EmbedderTest, ClosePipeToConnectedPeer) {
set_launch_type(LaunchType::PEER);
auto& controller = StartClient("ClosePipeToConnectedPeerClient");
MojoHandle server_mp = controller.pipe();
@@ -648,13 +636,7 @@ DEFINE_TEST_CLIENT_TEST_WITH_PIPE(ClosePipeToConnectedPeerClient, EmbedderTest,
MOJO_DEADLINE_INDEFINITE, nullptr));
}
-#if defined(OS_ANDROID)
-// Disabled on Android as suspected source of flake. https://crbug.com/666356.
-#define MAYBE_ClosePipeToConnectingPeer DISABLED_ClosePipeToConnectingPeer
-#else
-#define MAYBE_ClosePipeToConnectingPeer ClosePipeToConnectingPeer
-#endif
-TEST_F(EmbedderTest, MAYBE_ClosePipeToConnectingPeer) {
+TEST_F(EmbedderTest, ClosePipeToConnectingPeer) {
set_launch_type(LaunchType::PEER);
auto& controller = StartClient("ClosePipeToConnectingPeerClient");
controller.ClosePeerConnection();
diff --git a/chromium/mojo/edk/embedder/named_platform_handle_utils.h b/chromium/mojo/edk/embedder/named_platform_handle_utils.h
index f13e1765fab..b767ea0975c 100644
--- a/chromium/mojo/edk/embedder/named_platform_handle_utils.h
+++ b/chromium/mojo/edk/embedder/named_platform_handle_utils.h
@@ -18,6 +18,15 @@ namespace edk {
struct NamedPlatformHandle;
+#if defined(OS_POSIX)
+
+// The maximum length of the name of a unix domain socket. The standard size on
+// linux is 108, mac is 104. To maintain consistency across platforms we
+// standardize on the smaller value.
+const size_t kMaxSocketNameLength = 104;
+
+#endif
+
struct CreateServerHandleOptions {
#if defined(OS_WIN)
// If true, creating a server handle will fail if another pipe with the same
diff --git a/chromium/mojo/edk/embedder/named_platform_handle_utils_posix.cc b/chromium/mojo/edk/embedder/named_platform_handle_utils_posix.cc
index 4d9e8eece02..056f4d64e5d 100644
--- a/chromium/mojo/edk/embedder/named_platform_handle_utils_posix.cc
+++ b/chromium/mojo/edk/embedder/named_platform_handle_utils_posix.cc
@@ -19,12 +19,6 @@ namespace mojo {
namespace edk {
namespace {
-// The maximum length of the name of a socket for MODE_NAMED_SERVER or
-// MODE_NAMED_CLIENT if you want to pass in your own socket.
-// The standard size on linux is 108, mac is 104. To maintain consistency
-// across platforms we standardize on the smaller value.
-const size_t kMaxSocketNameLength = 104;
-
// This function fills in |unix_addr| with the appropriate data for the socket,
// and sets |unix_addr_len| to the length of the data therein.
// Returns true on success, or false on failure (typically because |handle.name|
diff --git a/chromium/mojo/edk/embedder/platform_channel_pair.h b/chromium/mojo/edk/embedder/platform_channel_pair.h
index f80de89cedd..9c93f760948 100644
--- a/chromium/mojo/edk/embedder/platform_channel_pair.h
+++ b/chromium/mojo/edk/embedder/platform_channel_pair.h
@@ -69,6 +69,7 @@ class MOJO_SYSTEM_IMPL_EXPORT PlatformChannelPair {
// |PrepareToPassClientHandleToChildProcess()| and launched the child (using
// the provided data), to create a client handle connected to the server
// handle (in the parent process).
+ // TODO(jcivelli): remove the command_line param. http://crbug.com/670106
static ScopedPlatformHandle PassClientHandleFromParentProcess(
const base::CommandLine& command_line);
diff --git a/chromium/mojo/edk/embedder/platform_channel_pair_posix.cc b/chromium/mojo/edk/embedder/platform_channel_pair_posix.cc
index 55f3ae24ab1..4760e955724 100644
--- a/chromium/mojo/edk/embedder/platform_channel_pair_posix.cc
+++ b/chromium/mojo/edk/embedder/platform_channel_pair_posix.cc
@@ -35,6 +35,15 @@ namespace edk {
namespace {
+#if defined(OS_ANDROID)
+enum {
+ // Leave room for any other descriptors defined in content for example.
+ // TODO(jcivelli): consider changing base::GlobalDescriptors to generate a
+ // key when setting the file descriptor (http://crbug.com/676442).
+ kAndroidClientHandleDescriptor =
+ base::GlobalDescriptors::kBaseDescriptor + 10000,
+};
+#else
bool IsTargetDescriptorUsed(
const base::FileHandleMappingVector& file_handle_mapping,
int target_fd) {
@@ -44,6 +53,7 @@ bool IsTargetDescriptorUsed(
}
return false;
}
+#endif
} // namespace
@@ -92,13 +102,21 @@ ScopedPlatformHandle
PlatformChannelPair::PassClientHandleFromParentProcessFromString(
const std::string& value) {
int client_fd = -1;
+#if defined(OS_ANDROID)
+ base::GlobalDescriptors::Key key = -1;
+ if (value.empty() || !base::StringToUint(value, &key)) {
+ LOG(ERROR) << "Missing or invalid --" << kMojoPlatformChannelHandleSwitch;
+ return ScopedPlatformHandle();
+ }
+ client_fd = base::GlobalDescriptors::GetInstance()->Get(key);
+#else
if (value.empty() ||
!base::StringToInt(value, &client_fd) ||
client_fd < base::GlobalDescriptors::kBaseDescriptor) {
LOG(ERROR) << "Missing or invalid --" << kMojoPlatformChannelHandleSwitch;
return ScopedPlatformHandle();
}
-
+#endif
return ScopedPlatformHandle(PlatformHandle(client_fd));
}
@@ -124,6 +142,12 @@ void PlatformChannelPair::PrepareToPassClientHandleToChildProcess(
std::string
PlatformChannelPair::PrepareToPassClientHandleToChildProcessAsString(
HandlePassingInformation* handle_passing_info) const {
+#if defined(OS_ANDROID)
+ int fd = client_handle_.get().handle;
+ handle_passing_info->push_back(
+ std::pair<int, int>(fd, kAndroidClientHandleDescriptor));
+ return base::UintToString(kAndroidClientHandleDescriptor);
+#else
DCHECK(handle_passing_info);
// This is an arbitrary sanity check. (Note that this guarantees that the loop
// below will terminate sanely.)
@@ -141,6 +165,7 @@ PlatformChannelPair::PrepareToPassClientHandleToChildProcessAsString(
handle_passing_info->push_back(
std::pair<int, int>(client_handle_.get().handle, target_fd));
return base::IntToString(target_fd);
+#endif
}
} // namespace edk
diff --git a/chromium/mojo/edk/embedder/platform_channel_utils_posix.cc b/chromium/mojo/edk/embedder/platform_channel_utils_posix.cc
index 9fda89ebb65..689b6eec0dc 100644
--- a/chromium/mojo/edk/embedder/platform_channel_utils_posix.cc
+++ b/chromium/mojo/edk/embedder/platform_channel_utils_posix.cc
@@ -247,7 +247,8 @@ ssize_t PlatformChannelRecvmsg(PlatformHandle h,
}
bool ServerAcceptConnection(PlatformHandle server_handle,
- ScopedPlatformHandle* connection_handle) {
+ ScopedPlatformHandle* connection_handle,
+ bool check_peer_user) {
DCHECK(server_handle.is_valid());
connection_handle->reset();
#if defined(OS_NACL)
@@ -260,7 +261,7 @@ bool ServerAcceptConnection(PlatformHandle server_handle,
return IsRecoverableError();
// Verify that the IPC channel peer is running as the same user.
- if (!IsPeerAuthorized(accept_handle.get())) {
+ if (check_peer_user && !IsPeerAuthorized(accept_handle.get())) {
return true;
}
diff --git a/chromium/mojo/edk/embedder/platform_channel_utils_posix.h b/chromium/mojo/edk/embedder/platform_channel_utils_posix.h
index 8bf2632e0ba..23cfa92a344 100644
--- a/chromium/mojo/edk/embedder/platform_channel_utils_posix.h
+++ b/chromium/mojo/edk/embedder/platform_channel_utils_posix.h
@@ -74,10 +74,12 @@ PlatformChannelRecvmsg(PlatformHandle h,
// Returns false if |server_handle| encounters an unrecoverable error.
// Returns true if it's valid to keep listening on |server_handle|. In this
// case, it's possible that a connection wasn't successfully established; then,
-// |connection_handle| will be invalid.
+// |connection_handle| will be invalid. If |check_peer_user| is True, the
+// connection will be rejected if the peer is running as a different user.
MOJO_SYSTEM_IMPL_EXPORT bool ServerAcceptConnection(
PlatformHandle server_handle,
- ScopedPlatformHandle* connection_handle);
+ ScopedPlatformHandle* connection_handle,
+ bool check_peer_user = true);
} // namespace edk
} // namespace mojo
diff --git a/chromium/mojo/edk/embedder/process_delegate.h b/chromium/mojo/edk/embedder/process_delegate.h
deleted file mode 100644
index 144f4a3aff8..00000000000
--- a/chromium/mojo/edk/embedder/process_delegate.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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.
-
-#ifndef MOJO_EDK_EMBEDDER_PROCESS_DELEGATE_H_
-#define MOJO_EDK_EMBEDDER_PROCESS_DELEGATE_H_
-
-#include "base/macros.h"
-#include "mojo/edk/system/system_impl_export.h"
-
-namespace mojo {
-namespace edk {
-
-// An interface for process delegates.
-class MOJO_SYSTEM_IMPL_EXPORT ProcessDelegate {
- public:
- // Called when |ShutdownIPCSupport()| has completed work on the I/O thread.
- virtual void OnShutdownComplete() = 0;
-
- protected:
- ProcessDelegate() {}
- virtual ~ProcessDelegate() {}
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ProcessDelegate);
-};
-
-} // namespace edk
-} // namespace mojo
-
-#endif // MOJO_EDK_EMBEDDER_PROCESS_DELEGATE_H_
diff --git a/chromium/mojo/edk/embedder/scoped_ipc_support.cc b/chromium/mojo/edk/embedder/scoped_ipc_support.cc
index 9c598b54467..f67210a8177 100644
--- a/chromium/mojo/edk/embedder/scoped_ipc_support.cc
+++ b/chromium/mojo/edk/embedder/scoped_ipc_support.cc
@@ -4,57 +4,35 @@
#include "mojo/edk/embedder/scoped_ipc_support.h"
-#include "base/lazy_instance.h"
-#include "base/logging.h"
-#include "base/macros.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/synchronization/waitable_event.h"
+#include "base/threading/thread_restrictions.h"
#include "mojo/edk/embedder/embedder.h"
-#include "mojo/edk/embedder/process_delegate.h"
namespace mojo {
namespace edk {
-namespace {
-class IPCSupportInitializer : public mojo::edk::ProcessDelegate {
- public:
- IPCSupportInitializer() {}
- ~IPCSupportInitializer() override {}
-
- void Init(scoped_refptr<base::TaskRunner> io_thread_task_runner) {
- CHECK(!io_thread_task_runner_);
- CHECK(io_thread_task_runner);
- io_thread_task_runner_ = io_thread_task_runner;
-
- mojo::edk::InitIPCSupport(this, io_thread_task_runner_);
- }
-
- void ShutDown() {
- CHECK(io_thread_task_runner_);
- mojo::edk::ShutdownIPCSupport();
- }
-
- private:
- // mojo::edk::ProcessDelegate:
- void OnShutdownComplete() override {
- // TODO(rockot): We should ensure that IO runner shutdown is blocked until
- // this is called.
- }
-
- scoped_refptr<base::TaskRunner> io_thread_task_runner_;
-
- DISALLOW_COPY_AND_ASSIGN(IPCSupportInitializer);
-};
-
-base::LazyInstance<IPCSupportInitializer>::Leaky ipc_support_initializer;
-
-} // namespace
-
ScopedIPCSupport::ScopedIPCSupport(
- scoped_refptr<base::TaskRunner> io_thread_task_runner) {
- ipc_support_initializer.Get().Init(io_thread_task_runner);
+ scoped_refptr<base::TaskRunner> io_thread_task_runner,
+ ShutdownPolicy shutdown_policy) : shutdown_policy_(shutdown_policy) {
+ InitIPCSupport(io_thread_task_runner);
}
ScopedIPCSupport::~ScopedIPCSupport() {
- ipc_support_initializer.Get().ShutDown();
+ if (shutdown_policy_ == ShutdownPolicy::FAST) {
+ ShutdownIPCSupport(base::Bind(&base::DoNothing));
+ return;
+ }
+
+ base::WaitableEvent shutdown_event(
+ base::WaitableEvent::ResetPolicy::MANUAL,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
+ ShutdownIPCSupport(base::Bind(&base::WaitableEvent::Signal,
+ base::Unretained(&shutdown_event)));
+
+ base::ThreadRestrictions::ScopedAllowWait allow_io;
+ shutdown_event.Wait();
}
} // namespace edk
diff --git a/chromium/mojo/edk/embedder/scoped_ipc_support.h b/chromium/mojo/edk/embedder/scoped_ipc_support.h
index a3b32da3b72..22d8e501139 100644
--- a/chromium/mojo/edk/embedder/scoped_ipc_support.h
+++ b/chromium/mojo/edk/embedder/scoped_ipc_support.h
@@ -5,26 +5,110 @@
#ifndef MOJO_EDK_EMBEDDER_SCOPED_IPC_SUPPORT_H_
#define MOJO_EDK_EMBEDDER_SCOPED_IPC_SUPPORT_H_
-#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/task_runner.h"
#include "mojo/edk/system/system_impl_export.h"
+namespace base {
+class TaskRunner;
+}
+
namespace mojo {
namespace edk {
-// Performs any necessary Mojo initialization on construction, and shuts
-// down Mojo on destruction.
-//
-// This should be instantiated once per process and retained as long as Mojo
-// is needed. The TaskRunner passed to the constructor should outlive this
-// object.
+// A simple class that calls |InitIPCSupport()| on construction and
+// |ShutdownIPCSupport()| on destruction, blocking the destructor on clean IPC
+// shutdown completion.
class MOJO_SYSTEM_IMPL_EXPORT ScopedIPCSupport {
public:
- ScopedIPCSupport(scoped_refptr<base::TaskRunner> io_thread_task_runner);
+ // ShutdownPolicy is a type for specifying the desired Mojo IPC support
+ // shutdown behavior used during ScopedIPCSupport destruction.
+ //
+ // What follows is a quick overview of why shutdown behavior is interesting
+ // and how you might decide which behavior is right for your use case.
+ //
+ // BACKGROUND
+ // ==========
+ //
+ // In order to facilitate efficient and reliable transfer of Mojo message pipe
+ // endpoints across process boundaries, the underlying model for a message
+ // pipe is actually a self-collapsing cycle of "ports." See
+ // //mojo/edk/system/ports for gritty implementation details.
+ //
+ // Ports are essentially globally unique identifiers used for system-wide
+ // message routing. Every message pipe consists of at least two such ports:
+ // the pipe's two concrete endpoints.
+ //
+ // When a message pipe endpoint is transferred over another message pipe, that
+ // endpoint's port (which subsequently exists only internally with no
+ // publicly-reachable handle) enters a transient proxying state for the
+ // remainder of its lifetime. Once sufficient information has been
+ // proagated throughout the system and this proxying port can be safely
+ // bypassed, it is garbage-collected.
+ //
+ // If a process is terminated while hosting any active proxy ports, this
+ // will necessarily break the message pipe(s) to which those ports belong.
+ //
+ // WHEN TO USE CLEAN SHUTDOWN
+ // ==========================
+ //
+ // Consider three processes, A, B, and C. Suppose A creates a message pipe,
+ // sending one end to B and the other to C. For some brief period of time,
+ // messages sent by B or C over this pipe may be proxied through A.
+ //
+ // If A is suddenly terminated, there may be no way for B's messages to reach
+ // C (and vice versa), since the message pipe state may not have been fully
+ // propagated to all concerned processes in the system. As such, both B and C
+ // may have no choice but to signal peer closure on their respective ends of
+ // the pipe, and thus the pipe may be broken despite a lack of intent by
+ // either B or C.
+ //
+ // This can also happen if A creates a pipe and passes one end to B, who then
+ // passes it along to C. B may temporarily proxy messages for this pipe
+ // between A and C, and B's sudden demise will in turn beget the pipe's
+ // own sudden demise.
+ //
+ // In situations where these sort of arrangements may occur, potentially
+ // proxying processes must ensure they are shut down cleanly in order to avoid
+ // flaky system behavior.
+ //
+ // WHEN TO USE FAST SHUTDOWN
+ // =========================
+ //
+ // As a general rule of thumb, if your process never creates a message pipe
+ // where both ends are passed to other processes, or never forwards a pipe
+ // endpoint from one process to another, fast shutdown is safe. Satisfaction
+ // of these constraints can be difficult to prove though, so clean shutdown is
+ // a safe default choice.
+ //
+ // Content renderer processes are a good example of a case where fast shutdown
+ // is safe, because as a matter of security and stability, a renderer cannot
+ // be trusted to do any proxying on behalf of two other processes anyway.
+ //
+ // There are other practical scenarios where fast shutdown is safe even if
+ // the process may have live proxies. For example, content's browser process
+ // is treated as a sort of master process in the system, in the sense that if
+ // the browser is terminated, no other part of the system is expected to
+ // continue normal operation anyway. In this case the side-effects of fast
+ // shutdown are irrelevant, so fast shutdown is preferred.
+ enum class ShutdownPolicy {
+ // Clean shutdown. This causes the ScopedIPCSupport destructor to *block*
+ // the calling thread until clean shutdown is complete. See explanation
+ // above for details.
+ CLEAN,
+
+ // Fast shutdown. In this case a cheap best-effort attempt is made to
+ // shut down the IPC system, but no effort is made to wait for its
+ // completion. See explanation above for details.
+ FAST,
+ };
+
+ ScopedIPCSupport(scoped_refptr<base::TaskRunner> io_thread_task_runner,
+ ShutdownPolicy shutdown_policy);
~ScopedIPCSupport();
private:
+ const ShutdownPolicy shutdown_policy_;
+
DISALLOW_COPY_AND_ASSIGN(ScopedIPCSupport);
};
diff --git a/chromium/mojo/edk/js/drain_data.cc b/chromium/mojo/edk/js/drain_data.cc
index ca5fdf44097..6bb4a46b14b 100644
--- a/chromium/mojo/edk/js/drain_data.cc
+++ b/chromium/mojo/edk/js/drain_data.cc
@@ -8,6 +8,7 @@
#include <stdint.h>
#include "base/bind.h"
+#include "base/memory/ptr_util.h"
#include "gin/array_buffer.h"
#include "gin/converter.h"
#include "gin/dictionary.h"
@@ -67,8 +68,7 @@ MojoResult DrainData::ReadData() {
if (result != MOJO_RESULT_OK)
return result;
const char* p = static_cast<const char*>(buffer);
- DataBuffer* data_buffer = new DataBuffer(p, p + num_bytes);
- data_buffers_.push_back(data_buffer);
+ data_buffers_.push_back(base::MakeUnique<DataBuffer>(p, p + num_bytes));
return EndReadDataRaw(handle_.get(), num_bytes);
}
diff --git a/chromium/mojo/edk/js/drain_data.h b/chromium/mojo/edk/js/drain_data.h
index 917ca05f2a9..6e8555c32bb 100644
--- a/chromium/mojo/edk/js/drain_data.h
+++ b/chromium/mojo/edk/js/drain_data.h
@@ -5,7 +5,9 @@
#ifndef MOJO_EDK_JS_DRAIN_DATA_H_
#define MOJO_EDK_JS_DRAIN_DATA_H_
-#include "base/memory/scoped_vector.h"
+#include <memory>
+#include <vector>
+
#include "gin/runner.h"
#include "mojo/public/cpp/system/core.h"
#include "mojo/public/cpp/system/watcher.h"
@@ -53,7 +55,7 @@ class DrainData {
Watcher handle_watcher_;
base::WeakPtr<gin::Runner> runner_;
v8::UniquePersistent<v8::Promise::Resolver> resolver_;
- ScopedVector<DataBuffer> data_buffers_;
+ std::vector<std::unique_ptr<DataBuffer>> data_buffers_;
};
} // namespace js
diff --git a/chromium/mojo/edk/js/tests/BUILD.gn b/chromium/mojo/edk/js/tests/BUILD.gn
index b21cdbc40b8..693a03ce254 100644
--- a/chromium/mojo/edk/js/tests/BUILD.gn
+++ b/chromium/mojo/edk/js/tests/BUILD.gn
@@ -24,7 +24,9 @@ source_set("js_to_cpp_tests") {
]
data = [
+ "binding_tests.js",
"connection_tests.js",
+ "interface_ptr_tests.js",
"js_to_cpp_tests.js",
"sample_service_tests.js",
]
diff --git a/chromium/mojo/edk/system/BUILD.gn b/chromium/mojo/edk/system/BUILD.gn
index 9023fbd35c0..c24458af6e8 100644
--- a/chromium/mojo/edk/system/BUILD.gn
+++ b/chromium/mojo/edk/system/BUILD.gn
@@ -78,7 +78,6 @@ component("system") {
public_deps = [
"//mojo/edk/embedder",
- "//mojo/edk/embedder:delegates",
"//mojo/edk/embedder:platform",
"//mojo/edk/system/ports",
"//mojo/public/c/system",
diff --git a/chromium/mojo/edk/system/channel_posix.cc b/chromium/mojo/edk/system/channel_posix.cc
index 77a5832de47..f4687562800 100644
--- a/chromium/mojo/edk/system/channel_posix.cc
+++ b/chromium/mojo/edk/system/channel_posix.cc
@@ -400,8 +400,26 @@ class ChannelPosix : public Channel,
}
if (result < 0) {
- if (errno != EAGAIN && errno != EWOULDBLOCK)
+ if (errno != EAGAIN && errno != EWOULDBLOCK
+#if defined(OS_MACOSX)
+ // On OS X if sendmsg() is trying to send fds between processes and
+ // there isn't enough room in the output buffer to send the fd
+ // structure over atomically then EMSGSIZE is returned.
+ //
+ // EMSGSIZE presents a problem since the system APIs can only call
+ // us when there's room in the socket buffer and not when there is
+ // "enough" room.
+ //
+ // The current behavior is to return to the event loop when EMSGSIZE
+ // is received and hopefull service another FD. This is however
+ // still technically a busy wait since the event loop will call us
+ // right back until the receiver has read enough data to allow
+ // passing the FD over atomically.
+ && errno != EMSGSIZE
+#endif
+ ) {
return false;
+ }
message_view.SetHandles(std::move(handles));
outgoing_messages_.emplace_front(std::move(message_view));
WaitForWriteOnIOThreadNoLock();
diff --git a/chromium/mojo/edk/system/core.cc b/chromium/mojo/edk/system/core.cc
index f37d42ef3ec..308c2879c4c 100644
--- a/chromium/mojo/edk/system/core.cc
+++ b/chromium/mojo/edk/system/core.cc
@@ -45,8 +45,8 @@ namespace {
// This is an unnecessarily large limit that is relatively easy to enforce.
const uint32_t kMaxHandlesPerMessage = 1024 * 1024;
-// TODO: Maybe we could negotiate a debugging pipe ID for cross-process pipes
-// too; for now we just use a constant. This only affects bootstrap pipes.
+// TODO(rockot): Maybe we could negotiate a debugging pipe ID for cross-process
+// pipes too; for now we just use a constant. This only affects bootstrap pipes.
const uint64_t kUnknownPipeIdForDebug = 0x7f7f7f7f7f7f7f7fUL;
void CallWatchCallback(MojoWatchCallback callback,
@@ -332,15 +332,7 @@ MojoResult Core::PassSharedMemoryHandle(
}
void Core::RequestShutdown(const base::Closure& callback) {
- base::Closure on_shutdown;
- if (base::ThreadTaskRunnerHandle::IsSet()) {
- on_shutdown = base::Bind(base::IgnoreResult(&base::TaskRunner::PostTask),
- base::ThreadTaskRunnerHandle::Get(),
- FROM_HERE, callback);
- } else {
- on_shutdown = callback;
- }
- GetNodeController()->RequestShutdown(on_shutdown);
+ GetNodeController()->RequestShutdown(callback);
}
ScopedMessagePipeHandle Core::CreateMessagePipe(
@@ -815,12 +807,12 @@ MojoResult Core::CreateDataPipe(
create_options.struct_size = sizeof(MojoCreateDataPipeOptions);
create_options.flags = options ? options->flags : 0;
create_options.element_num_bytes = options ? options->element_num_bytes : 1;
- // TODO: Use Configuration to get default data pipe capacity.
+ // TODO(rockot): Use Configuration to get default data pipe capacity.
create_options.capacity_num_bytes =
options && options->capacity_num_bytes ? options->capacity_num_bytes
: 64 * 1024;
- // TODO: Broker through the parent when necessary.
+ // TODO(rockot): Broker through the parent when necessary.
scoped_refptr<PlatformSharedBuffer> ring_buffer =
GetNodeController()->CreateSharedBuffer(
create_options.capacity_num_bytes);
@@ -1126,7 +1118,7 @@ MojoResult Core::WaitManyInternal(const MojoHandle* handles,
const MojoHandleSignals* signals,
uint32_t num_handles,
MojoDeadline deadline,
- uint32_t *result_index,
+ uint32_t* result_index,
HandleSignalsState* signals_states) {
CHECK(handles);
CHECK(signals);
diff --git a/chromium/mojo/edk/system/core.h b/chromium/mojo/edk/system/core.h
index e32e2d2a8e6..21b44b1a69f 100644
--- a/chromium/mojo/edk/system/core.h
+++ b/chromium/mojo/edk/system/core.h
@@ -6,6 +6,7 @@
#define MOJO_EDK_SYSTEM_CORE_H_
#include <memory>
+#include <string>
#include <vector>
#include "base/callback.h"
@@ -39,7 +40,7 @@ namespace edk {
// are thread-safe.
class MOJO_SYSTEM_IMPL_EXPORT Core {
public:
- explicit Core();
+ Core();
virtual ~Core();
// Called exactly once, shortly after construction, and before any other
@@ -278,7 +279,7 @@ class MOJO_SYSTEM_IMPL_EXPORT Core {
const MojoHandleSignals* signals,
uint32_t num_handles,
MojoDeadline deadline,
- uint32_t *result_index,
+ uint32_t* result_index,
HandleSignalsState* signals_states);
// Used to pass ownership of our NodeController over to the IO thread in the
diff --git a/chromium/mojo/edk/system/data_pipe_consumer_dispatcher.h b/chromium/mojo/edk/system/data_pipe_consumer_dispatcher.h
index 6a7fb1c5b03..8239b11462f 100644
--- a/chromium/mojo/edk/system/data_pipe_consumer_dispatcher.h
+++ b/chromium/mojo/edk/system/data_pipe_consumer_dispatcher.h
@@ -24,7 +24,6 @@
namespace mojo {
namespace edk {
-struct DataPipeControlMessage;
class NodeController;
// This is the Dispatcher implementation for the consumer handle for data
diff --git a/chromium/mojo/edk/system/data_pipe_control_message.h b/chromium/mojo/edk/system/data_pipe_control_message.h
index 82ee594ea94..ec84ea3c559 100644
--- a/chromium/mojo/edk/system/data_pipe_control_message.h
+++ b/chromium/mojo/edk/system/data_pipe_control_message.h
@@ -17,7 +17,6 @@ namespace mojo {
namespace edk {
class NodeController;
-class PortsMessage;
enum DataPipeCommand : uint32_t {
// Signal to the consumer that new data is available.
diff --git a/chromium/mojo/edk/system/message_pipe_dispatcher.h b/chromium/mojo/edk/system/message_pipe_dispatcher.h
index fddd0fd8cf8..6743222bef0 100644
--- a/chromium/mojo/edk/system/message_pipe_dispatcher.h
+++ b/chromium/mojo/edk/system/message_pipe_dispatcher.h
@@ -21,7 +21,6 @@ namespace mojo {
namespace edk {
class NodeController;
-class PortsMessage;
class MessagePipeDispatcher : public Dispatcher {
public:
diff --git a/chromium/mojo/edk/system/message_pipe_unittest.cc b/chromium/mojo/edk/system/message_pipe_unittest.cc
index fcfaeca1790..8f489508e92 100644
--- a/chromium/mojo/edk/system/message_pipe_unittest.cc
+++ b/chromium/mojo/edk/system/message_pipe_unittest.cc
@@ -706,6 +706,17 @@ TEST_F(FuseMessagePipeTest, FuseAfterPeerWriteAndClosure) {
EXPECT_EQ(MOJO_RESULT_OK, MojoClose(d));
}
+TEST_F(MessagePipeTest, ClosePipesStressTest) {
+ // Stress test to exercise https://crbug.com/665869.
+ const size_t kNumPipes = 100000;
+ for (size_t i = 0; i < kNumPipes; ++i) {
+ MojoHandle a, b;
+ CreateMessagePipe(&a, &b);
+ MojoClose(a);
+ MojoClose(b);
+ }
+}
+
} // namespace
} // namespace edk
} // namespace mojo
diff --git a/chromium/mojo/edk/system/multiprocess_message_pipe_unittest.cc b/chromium/mojo/edk/system/multiprocess_message_pipe_unittest.cc
index 011d8249095..11bb4053ac6 100644
--- a/chromium/mojo/edk/system/multiprocess_message_pipe_unittest.cc
+++ b/chromium/mojo/edk/system/multiprocess_message_pipe_unittest.cc
@@ -443,7 +443,8 @@ TEST_P(MultiprocessMessagePipeTestWithPipeCount, PlatformHandlePassing) {
}
char message[128];
- sprintf(message, "hello %d", static_cast<int>(pipe_count));
+ snprintf(message, sizeof(message), "hello %d",
+ static_cast<int>(pipe_count));
ASSERT_EQ(MOJO_RESULT_OK,
MojoWriteMessage(h, message,
static_cast<uint32_t>(strlen(message)),
@@ -465,9 +466,9 @@ TEST_P(MultiprocessMessagePipeTestWithPipeCount, PlatformHandlePassing) {
#if !defined(OS_ANDROID)
INSTANTIATE_TEST_CASE_P(PipeCount,
MultiprocessMessagePipeTestWithPipeCount,
- // TODO: Re-enable the 140-pipe case when ChannelPosix
- // has support for sending lots of handles.
- testing::Values(1u, 128u/*, 140u*/));
+ // TODO(rockot): Re-enable the 140-pipe case when
+ // ChannelPosix has support for sending lots of handles.
+ testing::Values(1u, 128u /*, 140u*/));
#endif
DEFINE_TEST_CLIENT_WITH_PIPE(CheckMessagePipe, MultiprocessMessagePipeTest, h) {
@@ -697,8 +698,6 @@ TEST_F(MultiprocessMessagePipeTest, DataPipeConsumer) {
TEST_P(MultiprocessMessagePipeTestWithPeerSupport, CreateMessagePipe) {
MojoHandle p0, p1;
CreateMessagePipe(&p0, &p1);
- VerifyTransmission(p0, p1, "hey man");
- VerifyTransmission(p1, p0, "slow down");
VerifyTransmission(p0, p1, std::string(10 * 1024 * 1024, 'a'));
VerifyTransmission(p1, p0, std::string(10 * 1024 * 1024, 'e'));
@@ -999,7 +998,7 @@ DEFINE_TEST_CLIENT_WITH_PIPE(CommandDrivenClient, MultiprocessMessagePipeTest,
}
}
- for (auto& pipe: named_pipes)
+ for (auto& pipe : named_pipes)
CloseHandle(pipe.second);
return 0;
@@ -1018,8 +1017,8 @@ TEST_F(MultiprocessMessagePipeTest, ChildToChildPipes) {
b.SendHandle("y", p1);
// Make sure they can talk.
- a.Send("say:x:hello sir");
- b.Send("hear:y:hello sir");
+ a.Send("say:x:hello");
+ b.Send("hear:y:hello");
b.Send("say:y:i love multiprocess pipes!");
a.Send("hear:x:i love multiprocess pipes!");
diff --git a/chromium/mojo/edk/system/node_controller.cc b/chromium/mojo/edk/system/node_controller.cc
index 1a481543569..25a7c87efad 100644
--- a/chromium/mojo/edk/system/node_controller.cc
+++ b/chromium/mojo/edk/system/node_controller.cc
@@ -719,6 +719,11 @@ void NodeController::SendPeerMessage(const ports::NodeName& name,
}
void NodeController::AcceptIncomingMessages() {
+ // This is an impactically large value which should never be reached in
+ // practice. See the CHECK below for usage.
+ constexpr size_t kMaxAcceptedMessages = 1000000;
+
+ size_t num_messages_accepted = 0;
while (incoming_messages_flag_) {
// TODO: We may need to be more careful to avoid starving the rest of the
// thread here. Revisit this if it turns out to be a problem. One
@@ -738,12 +743,24 @@ void NodeController::AcceptIncomingMessages() {
incoming_messages_flag_.Set(false);
messages_lock_.Release();
+ num_messages_accepted += messages.size();
while (!messages.empty()) {
node_->AcceptMessage(std::move(messages.front()));
messages.pop();
}
+
+ // This is effectively a safeguard against potential bugs which might lead
+ // to runaway message cycles. If any such cycles arise, we'll start seeing
+ // crash reports from this location.
+ CHECK_LE(num_messages_accepted, kMaxAcceptedMessages);
}
+ UMA_HISTOGRAM_CUSTOM_COUNTS("Mojo.System.MessagesAcceptedPerEvent",
+ static_cast<int32_t>(num_messages_accepted),
+ 1 /* min */,
+ 500 /* max */,
+ 50 /* bucket count */);
+
AttemptShutdownIfRequested();
}
diff --git a/chromium/mojo/edk/system/ports/name.cc b/chromium/mojo/edk/system/ports/name.cc
index 7088cbfd248..ea17698f978 100644
--- a/chromium/mojo/edk/system/ports/name.cc
+++ b/chromium/mojo/edk/system/ports/name.cc
@@ -8,6 +8,10 @@ namespace mojo {
namespace edk {
namespace ports {
+extern const PortName kInvalidPortName = {0, 0};
+
+extern const NodeName kInvalidNodeName = {0, 0};
+
std::ostream& operator<<(std::ostream& stream, const Name& name) {
std::ios::fmtflags flags(stream.flags());
stream << std::hex << std::uppercase << name.v1;
diff --git a/chromium/mojo/edk/system/ports/name.h b/chromium/mojo/edk/system/ports/name.h
index 1082719f6df..72e41b92ab6 100644
--- a/chromium/mojo/edk/system/ports/name.h
+++ b/chromium/mojo/edk/system/ports/name.h
@@ -40,14 +40,14 @@ struct PortName : Name {
PortName(uint64_t v1, uint64_t v2) : Name(v1, v2) {}
};
-const PortName kInvalidPortName = {0, 0};
+extern const PortName kInvalidPortName;
struct NodeName : Name {
NodeName() : Name(0, 0) {}
NodeName(uint64_t v1, uint64_t v2) : Name(v1, v2) {}
};
-const NodeName kInvalidNodeName = {0, 0};
+extern const NodeName kInvalidNodeName;
} // namespace ports
} // namespace edk
diff --git a/chromium/mojo/edk/system/ports/node.cc b/chromium/mojo/edk/system/ports/node.cc
index 186e8aaad95..bdb267db658 100644
--- a/chromium/mojo/edk/system/ports/node.cc
+++ b/chromium/mojo/edk/system/ports/node.cc
@@ -8,6 +8,7 @@
#include <utility>
+#include "base/atomicops.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
@@ -804,6 +805,11 @@ scoped_refptr<Port> Node::GetPort_Locked(const PortName& port_name) {
if (iter == ports_.end())
return nullptr;
+#if defined(OS_ANDROID) && defined(ARCH_CPU_ARM64)
+ // Workaround for https://crbug.com/665869.
+ base::subtle::MemoryBarrier();
+#endif
+
return iter->second;
}
diff --git a/chromium/mojo/edk/system/shared_buffer_dispatcher.h b/chromium/mojo/edk/system/shared_buffer_dispatcher.h
index 1648dd274b1..6015595317d 100644
--- a/chromium/mojo/edk/system/shared_buffer_dispatcher.h
+++ b/chromium/mojo/edk/system/shared_buffer_dispatcher.h
@@ -21,7 +21,6 @@ namespace mojo {
namespace edk {
class NodeController;
-class PlatformSupport;
class MOJO_SYSTEM_IMPL_EXPORT SharedBufferDispatcher final : public Dispatcher {
public:
diff --git a/chromium/mojo/edk/test/BUILD.gn b/chromium/mojo/edk/test/BUILD.gn
index ebacc646c23..a15456a32f6 100644
--- a/chromium/mojo/edk/test/BUILD.gn
+++ b/chromium/mojo/edk/test/BUILD.gn
@@ -9,8 +9,6 @@ static_library("test_support") {
sources = [
"mojo_test_base.cc",
"mojo_test_base.h",
- "scoped_ipc_support.cc",
- "scoped_ipc_support.h",
"test_utils.h",
"test_utils_posix.cc",
"test_utils_win.cc",
diff --git a/chromium/mojo/gpu/BUILD.gn b/chromium/mojo/gpu/BUILD.gn
deleted file mode 100644
index ad372388a64..00000000000
--- a/chromium/mojo/gpu/BUILD.gn
+++ /dev/null
@@ -1,18 +0,0 @@
-# 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.
-
-source_set("mojo_gles2_implementation") {
- sources = [
- "mojo_gles2_impl_autogen.cc",
- "mojo_gles2_impl_autogen.h",
- ]
-
- configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
-
- deps = [
- "//base",
- "//gpu/command_buffer/client:gles2_interface",
- "//mojo/public/c/gles2",
- ]
-}
diff --git a/chromium/mojo/gpu/DEPS b/chromium/mojo/gpu/DEPS
deleted file mode 100644
index 241389ee7b9..00000000000
--- a/chromium/mojo/gpu/DEPS
+++ /dev/null
@@ -1,4 +0,0 @@
-include_rules = [
- "+gpu/command_buffer/client",
- "+third_party/khronos/GLES2",
-]
diff --git a/chromium/mojo/gpu/OWNERS b/chromium/mojo/gpu/OWNERS
deleted file mode 100644
index cd07f4dafa3..00000000000
--- a/chromium/mojo/gpu/OWNERS
+++ /dev/null
@@ -1,5 +0,0 @@
-piman@chromium.org
-jbauman@chromium.org
-bajones@chromium.org
-zmo@chromium.org
-vmiura@chromium.org
diff --git a/chromium/mojo/gpu/mojo_gles2_impl_autogen.cc b/chromium/mojo/gpu/mojo_gles2_impl_autogen.cc
deleted file mode 100644
index 93377a58284..00000000000
--- a/chromium/mojo/gpu/mojo_gles2_impl_autogen.cc
+++ /dev/null
@@ -1,1899 +0,0 @@
-// Copyright 2014 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.
-
-// This file is auto-generated from
-// gpu/command_buffer/build_gles2_cmd_buffer.py
-// It's formatted by clang-format using chromium coding style:
-// clang-format -i -style=chromium filename
-// DO NOT EDIT!
-
-#include "mojo/gpu/mojo_gles2_impl_autogen.h"
-
-#include "base/logging.h"
-#include "mojo/public/c/gles2/chromium_extension.h"
-#include "mojo/public/c/gles2/gles2.h"
-
-namespace mojo {
-
-void MojoGLES2Impl::ActiveTexture(GLenum texture) {
- MojoGLES2MakeCurrent(context_);
- glActiveTexture(texture);
-}
-void MojoGLES2Impl::AttachShader(GLuint program, GLuint shader) {
- MojoGLES2MakeCurrent(context_);
- glAttachShader(program, shader);
-}
-void MojoGLES2Impl::BindAttribLocation(GLuint program,
- GLuint index,
- const char* name) {
- MojoGLES2MakeCurrent(context_);
- glBindAttribLocation(program, index, name);
-}
-void MojoGLES2Impl::BindBuffer(GLenum target, GLuint buffer) {
- MojoGLES2MakeCurrent(context_);
- glBindBuffer(target, buffer);
-}
-void MojoGLES2Impl::BindBufferBase(GLenum target, GLuint index, GLuint buffer) {
- NOTREACHED() << "Unimplemented BindBufferBase.";
-}
-void MojoGLES2Impl::BindBufferRange(GLenum target,
- GLuint index,
- GLuint buffer,
- GLintptr offset,
- GLsizeiptr size) {
- NOTREACHED() << "Unimplemented BindBufferRange.";
-}
-void MojoGLES2Impl::BindFramebuffer(GLenum target, GLuint framebuffer) {
- MojoGLES2MakeCurrent(context_);
- glBindFramebuffer(target, framebuffer);
-}
-void MojoGLES2Impl::BindRenderbuffer(GLenum target, GLuint renderbuffer) {
- MojoGLES2MakeCurrent(context_);
- glBindRenderbuffer(target, renderbuffer);
-}
-void MojoGLES2Impl::BindSampler(GLuint unit, GLuint sampler) {
- NOTREACHED() << "Unimplemented BindSampler.";
-}
-void MojoGLES2Impl::BindTexture(GLenum target, GLuint texture) {
- MojoGLES2MakeCurrent(context_);
- glBindTexture(target, texture);
-}
-void MojoGLES2Impl::BindTransformFeedback(GLenum target,
- GLuint transformfeedback) {
- NOTREACHED() << "Unimplemented BindTransformFeedback.";
-}
-void MojoGLES2Impl::BlendColor(GLclampf red,
- GLclampf green,
- GLclampf blue,
- GLclampf alpha) {
- MojoGLES2MakeCurrent(context_);
- glBlendColor(red, green, blue, alpha);
-}
-void MojoGLES2Impl::BlendEquation(GLenum mode) {
- MojoGLES2MakeCurrent(context_);
- glBlendEquation(mode);
-}
-void MojoGLES2Impl::BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) {
- MojoGLES2MakeCurrent(context_);
- glBlendEquationSeparate(modeRGB, modeAlpha);
-}
-void MojoGLES2Impl::BlendFunc(GLenum sfactor, GLenum dfactor) {
- MojoGLES2MakeCurrent(context_);
- glBlendFunc(sfactor, dfactor);
-}
-void MojoGLES2Impl::BlendFuncSeparate(GLenum srcRGB,
- GLenum dstRGB,
- GLenum srcAlpha,
- GLenum dstAlpha) {
- MojoGLES2MakeCurrent(context_);
- glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
-}
-void MojoGLES2Impl::BufferData(GLenum target,
- GLsizeiptr size,
- const void* data,
- GLenum usage) {
- MojoGLES2MakeCurrent(context_);
- glBufferData(target, size, data, usage);
-}
-void MojoGLES2Impl::BufferSubData(GLenum target,
- GLintptr offset,
- GLsizeiptr size,
- const void* data) {
- MojoGLES2MakeCurrent(context_);
- glBufferSubData(target, offset, size, data);
-}
-GLenum MojoGLES2Impl::CheckFramebufferStatus(GLenum target) {
- MojoGLES2MakeCurrent(context_);
- return glCheckFramebufferStatus(target);
-}
-void MojoGLES2Impl::Clear(GLbitfield mask) {
- MojoGLES2MakeCurrent(context_);
- glClear(mask);
-}
-void MojoGLES2Impl::ClearBufferfi(GLenum buffer,
- GLint drawbuffers,
- GLfloat depth,
- GLint stencil) {
- NOTREACHED() << "Unimplemented ClearBufferfi.";
-}
-void MojoGLES2Impl::ClearBufferfv(GLenum buffer,
- GLint drawbuffers,
- const GLfloat* value) {
- NOTREACHED() << "Unimplemented ClearBufferfv.";
-}
-void MojoGLES2Impl::ClearBufferiv(GLenum buffer,
- GLint drawbuffers,
- const GLint* value) {
- NOTREACHED() << "Unimplemented ClearBufferiv.";
-}
-void MojoGLES2Impl::ClearBufferuiv(GLenum buffer,
- GLint drawbuffers,
- const GLuint* value) {
- NOTREACHED() << "Unimplemented ClearBufferuiv.";
-}
-void MojoGLES2Impl::ClearColor(GLclampf red,
- GLclampf green,
- GLclampf blue,
- GLclampf alpha) {
- MojoGLES2MakeCurrent(context_);
- glClearColor(red, green, blue, alpha);
-}
-void MojoGLES2Impl::ClearDepthf(GLclampf depth) {
- MojoGLES2MakeCurrent(context_);
- glClearDepthf(depth);
-}
-void MojoGLES2Impl::ClearStencil(GLint s) {
- MojoGLES2MakeCurrent(context_);
- glClearStencil(s);
-}
-GLenum MojoGLES2Impl::ClientWaitSync(GLsync sync,
- GLbitfield flags,
- GLuint64 timeout) {
- NOTREACHED() << "Unimplemented ClientWaitSync.";
- return 0;
-}
-void MojoGLES2Impl::ColorMask(GLboolean red,
- GLboolean green,
- GLboolean blue,
- GLboolean alpha) {
- MojoGLES2MakeCurrent(context_);
- glColorMask(red, green, blue, alpha);
-}
-void MojoGLES2Impl::CompileShader(GLuint shader) {
- MojoGLES2MakeCurrent(context_);
- glCompileShader(shader);
-}
-void MojoGLES2Impl::CompressedTexImage2D(GLenum target,
- GLint level,
- GLenum internalformat,
- GLsizei width,
- GLsizei height,
- GLint border,
- GLsizei imageSize,
- const void* data) {
- MojoGLES2MakeCurrent(context_);
- glCompressedTexImage2D(target, level, internalformat, width, height, border,
- imageSize, data);
-}
-void MojoGLES2Impl::CompressedTexSubImage2D(GLenum target,
- GLint level,
- GLint xoffset,
- GLint yoffset,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLsizei imageSize,
- const void* data) {
- MojoGLES2MakeCurrent(context_);
- glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height,
- format, imageSize, data);
-}
-void MojoGLES2Impl::CompressedTexImage3D(GLenum target,
- GLint level,
- GLenum internalformat,
- GLsizei width,
- GLsizei height,
- GLsizei depth,
- GLint border,
- GLsizei imageSize,
- const void* data) {
- NOTREACHED() << "Unimplemented CompressedTexImage3D.";
-}
-void MojoGLES2Impl::CompressedTexSubImage3D(GLenum target,
- GLint level,
- GLint xoffset,
- GLint yoffset,
- GLint zoffset,
- GLsizei width,
- GLsizei height,
- GLsizei depth,
- GLenum format,
- GLsizei imageSize,
- const void* data) {
- NOTREACHED() << "Unimplemented CompressedTexSubImage3D.";
-}
-void MojoGLES2Impl::CopyBufferSubData(GLenum readtarget,
- GLenum writetarget,
- GLintptr readoffset,
- GLintptr writeoffset,
- GLsizeiptr size) {
- NOTREACHED() << "Unimplemented CopyBufferSubData.";
-}
-void MojoGLES2Impl::CopyTexImage2D(GLenum target,
- GLint level,
- GLenum internalformat,
- GLint x,
- GLint y,
- GLsizei width,
- GLsizei height,
- GLint border) {
- MojoGLES2MakeCurrent(context_);
- glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
-}
-void MojoGLES2Impl::CopyTexSubImage2D(GLenum target,
- GLint level,
- GLint xoffset,
- GLint yoffset,
- GLint x,
- GLint y,
- GLsizei width,
- GLsizei height) {
- MojoGLES2MakeCurrent(context_);
- glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
-}
-void MojoGLES2Impl::CopyTexSubImage3D(GLenum target,
- GLint level,
- GLint xoffset,
- GLint yoffset,
- GLint zoffset,
- GLint x,
- GLint y,
- GLsizei width,
- GLsizei height) {
- NOTREACHED() << "Unimplemented CopyTexSubImage3D.";
-}
-GLuint MojoGLES2Impl::CreateProgram() {
- MojoGLES2MakeCurrent(context_);
- return glCreateProgram();
-}
-GLuint MojoGLES2Impl::CreateShader(GLenum type) {
- MojoGLES2MakeCurrent(context_);
- return glCreateShader(type);
-}
-void MojoGLES2Impl::CullFace(GLenum mode) {
- MojoGLES2MakeCurrent(context_);
- glCullFace(mode);
-}
-void MojoGLES2Impl::DeleteBuffers(GLsizei n, const GLuint* buffers) {
- MojoGLES2MakeCurrent(context_);
- glDeleteBuffers(n, buffers);
-}
-void MojoGLES2Impl::DeleteFramebuffers(GLsizei n, const GLuint* framebuffers) {
- MojoGLES2MakeCurrent(context_);
- glDeleteFramebuffers(n, framebuffers);
-}
-void MojoGLES2Impl::DeleteProgram(GLuint program) {
- MojoGLES2MakeCurrent(context_);
- glDeleteProgram(program);
-}
-void MojoGLES2Impl::DeleteRenderbuffers(GLsizei n,
- const GLuint* renderbuffers) {
- MojoGLES2MakeCurrent(context_);
- glDeleteRenderbuffers(n, renderbuffers);
-}
-void MojoGLES2Impl::DeleteSamplers(GLsizei n, const GLuint* samplers) {
- NOTREACHED() << "Unimplemented DeleteSamplers.";
-}
-void MojoGLES2Impl::DeleteSync(GLsync sync) {
- NOTREACHED() << "Unimplemented DeleteSync.";
-}
-void MojoGLES2Impl::DeleteShader(GLuint shader) {
- MojoGLES2MakeCurrent(context_);
- glDeleteShader(shader);
-}
-void MojoGLES2Impl::DeleteTextures(GLsizei n, const GLuint* textures) {
- MojoGLES2MakeCurrent(context_);
- glDeleteTextures(n, textures);
-}
-void MojoGLES2Impl::DeleteTransformFeedbacks(GLsizei n, const GLuint* ids) {
- NOTREACHED() << "Unimplemented DeleteTransformFeedbacks.";
-}
-void MojoGLES2Impl::DepthFunc(GLenum func) {
- MojoGLES2MakeCurrent(context_);
- glDepthFunc(func);
-}
-void MojoGLES2Impl::DepthMask(GLboolean flag) {
- MojoGLES2MakeCurrent(context_);
- glDepthMask(flag);
-}
-void MojoGLES2Impl::DepthRangef(GLclampf zNear, GLclampf zFar) {
- MojoGLES2MakeCurrent(context_);
- glDepthRangef(zNear, zFar);
-}
-void MojoGLES2Impl::DetachShader(GLuint program, GLuint shader) {
- MojoGLES2MakeCurrent(context_);
- glDetachShader(program, shader);
-}
-void MojoGLES2Impl::Disable(GLenum cap) {
- MojoGLES2MakeCurrent(context_);
- glDisable(cap);
-}
-void MojoGLES2Impl::DisableVertexAttribArray(GLuint index) {
- MojoGLES2MakeCurrent(context_);
- glDisableVertexAttribArray(index);
-}
-void MojoGLES2Impl::DrawArrays(GLenum mode, GLint first, GLsizei count) {
- MojoGLES2MakeCurrent(context_);
- glDrawArrays(mode, first, count);
-}
-void MojoGLES2Impl::DrawElements(GLenum mode,
- GLsizei count,
- GLenum type,
- const void* indices) {
- MojoGLES2MakeCurrent(context_);
- glDrawElements(mode, count, type, indices);
-}
-void MojoGLES2Impl::DrawRangeElements(GLenum mode,
- GLuint start,
- GLuint end,
- GLsizei count,
- GLenum type,
- const void* indices) {
- NOTREACHED() << "Unimplemented DrawRangeElements.";
-}
-void MojoGLES2Impl::Enable(GLenum cap) {
- MojoGLES2MakeCurrent(context_);
- glEnable(cap);
-}
-void MojoGLES2Impl::EnableVertexAttribArray(GLuint index) {
- MojoGLES2MakeCurrent(context_);
- glEnableVertexAttribArray(index);
-}
-GLsync MojoGLES2Impl::FenceSync(GLenum condition, GLbitfield flags) {
- NOTREACHED() << "Unimplemented FenceSync.";
- return 0;
-}
-void MojoGLES2Impl::Finish() {
- MojoGLES2MakeCurrent(context_);
- glFinish();
-}
-void MojoGLES2Impl::Flush() {
- MojoGLES2MakeCurrent(context_);
- glFlush();
-}
-void MojoGLES2Impl::FramebufferRenderbuffer(GLenum target,
- GLenum attachment,
- GLenum renderbuffertarget,
- GLuint renderbuffer) {
- MojoGLES2MakeCurrent(context_);
- glFramebufferRenderbuffer(target, attachment, renderbuffertarget,
- renderbuffer);
-}
-void MojoGLES2Impl::FramebufferTexture2D(GLenum target,
- GLenum attachment,
- GLenum textarget,
- GLuint texture,
- GLint level) {
- MojoGLES2MakeCurrent(context_);
- glFramebufferTexture2D(target, attachment, textarget, texture, level);
-}
-void MojoGLES2Impl::FramebufferTextureLayer(GLenum target,
- GLenum attachment,
- GLuint texture,
- GLint level,
- GLint layer) {
- NOTREACHED() << "Unimplemented FramebufferTextureLayer.";
-}
-void MojoGLES2Impl::FrontFace(GLenum mode) {
- MojoGLES2MakeCurrent(context_);
- glFrontFace(mode);
-}
-void MojoGLES2Impl::GenBuffers(GLsizei n, GLuint* buffers) {
- MojoGLES2MakeCurrent(context_);
- glGenBuffers(n, buffers);
-}
-void MojoGLES2Impl::GenerateMipmap(GLenum target) {
- MojoGLES2MakeCurrent(context_);
- glGenerateMipmap(target);
-}
-void MojoGLES2Impl::GenFramebuffers(GLsizei n, GLuint* framebuffers) {
- MojoGLES2MakeCurrent(context_);
- glGenFramebuffers(n, framebuffers);
-}
-void MojoGLES2Impl::GenRenderbuffers(GLsizei n, GLuint* renderbuffers) {
- MojoGLES2MakeCurrent(context_);
- glGenRenderbuffers(n, renderbuffers);
-}
-void MojoGLES2Impl::GenSamplers(GLsizei n, GLuint* samplers) {
- NOTREACHED() << "Unimplemented GenSamplers.";
-}
-void MojoGLES2Impl::GenTextures(GLsizei n, GLuint* textures) {
- MojoGLES2MakeCurrent(context_);
- glGenTextures(n, textures);
-}
-void MojoGLES2Impl::GenTransformFeedbacks(GLsizei n, GLuint* ids) {
- NOTREACHED() << "Unimplemented GenTransformFeedbacks.";
-}
-void MojoGLES2Impl::GetActiveAttrib(GLuint program,
- GLuint index,
- GLsizei bufsize,
- GLsizei* length,
- GLint* size,
- GLenum* type,
- char* name) {
- MojoGLES2MakeCurrent(context_);
- glGetActiveAttrib(program, index, bufsize, length, size, type, name);
-}
-void MojoGLES2Impl::GetActiveUniform(GLuint program,
- GLuint index,
- GLsizei bufsize,
- GLsizei* length,
- GLint* size,
- GLenum* type,
- char* name) {
- MojoGLES2MakeCurrent(context_);
- glGetActiveUniform(program, index, bufsize, length, size, type, name);
-}
-void MojoGLES2Impl::GetActiveUniformBlockiv(GLuint program,
- GLuint index,
- GLenum pname,
- GLint* params) {
- NOTREACHED() << "Unimplemented GetActiveUniformBlockiv.";
-}
-void MojoGLES2Impl::GetActiveUniformBlockName(GLuint program,
- GLuint index,
- GLsizei bufsize,
- GLsizei* length,
- char* name) {
- NOTREACHED() << "Unimplemented GetActiveUniformBlockName.";
-}
-void MojoGLES2Impl::GetActiveUniformsiv(GLuint program,
- GLsizei count,
- const GLuint* indices,
- GLenum pname,
- GLint* params) {
- NOTREACHED() << "Unimplemented GetActiveUniformsiv.";
-}
-void MojoGLES2Impl::GetAttachedShaders(GLuint program,
- GLsizei maxcount,
- GLsizei* count,
- GLuint* shaders) {
- MojoGLES2MakeCurrent(context_);
- glGetAttachedShaders(program, maxcount, count, shaders);
-}
-GLint MojoGLES2Impl::GetAttribLocation(GLuint program, const char* name) {
- MojoGLES2MakeCurrent(context_);
- return glGetAttribLocation(program, name);
-}
-void MojoGLES2Impl::GetBooleanv(GLenum pname, GLboolean* params) {
- MojoGLES2MakeCurrent(context_);
- glGetBooleanv(pname, params);
-}
-void MojoGLES2Impl::GetBufferParameteri64v(GLenum target,
- GLenum pname,
- GLint64* params) {
- NOTREACHED() << "Unimplemented GetBufferParameteri64v.";
-}
-void MojoGLES2Impl::GetBufferParameteriv(GLenum target,
- GLenum pname,
- GLint* params) {
- MojoGLES2MakeCurrent(context_);
- glGetBufferParameteriv(target, pname, params);
-}
-GLenum MojoGLES2Impl::GetError() {
- MojoGLES2MakeCurrent(context_);
- return glGetError();
-}
-void MojoGLES2Impl::GetFloatv(GLenum pname, GLfloat* params) {
- MojoGLES2MakeCurrent(context_);
- glGetFloatv(pname, params);
-}
-GLint MojoGLES2Impl::GetFragDataLocation(GLuint program, const char* name) {
- NOTREACHED() << "Unimplemented GetFragDataLocation.";
- return 0;
-}
-void MojoGLES2Impl::GetFramebufferAttachmentParameteriv(GLenum target,
- GLenum attachment,
- GLenum pname,
- GLint* params) {
- MojoGLES2MakeCurrent(context_);
- glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
-}
-void MojoGLES2Impl::GetInteger64v(GLenum pname, GLint64* params) {
- NOTREACHED() << "Unimplemented GetInteger64v.";
-}
-void MojoGLES2Impl::GetIntegeri_v(GLenum pname, GLuint index, GLint* data) {
- NOTREACHED() << "Unimplemented GetIntegeri_v.";
-}
-void MojoGLES2Impl::GetInteger64i_v(GLenum pname, GLuint index, GLint64* data) {
- NOTREACHED() << "Unimplemented GetInteger64i_v.";
-}
-void MojoGLES2Impl::GetIntegerv(GLenum pname, GLint* params) {
- MojoGLES2MakeCurrent(context_);
- glGetIntegerv(pname, params);
-}
-void MojoGLES2Impl::GetInternalformativ(GLenum target,
- GLenum format,
- GLenum pname,
- GLsizei bufSize,
- GLint* params) {
- NOTREACHED() << "Unimplemented GetInternalformativ.";
-}
-void MojoGLES2Impl::GetProgramiv(GLuint program, GLenum pname, GLint* params) {
- MojoGLES2MakeCurrent(context_);
- glGetProgramiv(program, pname, params);
-}
-void MojoGLES2Impl::GetProgramInfoLog(GLuint program,
- GLsizei bufsize,
- GLsizei* length,
- char* infolog) {
- MojoGLES2MakeCurrent(context_);
- glGetProgramInfoLog(program, bufsize, length, infolog);
-}
-void MojoGLES2Impl::GetRenderbufferParameteriv(GLenum target,
- GLenum pname,
- GLint* params) {
- MojoGLES2MakeCurrent(context_);
- glGetRenderbufferParameteriv(target, pname, params);
-}
-void MojoGLES2Impl::GetSamplerParameterfv(GLuint sampler,
- GLenum pname,
- GLfloat* params) {
- NOTREACHED() << "Unimplemented GetSamplerParameterfv.";
-}
-void MojoGLES2Impl::GetSamplerParameteriv(GLuint sampler,
- GLenum pname,
- GLint* params) {
- NOTREACHED() << "Unimplemented GetSamplerParameteriv.";
-}
-void MojoGLES2Impl::GetShaderiv(GLuint shader, GLenum pname, GLint* params) {
- MojoGLES2MakeCurrent(context_);
- glGetShaderiv(shader, pname, params);
-}
-void MojoGLES2Impl::GetShaderInfoLog(GLuint shader,
- GLsizei bufsize,
- GLsizei* length,
- char* infolog) {
- MojoGLES2MakeCurrent(context_);
- glGetShaderInfoLog(shader, bufsize, length, infolog);
-}
-void MojoGLES2Impl::GetShaderPrecisionFormat(GLenum shadertype,
- GLenum precisiontype,
- GLint* range,
- GLint* precision) {
- MojoGLES2MakeCurrent(context_);
- glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
-}
-void MojoGLES2Impl::GetShaderSource(GLuint shader,
- GLsizei bufsize,
- GLsizei* length,
- char* source) {
- MojoGLES2MakeCurrent(context_);
- glGetShaderSource(shader, bufsize, length, source);
-}
-const GLubyte* MojoGLES2Impl::GetString(GLenum name) {
- MojoGLES2MakeCurrent(context_);
- return glGetString(name);
-}
-const GLubyte* MojoGLES2Impl::GetStringi(GLenum name, GLuint index) {
- NOTREACHED() << "Unimplemented GetStringi.";
- return 0;
-}
-void MojoGLES2Impl::GetSynciv(GLsync sync,
- GLenum pname,
- GLsizei bufsize,
- GLsizei* length,
- GLint* values) {
- NOTREACHED() << "Unimplemented GetSynciv.";
-}
-void MojoGLES2Impl::GetTexParameterfv(GLenum target,
- GLenum pname,
- GLfloat* params) {
- MojoGLES2MakeCurrent(context_);
- glGetTexParameterfv(target, pname, params);
-}
-void MojoGLES2Impl::GetTexParameteriv(GLenum target,
- GLenum pname,
- GLint* params) {
- MojoGLES2MakeCurrent(context_);
- glGetTexParameteriv(target, pname, params);
-}
-void MojoGLES2Impl::GetTransformFeedbackVarying(GLuint program,
- GLuint index,
- GLsizei bufsize,
- GLsizei* length,
- GLsizei* size,
- GLenum* type,
- char* name) {
- NOTREACHED() << "Unimplemented GetTransformFeedbackVarying.";
-}
-GLuint MojoGLES2Impl::GetUniformBlockIndex(GLuint program, const char* name) {
- NOTREACHED() << "Unimplemented GetUniformBlockIndex.";
- return 0;
-}
-void MojoGLES2Impl::GetUniformfv(GLuint program,
- GLint location,
- GLfloat* params) {
- MojoGLES2MakeCurrent(context_);
- glGetUniformfv(program, location, params);
-}
-void MojoGLES2Impl::GetUniformiv(GLuint program,
- GLint location,
- GLint* params) {
- MojoGLES2MakeCurrent(context_);
- glGetUniformiv(program, location, params);
-}
-void MojoGLES2Impl::GetUniformuiv(GLuint program,
- GLint location,
- GLuint* params) {
- NOTREACHED() << "Unimplemented GetUniformuiv.";
-}
-void MojoGLES2Impl::GetUniformIndices(GLuint program,
- GLsizei count,
- const char* const* names,
- GLuint* indices) {
- NOTREACHED() << "Unimplemented GetUniformIndices.";
-}
-GLint MojoGLES2Impl::GetUniformLocation(GLuint program, const char* name) {
- MojoGLES2MakeCurrent(context_);
- return glGetUniformLocation(program, name);
-}
-void MojoGLES2Impl::GetVertexAttribfv(GLuint index,
- GLenum pname,
- GLfloat* params) {
- MojoGLES2MakeCurrent(context_);
- glGetVertexAttribfv(index, pname, params);
-}
-void MojoGLES2Impl::GetVertexAttribiv(GLuint index,
- GLenum pname,
- GLint* params) {
- MojoGLES2MakeCurrent(context_);
- glGetVertexAttribiv(index, pname, params);
-}
-void MojoGLES2Impl::GetVertexAttribIiv(GLuint index,
- GLenum pname,
- GLint* params) {
- NOTREACHED() << "Unimplemented GetVertexAttribIiv.";
-}
-void MojoGLES2Impl::GetVertexAttribIuiv(GLuint index,
- GLenum pname,
- GLuint* params) {
- NOTREACHED() << "Unimplemented GetVertexAttribIuiv.";
-}
-void MojoGLES2Impl::GetVertexAttribPointerv(GLuint index,
- GLenum pname,
- void** pointer) {
- MojoGLES2MakeCurrent(context_);
- glGetVertexAttribPointerv(index, pname, pointer);
-}
-void MojoGLES2Impl::Hint(GLenum target, GLenum mode) {
- MojoGLES2MakeCurrent(context_);
- glHint(target, mode);
-}
-void MojoGLES2Impl::InvalidateFramebuffer(GLenum target,
- GLsizei count,
- const GLenum* attachments) {
- NOTREACHED() << "Unimplemented InvalidateFramebuffer.";
-}
-void MojoGLES2Impl::InvalidateSubFramebuffer(GLenum target,
- GLsizei count,
- const GLenum* attachments,
- GLint x,
- GLint y,
- GLsizei width,
- GLsizei height) {
- NOTREACHED() << "Unimplemented InvalidateSubFramebuffer.";
-}
-GLboolean MojoGLES2Impl::IsBuffer(GLuint buffer) {
- MojoGLES2MakeCurrent(context_);
- return glIsBuffer(buffer);
-}
-GLboolean MojoGLES2Impl::IsEnabled(GLenum cap) {
- MojoGLES2MakeCurrent(context_);
- return glIsEnabled(cap);
-}
-GLboolean MojoGLES2Impl::IsFramebuffer(GLuint framebuffer) {
- MojoGLES2MakeCurrent(context_);
- return glIsFramebuffer(framebuffer);
-}
-GLboolean MojoGLES2Impl::IsProgram(GLuint program) {
- MojoGLES2MakeCurrent(context_);
- return glIsProgram(program);
-}
-GLboolean MojoGLES2Impl::IsRenderbuffer(GLuint renderbuffer) {
- MojoGLES2MakeCurrent(context_);
- return glIsRenderbuffer(renderbuffer);
-}
-GLboolean MojoGLES2Impl::IsSampler(GLuint sampler) {
- NOTREACHED() << "Unimplemented IsSampler.";
- return 0;
-}
-GLboolean MojoGLES2Impl::IsShader(GLuint shader) {
- MojoGLES2MakeCurrent(context_);
- return glIsShader(shader);
-}
-GLboolean MojoGLES2Impl::IsSync(GLsync sync) {
- NOTREACHED() << "Unimplemented IsSync.";
- return 0;
-}
-GLboolean MojoGLES2Impl::IsTexture(GLuint texture) {
- MojoGLES2MakeCurrent(context_);
- return glIsTexture(texture);
-}
-GLboolean MojoGLES2Impl::IsTransformFeedback(GLuint transformfeedback) {
- NOTREACHED() << "Unimplemented IsTransformFeedback.";
- return 0;
-}
-void MojoGLES2Impl::LineWidth(GLfloat width) {
- MojoGLES2MakeCurrent(context_);
- glLineWidth(width);
-}
-void MojoGLES2Impl::LinkProgram(GLuint program) {
- MojoGLES2MakeCurrent(context_);
- glLinkProgram(program);
-}
-void MojoGLES2Impl::PauseTransformFeedback() {
- NOTREACHED() << "Unimplemented PauseTransformFeedback.";
-}
-void MojoGLES2Impl::PixelStorei(GLenum pname, GLint param) {
- MojoGLES2MakeCurrent(context_);
- glPixelStorei(pname, param);
-}
-void MojoGLES2Impl::PolygonOffset(GLfloat factor, GLfloat units) {
- MojoGLES2MakeCurrent(context_);
- glPolygonOffset(factor, units);
-}
-void MojoGLES2Impl::ReadBuffer(GLenum src) {
- NOTREACHED() << "Unimplemented ReadBuffer.";
-}
-void MojoGLES2Impl::ReadPixels(GLint x,
- GLint y,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLenum type,
- void* pixels) {
- MojoGLES2MakeCurrent(context_);
- glReadPixels(x, y, width, height, format, type, pixels);
-}
-void MojoGLES2Impl::ReleaseShaderCompiler() {
- MojoGLES2MakeCurrent(context_);
- glReleaseShaderCompiler();
-}
-void MojoGLES2Impl::RenderbufferStorage(GLenum target,
- GLenum internalformat,
- GLsizei width,
- GLsizei height) {
- MojoGLES2MakeCurrent(context_);
- glRenderbufferStorage(target, internalformat, width, height);
-}
-void MojoGLES2Impl::ResumeTransformFeedback() {
- NOTREACHED() << "Unimplemented ResumeTransformFeedback.";
-}
-void MojoGLES2Impl::SampleCoverage(GLclampf value, GLboolean invert) {
- MojoGLES2MakeCurrent(context_);
- glSampleCoverage(value, invert);
-}
-void MojoGLES2Impl::SamplerParameterf(GLuint sampler,
- GLenum pname,
- GLfloat param) {
- NOTREACHED() << "Unimplemented SamplerParameterf.";
-}
-void MojoGLES2Impl::SamplerParameterfv(GLuint sampler,
- GLenum pname,
- const GLfloat* params) {
- NOTREACHED() << "Unimplemented SamplerParameterfv.";
-}
-void MojoGLES2Impl::SamplerParameteri(GLuint sampler,
- GLenum pname,
- GLint param) {
- NOTREACHED() << "Unimplemented SamplerParameteri.";
-}
-void MojoGLES2Impl::SamplerParameteriv(GLuint sampler,
- GLenum pname,
- const GLint* params) {
- NOTREACHED() << "Unimplemented SamplerParameteriv.";
-}
-void MojoGLES2Impl::Scissor(GLint x, GLint y, GLsizei width, GLsizei height) {
- MojoGLES2MakeCurrent(context_);
- glScissor(x, y, width, height);
-}
-void MojoGLES2Impl::ShaderBinary(GLsizei n,
- const GLuint* shaders,
- GLenum binaryformat,
- const void* binary,
- GLsizei length) {
- MojoGLES2MakeCurrent(context_);
- glShaderBinary(n, shaders, binaryformat, binary, length);
-}
-void MojoGLES2Impl::ShaderSource(GLuint shader,
- GLsizei count,
- const GLchar* const* str,
- const GLint* length) {
- MojoGLES2MakeCurrent(context_);
- glShaderSource(shader, count, str, length);
-}
-void MojoGLES2Impl::ShallowFinishCHROMIUM() {
- MojoGLES2MakeCurrent(context_);
- glShallowFinishCHROMIUM();
-}
-void MojoGLES2Impl::ShallowFlushCHROMIUM() {
- MojoGLES2MakeCurrent(context_);
- glShallowFlushCHROMIUM();
-}
-void MojoGLES2Impl::OrderingBarrierCHROMIUM() {
- MojoGLES2MakeCurrent(context_);
- glOrderingBarrierCHROMIUM();
-}
-void MojoGLES2Impl::StencilFunc(GLenum func, GLint ref, GLuint mask) {
- MojoGLES2MakeCurrent(context_);
- glStencilFunc(func, ref, mask);
-}
-void MojoGLES2Impl::StencilFuncSeparate(GLenum face,
- GLenum func,
- GLint ref,
- GLuint mask) {
- MojoGLES2MakeCurrent(context_);
- glStencilFuncSeparate(face, func, ref, mask);
-}
-void MojoGLES2Impl::StencilMask(GLuint mask) {
- MojoGLES2MakeCurrent(context_);
- glStencilMask(mask);
-}
-void MojoGLES2Impl::StencilMaskSeparate(GLenum face, GLuint mask) {
- MojoGLES2MakeCurrent(context_);
- glStencilMaskSeparate(face, mask);
-}
-void MojoGLES2Impl::StencilOp(GLenum fail, GLenum zfail, GLenum zpass) {
- MojoGLES2MakeCurrent(context_);
- glStencilOp(fail, zfail, zpass);
-}
-void MojoGLES2Impl::StencilOpSeparate(GLenum face,
- GLenum fail,
- GLenum zfail,
- GLenum zpass) {
- MojoGLES2MakeCurrent(context_);
- glStencilOpSeparate(face, fail, zfail, zpass);
-}
-void MojoGLES2Impl::TexImage2D(GLenum target,
- GLint level,
- GLint internalformat,
- GLsizei width,
- GLsizei height,
- GLint border,
- GLenum format,
- GLenum type,
- const void* pixels) {
- MojoGLES2MakeCurrent(context_);
- glTexImage2D(target, level, internalformat, width, height, border, format,
- type, pixels);
-}
-void MojoGLES2Impl::TexImage3D(GLenum target,
- GLint level,
- GLint internalformat,
- GLsizei width,
- GLsizei height,
- GLsizei depth,
- GLint border,
- GLenum format,
- GLenum type,
- const void* pixels) {
- NOTREACHED() << "Unimplemented TexImage3D.";
-}
-void MojoGLES2Impl::TexParameterf(GLenum target, GLenum pname, GLfloat param) {
- MojoGLES2MakeCurrent(context_);
- glTexParameterf(target, pname, param);
-}
-void MojoGLES2Impl::TexParameterfv(GLenum target,
- GLenum pname,
- const GLfloat* params) {
- MojoGLES2MakeCurrent(context_);
- glTexParameterfv(target, pname, params);
-}
-void MojoGLES2Impl::TexParameteri(GLenum target, GLenum pname, GLint param) {
- MojoGLES2MakeCurrent(context_);
- glTexParameteri(target, pname, param);
-}
-void MojoGLES2Impl::TexParameteriv(GLenum target,
- GLenum pname,
- const GLint* params) {
- MojoGLES2MakeCurrent(context_);
- glTexParameteriv(target, pname, params);
-}
-void MojoGLES2Impl::TexStorage3D(GLenum target,
- GLsizei levels,
- GLenum internalFormat,
- GLsizei width,
- GLsizei height,
- GLsizei depth) {
- NOTREACHED() << "Unimplemented TexStorage3D.";
-}
-void MojoGLES2Impl::TexSubImage2D(GLenum target,
- GLint level,
- GLint xoffset,
- GLint yoffset,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLenum type,
- const void* pixels) {
- MojoGLES2MakeCurrent(context_);
- glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type,
- pixels);
-}
-void MojoGLES2Impl::TexSubImage3D(GLenum target,
- GLint level,
- GLint xoffset,
- GLint yoffset,
- GLint zoffset,
- GLsizei width,
- GLsizei height,
- GLsizei depth,
- GLenum format,
- GLenum type,
- const void* pixels) {
- NOTREACHED() << "Unimplemented TexSubImage3D.";
-}
-void MojoGLES2Impl::TransformFeedbackVaryings(GLuint program,
- GLsizei count,
- const char* const* varyings,
- GLenum buffermode) {
- NOTREACHED() << "Unimplemented TransformFeedbackVaryings.";
-}
-void MojoGLES2Impl::Uniform1f(GLint location, GLfloat x) {
- MojoGLES2MakeCurrent(context_);
- glUniform1f(location, x);
-}
-void MojoGLES2Impl::Uniform1fv(GLint location,
- GLsizei count,
- const GLfloat* v) {
- MojoGLES2MakeCurrent(context_);
- glUniform1fv(location, count, v);
-}
-void MojoGLES2Impl::Uniform1i(GLint location, GLint x) {
- MojoGLES2MakeCurrent(context_);
- glUniform1i(location, x);
-}
-void MojoGLES2Impl::Uniform1iv(GLint location, GLsizei count, const GLint* v) {
- MojoGLES2MakeCurrent(context_);
- glUniform1iv(location, count, v);
-}
-void MojoGLES2Impl::Uniform1ui(GLint location, GLuint x) {
- NOTREACHED() << "Unimplemented Uniform1ui.";
-}
-void MojoGLES2Impl::Uniform1uiv(GLint location,
- GLsizei count,
- const GLuint* v) {
- NOTREACHED() << "Unimplemented Uniform1uiv.";
-}
-void MojoGLES2Impl::Uniform2f(GLint location, GLfloat x, GLfloat y) {
- MojoGLES2MakeCurrent(context_);
- glUniform2f(location, x, y);
-}
-void MojoGLES2Impl::Uniform2fv(GLint location,
- GLsizei count,
- const GLfloat* v) {
- MojoGLES2MakeCurrent(context_);
- glUniform2fv(location, count, v);
-}
-void MojoGLES2Impl::Uniform2i(GLint location, GLint x, GLint y) {
- MojoGLES2MakeCurrent(context_);
- glUniform2i(location, x, y);
-}
-void MojoGLES2Impl::Uniform2iv(GLint location, GLsizei count, const GLint* v) {
- MojoGLES2MakeCurrent(context_);
- glUniform2iv(location, count, v);
-}
-void MojoGLES2Impl::Uniform2ui(GLint location, GLuint x, GLuint y) {
- NOTREACHED() << "Unimplemented Uniform2ui.";
-}
-void MojoGLES2Impl::Uniform2uiv(GLint location,
- GLsizei count,
- const GLuint* v) {
- NOTREACHED() << "Unimplemented Uniform2uiv.";
-}
-void MojoGLES2Impl::Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) {
- MojoGLES2MakeCurrent(context_);
- glUniform3f(location, x, y, z);
-}
-void MojoGLES2Impl::Uniform3fv(GLint location,
- GLsizei count,
- const GLfloat* v) {
- MojoGLES2MakeCurrent(context_);
- glUniform3fv(location, count, v);
-}
-void MojoGLES2Impl::Uniform3i(GLint location, GLint x, GLint y, GLint z) {
- MojoGLES2MakeCurrent(context_);
- glUniform3i(location, x, y, z);
-}
-void MojoGLES2Impl::Uniform3iv(GLint location, GLsizei count, const GLint* v) {
- MojoGLES2MakeCurrent(context_);
- glUniform3iv(location, count, v);
-}
-void MojoGLES2Impl::Uniform3ui(GLint location, GLuint x, GLuint y, GLuint z) {
- NOTREACHED() << "Unimplemented Uniform3ui.";
-}
-void MojoGLES2Impl::Uniform3uiv(GLint location,
- GLsizei count,
- const GLuint* v) {
- NOTREACHED() << "Unimplemented Uniform3uiv.";
-}
-void MojoGLES2Impl::Uniform4f(GLint location,
- GLfloat x,
- GLfloat y,
- GLfloat z,
- GLfloat w) {
- MojoGLES2MakeCurrent(context_);
- glUniform4f(location, x, y, z, w);
-}
-void MojoGLES2Impl::Uniform4fv(GLint location,
- GLsizei count,
- const GLfloat* v) {
- MojoGLES2MakeCurrent(context_);
- glUniform4fv(location, count, v);
-}
-void MojoGLES2Impl::Uniform4i(GLint location,
- GLint x,
- GLint y,
- GLint z,
- GLint w) {
- MojoGLES2MakeCurrent(context_);
- glUniform4i(location, x, y, z, w);
-}
-void MojoGLES2Impl::Uniform4iv(GLint location, GLsizei count, const GLint* v) {
- MojoGLES2MakeCurrent(context_);
- glUniform4iv(location, count, v);
-}
-void MojoGLES2Impl::Uniform4ui(GLint location,
- GLuint x,
- GLuint y,
- GLuint z,
- GLuint w) {
- NOTREACHED() << "Unimplemented Uniform4ui.";
-}
-void MojoGLES2Impl::Uniform4uiv(GLint location,
- GLsizei count,
- const GLuint* v) {
- NOTREACHED() << "Unimplemented Uniform4uiv.";
-}
-void MojoGLES2Impl::UniformBlockBinding(GLuint program,
- GLuint index,
- GLuint binding) {
- NOTREACHED() << "Unimplemented UniformBlockBinding.";
-}
-void MojoGLES2Impl::UniformMatrix2fv(GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat* value) {
- MojoGLES2MakeCurrent(context_);
- glUniformMatrix2fv(location, count, transpose, value);
-}
-void MojoGLES2Impl::UniformMatrix2x3fv(GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat* value) {
- NOTREACHED() << "Unimplemented UniformMatrix2x3fv.";
-}
-void MojoGLES2Impl::UniformMatrix2x4fv(GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat* value) {
- NOTREACHED() << "Unimplemented UniformMatrix2x4fv.";
-}
-void MojoGLES2Impl::UniformMatrix3fv(GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat* value) {
- MojoGLES2MakeCurrent(context_);
- glUniformMatrix3fv(location, count, transpose, value);
-}
-void MojoGLES2Impl::UniformMatrix3x2fv(GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat* value) {
- NOTREACHED() << "Unimplemented UniformMatrix3x2fv.";
-}
-void MojoGLES2Impl::UniformMatrix3x4fv(GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat* value) {
- NOTREACHED() << "Unimplemented UniformMatrix3x4fv.";
-}
-void MojoGLES2Impl::UniformMatrix4fv(GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat* value) {
- MojoGLES2MakeCurrent(context_);
- glUniformMatrix4fv(location, count, transpose, value);
-}
-void MojoGLES2Impl::UniformMatrix4x2fv(GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat* value) {
- NOTREACHED() << "Unimplemented UniformMatrix4x2fv.";
-}
-void MojoGLES2Impl::UniformMatrix4x3fv(GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat* value) {
- NOTREACHED() << "Unimplemented UniformMatrix4x3fv.";
-}
-void MojoGLES2Impl::UseProgram(GLuint program) {
- MojoGLES2MakeCurrent(context_);
- glUseProgram(program);
-}
-void MojoGLES2Impl::ValidateProgram(GLuint program) {
- MojoGLES2MakeCurrent(context_);
- glValidateProgram(program);
-}
-void MojoGLES2Impl::VertexAttrib1f(GLuint indx, GLfloat x) {
- MojoGLES2MakeCurrent(context_);
- glVertexAttrib1f(indx, x);
-}
-void MojoGLES2Impl::VertexAttrib1fv(GLuint indx, const GLfloat* values) {
- MojoGLES2MakeCurrent(context_);
- glVertexAttrib1fv(indx, values);
-}
-void MojoGLES2Impl::VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) {
- MojoGLES2MakeCurrent(context_);
- glVertexAttrib2f(indx, x, y);
-}
-void MojoGLES2Impl::VertexAttrib2fv(GLuint indx, const GLfloat* values) {
- MojoGLES2MakeCurrent(context_);
- glVertexAttrib2fv(indx, values);
-}
-void MojoGLES2Impl::VertexAttrib3f(GLuint indx,
- GLfloat x,
- GLfloat y,
- GLfloat z) {
- MojoGLES2MakeCurrent(context_);
- glVertexAttrib3f(indx, x, y, z);
-}
-void MojoGLES2Impl::VertexAttrib3fv(GLuint indx, const GLfloat* values) {
- MojoGLES2MakeCurrent(context_);
- glVertexAttrib3fv(indx, values);
-}
-void MojoGLES2Impl::VertexAttrib4f(GLuint indx,
- GLfloat x,
- GLfloat y,
- GLfloat z,
- GLfloat w) {
- MojoGLES2MakeCurrent(context_);
- glVertexAttrib4f(indx, x, y, z, w);
-}
-void MojoGLES2Impl::VertexAttrib4fv(GLuint indx, const GLfloat* values) {
- MojoGLES2MakeCurrent(context_);
- glVertexAttrib4fv(indx, values);
-}
-void MojoGLES2Impl::VertexAttribI4i(GLuint indx,
- GLint x,
- GLint y,
- GLint z,
- GLint w) {
- NOTREACHED() << "Unimplemented VertexAttribI4i.";
-}
-void MojoGLES2Impl::VertexAttribI4iv(GLuint indx, const GLint* values) {
- NOTREACHED() << "Unimplemented VertexAttribI4iv.";
-}
-void MojoGLES2Impl::VertexAttribI4ui(GLuint indx,
- GLuint x,
- GLuint y,
- GLuint z,
- GLuint w) {
- NOTREACHED() << "Unimplemented VertexAttribI4ui.";
-}
-void MojoGLES2Impl::VertexAttribI4uiv(GLuint indx, const GLuint* values) {
- NOTREACHED() << "Unimplemented VertexAttribI4uiv.";
-}
-void MojoGLES2Impl::VertexAttribIPointer(GLuint indx,
- GLint size,
- GLenum type,
- GLsizei stride,
- const void* ptr) {
- NOTREACHED() << "Unimplemented VertexAttribIPointer.";
-}
-void MojoGLES2Impl::VertexAttribPointer(GLuint indx,
- GLint size,
- GLenum type,
- GLboolean normalized,
- GLsizei stride,
- const void* ptr) {
- MojoGLES2MakeCurrent(context_);
- glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
-}
-void MojoGLES2Impl::Viewport(GLint x, GLint y, GLsizei width, GLsizei height) {
- MojoGLES2MakeCurrent(context_);
- glViewport(x, y, width, height);
-}
-void MojoGLES2Impl::WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) {
- NOTREACHED() << "Unimplemented WaitSync.";
-}
-void MojoGLES2Impl::BlitFramebufferCHROMIUM(GLint srcX0,
- GLint srcY0,
- GLint srcX1,
- GLint srcY1,
- GLint dstX0,
- GLint dstY0,
- GLint dstX1,
- GLint dstY1,
- GLbitfield mask,
- GLenum filter) {
- MojoGLES2MakeCurrent(context_);
- glBlitFramebufferCHROMIUM(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1,
- dstY1, mask, filter);
-}
-void MojoGLES2Impl::RenderbufferStorageMultisampleCHROMIUM(
- GLenum target,
- GLsizei samples,
- GLenum internalformat,
- GLsizei width,
- GLsizei height) {
- MojoGLES2MakeCurrent(context_);
- glRenderbufferStorageMultisampleCHROMIUM(target, samples, internalformat,
- width, height);
-}
-void MojoGLES2Impl::RenderbufferStorageMultisampleEXT(GLenum target,
- GLsizei samples,
- GLenum internalformat,
- GLsizei width,
- GLsizei height) {
- MojoGLES2MakeCurrent(context_);
- glRenderbufferStorageMultisampleEXT(target, samples, internalformat, width,
- height);
-}
-void MojoGLES2Impl::FramebufferTexture2DMultisampleEXT(GLenum target,
- GLenum attachment,
- GLenum textarget,
- GLuint texture,
- GLint level,
- GLsizei samples) {
- MojoGLES2MakeCurrent(context_);
- glFramebufferTexture2DMultisampleEXT(target, attachment, textarget, texture,
- level, samples);
-}
-void MojoGLES2Impl::TexStorage2DEXT(GLenum target,
- GLsizei levels,
- GLenum internalFormat,
- GLsizei width,
- GLsizei height) {
- MojoGLES2MakeCurrent(context_);
- glTexStorage2DEXT(target, levels, internalFormat, width, height);
-}
-void MojoGLES2Impl::GenQueriesEXT(GLsizei n, GLuint* queries) {
- MojoGLES2MakeCurrent(context_);
- glGenQueriesEXT(n, queries);
-}
-void MojoGLES2Impl::DeleteQueriesEXT(GLsizei n, const GLuint* queries) {
- MojoGLES2MakeCurrent(context_);
- glDeleteQueriesEXT(n, queries);
-}
-void MojoGLES2Impl::QueryCounterEXT(GLuint id, GLenum target) {
- MojoGLES2MakeCurrent(context_);
- glQueryCounterEXT(id, target);
-}
-GLboolean MojoGLES2Impl::IsQueryEXT(GLuint id) {
- MojoGLES2MakeCurrent(context_);
- return glIsQueryEXT(id);
-}
-void MojoGLES2Impl::BeginQueryEXT(GLenum target, GLuint id) {
- MojoGLES2MakeCurrent(context_);
- glBeginQueryEXT(target, id);
-}
-void MojoGLES2Impl::BeginTransformFeedback(GLenum primitivemode) {
- NOTREACHED() << "Unimplemented BeginTransformFeedback.";
-}
-void MojoGLES2Impl::EndQueryEXT(GLenum target) {
- MojoGLES2MakeCurrent(context_);
- glEndQueryEXT(target);
-}
-void MojoGLES2Impl::EndTransformFeedback() {
- NOTREACHED() << "Unimplemented EndTransformFeedback.";
-}
-void MojoGLES2Impl::GetQueryivEXT(GLenum target, GLenum pname, GLint* params) {
- MojoGLES2MakeCurrent(context_);
- glGetQueryivEXT(target, pname, params);
-}
-void MojoGLES2Impl::GetQueryObjectivEXT(GLuint id,
- GLenum pname,
- GLint* params) {
- MojoGLES2MakeCurrent(context_);
- glGetQueryObjectivEXT(id, pname, params);
-}
-void MojoGLES2Impl::GetQueryObjectuivEXT(GLuint id,
- GLenum pname,
- GLuint* params) {
- MojoGLES2MakeCurrent(context_);
- glGetQueryObjectuivEXT(id, pname, params);
-}
-void MojoGLES2Impl::GetQueryObjecti64vEXT(GLuint id,
- GLenum pname,
- GLint64* params) {
- MojoGLES2MakeCurrent(context_);
- glGetQueryObjecti64vEXT(id, pname, params);
-}
-void MojoGLES2Impl::GetQueryObjectui64vEXT(GLuint id,
- GLenum pname,
- GLuint64* params) {
- MojoGLES2MakeCurrent(context_);
- glGetQueryObjectui64vEXT(id, pname, params);
-}
-void MojoGLES2Impl::SetDisjointValueSyncCHROMIUM() {
- MojoGLES2MakeCurrent(context_);
- glSetDisjointValueSyncCHROMIUM();
-}
-void MojoGLES2Impl::InsertEventMarkerEXT(GLsizei length, const GLchar* marker) {
- MojoGLES2MakeCurrent(context_);
- glInsertEventMarkerEXT(length, marker);
-}
-void MojoGLES2Impl::PushGroupMarkerEXT(GLsizei length, const GLchar* marker) {
- MojoGLES2MakeCurrent(context_);
- glPushGroupMarkerEXT(length, marker);
-}
-void MojoGLES2Impl::PopGroupMarkerEXT() {
- MojoGLES2MakeCurrent(context_);
- glPopGroupMarkerEXT();
-}
-void MojoGLES2Impl::GenVertexArraysOES(GLsizei n, GLuint* arrays) {
- MojoGLES2MakeCurrent(context_);
- glGenVertexArraysOES(n, arrays);
-}
-void MojoGLES2Impl::DeleteVertexArraysOES(GLsizei n, const GLuint* arrays) {
- MojoGLES2MakeCurrent(context_);
- glDeleteVertexArraysOES(n, arrays);
-}
-GLboolean MojoGLES2Impl::IsVertexArrayOES(GLuint array) {
- MojoGLES2MakeCurrent(context_);
- return glIsVertexArrayOES(array);
-}
-void MojoGLES2Impl::BindVertexArrayOES(GLuint array) {
- MojoGLES2MakeCurrent(context_);
- glBindVertexArrayOES(array);
-}
-void MojoGLES2Impl::SwapBuffers() {
- MojoGLES2MakeCurrent(context_);
- glSwapBuffers();
-}
-GLuint MojoGLES2Impl::GetMaxValueInBufferCHROMIUM(GLuint buffer_id,
- GLsizei count,
- GLenum type,
- GLuint offset) {
- MojoGLES2MakeCurrent(context_);
- return glGetMaxValueInBufferCHROMIUM(buffer_id, count, type, offset);
-}
-GLboolean MojoGLES2Impl::EnableFeatureCHROMIUM(const char* feature) {
- MojoGLES2MakeCurrent(context_);
- return glEnableFeatureCHROMIUM(feature);
-}
-void* MojoGLES2Impl::MapBufferCHROMIUM(GLuint target, GLenum access) {
- MojoGLES2MakeCurrent(context_);
- return glMapBufferCHROMIUM(target, access);
-}
-GLboolean MojoGLES2Impl::UnmapBufferCHROMIUM(GLuint target) {
- MojoGLES2MakeCurrent(context_);
- return glUnmapBufferCHROMIUM(target);
-}
-void* MojoGLES2Impl::MapBufferSubDataCHROMIUM(GLuint target,
- GLintptr offset,
- GLsizeiptr size,
- GLenum access) {
- MojoGLES2MakeCurrent(context_);
- return glMapBufferSubDataCHROMIUM(target, offset, size, access);
-}
-void MojoGLES2Impl::UnmapBufferSubDataCHROMIUM(const void* mem) {
- MojoGLES2MakeCurrent(context_);
- glUnmapBufferSubDataCHROMIUM(mem);
-}
-void* MojoGLES2Impl::MapBufferRange(GLenum target,
- GLintptr offset,
- GLsizeiptr size,
- GLbitfield access) {
- NOTREACHED() << "Unimplemented MapBufferRange.";
- return 0;
-}
-GLboolean MojoGLES2Impl::UnmapBuffer(GLenum target) {
- NOTREACHED() << "Unimplemented UnmapBuffer.";
- return 0;
-}
-void* MojoGLES2Impl::MapTexSubImage2DCHROMIUM(GLenum target,
- GLint level,
- GLint xoffset,
- GLint yoffset,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLenum type,
- GLenum access) {
- MojoGLES2MakeCurrent(context_);
- return glMapTexSubImage2DCHROMIUM(target, level, xoffset, yoffset, width,
- height, format, type, access);
-}
-void MojoGLES2Impl::UnmapTexSubImage2DCHROMIUM(const void* mem) {
- MojoGLES2MakeCurrent(context_);
- glUnmapTexSubImage2DCHROMIUM(mem);
-}
-void MojoGLES2Impl::ResizeCHROMIUM(GLuint width,
- GLuint height,
- GLfloat scale_factor,
- GLboolean alpha) {
- MojoGLES2MakeCurrent(context_);
- glResizeCHROMIUM(width, height, scale_factor, alpha);
-}
-const GLchar* MojoGLES2Impl::GetRequestableExtensionsCHROMIUM() {
- MojoGLES2MakeCurrent(context_);
- return glGetRequestableExtensionsCHROMIUM();
-}
-void MojoGLES2Impl::RequestExtensionCHROMIUM(const char* extension) {
- MojoGLES2MakeCurrent(context_);
- glRequestExtensionCHROMIUM(extension);
-}
-void MojoGLES2Impl::GetProgramInfoCHROMIUM(GLuint program,
- GLsizei bufsize,
- GLsizei* size,
- void* info) {
- MojoGLES2MakeCurrent(context_);
- glGetProgramInfoCHROMIUM(program, bufsize, size, info);
-}
-void MojoGLES2Impl::GetUniformBlocksCHROMIUM(GLuint program,
- GLsizei bufsize,
- GLsizei* size,
- void* info) {
- NOTREACHED() << "Unimplemented GetUniformBlocksCHROMIUM.";
-}
-void MojoGLES2Impl::GetTransformFeedbackVaryingsCHROMIUM(GLuint program,
- GLsizei bufsize,
- GLsizei* size,
- void* info) {
- NOTREACHED() << "Unimplemented GetTransformFeedbackVaryingsCHROMIUM.";
-}
-void MojoGLES2Impl::GetUniformsES3CHROMIUM(GLuint program,
- GLsizei bufsize,
- GLsizei* size,
- void* info) {
- NOTREACHED() << "Unimplemented GetUniformsES3CHROMIUM.";
-}
-GLuint MojoGLES2Impl::CreateImageCHROMIUM(ClientBuffer buffer,
- GLsizei width,
- GLsizei height,
- GLenum internalformat) {
- MojoGLES2MakeCurrent(context_);
- return glCreateImageCHROMIUM(buffer, width, height, internalformat);
-}
-void MojoGLES2Impl::DestroyImageCHROMIUM(GLuint image_id) {
- MojoGLES2MakeCurrent(context_);
- glDestroyImageCHROMIUM(image_id);
-}
-GLuint MojoGLES2Impl::CreateGpuMemoryBufferImageCHROMIUM(GLsizei width,
- GLsizei height,
- GLenum internalformat,
- GLenum usage) {
- MojoGLES2MakeCurrent(context_);
- return glCreateGpuMemoryBufferImageCHROMIUM(width, height, internalformat,
- usage);
-}
-void MojoGLES2Impl::GetTranslatedShaderSourceANGLE(GLuint shader,
- GLsizei bufsize,
- GLsizei* length,
- char* source) {
- MojoGLES2MakeCurrent(context_);
- glGetTranslatedShaderSourceANGLE(shader, bufsize, length, source);
-}
-void MojoGLES2Impl::PostSubBufferCHROMIUM(GLint x,
- GLint y,
- GLint width,
- GLint height) {
- MojoGLES2MakeCurrent(context_);
- glPostSubBufferCHROMIUM(x, y, width, height);
-}
-void MojoGLES2Impl::CopyTextureCHROMIUM(GLenum source_id,
- GLenum dest_id,
- GLint internalformat,
- GLenum dest_type,
- GLboolean unpack_flip_y,
- GLboolean unpack_premultiply_alpha,
- GLboolean unpack_unmultiply_alpha) {
- MojoGLES2MakeCurrent(context_);
- glCopyTextureCHROMIUM(source_id, dest_id, internalformat, dest_type,
- unpack_flip_y, unpack_premultiply_alpha,
- unpack_unmultiply_alpha);
-}
-void MojoGLES2Impl::CopySubTextureCHROMIUM(GLenum source_id,
- GLenum dest_id,
- GLint xoffset,
- GLint yoffset,
- GLint x,
- GLint y,
- GLsizei width,
- GLsizei height,
- GLboolean unpack_flip_y,
- GLboolean unpack_premultiply_alpha,
- GLboolean unpack_unmultiply_alpha) {
- MojoGLES2MakeCurrent(context_);
- glCopySubTextureCHROMIUM(source_id, dest_id, xoffset, yoffset, x, y, width,
- height, unpack_flip_y, unpack_premultiply_alpha,
- unpack_unmultiply_alpha);
-}
-void MojoGLES2Impl::CompressedCopyTextureCHROMIUM(GLenum source_id,
- GLenum dest_id) {
- MojoGLES2MakeCurrent(context_);
- glCompressedCopyTextureCHROMIUM(source_id, dest_id);
-}
-void MojoGLES2Impl::DrawArraysInstancedANGLE(GLenum mode,
- GLint first,
- GLsizei count,
- GLsizei primcount) {
- MojoGLES2MakeCurrent(context_);
- glDrawArraysInstancedANGLE(mode, first, count, primcount);
-}
-void MojoGLES2Impl::DrawElementsInstancedANGLE(GLenum mode,
- GLsizei count,
- GLenum type,
- const void* indices,
- GLsizei primcount) {
- MojoGLES2MakeCurrent(context_);
- glDrawElementsInstancedANGLE(mode, count, type, indices, primcount);
-}
-void MojoGLES2Impl::VertexAttribDivisorANGLE(GLuint index, GLuint divisor) {
- MojoGLES2MakeCurrent(context_);
- glVertexAttribDivisorANGLE(index, divisor);
-}
-void MojoGLES2Impl::GenMailboxCHROMIUM(GLbyte* mailbox) {
- MojoGLES2MakeCurrent(context_);
- glGenMailboxCHROMIUM(mailbox);
-}
-void MojoGLES2Impl::ProduceTextureCHROMIUM(GLenum target,
- const GLbyte* mailbox) {
- MojoGLES2MakeCurrent(context_);
- glProduceTextureCHROMIUM(target, mailbox);
-}
-void MojoGLES2Impl::ProduceTextureDirectCHROMIUM(GLuint texture,
- GLenum target,
- const GLbyte* mailbox) {
- MojoGLES2MakeCurrent(context_);
- glProduceTextureDirectCHROMIUM(texture, target, mailbox);
-}
-void MojoGLES2Impl::ConsumeTextureCHROMIUM(GLenum target,
- const GLbyte* mailbox) {
- MojoGLES2MakeCurrent(context_);
- glConsumeTextureCHROMIUM(target, mailbox);
-}
-GLuint MojoGLES2Impl::CreateAndConsumeTextureCHROMIUM(GLenum target,
- const GLbyte* mailbox) {
- MojoGLES2MakeCurrent(context_);
- return glCreateAndConsumeTextureCHROMIUM(target, mailbox);
-}
-void MojoGLES2Impl::BindUniformLocationCHROMIUM(GLuint program,
- GLint location,
- const char* name) {
- MojoGLES2MakeCurrent(context_);
- glBindUniformLocationCHROMIUM(program, location, name);
-}
-void MojoGLES2Impl::BindTexImage2DCHROMIUM(GLenum target, GLint imageId) {
- MojoGLES2MakeCurrent(context_);
- glBindTexImage2DCHROMIUM(target, imageId);
-}
-void MojoGLES2Impl::ReleaseTexImage2DCHROMIUM(GLenum target, GLint imageId) {
- MojoGLES2MakeCurrent(context_);
- glReleaseTexImage2DCHROMIUM(target, imageId);
-}
-void MojoGLES2Impl::TraceBeginCHROMIUM(const char* category_name,
- const char* trace_name) {
- MojoGLES2MakeCurrent(context_);
- glTraceBeginCHROMIUM(category_name, trace_name);
-}
-void MojoGLES2Impl::TraceEndCHROMIUM() {
- MojoGLES2MakeCurrent(context_);
- glTraceEndCHROMIUM();
-}
-void MojoGLES2Impl::DiscardFramebufferEXT(GLenum target,
- GLsizei count,
- const GLenum* attachments) {
- MojoGLES2MakeCurrent(context_);
- glDiscardFramebufferEXT(target, count, attachments);
-}
-void MojoGLES2Impl::LoseContextCHROMIUM(GLenum current, GLenum other) {
- MojoGLES2MakeCurrent(context_);
- glLoseContextCHROMIUM(current, other);
-}
-GLuint64 MojoGLES2Impl::InsertFenceSyncCHROMIUM() {
- MojoGLES2MakeCurrent(context_);
- return glInsertFenceSyncCHROMIUM();
-}
-void MojoGLES2Impl::GenSyncTokenCHROMIUM(GLuint64 fence_sync,
- GLbyte* sync_token) {
- MojoGLES2MakeCurrent(context_);
- glGenSyncTokenCHROMIUM(fence_sync, sync_token);
-}
-void MojoGLES2Impl::GenUnverifiedSyncTokenCHROMIUM(GLuint64 fence_sync,
- GLbyte* sync_token) {
- MojoGLES2MakeCurrent(context_);
- glGenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token);
-}
-void MojoGLES2Impl::VerifySyncTokensCHROMIUM(GLbyte** sync_tokens,
- GLsizei count) {
- MojoGLES2MakeCurrent(context_);
- glVerifySyncTokensCHROMIUM(sync_tokens, count);
-}
-void MojoGLES2Impl::WaitSyncTokenCHROMIUM(const GLbyte* sync_token) {
- MojoGLES2MakeCurrent(context_);
- glWaitSyncTokenCHROMIUM(sync_token);
-}
-void MojoGLES2Impl::DrawBuffersEXT(GLsizei count, const GLenum* bufs) {
- MojoGLES2MakeCurrent(context_);
- glDrawBuffersEXT(count, bufs);
-}
-void MojoGLES2Impl::DiscardBackbufferCHROMIUM() {
- MojoGLES2MakeCurrent(context_);
- glDiscardBackbufferCHROMIUM();
-}
-void MojoGLES2Impl::ScheduleOverlayPlaneCHROMIUM(GLint plane_z_order,
- GLenum plane_transform,
- GLuint overlay_texture_id,
- GLint bounds_x,
- GLint bounds_y,
- GLint bounds_width,
- GLint bounds_height,
- GLfloat uv_x,
- GLfloat uv_y,
- GLfloat uv_width,
- GLfloat uv_height) {
- MojoGLES2MakeCurrent(context_);
- glScheduleOverlayPlaneCHROMIUM(
- plane_z_order, plane_transform, overlay_texture_id, bounds_x, bounds_y,
- bounds_width, bounds_height, uv_x, uv_y, uv_width, uv_height);
-}
-void MojoGLES2Impl::ScheduleCALayerCHROMIUM(GLuint contents_texture_id,
- const GLfloat* contents_rect,
- GLfloat opacity,
- GLuint background_color,
- GLuint edge_aa_mask,
- const GLfloat* bounds_rect,
- GLboolean is_clipped,
- const GLfloat* clip_rect,
- GLint sorting_context_id,
- const GLfloat* transform,
- GLuint filter) {
- MojoGLES2MakeCurrent(context_);
- glScheduleCALayerCHROMIUM(contents_texture_id, contents_rect, opacity,
- background_color, edge_aa_mask, bounds_rect,
- is_clipped, clip_rect, sorting_context_id,
- transform, filter);
-}
-void MojoGLES2Impl::CommitOverlayPlanesCHROMIUM() {
- MojoGLES2MakeCurrent(context_);
- glCommitOverlayPlanesCHROMIUM();
-}
-void MojoGLES2Impl::SwapInterval(GLint interval) {
- MojoGLES2MakeCurrent(context_);
- glSwapInterval(interval);
-}
-void MojoGLES2Impl::FlushDriverCachesCHROMIUM() {
- MojoGLES2MakeCurrent(context_);
- glFlushDriverCachesCHROMIUM();
-}
-GLuint MojoGLES2Impl::GetLastFlushIdCHROMIUM() {
- MojoGLES2MakeCurrent(context_);
- return glGetLastFlushIdCHROMIUM();
-}
-void MojoGLES2Impl::MatrixLoadfCHROMIUM(GLenum matrixMode, const GLfloat* m) {
- MojoGLES2MakeCurrent(context_);
- glMatrixLoadfCHROMIUM(matrixMode, m);
-}
-void MojoGLES2Impl::MatrixLoadIdentityCHROMIUM(GLenum matrixMode) {
- MojoGLES2MakeCurrent(context_);
- glMatrixLoadIdentityCHROMIUM(matrixMode);
-}
-GLuint MojoGLES2Impl::GenPathsCHROMIUM(GLsizei range) {
- MojoGLES2MakeCurrent(context_);
- return glGenPathsCHROMIUM(range);
-}
-void MojoGLES2Impl::DeletePathsCHROMIUM(GLuint path, GLsizei range) {
- MojoGLES2MakeCurrent(context_);
- glDeletePathsCHROMIUM(path, range);
-}
-GLboolean MojoGLES2Impl::IsPathCHROMIUM(GLuint path) {
- MojoGLES2MakeCurrent(context_);
- return glIsPathCHROMIUM(path);
-}
-void MojoGLES2Impl::PathCommandsCHROMIUM(GLuint path,
- GLsizei numCommands,
- const GLubyte* commands,
- GLsizei numCoords,
- GLenum coordType,
- const GLvoid* coords) {
- MojoGLES2MakeCurrent(context_);
- glPathCommandsCHROMIUM(path, numCommands, commands, numCoords, coordType,
- coords);
-}
-void MojoGLES2Impl::PathParameterfCHROMIUM(GLuint path,
- GLenum pname,
- GLfloat value) {
- MojoGLES2MakeCurrent(context_);
- glPathParameterfCHROMIUM(path, pname, value);
-}
-void MojoGLES2Impl::PathParameteriCHROMIUM(GLuint path,
- GLenum pname,
- GLint value) {
- MojoGLES2MakeCurrent(context_);
- glPathParameteriCHROMIUM(path, pname, value);
-}
-void MojoGLES2Impl::PathStencilFuncCHROMIUM(GLenum func,
- GLint ref,
- GLuint mask) {
- MojoGLES2MakeCurrent(context_);
- glPathStencilFuncCHROMIUM(func, ref, mask);
-}
-void MojoGLES2Impl::StencilFillPathCHROMIUM(GLuint path,
- GLenum fillMode,
- GLuint mask) {
- MojoGLES2MakeCurrent(context_);
- glStencilFillPathCHROMIUM(path, fillMode, mask);
-}
-void MojoGLES2Impl::StencilStrokePathCHROMIUM(GLuint path,
- GLint reference,
- GLuint mask) {
- MojoGLES2MakeCurrent(context_);
- glStencilStrokePathCHROMIUM(path, reference, mask);
-}
-void MojoGLES2Impl::CoverFillPathCHROMIUM(GLuint path, GLenum coverMode) {
- MojoGLES2MakeCurrent(context_);
- glCoverFillPathCHROMIUM(path, coverMode);
-}
-void MojoGLES2Impl::CoverStrokePathCHROMIUM(GLuint path, GLenum coverMode) {
- MojoGLES2MakeCurrent(context_);
- glCoverStrokePathCHROMIUM(path, coverMode);
-}
-void MojoGLES2Impl::StencilThenCoverFillPathCHROMIUM(GLuint path,
- GLenum fillMode,
- GLuint mask,
- GLenum coverMode) {
- MojoGLES2MakeCurrent(context_);
- glStencilThenCoverFillPathCHROMIUM(path, fillMode, mask, coverMode);
-}
-void MojoGLES2Impl::StencilThenCoverStrokePathCHROMIUM(GLuint path,
- GLint reference,
- GLuint mask,
- GLenum coverMode) {
- MojoGLES2MakeCurrent(context_);
- glStencilThenCoverStrokePathCHROMIUM(path, reference, mask, coverMode);
-}
-void MojoGLES2Impl::StencilFillPathInstancedCHROMIUM(
- GLsizei numPaths,
- GLenum pathNameType,
- const GLvoid* paths,
- GLuint pathBase,
- GLenum fillMode,
- GLuint mask,
- GLenum transformType,
- const GLfloat* transformValues) {
- MojoGLES2MakeCurrent(context_);
- glStencilFillPathInstancedCHROMIUM(numPaths, pathNameType, paths, pathBase,
- fillMode, mask, transformType,
- transformValues);
-}
-void MojoGLES2Impl::StencilStrokePathInstancedCHROMIUM(
- GLsizei numPaths,
- GLenum pathNameType,
- const GLvoid* paths,
- GLuint pathBase,
- GLint reference,
- GLuint mask,
- GLenum transformType,
- const GLfloat* transformValues) {
- MojoGLES2MakeCurrent(context_);
- glStencilStrokePathInstancedCHROMIUM(numPaths, pathNameType, paths, pathBase,
- reference, mask, transformType,
- transformValues);
-}
-void MojoGLES2Impl::CoverFillPathInstancedCHROMIUM(
- GLsizei numPaths,
- GLenum pathNameType,
- const GLvoid* paths,
- GLuint pathBase,
- GLenum coverMode,
- GLenum transformType,
- const GLfloat* transformValues) {
- MojoGLES2MakeCurrent(context_);
- glCoverFillPathInstancedCHROMIUM(numPaths, pathNameType, paths, pathBase,
- coverMode, transformType, transformValues);
-}
-void MojoGLES2Impl::CoverStrokePathInstancedCHROMIUM(
- GLsizei numPaths,
- GLenum pathNameType,
- const GLvoid* paths,
- GLuint pathBase,
- GLenum coverMode,
- GLenum transformType,
- const GLfloat* transformValues) {
- MojoGLES2MakeCurrent(context_);
- glCoverStrokePathInstancedCHROMIUM(numPaths, pathNameType, paths, pathBase,
- coverMode, transformType, transformValues);
-}
-void MojoGLES2Impl::StencilThenCoverFillPathInstancedCHROMIUM(
- GLsizei numPaths,
- GLenum pathNameType,
- const GLvoid* paths,
- GLuint pathBase,
- GLenum fillMode,
- GLuint mask,
- GLenum coverMode,
- GLenum transformType,
- const GLfloat* transformValues) {
- MojoGLES2MakeCurrent(context_);
- glStencilThenCoverFillPathInstancedCHROMIUM(
- numPaths, pathNameType, paths, pathBase, fillMode, mask, coverMode,
- transformType, transformValues);
-}
-void MojoGLES2Impl::StencilThenCoverStrokePathInstancedCHROMIUM(
- GLsizei numPaths,
- GLenum pathNameType,
- const GLvoid* paths,
- GLuint pathBase,
- GLint reference,
- GLuint mask,
- GLenum coverMode,
- GLenum transformType,
- const GLfloat* transformValues) {
- MojoGLES2MakeCurrent(context_);
- glStencilThenCoverStrokePathInstancedCHROMIUM(
- numPaths, pathNameType, paths, pathBase, reference, mask, coverMode,
- transformType, transformValues);
-}
-void MojoGLES2Impl::BindFragmentInputLocationCHROMIUM(GLuint program,
- GLint location,
- const char* name) {
- MojoGLES2MakeCurrent(context_);
- glBindFragmentInputLocationCHROMIUM(program, location, name);
-}
-void MojoGLES2Impl::ProgramPathFragmentInputGenCHROMIUM(GLuint program,
- GLint location,
- GLenum genMode,
- GLint components,
- const GLfloat* coeffs) {
- MojoGLES2MakeCurrent(context_);
- glProgramPathFragmentInputGenCHROMIUM(program, location, genMode, components,
- coeffs);
-}
-void MojoGLES2Impl::CoverageModulationCHROMIUM(GLenum components) {
- MojoGLES2MakeCurrent(context_);
- glCoverageModulationCHROMIUM(components);
-}
-GLenum MojoGLES2Impl::GetGraphicsResetStatusKHR() {
- MojoGLES2MakeCurrent(context_);
- return glGetGraphicsResetStatusKHR();
-}
-void MojoGLES2Impl::BlendBarrierKHR() {
- MojoGLES2MakeCurrent(context_);
- glBlendBarrierKHR();
-}
-void MojoGLES2Impl::ApplyScreenSpaceAntialiasingCHROMIUM() {
- MojoGLES2MakeCurrent(context_);
- glApplyScreenSpaceAntialiasingCHROMIUM();
-}
-void MojoGLES2Impl::BindFragDataLocationIndexedEXT(GLuint program,
- GLuint colorNumber,
- GLuint index,
- const char* name) {
- MojoGLES2MakeCurrent(context_);
- glBindFragDataLocationIndexedEXT(program, colorNumber, index, name);
-}
-void MojoGLES2Impl::BindFragDataLocationEXT(GLuint program,
- GLuint colorNumber,
- const char* name) {
- MojoGLES2MakeCurrent(context_);
- glBindFragDataLocationEXT(program, colorNumber, name);
-}
-GLint MojoGLES2Impl::GetFragDataIndexEXT(GLuint program, const char* name) {
- MojoGLES2MakeCurrent(context_);
- return glGetFragDataIndexEXT(program, name);
-}
-void MojoGLES2Impl::UniformMatrix4fvStreamTextureMatrixCHROMIUM(
- GLint location,
- GLboolean transpose,
- const GLfloat* default_value) {
- MojoGLES2MakeCurrent(context_);
- glUniformMatrix4fvStreamTextureMatrixCHROMIUM(location, transpose,
- default_value);
-}
-
-} // namespace mojo
diff --git a/chromium/mojo/gpu/mojo_gles2_impl_autogen.h b/chromium/mojo/gpu/mojo_gles2_impl_autogen.h
deleted file mode 100644
index fd0e5bd3283..00000000000
--- a/chromium/mojo/gpu/mojo_gles2_impl_autogen.h
+++ /dev/null
@@ -1,890 +0,0 @@
-// Copyright 2014 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.
-
-// This file is auto-generated from
-// gpu/command_buffer/build_gles2_cmd_buffer.py
-// It's formatted by clang-format using chromium coding style:
-// clang-format -i -style=chromium filename
-// DO NOT EDIT!
-
-// This file is included by gles2_interface.h to declare the
-// GL api functions.
-#ifndef MOJO_GPU_MOJO_GLES2_IMPL_AUTOGEN_H_
-#define MOJO_GPU_MOJO_GLES2_IMPL_AUTOGEN_H_
-
-#include <memory>
-
-#include "gpu/command_buffer/client/gles2_interface.h"
-#include "mojo/public/c/gles2/gles2.h"
-
-namespace mojo {
-
-class MojoGLES2Impl : public gpu::gles2::GLES2Interface {
- public:
- explicit MojoGLES2Impl(MojoGLES2Context context) { context_ = context; }
- ~MojoGLES2Impl() override {}
- void ActiveTexture(GLenum texture) override;
- void AttachShader(GLuint program, GLuint shader) override;
- void BindAttribLocation(GLuint program,
- GLuint index,
- const char* name) override;
- void BindBuffer(GLenum target, GLuint buffer) override;
- void BindBufferBase(GLenum target, GLuint index, GLuint buffer) override;
- void BindBufferRange(GLenum target,
- GLuint index,
- GLuint buffer,
- GLintptr offset,
- GLsizeiptr size) override;
- void BindFramebuffer(GLenum target, GLuint framebuffer) override;
- void BindRenderbuffer(GLenum target, GLuint renderbuffer) override;
- void BindSampler(GLuint unit, GLuint sampler) override;
- void BindTexture(GLenum target, GLuint texture) override;
- void BindTransformFeedback(GLenum target, GLuint transformfeedback) override;
- void BlendColor(GLclampf red,
- GLclampf green,
- GLclampf blue,
- GLclampf alpha) override;
- void BlendEquation(GLenum mode) override;
- void BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) override;
- void BlendFunc(GLenum sfactor, GLenum dfactor) override;
- void BlendFuncSeparate(GLenum srcRGB,
- GLenum dstRGB,
- GLenum srcAlpha,
- GLenum dstAlpha) override;
- void BufferData(GLenum target,
- GLsizeiptr size,
- const void* data,
- GLenum usage) override;
- void BufferSubData(GLenum target,
- GLintptr offset,
- GLsizeiptr size,
- const void* data) override;
- GLenum CheckFramebufferStatus(GLenum target) override;
- void Clear(GLbitfield mask) override;
- void ClearBufferfi(GLenum buffer,
- GLint drawbuffers,
- GLfloat depth,
- GLint stencil) override;
- void ClearBufferfv(GLenum buffer,
- GLint drawbuffers,
- const GLfloat* value) override;
- void ClearBufferiv(GLenum buffer,
- GLint drawbuffers,
- const GLint* value) override;
- void ClearBufferuiv(GLenum buffer,
- GLint drawbuffers,
- const GLuint* value) override;
- void ClearColor(GLclampf red,
- GLclampf green,
- GLclampf blue,
- GLclampf alpha) override;
- void ClearDepthf(GLclampf depth) override;
- void ClearStencil(GLint s) override;
- GLenum ClientWaitSync(GLsync sync,
- GLbitfield flags,
- GLuint64 timeout) override;
- void ColorMask(GLboolean red,
- GLboolean green,
- GLboolean blue,
- GLboolean alpha) override;
- void CompileShader(GLuint shader) override;
- void CompressedTexImage2D(GLenum target,
- GLint level,
- GLenum internalformat,
- GLsizei width,
- GLsizei height,
- GLint border,
- GLsizei imageSize,
- const void* data) override;
- void CompressedTexSubImage2D(GLenum target,
- GLint level,
- GLint xoffset,
- GLint yoffset,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLsizei imageSize,
- const void* data) override;
- void CompressedTexImage3D(GLenum target,
- GLint level,
- GLenum internalformat,
- GLsizei width,
- GLsizei height,
- GLsizei depth,
- GLint border,
- GLsizei imageSize,
- const void* data) override;
- void CompressedTexSubImage3D(GLenum target,
- GLint level,
- GLint xoffset,
- GLint yoffset,
- GLint zoffset,
- GLsizei width,
- GLsizei height,
- GLsizei depth,
- GLenum format,
- GLsizei imageSize,
- const void* data) override;
- void CopyBufferSubData(GLenum readtarget,
- GLenum writetarget,
- GLintptr readoffset,
- GLintptr writeoffset,
- GLsizeiptr size) override;
- void CopyTexImage2D(GLenum target,
- GLint level,
- GLenum internalformat,
- GLint x,
- GLint y,
- GLsizei width,
- GLsizei height,
- GLint border) override;
- void CopyTexSubImage2D(GLenum target,
- GLint level,
- GLint xoffset,
- GLint yoffset,
- GLint x,
- GLint y,
- GLsizei width,
- GLsizei height) override;
- void CopyTexSubImage3D(GLenum target,
- GLint level,
- GLint xoffset,
- GLint yoffset,
- GLint zoffset,
- GLint x,
- GLint y,
- GLsizei width,
- GLsizei height) override;
- GLuint CreateProgram() override;
- GLuint CreateShader(GLenum type) override;
- void CullFace(GLenum mode) override;
- void DeleteBuffers(GLsizei n, const GLuint* buffers) override;
- void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers) override;
- void DeleteProgram(GLuint program) override;
- void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) override;
- void DeleteSamplers(GLsizei n, const GLuint* samplers) override;
- void DeleteSync(GLsync sync) override;
- void DeleteShader(GLuint shader) override;
- void DeleteTextures(GLsizei n, const GLuint* textures) override;
- void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids) override;
- void DepthFunc(GLenum func) override;
- void DepthMask(GLboolean flag) override;
- void DepthRangef(GLclampf zNear, GLclampf zFar) override;
- void DetachShader(GLuint program, GLuint shader) override;
- void Disable(GLenum cap) override;
- void DisableVertexAttribArray(GLuint index) override;
- void DrawArrays(GLenum mode, GLint first, GLsizei count) override;
- void DrawElements(GLenum mode,
- GLsizei count,
- GLenum type,
- const void* indices) override;
- void DrawRangeElements(GLenum mode,
- GLuint start,
- GLuint end,
- GLsizei count,
- GLenum type,
- const void* indices) override;
- void Enable(GLenum cap) override;
- void EnableVertexAttribArray(GLuint index) override;
- GLsync FenceSync(GLenum condition, GLbitfield flags) override;
- void Finish() override;
- void Flush() override;
- void FramebufferRenderbuffer(GLenum target,
- GLenum attachment,
- GLenum renderbuffertarget,
- GLuint renderbuffer) override;
- void FramebufferTexture2D(GLenum target,
- GLenum attachment,
- GLenum textarget,
- GLuint texture,
- GLint level) override;
- void FramebufferTextureLayer(GLenum target,
- GLenum attachment,
- GLuint texture,
- GLint level,
- GLint layer) override;
- void FrontFace(GLenum mode) override;
- void GenBuffers(GLsizei n, GLuint* buffers) override;
- void GenerateMipmap(GLenum target) override;
- void GenFramebuffers(GLsizei n, GLuint* framebuffers) override;
- void GenRenderbuffers(GLsizei n, GLuint* renderbuffers) override;
- void GenSamplers(GLsizei n, GLuint* samplers) override;
- void GenTextures(GLsizei n, GLuint* textures) override;
- void GenTransformFeedbacks(GLsizei n, GLuint* ids) override;
- void GetActiveAttrib(GLuint program,
- GLuint index,
- GLsizei bufsize,
- GLsizei* length,
- GLint* size,
- GLenum* type,
- char* name) override;
- void GetActiveUniform(GLuint program,
- GLuint index,
- GLsizei bufsize,
- GLsizei* length,
- GLint* size,
- GLenum* type,
- char* name) override;
- void GetActiveUniformBlockiv(GLuint program,
- GLuint index,
- GLenum pname,
- GLint* params) override;
- void GetActiveUniformBlockName(GLuint program,
- GLuint index,
- GLsizei bufsize,
- GLsizei* length,
- char* name) override;
- void GetActiveUniformsiv(GLuint program,
- GLsizei count,
- const GLuint* indices,
- GLenum pname,
- GLint* params) override;
- void GetAttachedShaders(GLuint program,
- GLsizei maxcount,
- GLsizei* count,
- GLuint* shaders) override;
- GLint GetAttribLocation(GLuint program, const char* name) override;
- void GetBooleanv(GLenum pname, GLboolean* params) override;
- void GetBufferParameteri64v(GLenum target,
- GLenum pname,
- GLint64* params) override;
- void GetBufferParameteriv(GLenum target,
- GLenum pname,
- GLint* params) override;
- GLenum GetError() override;
- void GetFloatv(GLenum pname, GLfloat* params) override;
- GLint GetFragDataLocation(GLuint program, const char* name) override;
- void GetFramebufferAttachmentParameteriv(GLenum target,
- GLenum attachment,
- GLenum pname,
- GLint* params) override;
- void GetInteger64v(GLenum pname, GLint64* params) override;
- void GetIntegeri_v(GLenum pname, GLuint index, GLint* data) override;
- void GetInteger64i_v(GLenum pname, GLuint index, GLint64* data) override;
- void GetIntegerv(GLenum pname, GLint* params) override;
- void GetInternalformativ(GLenum target,
- GLenum format,
- GLenum pname,
- GLsizei bufSize,
- GLint* params) override;
- void GetProgramiv(GLuint program, GLenum pname, GLint* params) override;
- void GetProgramInfoLog(GLuint program,
- GLsizei bufsize,
- GLsizei* length,
- char* infolog) override;
- void GetRenderbufferParameteriv(GLenum target,
- GLenum pname,
- GLint* params) override;
- void GetSamplerParameterfv(GLuint sampler,
- GLenum pname,
- GLfloat* params) override;
- void GetSamplerParameteriv(GLuint sampler,
- GLenum pname,
- GLint* params) override;
- void GetShaderiv(GLuint shader, GLenum pname, GLint* params) override;
- void GetShaderInfoLog(GLuint shader,
- GLsizei bufsize,
- GLsizei* length,
- char* infolog) override;
- void GetShaderPrecisionFormat(GLenum shadertype,
- GLenum precisiontype,
- GLint* range,
- GLint* precision) override;
- void GetShaderSource(GLuint shader,
- GLsizei bufsize,
- GLsizei* length,
- char* source) override;
- const GLubyte* GetString(GLenum name) override;
- const GLubyte* GetStringi(GLenum name, GLuint index) override;
- void GetSynciv(GLsync sync,
- GLenum pname,
- GLsizei bufsize,
- GLsizei* length,
- GLint* values) override;
- void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) override;
- void GetTexParameteriv(GLenum target, GLenum pname, GLint* params) override;
- void GetTransformFeedbackVarying(GLuint program,
- GLuint index,
- GLsizei bufsize,
- GLsizei* length,
- GLsizei* size,
- GLenum* type,
- char* name) override;
- GLuint GetUniformBlockIndex(GLuint program, const char* name) override;
- void GetUniformfv(GLuint program, GLint location, GLfloat* params) override;
- void GetUniformiv(GLuint program, GLint location, GLint* params) override;
- void GetUniformuiv(GLuint program, GLint location, GLuint* params) override;
- void GetUniformIndices(GLuint program,
- GLsizei count,
- const char* const* names,
- GLuint* indices) override;
- GLint GetUniformLocation(GLuint program, const char* name) override;
- void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) override;
- void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params) override;
- void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) override;
- void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) override;
- void GetVertexAttribPointerv(GLuint index,
- GLenum pname,
- void** pointer) override;
- void Hint(GLenum target, GLenum mode) override;
- void InvalidateFramebuffer(GLenum target,
- GLsizei count,
- const GLenum* attachments) override;
- void InvalidateSubFramebuffer(GLenum target,
- GLsizei count,
- const GLenum* attachments,
- GLint x,
- GLint y,
- GLsizei width,
- GLsizei height) override;
- GLboolean IsBuffer(GLuint buffer) override;
- GLboolean IsEnabled(GLenum cap) override;
- GLboolean IsFramebuffer(GLuint framebuffer) override;
- GLboolean IsProgram(GLuint program) override;
- GLboolean IsRenderbuffer(GLuint renderbuffer) override;
- GLboolean IsSampler(GLuint sampler) override;
- GLboolean IsShader(GLuint shader) override;
- GLboolean IsSync(GLsync sync) override;
- GLboolean IsTexture(GLuint texture) override;
- GLboolean IsTransformFeedback(GLuint transformfeedback) override;
- void LineWidth(GLfloat width) override;
- void LinkProgram(GLuint program) override;
- void PauseTransformFeedback() override;
- void PixelStorei(GLenum pname, GLint param) override;
- void PolygonOffset(GLfloat factor, GLfloat units) override;
- void ReadBuffer(GLenum src) override;
- void ReadPixels(GLint x,
- GLint y,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLenum type,
- void* pixels) override;
- void ReleaseShaderCompiler() override;
- void RenderbufferStorage(GLenum target,
- GLenum internalformat,
- GLsizei width,
- GLsizei height) override;
- void ResumeTransformFeedback() override;
- void SampleCoverage(GLclampf value, GLboolean invert) override;
- void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) override;
- void SamplerParameterfv(GLuint sampler,
- GLenum pname,
- const GLfloat* params) override;
- void SamplerParameteri(GLuint sampler, GLenum pname, GLint param) override;
- void SamplerParameteriv(GLuint sampler,
- GLenum pname,
- const GLint* params) override;
- void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) override;
- void ShaderBinary(GLsizei n,
- const GLuint* shaders,
- GLenum binaryformat,
- const void* binary,
- GLsizei length) override;
- void ShaderSource(GLuint shader,
- GLsizei count,
- const GLchar* const* str,
- const GLint* length) override;
- void ShallowFinishCHROMIUM() override;
- void ShallowFlushCHROMIUM() override;
- void OrderingBarrierCHROMIUM() override;
- void StencilFunc(GLenum func, GLint ref, GLuint mask) override;
- void StencilFuncSeparate(GLenum face,
- GLenum func,
- GLint ref,
- GLuint mask) override;
- void StencilMask(GLuint mask) override;
- void StencilMaskSeparate(GLenum face, GLuint mask) override;
- void StencilOp(GLenum fail, GLenum zfail, GLenum zpass) override;
- void StencilOpSeparate(GLenum face,
- GLenum fail,
- GLenum zfail,
- GLenum zpass) override;
- void TexImage2D(GLenum target,
- GLint level,
- GLint internalformat,
- GLsizei width,
- GLsizei height,
- GLint border,
- GLenum format,
- GLenum type,
- const void* pixels) override;
- void TexImage3D(GLenum target,
- GLint level,
- GLint internalformat,
- GLsizei width,
- GLsizei height,
- GLsizei depth,
- GLint border,
- GLenum format,
- GLenum type,
- const void* pixels) override;
- void TexParameterf(GLenum target, GLenum pname, GLfloat param) override;
- void TexParameterfv(GLenum target,
- GLenum pname,
- const GLfloat* params) override;
- void TexParameteri(GLenum target, GLenum pname, GLint param) override;
- void TexParameteriv(GLenum target,
- GLenum pname,
- const GLint* params) override;
- void TexStorage3D(GLenum target,
- GLsizei levels,
- GLenum internalFormat,
- GLsizei width,
- GLsizei height,
- GLsizei depth) override;
- void TexSubImage2D(GLenum target,
- GLint level,
- GLint xoffset,
- GLint yoffset,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLenum type,
- const void* pixels) override;
- void TexSubImage3D(GLenum target,
- GLint level,
- GLint xoffset,
- GLint yoffset,
- GLint zoffset,
- GLsizei width,
- GLsizei height,
- GLsizei depth,
- GLenum format,
- GLenum type,
- const void* pixels) override;
- void TransformFeedbackVaryings(GLuint program,
- GLsizei count,
- const char* const* varyings,
- GLenum buffermode) override;
- void Uniform1f(GLint location, GLfloat x) override;
- void Uniform1fv(GLint location, GLsizei count, const GLfloat* v) override;
- void Uniform1i(GLint location, GLint x) override;
- void Uniform1iv(GLint location, GLsizei count, const GLint* v) override;
- void Uniform1ui(GLint location, GLuint x) override;
- void Uniform1uiv(GLint location, GLsizei count, const GLuint* v) override;
- void Uniform2f(GLint location, GLfloat x, GLfloat y) override;
- void Uniform2fv(GLint location, GLsizei count, const GLfloat* v) override;
- void Uniform2i(GLint location, GLint x, GLint y) override;
- void Uniform2iv(GLint location, GLsizei count, const GLint* v) override;
- void Uniform2ui(GLint location, GLuint x, GLuint y) override;
- void Uniform2uiv(GLint location, GLsizei count, const GLuint* v) override;
- void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) override;
- void Uniform3fv(GLint location, GLsizei count, const GLfloat* v) override;
- void Uniform3i(GLint location, GLint x, GLint y, GLint z) override;
- void Uniform3iv(GLint location, GLsizei count, const GLint* v) override;
- void Uniform3ui(GLint location, GLuint x, GLuint y, GLuint z) override;
- void Uniform3uiv(GLint location, GLsizei count, const GLuint* v) override;
- void Uniform4f(GLint location,
- GLfloat x,
- GLfloat y,
- GLfloat z,
- GLfloat w) override;
- void Uniform4fv(GLint location, GLsizei count, const GLfloat* v) override;
- void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) override;
- void Uniform4iv(GLint location, GLsizei count, const GLint* v) override;
- void Uniform4ui(GLint location,
- GLuint x,
- GLuint y,
- GLuint z,
- GLuint w) override;
- void Uniform4uiv(GLint location, GLsizei count, const GLuint* v) override;
- void UniformBlockBinding(GLuint program,
- GLuint index,
- GLuint binding) override;
- void UniformMatrix2fv(GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat* value) override;
- void UniformMatrix2x3fv(GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat* value) override;
- void UniformMatrix2x4fv(GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat* value) override;
- void UniformMatrix3fv(GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat* value) override;
- void UniformMatrix3x2fv(GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat* value) override;
- void UniformMatrix3x4fv(GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat* value) override;
- void UniformMatrix4fv(GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat* value) override;
- void UniformMatrix4x2fv(GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat* value) override;
- void UniformMatrix4x3fv(GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat* value) override;
- void UseProgram(GLuint program) override;
- void ValidateProgram(GLuint program) override;
- void VertexAttrib1f(GLuint indx, GLfloat x) override;
- void VertexAttrib1fv(GLuint indx, const GLfloat* values) override;
- void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) override;
- void VertexAttrib2fv(GLuint indx, const GLfloat* values) override;
- void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) override;
- void VertexAttrib3fv(GLuint indx, const GLfloat* values) override;
- void VertexAttrib4f(GLuint indx,
- GLfloat x,
- GLfloat y,
- GLfloat z,
- GLfloat w) override;
- void VertexAttrib4fv(GLuint indx, const GLfloat* values) override;
- void VertexAttribI4i(GLuint indx,
- GLint x,
- GLint y,
- GLint z,
- GLint w) override;
- void VertexAttribI4iv(GLuint indx, const GLint* values) override;
- void VertexAttribI4ui(GLuint indx,
- GLuint x,
- GLuint y,
- GLuint z,
- GLuint w) override;
- void VertexAttribI4uiv(GLuint indx, const GLuint* values) override;
- void VertexAttribIPointer(GLuint indx,
- GLint size,
- GLenum type,
- GLsizei stride,
- const void* ptr) override;
- void VertexAttribPointer(GLuint indx,
- GLint size,
- GLenum type,
- GLboolean normalized,
- GLsizei stride,
- const void* ptr) override;
- void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) override;
- void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) override;
- void BlitFramebufferCHROMIUM(GLint srcX0,
- GLint srcY0,
- GLint srcX1,
- GLint srcY1,
- GLint dstX0,
- GLint dstY0,
- GLint dstX1,
- GLint dstY1,
- GLbitfield mask,
- GLenum filter) override;
- void RenderbufferStorageMultisampleCHROMIUM(GLenum target,
- GLsizei samples,
- GLenum internalformat,
- GLsizei width,
- GLsizei height) override;
- void RenderbufferStorageMultisampleEXT(GLenum target,
- GLsizei samples,
- GLenum internalformat,
- GLsizei width,
- GLsizei height) override;
- void FramebufferTexture2DMultisampleEXT(GLenum target,
- GLenum attachment,
- GLenum textarget,
- GLuint texture,
- GLint level,
- GLsizei samples) override;
- void TexStorage2DEXT(GLenum target,
- GLsizei levels,
- GLenum internalFormat,
- GLsizei width,
- GLsizei height) override;
- void GenQueriesEXT(GLsizei n, GLuint* queries) override;
- void DeleteQueriesEXT(GLsizei n, const GLuint* queries) override;
- void QueryCounterEXT(GLuint id, GLenum target) override;
- GLboolean IsQueryEXT(GLuint id) override;
- void BeginQueryEXT(GLenum target, GLuint id) override;
- void BeginTransformFeedback(GLenum primitivemode) override;
- void EndQueryEXT(GLenum target) override;
- void EndTransformFeedback() override;
- void GetQueryivEXT(GLenum target, GLenum pname, GLint* params) override;
- void GetQueryObjectivEXT(GLuint id, GLenum pname, GLint* params) override;
- void GetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint* params) override;
- void GetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64* params) override;
- void GetQueryObjectui64vEXT(GLuint id,
- GLenum pname,
- GLuint64* params) override;
- void SetDisjointValueSyncCHROMIUM() override;
- void InsertEventMarkerEXT(GLsizei length, const GLchar* marker) override;
- void PushGroupMarkerEXT(GLsizei length, const GLchar* marker) override;
- void PopGroupMarkerEXT() override;
- void GenVertexArraysOES(GLsizei n, GLuint* arrays) override;
- void DeleteVertexArraysOES(GLsizei n, const GLuint* arrays) override;
- GLboolean IsVertexArrayOES(GLuint array) override;
- void BindVertexArrayOES(GLuint array) override;
- void SwapBuffers() override;
- GLuint GetMaxValueInBufferCHROMIUM(GLuint buffer_id,
- GLsizei count,
- GLenum type,
- GLuint offset) override;
- GLboolean EnableFeatureCHROMIUM(const char* feature) override;
- void* MapBufferCHROMIUM(GLuint target, GLenum access) override;
- GLboolean UnmapBufferCHROMIUM(GLuint target) override;
- void* MapBufferSubDataCHROMIUM(GLuint target,
- GLintptr offset,
- GLsizeiptr size,
- GLenum access) override;
- void UnmapBufferSubDataCHROMIUM(const void* mem) override;
- void* MapBufferRange(GLenum target,
- GLintptr offset,
- GLsizeiptr size,
- GLbitfield access) override;
- GLboolean UnmapBuffer(GLenum target) override;
- void* MapTexSubImage2DCHROMIUM(GLenum target,
- GLint level,
- GLint xoffset,
- GLint yoffset,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLenum type,
- GLenum access) override;
- void UnmapTexSubImage2DCHROMIUM(const void* mem) override;
- void ResizeCHROMIUM(GLuint width,
- GLuint height,
- GLfloat scale_factor,
- GLboolean alpha) override;
- const GLchar* GetRequestableExtensionsCHROMIUM() override;
- void RequestExtensionCHROMIUM(const char* extension) override;
- void GetProgramInfoCHROMIUM(GLuint program,
- GLsizei bufsize,
- GLsizei* size,
- void* info) override;
- void GetUniformBlocksCHROMIUM(GLuint program,
- GLsizei bufsize,
- GLsizei* size,
- void* info) override;
- void GetTransformFeedbackVaryingsCHROMIUM(GLuint program,
- GLsizei bufsize,
- GLsizei* size,
- void* info) override;
- void GetUniformsES3CHROMIUM(GLuint program,
- GLsizei bufsize,
- GLsizei* size,
- void* info) override;
- GLuint CreateImageCHROMIUM(ClientBuffer buffer,
- GLsizei width,
- GLsizei height,
- GLenum internalformat) override;
- void DestroyImageCHROMIUM(GLuint image_id) override;
- GLuint CreateGpuMemoryBufferImageCHROMIUM(GLsizei width,
- GLsizei height,
- GLenum internalformat,
- GLenum usage) override;
- void GetTranslatedShaderSourceANGLE(GLuint shader,
- GLsizei bufsize,
- GLsizei* length,
- char* source) override;
- void PostSubBufferCHROMIUM(GLint x,
- GLint y,
- GLint width,
- GLint height) override;
- void CopyTextureCHROMIUM(GLenum source_id,
- GLenum dest_id,
- GLint internalformat,
- GLenum dest_type,
- GLboolean unpack_flip_y,
- GLboolean unpack_premultiply_alpha,
- GLboolean unpack_unmultiply_alpha) override;
- void CopySubTextureCHROMIUM(GLenum source_id,
- GLenum dest_id,
- GLint xoffset,
- GLint yoffset,
- GLint x,
- GLint y,
- GLsizei width,
- GLsizei height,
- GLboolean unpack_flip_y,
- GLboolean unpack_premultiply_alpha,
- GLboolean unpack_unmultiply_alpha) override;
- void CompressedCopyTextureCHROMIUM(GLenum source_id, GLenum dest_id) override;
- void DrawArraysInstancedANGLE(GLenum mode,
- GLint first,
- GLsizei count,
- GLsizei primcount) override;
- void DrawElementsInstancedANGLE(GLenum mode,
- GLsizei count,
- GLenum type,
- const void* indices,
- GLsizei primcount) override;
- void VertexAttribDivisorANGLE(GLuint index, GLuint divisor) override;
- void GenMailboxCHROMIUM(GLbyte* mailbox) override;
- void ProduceTextureCHROMIUM(GLenum target, const GLbyte* mailbox) override;
- void ProduceTextureDirectCHROMIUM(GLuint texture,
- GLenum target,
- const GLbyte* mailbox) override;
- void ConsumeTextureCHROMIUM(GLenum target, const GLbyte* mailbox) override;
- GLuint CreateAndConsumeTextureCHROMIUM(GLenum target,
- const GLbyte* mailbox) override;
- void BindUniformLocationCHROMIUM(GLuint program,
- GLint location,
- const char* name) override;
- void BindTexImage2DCHROMIUM(GLenum target, GLint imageId) override;
- void ReleaseTexImage2DCHROMIUM(GLenum target, GLint imageId) override;
- void TraceBeginCHROMIUM(const char* category_name,
- const char* trace_name) override;
- void TraceEndCHROMIUM() override;
- void DiscardFramebufferEXT(GLenum target,
- GLsizei count,
- const GLenum* attachments) override;
- void LoseContextCHROMIUM(GLenum current, GLenum other) override;
- GLuint64 InsertFenceSyncCHROMIUM() override;
- void GenSyncTokenCHROMIUM(GLuint64 fence_sync, GLbyte* sync_token) override;
- void GenUnverifiedSyncTokenCHROMIUM(GLuint64 fence_sync,
- GLbyte* sync_token) override;
- void VerifySyncTokensCHROMIUM(GLbyte** sync_tokens, GLsizei count) override;
- void WaitSyncTokenCHROMIUM(const GLbyte* sync_token) override;
- void DrawBuffersEXT(GLsizei count, const GLenum* bufs) override;
- void DiscardBackbufferCHROMIUM() override;
- void ScheduleOverlayPlaneCHROMIUM(GLint plane_z_order,
- GLenum plane_transform,
- GLuint overlay_texture_id,
- GLint bounds_x,
- GLint bounds_y,
- GLint bounds_width,
- GLint bounds_height,
- GLfloat uv_x,
- GLfloat uv_y,
- GLfloat uv_width,
- GLfloat uv_height) override;
- void ScheduleCALayerCHROMIUM(GLuint contents_texture_id,
- const GLfloat* contents_rect,
- GLfloat opacity,
- GLuint background_color,
- GLuint edge_aa_mask,
- const GLfloat* bounds_rect,
- GLboolean is_clipped,
- const GLfloat* clip_rect,
- GLint sorting_context_id,
- const GLfloat* transform,
- GLuint filter) override;
- void CommitOverlayPlanesCHROMIUM() override;
- void SwapInterval(GLint interval) override;
- void FlushDriverCachesCHROMIUM() override;
- GLuint GetLastFlushIdCHROMIUM() override;
- void MatrixLoadfCHROMIUM(GLenum matrixMode, const GLfloat* m) override;
- void MatrixLoadIdentityCHROMIUM(GLenum matrixMode) override;
- GLuint GenPathsCHROMIUM(GLsizei range) override;
- void DeletePathsCHROMIUM(GLuint path, GLsizei range) override;
- GLboolean IsPathCHROMIUM(GLuint path) override;
- void PathCommandsCHROMIUM(GLuint path,
- GLsizei numCommands,
- const GLubyte* commands,
- GLsizei numCoords,
- GLenum coordType,
- const GLvoid* coords) override;
- void PathParameterfCHROMIUM(GLuint path,
- GLenum pname,
- GLfloat value) override;
- void PathParameteriCHROMIUM(GLuint path, GLenum pname, GLint value) override;
- void PathStencilFuncCHROMIUM(GLenum func, GLint ref, GLuint mask) override;
- void StencilFillPathCHROMIUM(GLuint path,
- GLenum fillMode,
- GLuint mask) override;
- void StencilStrokePathCHROMIUM(GLuint path,
- GLint reference,
- GLuint mask) override;
- void CoverFillPathCHROMIUM(GLuint path, GLenum coverMode) override;
- void CoverStrokePathCHROMIUM(GLuint path, GLenum coverMode) override;
- void StencilThenCoverFillPathCHROMIUM(GLuint path,
- GLenum fillMode,
- GLuint mask,
- GLenum coverMode) override;
- void StencilThenCoverStrokePathCHROMIUM(GLuint path,
- GLint reference,
- GLuint mask,
- GLenum coverMode) override;
- void StencilFillPathInstancedCHROMIUM(
- GLsizei numPaths,
- GLenum pathNameType,
- const GLvoid* paths,
- GLuint pathBase,
- GLenum fillMode,
- GLuint mask,
- GLenum transformType,
- const GLfloat* transformValues) override;
- void StencilStrokePathInstancedCHROMIUM(
- GLsizei numPaths,
- GLenum pathNameType,
- const GLvoid* paths,
- GLuint pathBase,
- GLint reference,
- GLuint mask,
- GLenum transformType,
- const GLfloat* transformValues) override;
- void CoverFillPathInstancedCHROMIUM(GLsizei numPaths,
- GLenum pathNameType,
- const GLvoid* paths,
- GLuint pathBase,
- GLenum coverMode,
- GLenum transformType,
- const GLfloat* transformValues) override;
- void CoverStrokePathInstancedCHROMIUM(
- GLsizei numPaths,
- GLenum pathNameType,
- const GLvoid* paths,
- GLuint pathBase,
- GLenum coverMode,
- GLenum transformType,
- const GLfloat* transformValues) override;
- void StencilThenCoverFillPathInstancedCHROMIUM(
- GLsizei numPaths,
- GLenum pathNameType,
- const GLvoid* paths,
- GLuint pathBase,
- GLenum fillMode,
- GLuint mask,
- GLenum coverMode,
- GLenum transformType,
- const GLfloat* transformValues) override;
- void StencilThenCoverStrokePathInstancedCHROMIUM(
- GLsizei numPaths,
- GLenum pathNameType,
- const GLvoid* paths,
- GLuint pathBase,
- GLint reference,
- GLuint mask,
- GLenum coverMode,
- GLenum transformType,
- const GLfloat* transformValues) override;
- void BindFragmentInputLocationCHROMIUM(GLuint program,
- GLint location,
- const char* name) override;
- void ProgramPathFragmentInputGenCHROMIUM(GLuint program,
- GLint location,
- GLenum genMode,
- GLint components,
- const GLfloat* coeffs) override;
- void CoverageModulationCHROMIUM(GLenum components) override;
- GLenum GetGraphicsResetStatusKHR() override;
- void BlendBarrierKHR() override;
- void ApplyScreenSpaceAntialiasingCHROMIUM() override;
- void BindFragDataLocationIndexedEXT(GLuint program,
- GLuint colorNumber,
- GLuint index,
- const char* name) override;
- void BindFragDataLocationEXT(GLuint program,
- GLuint colorNumber,
- const char* name) override;
- GLint GetFragDataIndexEXT(GLuint program, const char* name) override;
- void UniformMatrix4fvStreamTextureMatrixCHROMIUM(
- GLint location,
- GLboolean transpose,
- const GLfloat* default_value) override;
-
- private:
- MojoGLES2Context context_;
-};
-
-} // namespace mojo
-#endif // MOJO_GPU_MOJO_GLES2_IMPL_AUTOGEN_H_
diff --git a/chromium/mojo/public/BUILD.gn b/chromium/mojo/public/BUILD.gn
index 9b76102be78..3baf6670645 100644
--- a/chromium/mojo/public/BUILD.gn
+++ b/chromium/mojo/public/BUILD.gn
@@ -23,7 +23,6 @@ group("sdk") {
deps = [
"c/system",
"cpp/bindings",
- "interfaces/bindings",
"js",
]
}
diff --git a/chromium/mojo/public/cpp/bindings/BUILD.gn b/chromium/mojo/public/cpp/bindings/BUILD.gn
index 2dded0b7d1c..06d8116a939 100644
--- a/chromium/mojo/public/cpp/bindings/BUILD.gn
+++ b/chromium/mojo/public/cpp/bindings/BUILD.gn
@@ -21,11 +21,9 @@ component("bindings") {
"$interfaces_bindings_gen_dir/pipe_control_messages.mojom-shared.h",
"$interfaces_bindings_gen_dir/pipe_control_messages.mojom.cc",
"$interfaces_bindings_gen_dir/pipe_control_messages.mojom.h",
- "array.h",
"array_data_view.h",
"array_traits.h",
"array_traits_carray.h",
- "array_traits_standard.h",
"array_traits_stl.h",
"associated_binding.h",
"associated_binding_set.h",
@@ -93,8 +91,6 @@ component("bindings") {
"lib/no_interface.cc",
"lib/pipe_control_message_handler.cc",
"lib/pipe_control_message_proxy.cc",
- "lib/router.cc",
- "lib/router.h",
"lib/scoped_interface_endpoint_handle.cc",
"lib/serialization.h",
"lib/serialization_context.cc",
@@ -118,7 +114,6 @@ component("bindings") {
"map.h",
"map_data_view.h",
"map_traits.h",
- "map_traits_standard.h",
"map_traits_stl.h",
"message.h",
"message_header_validator.h",
@@ -130,11 +125,8 @@ component("bindings") {
"pipe_control_message_handler_delegate.h",
"pipe_control_message_proxy.h",
"scoped_interface_endpoint_handle.h",
- "stl_converters.h",
- "string.h",
"string_data_view.h",
"string_traits.h",
- "string_traits_standard.h",
"string_traits_stl.h",
"string_traits_string16.h",
"string_traits_string_piece.h",
@@ -176,17 +168,13 @@ if (!is_ios) {
# TODO(yzshen): crbug.com/617718 Consider moving this into blink.
source_set("wtf_support") {
sources = [
- "array_traits_wtf.h",
"array_traits_wtf_vector.h",
"lib/string_traits_wtf.cc",
"lib/wtf_clone_equals_util.h",
"lib/wtf_hash_util.h",
"lib/wtf_serialization.h",
- "map_traits_wtf.h",
"map_traits_wtf_hash_map.h",
"string_traits_wtf.h",
- "wtf_array.h",
- "wtf_map.h",
]
public_deps = [
diff --git a/chromium/mojo/public/cpp/bindings/array.h b/chromium/mojo/public/cpp/bindings/array.h
deleted file mode 100644
index faf7398fffd..00000000000
--- a/chromium/mojo/public/cpp/bindings/array.h
+++ /dev/null
@@ -1,289 +0,0 @@
-// Copyright 2013 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.
-
-#ifndef MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_
-#define MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_
-
-#include <stddef.h>
-#include <string.h>
-#include <algorithm>
-#include <set>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "base/macros.h"
-#include "mojo/public/cpp/bindings/lib/array_internal.h"
-#include "mojo/public/cpp/bindings/lib/bindings_internal.h"
-#include "mojo/public/cpp/bindings/lib/clone_equals_util.h"
-#include "mojo/public/cpp/bindings/lib/hash_util.h"
-#include "mojo/public/cpp/bindings/lib/template_util.h"
-#include "mojo/public/cpp/bindings/type_converter.h"
-
-namespace mojo {
-
-// Represents a moveable array with contents of type |T|. The array can be null,
-// meaning that no value has been assigned to it. Null is distinct from empty.
-template <typename T>
-class Array {
- public:
- using ConstRefType = typename std::vector<T>::const_reference;
- using RefType = typename std::vector<T>::reference;
-
- using Element = T;
-
- using iterator = typename std::vector<T>::iterator;
- using const_iterator = typename std::vector<T>::const_iterator;
-
- // Constructs an empty array.
- Array() : is_null_(false) {}
- // Constructs a null array.
- Array(std::nullptr_t null_pointer) : is_null_(true) {}
-
- // Constructs a new non-null array of the specified size. The elements will
- // be value-initialized (meaning that they will be initialized by their
- // default constructor, if any, or else zero-initialized).
- explicit Array(size_t size) : vec_(size), is_null_(false) {}
- ~Array() {}
-
- // Copies the contents of |other| into this array.
- Array(const std::vector<T>& other) : vec_(other), is_null_(false) {}
-
- // Moves the contents of |other| into this array.
- Array(std::vector<T>&& other) : vec_(std::move(other)), is_null_(false) {}
- Array(Array&& other) : is_null_(true) { Take(&other); }
-
- Array& operator=(std::vector<T>&& other) {
- vec_ = std::move(other);
- is_null_ = false;
- return *this;
- }
- Array& operator=(Array&& other) {
- Take(&other);
- return *this;
- }
-
- Array& operator=(std::nullptr_t null_pointer) {
- is_null_ = true;
- vec_.clear();
- return *this;
- }
-
- // Creates a non-null array of the specified size. The elements will be
- // value-initialized (meaning that they will be initialized by their default
- // constructor, if any, or else zero-initialized).
- static Array New(size_t size) { return Array(size); }
-
- // Creates a new array with a copy of the contents of |other|.
- template <typename U>
- static Array From(const U& other) {
- return TypeConverter<Array, U>::Convert(other);
- }
-
- // Copies the contents of this array to a new object of type |U|.
- template <typename U>
- U To() const {
- return TypeConverter<U, Array>::Convert(*this);
- }
-
- // Indicates whether the array is null (which is distinct from empty).
- bool is_null() const { return is_null_; }
-
- // Indicates whether the array is empty (which is distinct from null).
- bool empty() const { return vec_.empty() && !is_null_; }
-
- // Returns a reference to the first element of the array. Calling this on a
- // null or empty array causes undefined behavior.
- ConstRefType front() const { return vec_.front(); }
- RefType front() { return vec_.front(); }
-
- iterator begin() { return vec_.begin(); }
- const_iterator begin() const { return vec_.begin(); }
- iterator end() { return vec_.end(); }
- const_iterator end() const { return vec_.end(); }
-
- // Returns the size of the array, which will be zero if the array is null.
- size_t size() const { return vec_.size(); }
-
- // Returns a reference to the element at zero-based |offset|. Calling this on
- // an array with size less than |offset|+1 causes undefined behavior.
- ConstRefType at(size_t offset) const { return vec_.at(offset); }
- ConstRefType operator[](size_t offset) const { return at(offset); }
- RefType at(size_t offset) { return vec_.at(offset); }
- RefType operator[](size_t offset) { return at(offset); }
-
- // Pushes |value| onto the back of the array. If this array was null, it will
- // become non-null with a size of 1.
- void push_back(const T& value) {
- is_null_ = false;
- vec_.push_back(value);
- }
- void push_back(T&& value) {
- is_null_ = false;
- vec_.push_back(std::move(value));
- }
-
- // Resizes the array to |size| and makes it non-null. Otherwise, works just
- // like the resize method of |std::vector|.
- void resize(size_t size) {
- is_null_ = false;
- vec_.resize(size);
- }
-
- // Sets the array to empty (even if previously it was null.)
- void SetToEmpty() { resize(0); }
-
- // Ensures the underlying storage can store up to |size| elements without
- // performing reallocations. This works like the reserve method of
- // |std::vector|.
- void reserve(size_t size) { vec_.reserve(size); }
-
- // Returns a const reference to the |std::vector| managed by this class. If
- // the array is null, this will be an empty vector.
- const std::vector<T>& storage() const { return vec_; }
-
- // Passes the underlying storage and resets this array to null.
- std::vector<T> PassStorage() {
- is_null_ = true;
- return std::move(vec_);
- }
-
- operator const std::vector<T>&() const { return vec_; }
-
- void Swap(Array* other) {
- std::swap(is_null_, other->is_null_);
- vec_.swap(other->vec_);
- }
-
- // Swaps the contents of this array with the specified vector, making this
- // array non-null. Since the vector cannot represent null, it will just be
- // made empty if this array is null.
- void Swap(std::vector<T>* other) {
- is_null_ = false;
- vec_.swap(*other);
- }
-
- // Returns a copy of the array where each value of the new array has been
- // "cloned" from the corresponding value of this array. If the element type
- // defines a Clone() method, it will be used; otherwise copy
- // constructor/assignment will be used.
- //
- // Please note that calling this method will fail compilation if the element
- // type cannot be cloned (which usually means that it is a Mojo handle type or
- // a type containing Mojo handles).
- Array Clone() const {
- Array result;
- result.is_null_ = is_null_;
- result.vec_ = internal::Clone(vec_);
- return result;
- }
-
- // Indicates whether the contents of this array are equal to |other|. A null
- // array is only equal to another null array. If the element type defines an
- // Equals() method, it will be used; otherwise == operator will be used.
- bool Equals(const Array& other) const {
- if (is_null() != other.is_null())
- return false;
- return internal::Equals(vec_, other.vec_);
- }
-
- size_t Hash(size_t seed) const {
- return is_null() ? seed : internal::Hash(seed, vec_);
- }
-
- private:
- typedef std::vector<T> Array::*Testable;
-
- public:
- operator Testable() const { return is_null_ ? 0 : &Array::vec_; }
-
- private:
- // Forbid the == and != operators explicitly, otherwise Array will be
- // converted to Testable to do == or != comparison.
- template <typename U>
- bool operator==(const Array<U>& other) const = delete;
- template <typename U>
- bool operator!=(const Array<U>& other) const = delete;
-
- void Take(Array* other) {
- operator=(nullptr);
- Swap(other);
- }
-
- std::vector<T> vec_;
- bool is_null_;
-
- DISALLOW_COPY_AND_ASSIGN(Array);
-};
-
-// A |TypeConverter| that will create an |Array<T>| containing a copy of the
-// contents of an |std::vector<E>|, using |TypeConverter<T, E>| to copy each
-// element. The returned array will always be non-null.
-template <typename T, typename E>
-struct TypeConverter<Array<T>, std::vector<E>> {
- static Array<T> Convert(const std::vector<E>& input) {
- Array<T> result(input.size());
- for (size_t i = 0; i < input.size(); ++i)
- result[i] = TypeConverter<T, E>::Convert(input[i]);
- return std::move(result);
- }
-};
-
-// A |TypeConverter| that will create an |std::vector<E>| containing a copy of
-// the contents of an |Array<T>|, using |TypeConverter<E, T>| to copy each
-// element. If the input array is null, the output vector will be empty.
-template <typename E, typename T>
-struct TypeConverter<std::vector<E>, Array<T>> {
- static std::vector<E> Convert(const Array<T>& input) {
- std::vector<E> result;
- if (!input.is_null()) {
- result.resize(input.size());
- for (size_t i = 0; i < input.size(); ++i)
- result[i] = TypeConverter<E, T>::Convert(input[i]);
- }
- return result;
- }
-};
-
-// A |TypeConverter| that will create an |Array<T>| containing a copy of the
-// contents of an |std::set<E>|, using |TypeConverter<T, E>| to copy each
-// element. The returned array will always be non-null.
-template <typename T, typename E>
-struct TypeConverter<Array<T>, std::set<E>> {
- static Array<T> Convert(const std::set<E>& input) {
- Array<T> result;
- for (auto i : input)
- result.push_back(TypeConverter<T, E>::Convert(i));
- return std::move(result);
- }
-};
-
-// A |TypeConverter| that will create an |std::set<E>| containing a copy of
-// the contents of an |Array<T>|, using |TypeConverter<E, T>| to copy each
-// element. If the input array is null, the output set will be empty.
-template <typename E, typename T>
-struct TypeConverter<std::set<E>, Array<T>> {
- static std::set<E> Convert(const Array<T>& input) {
- std::set<E> result;
- if (!input.is_null()) {
- for (size_t i = 0; i < input.size(); ++i)
- result.insert(TypeConverter<E, T>::Convert(input[i]));
- }
- return result;
- }
-};
-
-// Less than operator to allow Arrays as keys in std maps and sets.
-template <typename T>
-inline bool operator<(const Array<T>& a, const Array<T>& b) {
- if (a.is_null())
- return !b.is_null();
- if (b.is_null())
- return false;
- return a.storage() < b.storage();
-}
-
-} // namespace mojo
-
-#endif // MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_
diff --git a/chromium/mojo/public/cpp/bindings/array_traits_standard.h b/chromium/mojo/public/cpp/bindings/array_traits_standard.h
deleted file mode 100644
index 862de6b6d0d..00000000000
--- a/chromium/mojo/public/cpp/bindings/array_traits_standard.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2016 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.
-
-#ifndef MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_STANDARD_H_
-#define MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_STANDARD_H_
-
-#include "mojo/public/cpp/bindings/array.h"
-#include "mojo/public/cpp/bindings/array_traits.h"
-
-namespace mojo {
-
-template <typename T>
-struct ArrayTraits<Array<T>> {
- using Element = T;
-
- static bool IsNull(const Array<T>& input) { return input.is_null(); }
- static void SetToNull(Array<T>* output) { *output = nullptr; }
-
- static size_t GetSize(const Array<T>& input) { return input.size(); }
-
- static T* GetData(Array<T>& input) { return &input.front(); }
-
- static const T* GetData(const Array<T>& input) { return &input.front(); }
-
- static typename Array<T>::RefType GetAt(Array<T>& input, size_t index) {
- return input[index];
- }
-
- static typename Array<T>::ConstRefType GetAt(const Array<T>& input,
- size_t index) {
- return input[index];
- }
-
- static bool Resize(Array<T>& input, size_t size) {
- input.resize(size);
- return true;
- }
-};
-
-} // namespace mojo
-
-#endif // MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_STANDARD_H_
diff --git a/chromium/mojo/public/cpp/bindings/array_traits_wtf.h b/chromium/mojo/public/cpp/bindings/array_traits_wtf.h
deleted file mode 100644
index 7e773fc6668..00000000000
--- a/chromium/mojo/public/cpp/bindings/array_traits_wtf.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2016 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.
-
-#ifndef MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_WTF_H_
-#define MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_WTF_H_
-
-#include "mojo/public/cpp/bindings/array_traits.h"
-#include "mojo/public/cpp/bindings/wtf_array.h"
-
-namespace mojo {
-
-template <typename U>
-struct ArrayTraits<WTFArray<U>> {
- using Element = U;
-
- static bool IsNull(const WTFArray<U>& input) { return input.is_null(); }
- static void SetToNull(WTFArray<U>* output) { *output = nullptr; }
-
- static size_t GetSize(const WTFArray<U>& input) { return input.size(); }
-
- static U* GetData(WTFArray<U>& input) { return &input.front(); }
-
- static const U* GetData(const WTFArray<U>& input) { return &input.front(); }
-
- static U& GetAt(WTFArray<U>& input, size_t index) { return input[index]; }
-
- static const U& GetAt(const WTFArray<U>& input, size_t index) {
- return input[index];
- }
-
- static bool Resize(WTFArray<U>& input, size_t size) {
- input.resize(size);
- return true;
- }
-};
-
-} // namespace mojo
-
-#endif // MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_WTF_H_
diff --git a/chromium/mojo/public/cpp/bindings/associated_interface_ptr.h b/chromium/mojo/public/cpp/bindings/associated_interface_ptr.h
index 3bdb319548a..5d83e48103c 100644
--- a/chromium/mojo/public/cpp/bindings/associated_interface_ptr.h
+++ b/chromium/mojo/public/cpp/bindings/associated_interface_ptr.h
@@ -204,7 +204,7 @@ class AssociatedInterfacePtr {
// Creates an associated interface. The output |ptr| should be used locally
// while the returned request should be passed through the message pipe endpoint
-// referred to by |associated_group| to setup the corresponding asssociated
+// referred to by |associated_group| to setup the corresponding associated
// interface implementation at the remote side.
//
// NOTE: |ptr| should NOT be used to make calls before the request is sent.
@@ -212,7 +212,7 @@ class AssociatedInterfacePtr {
// as soon as the request is sent, |ptr| is usable. There is no need to wait
// until the request is bound to an implementation at the remote side.
template <typename Interface>
-AssociatedInterfaceRequest<Interface> GetProxy(
+AssociatedInterfaceRequest<Interface> MakeRequest(
AssociatedInterfacePtr<Interface>* ptr,
AssociatedGroup* group,
scoped_refptr<base::SingleThreadTaskRunner> runner =
@@ -226,16 +226,70 @@ AssociatedInterfaceRequest<Interface> GetProxy(
return request;
}
-// Creates an associated interface proxy which casts its messages into the void.
+// Creates an associated interface proxy in its own AssociatedGroup.
template <typename Interface>
-void GetDummyProxyForTesting(AssociatedInterfacePtr<Interface>* proxy) {
+AssociatedInterfaceRequest<Interface> MakeRequestForTesting(
+ AssociatedInterfacePtr<Interface>* ptr,
+ scoped_refptr<base::SingleThreadTaskRunner> runner =
+ base::ThreadTaskRunnerHandle::Get()) {
+ MessagePipe pipe;
+ using internal::MultiplexRouter;
+ scoped_refptr<MultiplexRouter> router0 = new MultiplexRouter(
+ std::move(pipe.handle0), MultiplexRouter::MULTI_INTERFACE, true, runner);
+ scoped_refptr<MultiplexRouter> router1 = new MultiplexRouter(
+ std::move(pipe.handle1), MultiplexRouter::MULTI_INTERFACE, false, runner);
+
+ AssociatedInterfacePtrInfo<Interface> ptr_info;
+ AssociatedInterfaceRequest<Interface> request;
+ router1->CreateAssociatedGroup()->CreateAssociatedInterface(
+ AssociatedGroup::WILL_PASS_PTR, &ptr_info, &request);
+
+ // Emulate passing |ptr_info| across a pipe.
+ ScopedInterfaceEndpointHandle handle = ptr_info.PassHandle();
+ DCHECK(!handle.is_local());
+ ptr->Bind(AssociatedInterfacePtrInfo<Interface>(
+ router0->CreateLocalEndpointHandle(handle.release()),
+ ptr_info.version()),
+ std::move(runner));
+
+ return request;
+}
+
+// Like |GetProxy|, but the interface is never associated with any other
+// interface. The returned request can be bound directly to the corresponding
+// associated interface implementation, without first passing it through a
+// message pipe endpoint.
+//
+// This function has two main uses:
+//
+// * In testing, where the returned request is bound to e.g. a mock and there
+// are no other interfaces involved.
+//
+// * When discarding messages sent on an interface, which can be done by
+// discarding the returned request.
+template <typename Interface>
+AssociatedInterfaceRequest<Interface> GetIsolatedProxy(
+ AssociatedInterfacePtr<Interface>* ptr) {
MessagePipe pipe;
- scoped_refptr<internal::MultiplexRouter> router =
+ scoped_refptr<internal::MultiplexRouter> router0 =
new internal::MultiplexRouter(std::move(pipe.handle0),
internal::MultiplexRouter::MULTI_INTERFACE,
false, base::ThreadTaskRunnerHandle::Get());
- std::unique_ptr<AssociatedGroup> group = router->CreateAssociatedGroup();
- GetProxy(proxy, group.get());
+ scoped_refptr<internal::MultiplexRouter> router1 =
+ new internal::MultiplexRouter(std::move(pipe.handle1),
+ internal::MultiplexRouter::MULTI_INTERFACE,
+ true, base::ThreadTaskRunnerHandle::Get());
+
+ ScopedInterfaceEndpointHandle endpoint0, endpoint1;
+ router0->CreateEndpointHandlePair(&endpoint0, &endpoint1);
+ endpoint1 = router1->CreateLocalEndpointHandle(endpoint1.release());
+
+ ptr->Bind(AssociatedInterfacePtrInfo<Interface>(std::move(endpoint0),
+ Interface::Version_));
+
+ AssociatedInterfaceRequest<Interface> request;
+ request.Bind(std::move(endpoint1));
+ return request;
}
} // namespace mojo
diff --git a/chromium/mojo/public/cpp/bindings/binding.h b/chromium/mojo/public/cpp/bindings/binding.h
index 249655d6e05..740a3952d2d 100644
--- a/chromium/mojo/public/cpp/bindings/binding.h
+++ b/chromium/mojo/public/cpp/bindings/binding.h
@@ -275,7 +275,7 @@ class Binding {
void EnableTestingMode() { internal_state_.EnableTestingMode(); }
private:
- internal::BindingState<Interface, true, ImplRefTraits> internal_state_;
+ internal::BindingState<Interface, ImplRefTraits> internal_state_;
DISALLOW_COPY_AND_ASSIGN(Binding);
};
diff --git a/chromium/mojo/public/cpp/bindings/binding_set.h b/chromium/mojo/public/cpp/bindings/binding_set.h
index 0ae23889849..3c087c2c952 100644
--- a/chromium/mojo/public/cpp/bindings/binding_set.h
+++ b/chromium/mojo/public/cpp/bindings/binding_set.h
@@ -11,6 +11,7 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/connection_error_callback.h"
#include "mojo/public/cpp/bindings/interface_ptr.h"
@@ -27,8 +28,8 @@ struct BindingSetTraits<Binding<Interface>> {
using ProxyType = InterfacePtr<Interface>;
using RequestType = InterfaceRequest<Interface>;
- static RequestType GetProxy(ProxyType* proxy) {
- return mojo::GetProxy(proxy);
+ static RequestType MakeRequest(ProxyType* proxy) {
+ return mojo::MakeRequest(proxy);
}
};
@@ -114,7 +115,7 @@ class BindingSet {
ProxyType CreateInterfacePtrAndBind(Interface* impl,
BindingId* id_storage = nullptr) {
ProxyType proxy;
- BindingId id = AddBinding(impl, Traits::GetProxy(&proxy));
+ BindingId id = AddBinding(impl, Traits::MakeRequest(&proxy));
if (id_storage)
*id_storage = id;
return proxy;
diff --git a/chromium/mojo/public/cpp/bindings/interface_endpoint_client.h b/chromium/mojo/public/cpp/bindings/interface_endpoint_client.h
index 6129d75bbf7..da5df227160 100644
--- a/chromium/mojo/public/cpp/bindings/interface_endpoint_client.h
+++ b/chromium/mojo/public/cpp/bindings/interface_endpoint_client.h
@@ -37,8 +37,7 @@ class InterfaceEndpointController;
// endpoint, either the implementation side or the client side.
// It should only be accessed and destructed on the creating thread.
class MOJO_CPP_BINDINGS_EXPORT InterfaceEndpointClient
- : NON_EXPORTED_BASE(public MessageReceiverWithResponder),
- public base::MessageLoop::DestructionObserver {
+ : NON_EXPORTED_BASE(public MessageReceiverWithResponder) {
public:
// |receiver| is okay to be null. If it is not null, it must outlive this
// object.
@@ -149,10 +148,6 @@ class MOJO_CPP_BINDINGS_EXPORT InterfaceEndpointClient
};
bool HandleValidatedMessage(Message* message);
- void StopObservingIfNecessary();
-
- // base::MessageLoop::DestructionObserver:
- void WillDestroyCurrentMessageLoop() override;
ScopedInterfaceEndpointHandle handle_;
std::unique_ptr<AssociatedGroup> associated_group_;
@@ -176,8 +171,6 @@ class MOJO_CPP_BINDINGS_EXPORT InterfaceEndpointClient
internal::ControlMessageProxy control_message_proxy_;
internal::ControlMessageHandler control_message_handler_;
- bool observing_message_loop_destruction_ = true;
-
base::ThreadChecker thread_checker_;
base::WeakPtrFactory<InterfaceEndpointClient> weak_ptr_factory_;
diff --git a/chromium/mojo/public/cpp/bindings/interface_ptr.h b/chromium/mojo/public/cpp/bindings/interface_ptr.h
index bd77ead0428..a86761106e2 100644
--- a/chromium/mojo/public/cpp/bindings/interface_ptr.h
+++ b/chromium/mojo/public/cpp/bindings/interface_ptr.h
@@ -201,7 +201,7 @@ class InterfacePtr {
}
// DO NOT USE. Exposed only for internal use and for testing.
- internal::InterfacePtrState<Interface, true>* internal_state() {
+ internal::InterfacePtrState<Interface>* internal_state() {
return &internal_state_;
}
@@ -209,7 +209,7 @@ class InterfacePtr {
// implicitly convertible to a real bool (which is dangerous).
private:
// TODO(dcheng): Use an explicit conversion operator.
- typedef internal::InterfacePtrState<Interface, true> InterfacePtr::*Testable;
+ typedef internal::InterfacePtrState<Interface> InterfacePtr::*Testable;
public:
operator Testable() const {
@@ -225,7 +225,7 @@ class InterfacePtr {
template <typename T>
bool operator!=(const InterfacePtr<T>& other) const = delete;
- typedef internal::InterfacePtrState<Interface, true> State;
+ typedef internal::InterfacePtrState<Interface> State;
mutable State internal_state_;
DISALLOW_COPY_AND_ASSIGN(InterfacePtr);
diff --git a/chromium/mojo/public/cpp/bindings/interface_request.h b/chromium/mojo/public/cpp/bindings/interface_request.h
index 5d75dd3e610..ab237656cfb 100644
--- a/chromium/mojo/public/cpp/bindings/interface_request.h
+++ b/chromium/mojo/public/cpp/bindings/interface_request.h
@@ -31,6 +31,19 @@ class InterfaceRequest {
InterfaceRequest() {}
InterfaceRequest(decltype(nullptr)) {}
+ // Creates a new message pipe over which Interface is to be served, binding
+ // the specified InterfacePtr to one end of the message pipe and this
+ // InterfaceRequest to the other. For example usage, see comments on
+ // MakeRequest(InterfacePtr*) below.
+ explicit InterfaceRequest(InterfacePtr<Interface>* ptr,
+ scoped_refptr<base::SingleThreadTaskRunner> runner =
+ base::ThreadTaskRunnerHandle::Get()) {
+ MessagePipe pipe;
+ ptr->Bind(InterfacePtrInfo<Interface>(std::move(pipe.handle0), 0u),
+ std::move(runner));
+ Bind(std::move(pipe.handle1));
+ }
+
// Takes the message pipe from another InterfaceRequest.
InterfaceRequest(InterfaceRequest&& other) {
handle_ = std::move(other.handle_);
@@ -120,9 +133,9 @@ InterfaceRequest<Interface> MakeRequest(ScopedMessagePipeHandle handle) {
//
// DatabasePtr database = ...; // Connect to database.
// TablePtr table;
-// database->OpenTable(GetProxy(&table));
+// database->OpenTable(MakeRequest(&table));
//
-// Upon return from GetProxy, |table| is ready to have methods called on it.
+// Upon return from MakeRequest, |table| is ready to have methods called on it.
//
// Example #2: Registering a local implementation with a remote service.
// =====================================================================
@@ -136,19 +149,16 @@ InterfaceRequest<Interface> MakeRequest(ScopedMessagePipeHandle handle) {
//
// CollectorPtr collector = ...; // Connect to Collector.
// SourcePtr source;
-// InterfaceRequest<Source> source_request = GetProxy(&source);
+// InterfaceRequest<Source> source_request(&source);
// collector->RegisterSource(std::move(source));
// CreateSource(std::move(source_request)); // Create implementation locally.
//
template <typename Interface>
-InterfaceRequest<Interface> GetProxy(
+InterfaceRequest<Interface> MakeRequest(
InterfacePtr<Interface>* ptr,
scoped_refptr<base::SingleThreadTaskRunner> runner =
base::ThreadTaskRunnerHandle::Get()) {
- MessagePipe pipe;
- ptr->Bind(InterfacePtrInfo<Interface>(std::move(pipe.handle0), 0u),
- std::move(runner));
- return MakeRequest<Interface>(std::move(pipe.handle1));
+ return InterfaceRequest<Interface>(ptr, runner);
}
// Fuses an InterfaceRequest<T> endpoint with an InterfacePtrInfo<T> endpoint.
diff --git a/chromium/mojo/public/cpp/bindings/lib/array_serialization.h b/chromium/mojo/public/cpp/bindings/lib/array_serialization.h
index 9e68f452458..acfd4e3ec63 100644
--- a/chromium/mojo/public/cpp/bindings/lib/array_serialization.h
+++ b/chromium/mojo/public/cpp/bindings/lib/array_serialization.h
@@ -19,7 +19,6 @@
#include "mojo/public/cpp/bindings/lib/serialization_forward.h"
#include "mojo/public/cpp/bindings/lib/template_util.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
-#include "mojo/public/cpp/bindings/map.h"
namespace mojo {
namespace internal {
diff --git a/chromium/mojo/public/cpp/bindings/lib/binding_state.cc b/chromium/mojo/public/cpp/bindings/lib/binding_state.cc
index e41258f586c..0ec445e89c9 100644
--- a/chromium/mojo/public/cpp/bindings/lib/binding_state.cc
+++ b/chromium/mojo/public/cpp/bindings/lib/binding_state.cc
@@ -9,108 +9,34 @@
namespace mojo {
namespace internal {
-SimpleBindingState::SimpleBindingState() = default;
+BindingStateBase::BindingStateBase() = default;
-SimpleBindingState::~SimpleBindingState() = default;
+BindingStateBase::~BindingStateBase() = default;
-void SimpleBindingState::AddFilter(std::unique_ptr<MessageReceiver> filter) {
- DCHECK(router_);
- router_->AddFilter(std::move(filter));
-}
-
-void SimpleBindingState::PauseIncomingMethodCallProcessing() {
- DCHECK(router_);
- router_->PauseIncomingMethodCallProcessing();
-}
-void SimpleBindingState::ResumeIncomingMethodCallProcessing() {
- DCHECK(router_);
- router_->ResumeIncomingMethodCallProcessing();
-}
-
-bool SimpleBindingState::WaitForIncomingMethodCall(MojoDeadline deadline) {
- DCHECK(router_);
- return router_->WaitForIncomingMessage(deadline);
-}
-
-void SimpleBindingState::Close() {
- if (!router_)
- return;
-
- router_->CloseMessagePipe();
- DestroyRouter();
-}
-
-void SimpleBindingState::CloseWithReason(uint32_t custom_reason,
- const std::string& description) {
- if (router_)
- router_->control_message_proxy()->SendDisconnectReason(custom_reason,
- description);
- Close();
-}
-
-void SimpleBindingState::FlushForTesting() {
- router_->control_message_proxy()->FlushForTesting();
-}
-
-void SimpleBindingState::EnableTestingMode() {
- DCHECK(is_bound());
- router_->EnableTestingMode();
-}
-
-void SimpleBindingState::BindInternal(
- ScopedMessagePipeHandle handle,
- scoped_refptr<base::SingleThreadTaskRunner> runner,
- const char* interface_name,
- std::unique_ptr<MessageReceiver> request_validator,
- bool has_sync_methods,
- MessageReceiverWithResponderStatus* stub,
- uint32_t interface_version) {
- FilterChain filters;
- filters.Append<MessageHeaderValidator>(interface_name);
- filters.Append(std::move(request_validator));
-
- router_ = new internal::Router(std::move(handle), std::move(filters),
- has_sync_methods, std::move(runner),
- interface_version);
- router_->set_incoming_receiver(stub);
-}
-
-void SimpleBindingState::DestroyRouter() {
- delete router_;
- router_ = nullptr;
-}
-
-// -----------------------------------------------------------------------------
-
-MultiplexedBindingState::MultiplexedBindingState() = default;
-
-MultiplexedBindingState::~MultiplexedBindingState() = default;
-
-void MultiplexedBindingState::AddFilter(
- std::unique_ptr<MessageReceiver> filter) {
+void BindingStateBase::AddFilter(std::unique_ptr<MessageReceiver> filter) {
DCHECK(endpoint_client_);
endpoint_client_->AddFilter(std::move(filter));
}
-bool MultiplexedBindingState::HasAssociatedInterfaces() const {
+bool BindingStateBase::HasAssociatedInterfaces() const {
return router_ ? router_->HasAssociatedEndpoints() : false;
}
-void MultiplexedBindingState::PauseIncomingMethodCallProcessing() {
+void BindingStateBase::PauseIncomingMethodCallProcessing() {
DCHECK(router_);
router_->PauseIncomingMethodCallProcessing();
}
-void MultiplexedBindingState::ResumeIncomingMethodCallProcessing() {
+void BindingStateBase::ResumeIncomingMethodCallProcessing() {
DCHECK(router_);
router_->ResumeIncomingMethodCallProcessing();
}
-bool MultiplexedBindingState::WaitForIncomingMethodCall(MojoDeadline deadline) {
+bool BindingStateBase::WaitForIncomingMethodCall(MojoDeadline deadline) {
DCHECK(router_);
return router_->WaitForIncomingMessage(deadline);
}
-void MultiplexedBindingState::Close() {
+void BindingStateBase::Close() {
if (!router_)
return;
@@ -119,24 +45,24 @@ void MultiplexedBindingState::Close() {
router_ = nullptr;
}
-void MultiplexedBindingState::CloseWithReason(uint32_t custom_reason,
- const std::string& description) {
+void BindingStateBase::CloseWithReason(uint32_t custom_reason,
+ const std::string& description) {
if (endpoint_client_)
endpoint_client_->control_message_proxy()->SendDisconnectReason(
custom_reason, description);
Close();
}
-void MultiplexedBindingState::FlushForTesting() {
+void BindingStateBase::FlushForTesting() {
endpoint_client_->control_message_proxy()->FlushForTesting();
}
-void MultiplexedBindingState::EnableTestingMode() {
+void BindingStateBase::EnableTestingMode() {
DCHECK(is_bound());
router_->EnableTestingMode();
}
-void MultiplexedBindingState::BindInternal(
+void BindingStateBase::BindInternal(
ScopedMessagePipeHandle handle,
scoped_refptr<base::SingleThreadTaskRunner> runner,
const char* interface_name,
diff --git a/chromium/mojo/public/cpp/bindings/lib/binding_state.h b/chromium/mojo/public/cpp/bindings/lib/binding_state.h
index a947cf73c57..a57d904041d 100644
--- a/chromium/mojo/public/cpp/bindings/lib/binding_state.h
+++ b/chromium/mojo/public/cpp/bindings/lib/binding_state.h
@@ -26,7 +26,6 @@
#include "mojo/public/cpp/bindings/interface_ptr_info.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "mojo/public/cpp/bindings/lib/multiplex_router.h"
-#include "mojo/public/cpp/bindings/lib/router.h"
#include "mojo/public/cpp/bindings/message_header_validator.h"
#include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
#include "mojo/public/cpp/system/core.h"
@@ -34,113 +33,10 @@
namespace mojo {
namespace internal {
-// Base class used for templated binding primitives which bind a pipe
-// exclusively to a single interface.
-class MOJO_CPP_BINDINGS_EXPORT SimpleBindingState {
+class MOJO_CPP_BINDINGS_EXPORT BindingStateBase {
public:
- SimpleBindingState();
- ~SimpleBindingState();
-
- void AddFilter(std::unique_ptr<MessageReceiver> filter);
-
- bool HasAssociatedInterfaces() const { return false; }
-
- void PauseIncomingMethodCallProcessing();
- void ResumeIncomingMethodCallProcessing();
-
- bool WaitForIncomingMethodCall(
- MojoDeadline deadline = MOJO_DEADLINE_INDEFINITE);
-
- void Close();
- void CloseWithReason(uint32_t custom_reason, const std::string& description);
-
- void set_connection_error_handler(const base::Closure& error_handler) {
- DCHECK(is_bound());
- router_->set_connection_error_handler(error_handler);
- }
-
- void set_connection_error_with_reason_handler(
- const ConnectionErrorWithReasonCallback& error_handler) {
- DCHECK(is_bound());
- router_->set_connection_error_with_reason_handler(error_handler);
- }
-
- bool is_bound() const { return !!router_; }
-
- MessagePipeHandle handle() const {
- DCHECK(is_bound());
- return router_->handle();
- }
-
- AssociatedGroup* associated_group() { return nullptr; }
-
- void FlushForTesting();
-
- void EnableTestingMode();
-
- protected:
- void BindInternal(ScopedMessagePipeHandle handle,
- scoped_refptr<base::SingleThreadTaskRunner> runner,
- const char* interface_name,
- std::unique_ptr<MessageReceiver> request_validator,
- bool has_sync_methods,
- MessageReceiverWithResponderStatus* stub,
- uint32_t interface_version);
-
- void DestroyRouter();
-
- internal::Router* router_ = nullptr;
-};
-
-template <typename Interface, bool use_multiplex_router, typename ImplRefTraits>
-class BindingState;
-
-// Uses a single-threaded, dedicated router. If |Interface| doesn't have any
-// methods to pass associated interface pointers or requests, there won't be
-// multiple interfaces running on the underlying message pipe. In that case, we
-// can use this specialization to reduce cost.
-template <typename Interface, typename ImplRefTraits>
-class BindingState<Interface, false, ImplRefTraits>
- : public SimpleBindingState {
- public:
- using ImplPointerType = typename ImplRefTraits::PointerType;
-
- explicit BindingState(ImplPointerType impl) {
- stub_.set_sink(std::move(impl));
- }
-
- ~BindingState() { Close(); }
-
- void Bind(ScopedMessagePipeHandle handle,
- scoped_refptr<base::SingleThreadTaskRunner> runner) {
- DCHECK(!router_);
- SimpleBindingState::BindInternal(
- std::move(handle), runner, Interface::Name_,
- base::MakeUnique<typename Interface::RequestValidator_>(),
- Interface::HasSyncMethods_, &stub_, Interface::Version_);
- }
-
- InterfaceRequest<Interface> Unbind() {
- InterfaceRequest<Interface> request =
- MakeRequest<Interface>(router_->PassMessagePipe());
- DestroyRouter();
- return std::move(request);
- }
-
- Interface* impl() { return ImplRefTraits::GetRawPointer(&stub_.sink()); }
-
- private:
- typename Interface::template Stub_<ImplRefTraits> stub_;
-
- DISALLOW_COPY_AND_ASSIGN(BindingState);
-};
-
-// Base class used for templated binding primitives which may bind a pipe to
-// multiple interfaces.
-class MOJO_CPP_BINDINGS_EXPORT MultiplexedBindingState {
- public:
- MultiplexedBindingState();
- ~MultiplexedBindingState();
+ BindingStateBase();
+ ~BindingStateBase();
void AddFilter(std::unique_ptr<MessageReceiver> filter);
@@ -195,11 +91,8 @@ class MOJO_CPP_BINDINGS_EXPORT MultiplexedBindingState {
std::unique_ptr<InterfaceEndpointClient> endpoint_client_;
};
-// Uses a multiplexing router. If |Interface| has methods to pass associated
-// interface pointers or requests, this specialization should be used.
template <typename Interface, typename ImplRefTraits>
-class BindingState<Interface, true, ImplRefTraits>
- : public MultiplexedBindingState {
+class BindingState : public BindingStateBase {
public:
using ImplPointerType = typename ImplRefTraits::PointerType;
@@ -211,7 +104,7 @@ class BindingState<Interface, true, ImplRefTraits>
void Bind(ScopedMessagePipeHandle handle,
scoped_refptr<base::SingleThreadTaskRunner> runner) {
- MultiplexedBindingState::BindInternal(
+ BindingStateBase::BindInternal(
std::move(handle), runner, Interface::Name_,
base::MakeUnique<typename Interface::RequestValidator_>(),
Interface::PassesAssociatedKinds_, Interface::HasSyncMethods_, &stub_,
diff --git a/chromium/mojo/public/cpp/bindings/lib/hash_util.h b/chromium/mojo/public/cpp/bindings/lib/hash_util.h
index c37599c4ce2..93280d69daf 100644
--- a/chromium/mojo/public/cpp/bindings/lib/hash_util.h
+++ b/chromium/mojo/public/cpp/bindings/lib/hash_util.h
@@ -10,6 +10,7 @@
#include <type_traits>
#include <vector>
+#include "base/optional.h"
#include "mojo/public/cpp/bindings/lib/template_util.h"
namespace mojo {
@@ -63,6 +64,16 @@ struct HashTraits<std::vector<T>, false> {
};
template <typename T>
+struct HashTraits<base::Optional<std::vector<T>>, false> {
+ static size_t Hash(size_t seed, const base::Optional<std::vector<T>>& value) {
+ if (!value)
+ return HashCombine(seed, 0);
+
+ return Hash(seed, *value);
+ }
+};
+
+template <typename T>
size_t Hash(size_t seed, const T& value) {
return HashTraits<T>::Hash(seed, value);
}
diff --git a/chromium/mojo/public/cpp/bindings/lib/interface_endpoint_client.cc b/chromium/mojo/public/cpp/bindings/lib/interface_endpoint_client.cc
index a6a9c0686bb..c33e5587180 100644
--- a/chromium/mojo/public/cpp/bindings/lib/interface_endpoint_client.cc
+++ b/chromium/mojo/public/cpp/bindings/lib/interface_endpoint_client.cc
@@ -159,15 +159,11 @@ InterfaceEndpointClient::InterfaceEndpointClient(
handle_, this, task_runner_);
if (expect_sync_requests)
controller_->AllowWokenUpBySyncWatchOnSameThread();
-
- base::MessageLoop::current()->AddDestructionObserver(this);
}
InterfaceEndpointClient::~InterfaceEndpointClient() {
DCHECK(thread_checker_.CalledOnValidThread());
- StopObservingIfNecessary();
-
if (handle_.is_valid())
handle_.group_controller()->DetachEndpointClient(handle_);
}
@@ -342,17 +338,4 @@ bool InterfaceEndpointClient::HandleValidatedMessage(Message* message) {
}
}
-void InterfaceEndpointClient::StopObservingIfNecessary() {
- if (!observing_message_loop_destruction_)
- return;
-
- observing_message_loop_destruction_ = false;
- base::MessageLoop::current()->RemoveDestructionObserver(this);
-}
-
-void InterfaceEndpointClient::WillDestroyCurrentMessageLoop() {
- StopObservingIfNecessary();
- NotifyError();
-}
-
} // namespace mojo
diff --git a/chromium/mojo/public/cpp/bindings/lib/interface_ptr_state.h b/chromium/mojo/public/cpp/bindings/lib/interface_ptr_state.h
index 8f73a25d109..f4c63d2f022 100644
--- a/chromium/mojo/public/cpp/bindings/lib/interface_ptr_state.h
+++ b/chromium/mojo/public/cpp/bindings/lib/interface_ptr_state.h
@@ -28,186 +28,14 @@
#include "mojo/public/cpp/bindings/lib/control_message_handler.h"
#include "mojo/public/cpp/bindings/lib/control_message_proxy.h"
#include "mojo/public/cpp/bindings/lib/multiplex_router.h"
-#include "mojo/public/cpp/bindings/lib/router.h"
#include "mojo/public/cpp/bindings/message_header_validator.h"
#include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
namespace mojo {
namespace internal {
-template <typename Interface, bool use_multiplex_router>
-class InterfacePtrState;
-
-// Uses a single-threaded, dedicated router. If |Interface| doesn't have any
-// methods to pass associated interface pointers or requests, there won't be
-// multiple interfaces running on the underlying message pipe. In that case, we
-// can use this specialization to reduce cost.
-template <typename Interface>
-class InterfacePtrState<Interface, false> {
- public:
- InterfacePtrState() : proxy_(nullptr), router_(nullptr), version_(0u) {}
-
- ~InterfacePtrState() {
- // Destruction order matters here. We delete |proxy_| first, even though
- // |router_| may have a reference to it, so that destructors for any request
- // callbacks still pending can interact with the InterfacePtr.
- delete proxy_;
- delete router_;
- }
-
- Interface* instance() {
- ConfigureProxyIfNecessary();
-
- // This will be null if the object is not bound.
- return proxy_;
- }
-
- uint32_t version() const { return version_; }
-
- void QueryVersion(const base::Callback<void(uint32_t)>& callback) {
- ConfigureProxyIfNecessary();
-
- // It is safe to capture |this| because the callback won't be run after this
- // object goes away.
- router_->control_message_proxy()->QueryVersion(base::Bind(
- &InterfacePtrState::OnQueryVersion, base::Unretained(this), callback));
- }
-
- void RequireVersion(uint32_t version) {
- ConfigureProxyIfNecessary();
-
- if (version <= version_)
- return;
-
- version_ = version;
- router_->control_message_proxy()->RequireVersion(version);
- }
-
- void FlushForTesting() {
- ConfigureProxyIfNecessary();
- router_->control_message_proxy()->FlushForTesting();
- }
-
- void SendDisconnectReason(uint32_t custom_reason,
- const std::string& description) {
- ConfigureProxyIfNecessary();
- router_->control_message_proxy()->SendDisconnectReason(custom_reason,
- description);
- }
-
- void Swap(InterfacePtrState* other) {
- using std::swap;
- swap(other->proxy_, proxy_);
- swap(other->router_, router_);
- handle_.swap(other->handle_);
- runner_.swap(other->runner_);
- swap(other->version_, version_);
- }
-
- void Bind(InterfacePtrInfo<Interface> info,
- scoped_refptr<base::SingleThreadTaskRunner> runner) {
- DCHECK(!proxy_);
- DCHECK(!router_);
- DCHECK(!handle_.is_valid());
- DCHECK_EQ(0u, version_);
- DCHECK(info.is_valid());
-
- handle_ = info.PassHandle();
- version_ = info.version();
- runner_ = std::move(runner);
- }
-
- bool HasAssociatedInterfaces() const { return false; }
-
- // After this method is called, the object is in an invalid state and
- // shouldn't be reused.
- InterfacePtrInfo<Interface> PassInterface() {
- return InterfacePtrInfo<Interface>(
- router_ ? router_->PassMessagePipe() : std::move(handle_), version_);
- }
-
- bool is_bound() const { return handle_.is_valid() || router_; }
-
- bool encountered_error() const {
- return router_ ? router_->encountered_error() : false;
- }
-
- void set_connection_error_handler(const base::Closure& error_handler) {
- ConfigureProxyIfNecessary();
-
- DCHECK(router_);
- router_->set_connection_error_handler(error_handler);
- }
-
- void set_connection_error_with_reason_handler(
- const ConnectionErrorWithReasonCallback& error_handler) {
- ConfigureProxyIfNecessary();
-
- DCHECK(router_);
- router_->set_connection_error_with_reason_handler(error_handler);
- }
-
- // Returns true if bound and awaiting a response to a message.
- bool has_pending_callbacks() const {
- return router_ && router_->has_pending_responders();
- }
-
- AssociatedGroup* associated_group() { return nullptr; }
-
- void EnableTestingMode() {
- ConfigureProxyIfNecessary();
- router_->EnableTestingMode();
- }
-
- private:
- using Proxy = typename Interface::Proxy_;
-
- void ConfigureProxyIfNecessary() {
- // The proxy has been configured.
- if (proxy_) {
- DCHECK(router_);
- return;
- }
- // The object hasn't been bound.
- if (!handle_.is_valid())
- return;
-
- FilterChain filters;
- filters.Append<MessageHeaderValidator>(Interface::Name_);
- filters.Append<typename Interface::ResponseValidator_>();
-
- // The version is only queried from the client so the value passed here
- // will not be used.
- router_ = new Router(std::move(handle_), std::move(filters), false,
- std::move(runner_), 0u);
-
- proxy_ = new Proxy(router_);
- }
-
- void OnQueryVersion(const base::Callback<void(uint32_t)>& callback,
- uint32_t version) {
- version_ = version;
- callback.Run(version);
- }
-
- Proxy* proxy_;
- Router* router_;
-
- // |proxy_| and |router_| are not initialized until read/write with the
- // message pipe handle is needed. |handle_| is valid between the Bind() call
- // and the initialization of |proxy_| and |router_|.
- ScopedMessagePipeHandle handle_;
- scoped_refptr<base::SingleThreadTaskRunner> runner_;
-
- uint32_t version_;
-
- DISALLOW_COPY_AND_ASSIGN(InterfacePtrState);
-};
-
-// Uses a multiplexing router. If |Interface| has methods to pass associated
-// interface pointers or requests, this specialization should be used.
template <typename Interface>
-class InterfacePtrState<Interface, true> {
+class InterfacePtrState {
public:
InterfacePtrState() : version_(0u) {}
diff --git a/chromium/mojo/public/cpp/bindings/lib/multiplex_router.cc b/chromium/mojo/public/cpp/bindings/lib/multiplex_router.cc
index 5602b2a0591..14ea6474075 100644
--- a/chromium/mojo/public/cpp/bindings/lib/multiplex_router.cc
+++ b/chromium/mojo/public/cpp/bindings/lib/multiplex_router.cc
@@ -335,8 +335,16 @@ MultiplexRouter::~MultiplexRouter() {
// because it may remove the corresponding value from the map.
++iter;
- DCHECK(endpoint->closed());
- UpdateEndpointStateMayRemove(endpoint, PEER_ENDPOINT_CLOSED);
+ if (!endpoint->closed()) {
+ // This happens when a NotifyPeerEndpointClosed message been received, but
+ // (1) the interface ID hasn't been used to create local endpoint handle;
+ // and (2) a NotifyEndpointClosedBeforeSent hasn't been received.
+ DCHECK(!endpoint->client());
+ DCHECK(endpoint->peer_closed());
+ UpdateEndpointStateMayRemove(endpoint, ENDPOINT_CLOSED);
+ } else {
+ UpdateEndpointStateMayRemove(endpoint, PEER_ENDPOINT_CLOSED);
+ }
}
DCHECK(endpoints_.empty());
diff --git a/chromium/mojo/public/cpp/bindings/lib/multiplex_router.h b/chromium/mojo/public/cpp/bindings/lib/multiplex_router.h
index 8a6e2ed28b0..0d5899870b8 100644
--- a/chromium/mojo/public/cpp/bindings/lib/multiplex_router.h
+++ b/chromium/mojo/public/cpp/bindings/lib/multiplex_router.h
@@ -37,8 +37,6 @@ class SingleThreadTaskRunner;
namespace mojo {
-class AssociatedGroup;
-
namespace internal {
// MultiplexRouter supports routing messages for multiple interfaces over a
diff --git a/chromium/mojo/public/cpp/bindings/lib/native_struct.cc b/chromium/mojo/public/cpp/bindings/lib/native_struct.cc
index 2d60eb0d7e2..3c3c2c37f04 100644
--- a/chromium/mojo/public/cpp/bindings/lib/native_struct.cc
+++ b/chromium/mojo/public/cpp/bindings/lib/native_struct.cc
@@ -15,18 +15,18 @@ NativeStructPtr NativeStruct::New() {
return rv;
}
-NativeStruct::NativeStruct() : data(nullptr) {}
+NativeStruct::NativeStruct() {}
NativeStruct::~NativeStruct() {}
NativeStructPtr NativeStruct::Clone() const {
NativeStructPtr rv(New());
- rv->data = data.Clone();
+ rv->data = data;
return rv;
}
bool NativeStruct::Equals(const NativeStruct& other) const {
- return data.Equals(other.data);
+ return data == other.data;
}
size_t NativeStruct::Hash(size_t seed) const {
diff --git a/chromium/mojo/public/cpp/bindings/lib/native_struct_data.h b/chromium/mojo/public/cpp/bindings/lib/native_struct_data.h
index e4f3aaf028f..1c7cd81c770 100644
--- a/chromium/mojo/public/cpp/bindings/lib/native_struct_data.h
+++ b/chromium/mojo/public/cpp/bindings/lib/native_struct_data.h
@@ -14,7 +14,6 @@
namespace mojo {
namespace internal {
-class Buffer;
class ValidationContext;
class MOJO_CPP_BINDINGS_EXPORT NativeStruct_Data {
diff --git a/chromium/mojo/public/cpp/bindings/lib/router.cc b/chromium/mojo/public/cpp/bindings/lib/router.cc
deleted file mode 100644
index 36f6625041a..00000000000
--- a/chromium/mojo/public/cpp/bindings/lib/router.cc
+++ /dev/null
@@ -1,347 +0,0 @@
-// Copyright 2014 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/lib/router.h"
-
-#include <stdint.h>
-
-#include <utility>
-
-#include "base/bind.h"
-#include "base/location.h"
-#include "base/logging.h"
-#include "base/memory/ptr_util.h"
-#include "base/stl_util.h"
-#include "mojo/public/cpp/bindings/lib/validation_util.h"
-#include "mojo/public/cpp/bindings/sync_call_restrictions.h"
-
-namespace mojo {
-namespace internal {
-
-// ----------------------------------------------------------------------------
-
-namespace {
-
-void DCheckIfInvalid(const base::WeakPtr<Router>& router,
- const std::string& message) {
- bool is_valid = router && !router->encountered_error() && router->is_valid();
- DCHECK(!is_valid) << message;
-}
-
-class ResponderThunk : public MessageReceiverWithStatus {
- public:
- explicit ResponderThunk(const base::WeakPtr<Router>& router,
- scoped_refptr<base::SingleThreadTaskRunner> runner)
- : router_(router),
- accept_was_invoked_(false),
- task_runner_(std::move(runner)) {}
- ~ResponderThunk() override {
- if (!accept_was_invoked_) {
- // The Service handled a message that was expecting a response
- // but did not send a response.
- // We raise an error to signal the calling application that an error
- // condition occurred. Without this the calling application would have no
- // way of knowing it should stop waiting for a response.
- if (task_runner_->RunsTasksOnCurrentThread()) {
- // Please note that even if this code is run from a different task
- // runner on the same thread as |task_runner_|, it is okay to directly
- // call Router::RaiseError(), because it will raise error from the
- // correct task runner asynchronously.
- if (router_)
- router_->RaiseError();
- } else {
- task_runner_->PostTask(FROM_HERE,
- base::Bind(&Router::RaiseError, router_));
- }
- }
- }
-
- // MessageReceiver implementation:
- bool Accept(Message* message) override {
- DCHECK(task_runner_->RunsTasksOnCurrentThread());
- accept_was_invoked_ = true;
- DCHECK(message->has_flag(Message::kFlagIsResponse));
-
- bool result = false;
-
- if (router_)
- result = router_->Accept(message);
-
- return result;
- }
-
- // MessageReceiverWithStatus implementation:
- bool IsValid() override {
- DCHECK(task_runner_->RunsTasksOnCurrentThread());
- return router_ && !router_->encountered_error() && router_->is_valid();
- }
-
- void DCheckInvalid(const std::string& message) override {
- if (task_runner_->RunsTasksOnCurrentThread()) {
- DCheckIfInvalid(router_, message);
- } else {
- task_runner_->PostTask(FROM_HERE,
- base::Bind(&DCheckIfInvalid, router_, message));
- }
- }
-
- private:
- base::WeakPtr<Router> router_;
- bool accept_was_invoked_;
- scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
-};
-
-} // namespace
-
-// ----------------------------------------------------------------------------
-
-Router::SyncResponseInfo::SyncResponseInfo(bool* in_response_received)
- : response_received(in_response_received) {}
-
-Router::SyncResponseInfo::~SyncResponseInfo() {}
-
-// ----------------------------------------------------------------------------
-
-Router::HandleIncomingMessageThunk::HandleIncomingMessageThunk(Router* router)
- : router_(router) {
-}
-
-Router::HandleIncomingMessageThunk::~HandleIncomingMessageThunk() {
-}
-
-bool Router::HandleIncomingMessageThunk::Accept(Message* message) {
- return router_->HandleIncomingMessage(message);
-}
-
-// ----------------------------------------------------------------------------
-
-Router::Router(ScopedMessagePipeHandle message_pipe,
- FilterChain filters,
- bool expects_sync_requests,
- scoped_refptr<base::SingleThreadTaskRunner> runner,
- int interface_version)
- : thunk_(this),
- filters_(std::move(filters)),
- connector_(std::move(message_pipe),
- Connector::SINGLE_THREADED_SEND,
- std::move(runner)),
- incoming_receiver_(nullptr),
- next_request_id_(0),
- testing_mode_(false),
- pending_task_for_messages_(false),
- encountered_error_(false),
- control_message_proxy_(this),
- control_message_handler_(interface_version),
- weak_factory_(this) {
- filters_.SetSink(&thunk_);
- if (expects_sync_requests)
- connector_.AllowWokenUpBySyncWatchOnSameThread();
- connector_.set_incoming_receiver(&filters_);
- connector_.set_connection_error_handler(
- base::Bind(&Router::OnConnectionError, base::Unretained(this)));
-}
-
-Router::~Router() {}
-
-void Router::AddFilter(std::unique_ptr<MessageReceiver> filter) {
- filters_.Append(std::move(filter));
-}
-
-bool Router::Accept(Message* message) {
- DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(!message->has_flag(Message::kFlagExpectsResponse));
- return connector_.Accept(message);
-}
-
-bool Router::AcceptWithResponder(Message* message, MessageReceiver* responder) {
- DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(message->has_flag(Message::kFlagExpectsResponse));
-
- // Reserve 0 in case we want it to convey special meaning in the future.
- uint64_t request_id = next_request_id_++;
- if (request_id == 0)
- request_id = next_request_id_++;
-
- bool is_sync = message->has_flag(Message::kFlagIsSync);
- message->set_request_id(request_id);
- if (!connector_.Accept(message))
- return false;
-
- if (!is_sync) {
- // We assume ownership of |responder|.
- async_responders_[request_id] = base::WrapUnique(responder);
- return true;
- }
-
- SyncCallRestrictions::AssertSyncCallAllowed();
-
- bool response_received = false;
- std::unique_ptr<MessageReceiver> sync_responder(responder);
- sync_responses_.insert(std::make_pair(
- request_id, base::MakeUnique<SyncResponseInfo>(&response_received)));
-
- base::WeakPtr<Router> weak_self = weak_factory_.GetWeakPtr();
- connector_.SyncWatch(&response_received);
- // Make sure that this instance hasn't been destroyed.
- if (weak_self) {
- DCHECK(base::ContainsKey(sync_responses_, request_id));
- auto iter = sync_responses_.find(request_id);
- DCHECK_EQ(&response_received, iter->second->response_received);
- if (response_received)
- ignore_result(sync_responder->Accept(&iter->second->response));
- sync_responses_.erase(iter);
- }
-
- // Return true means that we take ownership of |responder|.
- return true;
-}
-
-void Router::EnableTestingMode() {
- DCHECK(thread_checker_.CalledOnValidThread());
- testing_mode_ = true;
- connector_.set_enforce_errors_from_incoming_receiver(false);
-}
-
-bool Router::HandleIncomingMessage(Message* message) {
- DCHECK(thread_checker_.CalledOnValidThread());
-
- const bool during_sync_call =
- connector_.during_sync_handle_watcher_callback();
- if (!message->has_flag(Message::kFlagIsSync) &&
- (during_sync_call || !pending_messages_.empty())) {
- pending_messages_.emplace(std::move(*message));
-
- if (!pending_task_for_messages_) {
- pending_task_for_messages_ = true;
- connector_.task_runner()->PostTask(
- FROM_HERE, base::Bind(&Router::HandleQueuedMessages,
- weak_factory_.GetWeakPtr()));
- }
-
- return true;
- }
-
- return HandleMessageInternal(message);
-}
-
-void Router::HandleQueuedMessages() {
- DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(pending_task_for_messages_);
-
- base::WeakPtr<Router> weak_self = weak_factory_.GetWeakPtr();
- while (!pending_messages_.empty()) {
- Message message(std::move(pending_messages_.front()));
- pending_messages_.pop();
-
- bool result = HandleMessageInternal(&message);
- if (!weak_self)
- return;
-
- if (!result && !testing_mode_) {
- connector_.RaiseError();
- break;
- }
- }
-
- pending_task_for_messages_ = false;
-
- // We may have already seen a connection error from the connector, but
- // haven't notified the user because we want to process all the queued
- // messages first. We should do it now.
- if (connector_.encountered_error() && !encountered_error_)
- OnConnectionError();
-}
-
-bool Router::HandleMessageInternal(Message* message) {
- DCHECK(!encountered_error_);
-
- if (message->has_flag(Message::kFlagExpectsResponse)) {
- MessageReceiverWithStatus* responder = new ResponderThunk(
- weak_factory_.GetWeakPtr(), connector_.task_runner());
- bool ok = false;
- if (mojo::internal::ControlMessageHandler::IsControlMessage(message)) {
- ok = control_message_handler_.AcceptWithResponder(message, responder);
- } else {
- ok = incoming_receiver_->AcceptWithResponder(message, responder);
- }
- if (!ok)
- delete responder;
- return ok;
-
- } else if (message->has_flag(Message::kFlagIsResponse)) {
- uint64_t request_id = message->request_id();
-
- if (message->has_flag(Message::kFlagIsSync)) {
- auto it = sync_responses_.find(request_id);
- if (it == sync_responses_.end()) {
- DCHECK(testing_mode_);
- return false;
- }
- it->second->response = std::move(*message);
- *it->second->response_received = true;
- return true;
- }
-
- auto it = async_responders_.find(request_id);
- if (it == async_responders_.end()) {
- DCHECK(testing_mode_);
- return false;
- }
- std::unique_ptr<MessageReceiver> responder = std::move(it->second);
- async_responders_.erase(it);
- return responder->Accept(message);
- } else {
- if (mojo::internal::ControlMessageHandler::IsControlMessage(message))
- return control_message_handler_.Accept(message);
-
- return incoming_receiver_->Accept(message);
- }
-}
-
-void Router::OnConnectionError() {
- if (encountered_error_)
- return;
-
- if (!pending_messages_.empty()) {
- // After all the pending messages are processed, we will check whether an
- // error has been encountered and run the user's connection error handler
- // if necessary.
- DCHECK(pending_task_for_messages_);
- return;
- }
-
- if (connector_.during_sync_handle_watcher_callback()) {
- // We don't want the error handler to reenter an ongoing sync call.
- connector_.task_runner()->PostTask(
- FROM_HERE,
- base::Bind(&Router::OnConnectionError, weak_factory_.GetWeakPtr()));
- return;
- }
-
- control_message_proxy_.OnConnectionError();
-
- encountered_error_ = true;
-
- // Response callbacks may hold on to resource, and there's no need to keep
- // them alive any longer. Note that it's allowed that a pending response
- // callback may own this endpoint, so we simply move the responders onto the
- // stack here and let them be destroyed when the stack unwinds.
- AsyncResponderMap responders = std::move(async_responders_);
-
- if (!error_handler_.is_null()) {
- error_handler_.Run();
- } else if (!error_with_reason_handler_.is_null()) {
- // Make a copy on the stack. If we directly pass a reference to a member of
- // |control_message_handler_|, that reference will be invalidated as soon as
- // the user destroys the interface endpoint.
- std::string description = control_message_handler_.disconnect_description();
- error_with_reason_handler_.Run(
- control_message_handler_.disconnect_custom_reason(), description);
- }
-}
-
-// ----------------------------------------------------------------------------
-
-} // namespace internal
-} // namespace mojo
diff --git a/chromium/mojo/public/cpp/bindings/lib/router.h b/chromium/mojo/public/cpp/bindings/lib/router.h
deleted file mode 100644
index d07bfeedf02..00000000000
--- a/chromium/mojo/public/cpp/bindings/lib/router.h
+++ /dev/null
@@ -1,206 +0,0 @@
-// Copyright 2014 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.
-
-#ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_
-#define MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_
-
-#include <stdint.h>
-
-#include <map>
-#include <memory>
-#include <queue>
-
-#include "base/callback.h"
-#include "base/compiler_specific.h"
-#include "base/macros.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/weak_ptr.h"
-#include "base/single_thread_task_runner.h"
-#include "base/threading/thread_checker.h"
-#include "mojo/public/cpp/bindings/bindings_export.h"
-#include "mojo/public/cpp/bindings/connection_error_callback.h"
-#include "mojo/public/cpp/bindings/connector.h"
-#include "mojo/public/cpp/bindings/filter_chain.h"
-#include "mojo/public/cpp/bindings/lib/control_message_handler.h"
-#include "mojo/public/cpp/bindings/lib/control_message_proxy.h"
-#include "mojo/public/cpp/bindings/message.h"
-
-namespace mojo {
-namespace internal {
-
-// TODO(yzshen): Consider removing this class and use MultiplexRouter in all
-// cases. crbug.com/594244
-class MOJO_CPP_BINDINGS_EXPORT Router
- : NON_EXPORTED_BASE(public MessageReceiverWithResponder) {
- public:
- Router(ScopedMessagePipeHandle message_pipe,
- FilterChain filters,
- bool expects_sync_requests,
- scoped_refptr<base::SingleThreadTaskRunner> runner,
- int interface_version);
- ~Router() override;
-
- // Sets the receiver to handle messages read from the message pipe that do
- // not have the Message::kFlagIsResponse flag set.
- void set_incoming_receiver(MessageReceiverWithResponderStatus* receiver) {
- incoming_receiver_ = receiver;
- }
-
- // Sets the error handler to receive notifications when an error is
- // encountered while reading from the pipe or waiting to read from the pipe.
- void set_connection_error_handler(const base::Closure& error_handler) {
- error_handler_ = error_handler;
- error_with_reason_handler_.Reset();
- }
- void set_connection_error_with_reason_handler(
- const ConnectionErrorWithReasonCallback& error_handler) {
- error_with_reason_handler_ = error_handler;
- error_handler_.Reset();
- }
-
- // Returns true if an error was encountered while reading from the pipe or
- // waiting to read from the pipe.
- bool encountered_error() const {
- DCHECK(thread_checker_.CalledOnValidThread());
- return encountered_error_;
- }
-
- // Is the router bound to a MessagePipe handle?
- bool is_valid() const {
- DCHECK(thread_checker_.CalledOnValidThread());
- return connector_.is_valid();
- }
-
- void AddFilter(std::unique_ptr<MessageReceiver> filter);
-
- // Please note that this method shouldn't be called unless it results from an
- // explicit request of the user of bindings (e.g., the user sets an
- // InterfacePtr to null or closes a Binding).
- void CloseMessagePipe() {
- DCHECK(thread_checker_.CalledOnValidThread());
- connector_.CloseMessagePipe();
- }
-
- ScopedMessagePipeHandle PassMessagePipe() {
- DCHECK(thread_checker_.CalledOnValidThread());
- return connector_.PassMessagePipe();
- }
-
- void RaiseError() {
- DCHECK(thread_checker_.CalledOnValidThread());
- connector_.RaiseError();
- }
-
- // MessageReceiver implementation:
- bool Accept(Message* message) override;
- bool AcceptWithResponder(Message* message,
- MessageReceiver* responder) override;
-
- // Blocks the current thread until the first incoming method call, i.e.,
- // either a call to a client method or a callback method, or |deadline|.
- bool WaitForIncomingMessage(MojoDeadline deadline) {
- DCHECK(thread_checker_.CalledOnValidThread());
- return connector_.WaitForIncomingMessage(deadline);
- }
-
- // See Binding for details of pause/resume.
- // Note: This doesn't strictly pause incoming calls. If there are
- // queued messages, they may be dispatched during pause.
- void PauseIncomingMethodCallProcessing() {
- DCHECK(thread_checker_.CalledOnValidThread());
- connector_.PauseIncomingMethodCallProcessing();
- }
- void ResumeIncomingMethodCallProcessing() {
- DCHECK(thread_checker_.CalledOnValidThread());
- connector_.ResumeIncomingMethodCallProcessing();
- }
-
- // Sets this object to testing mode.
- // In testing mode:
- // - the object is more tolerant of unrecognized response messages;
- // - the connector continues working after seeing errors from its incoming
- // receiver.
- void EnableTestingMode();
-
- MessagePipeHandle handle() const { return connector_.handle(); }
-
- // Returns true if this Router has any pending callbacks.
- bool has_pending_responders() const {
- DCHECK(thread_checker_.CalledOnValidThread());
- return !async_responders_.empty() || !sync_responses_.empty();
- }
-
- ControlMessageProxy* control_message_proxy() {
- return &control_message_proxy_;
- }
-
- bool SimulateReceivingMessageForTesting(Message* message) {
- return filters_.Accept(message);
- }
-
- private:
- // Maps from the id of a response to the MessageReceiver that handles the
- // response.
- using AsyncResponderMap =
- std::map<uint64_t, std::unique_ptr<MessageReceiver>>;
-
- struct SyncResponseInfo {
- public:
- explicit SyncResponseInfo(bool* in_response_received);
- ~SyncResponseInfo();
-
- Message response;
-
- // Points to a stack-allocated variable.
- bool* response_received;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(SyncResponseInfo);
- };
-
- using SyncResponseMap = std::map<uint64_t, std::unique_ptr<SyncResponseInfo>>;
-
- class HandleIncomingMessageThunk : public MessageReceiver {
- public:
- HandleIncomingMessageThunk(Router* router);
- ~HandleIncomingMessageThunk() override;
-
- // MessageReceiver implementation:
- bool Accept(Message* message) override;
-
- private:
- Router* router_;
- };
-
- bool HandleIncomingMessage(Message* message);
- void HandleQueuedMessages();
- bool HandleMessageInternal(Message* message);
-
- void OnConnectionError();
-
- HandleIncomingMessageThunk thunk_;
- FilterChain filters_;
- Connector connector_;
- MessageReceiverWithResponderStatus* incoming_receiver_;
- AsyncResponderMap async_responders_;
- SyncResponseMap sync_responses_;
- uint64_t next_request_id_;
- bool testing_mode_;
- std::queue<Message> pending_messages_;
- // Whether a task has been posted to trigger processing of
- // |pending_messages_|.
- bool pending_task_for_messages_;
- bool encountered_error_;
- base::Closure error_handler_;
- ConnectionErrorWithReasonCallback error_with_reason_handler_;
- ControlMessageProxy control_message_proxy_;
- ControlMessageHandler control_message_handler_;
- base::ThreadChecker thread_checker_;
- base::WeakPtrFactory<Router> weak_factory_;
-};
-
-} // namespace internal
-} // namespace mojo
-
-#endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_
diff --git a/chromium/mojo/public/cpp/bindings/lib/serialization.h b/chromium/mojo/public/cpp/bindings/lib/serialization.h
index a570e2205bf..6f0b6afa9ee 100644
--- a/chromium/mojo/public/cpp/bindings/lib/serialization.h
+++ b/chromium/mojo/public/cpp/bindings/lib/serialization.h
@@ -8,7 +8,6 @@
#include <string.h>
#include "mojo/public/cpp/bindings/array_traits_carray.h"
-#include "mojo/public/cpp/bindings/array_traits_standard.h"
#include "mojo/public/cpp/bindings/array_traits_stl.h"
#include "mojo/public/cpp/bindings/lib/array_serialization.h"
#include "mojo/public/cpp/bindings/lib/buffer.h"
@@ -18,9 +17,7 @@
#include "mojo/public/cpp/bindings/lib/native_struct_serialization.h"
#include "mojo/public/cpp/bindings/lib/string_serialization.h"
#include "mojo/public/cpp/bindings/lib/template_util.h"
-#include "mojo/public/cpp/bindings/map_traits_standard.h"
#include "mojo/public/cpp/bindings/map_traits_stl.h"
-#include "mojo/public/cpp/bindings/string_traits_standard.h"
#include "mojo/public/cpp/bindings/string_traits_stl.h"
#include "mojo/public/cpp/bindings/string_traits_string16.h"
#include "mojo/public/cpp/bindings/string_traits_string_piece.h"
@@ -44,7 +41,7 @@ DataArrayType StructSerializeImpl(UserType* input) {
void* result_buffer = &result.front();
// The serialization logic requires that the buffer is 8-byte aligned. If the
// result buffer is not properly aligned, we have to do an extra copy. In
- // practice, this should never happen for mojo::Array (backed by std::vector).
+ // practice, this should never happen for std::vector.
bool need_copy = !IsAligned(result_buffer);
if (need_copy) {
@@ -72,11 +69,9 @@ bool StructDeserializeImpl(const DataArrayType& input, UserType* output) {
"Unexpected type.");
using DataType = typename MojomTypeTraits<MojomType>::Data;
- if (input.is_null())
- return false;
-
+ // TODO(sammc): Use DataArrayType::empty() once WTF::Vector::empty() exists.
void* input_buffer =
- input.empty()
+ input.size() == 0
? nullptr
: const_cast<void*>(reinterpret_cast<const void*>(&input.front()));
diff --git a/chromium/mojo/public/cpp/bindings/lib/sync_handle_registry.cc b/chromium/mojo/public/cpp/bindings/lib/sync_handle_registry.cc
index cc831371757..f556c4c2159 100644
--- a/chromium/mojo/public/cpp/bindings/lib/sync_handle_registry.cc
+++ b/chromium/mojo/public/cpp/bindings/lib/sync_handle_registry.cc
@@ -108,9 +108,17 @@ SyncHandleRegistry::SyncHandleRegistry() {
SyncHandleRegistry::~SyncHandleRegistry() {
DCHECK(thread_checker_.CalledOnValidThread());
+ // This object may be destructed after the thread local storage slot used by
+ // |g_current_sync_handle_watcher| is reset during thread shutdown.
+ // For example, another slot in the thread local storage holds a referrence to
+ // this object, and that slot is cleaned up after
+ // |g_current_sync_handle_watcher|.
+ if (!g_current_sync_handle_watcher.Pointer()->Get())
+ return;
+
// If this breaks, it is likely that the global variable is bulit into and
// accessed from multiple modules.
- CHECK_EQ(this, g_current_sync_handle_watcher.Pointer()->Get());
+ DCHECK_EQ(this, g_current_sync_handle_watcher.Pointer()->Get());
g_current_sync_handle_watcher.Pointer()->Set(nullptr);
}
diff --git a/chromium/mojo/public/cpp/bindings/lib/wtf_serialization.h b/chromium/mojo/public/cpp/bindings/lib/wtf_serialization.h
index 132e19cd6b6..0f112b9143e 100644
--- a/chromium/mojo/public/cpp/bindings/lib/wtf_serialization.h
+++ b/chromium/mojo/public/cpp/bindings/lib/wtf_serialization.h
@@ -5,9 +5,7 @@
#ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_WTF_SERIALIZATION_H_
#define MOJO_PUBLIC_CPP_BINDINGS_LIB_WTF_SERIALIZATION_H_
-#include "mojo/public/cpp/bindings/array_traits_wtf.h"
#include "mojo/public/cpp/bindings/array_traits_wtf_vector.h"
-#include "mojo/public/cpp/bindings/map_traits_wtf.h"
#include "mojo/public/cpp/bindings/map_traits_wtf_hash_map.h"
#include "mojo/public/cpp/bindings/string_traits_wtf.h"
diff --git a/chromium/mojo/public/cpp/bindings/map.h b/chromium/mojo/public/cpp/bindings/map.h
index d4c79525ee8..c1ba0756a3f 100644
--- a/chromium/mojo/public/cpp/bindings/map.h
+++ b/chromium/mojo/public/cpp/bindings/map.h
@@ -5,299 +5,37 @@
#ifndef MOJO_PUBLIC_CPP_BINDINGS_MAP_H_
#define MOJO_PUBLIC_CPP_BINDINGS_MAP_H_
-#include <stddef.h>
#include <map>
#include <unordered_map>
#include <utility>
-#include "base/logging.h"
-#include "base/macros.h"
-#include "mojo/public/cpp/bindings/array.h"
-#include "mojo/public/cpp/bindings/lib/map_data_internal.h"
-#include "mojo/public/cpp/bindings/lib/template_util.h"
-#include "mojo/public/cpp/bindings/type_converter.h"
-
namespace mojo {
-// A move-only map that can handle move-only values. Map has the following
-// characteristics:
-// - The map itself can be null, and this is distinct from empty.
-// - Keys must not be move-only.
-// - The Key-type's "<" operator is used to sort the entries, and also is
-// used to determine equality of the key values.
-// - There can only be one entry per unique key.
-// - Values of move-only types will be moved into the Map when they are added
-// using the insert() method.
-template <typename K, typename V>
-class Map {
- public:
- using Key = K;
- using Value = V;
-
- // Map keys cannot be move only classes.
- static_assert(!internal::IsMoveOnlyType<Key>::value,
- "Map keys cannot be move only types.");
-
- using Iterator = typename std::map<Key, Value>::iterator;
- using ConstIterator = typename std::map<Key, Value>::const_iterator;
-
- // Constructs an empty map.
- Map() : is_null_(false) {}
- // Constructs a null map.
- Map(std::nullptr_t null_pointer) : is_null_(true) {}
-
- // Constructs a non-null Map containing the specified |keys| mapped to the
- // corresponding |values|.
- Map(mojo::Array<Key> keys, mojo::Array<Value> values) : is_null_(false) {
- DCHECK(keys.size() == values.size());
- for (size_t i = 0; i < keys.size(); ++i)
- map_.insert(std::make_pair(keys[i], std::move(values[i])));
- }
-
- ~Map() {}
-
- Map(std::map<Key, Value>&& other) : map_(std::move(other)), is_null_(false) {}
- Map(Map&& other) : is_null_(true) { Take(&other); }
-
- Map& operator=(std::map<Key, Value>&& other) {
- is_null_ = false;
- map_ = std::move(other);
- return *this;
- }
- Map& operator=(Map&& other) {
- Take(&other);
- return *this;
- }
-
- Map& operator=(std::nullptr_t null_pointer) {
- is_null_ = true;
- map_.clear();
- return *this;
- }
-
- // Copies the contents of some other type of map into a new Map using a
- // TypeConverter. A TypeConverter for std::map to Map is defined below.
- template <typename U>
- static Map From(const U& other) {
- return TypeConverter<Map, U>::Convert(other);
- }
-
- // Copies the contents of the Map into some other type of map. A TypeConverter
- // for Map to std::map is defined below.
- template <typename U>
- U To() const {
- return TypeConverter<U, Map>::Convert(*this);
- }
-
- // Indicates whether the map is null (which is distinct from empty).
- bool is_null() const { return is_null_; }
-
- // Indicates whether the map is empty (which is distinct from null).
- bool empty() const { return map_.empty() && !is_null_; }
-
- // Indicates the number of keys in the map, which will be zero if the map is
- // null.
- size_t size() const { return map_.size(); }
-
- // Inserts a key-value pair into the map. Like std::map, this does not insert
- // |value| if |key| is already a member of the map.
- void insert(const Key& key, const Value& value) {
- is_null_ = false;
- map_.insert(std::make_pair(key, value));
- }
- void insert(const Key& key, Value&& value) {
- is_null_ = false;
- map_.insert(std::make_pair(key, std::move(value)));
- }
-
- // Returns a reference to the value associated with the specified key,
- // crashing the process if the key is not present in the map.
- Value& at(const Key& key) { return map_.at(key); }
- const Value& at(const Key& key) const { return map_.at(key); }
-
- // Returns a reference to the value associated with the specified key,
- // creating a new entry if the key is not already present in the map. A
- // newly-created value will be value-initialized (meaning that it will be
- // initialized by the default constructor of the value type, if any, or else
- // will be zero-initialized).
- Value& operator[](const Key& key) {
- is_null_ = false;
- return map_[key];
- }
-
- // Sets the map to empty (even if previously it was null).
- void SetToEmpty() {
- is_null_ = false;
- map_.clear();
- }
-
- // Returns a const reference to the std::map managed by this class. If this
- // object is null, the return value will be an empty map.
- const std::map<Key, Value>& storage() const { return map_; }
-
- // Passes the underlying storage and resets this map to null.
- std::map<Key, Value> PassStorage() {
- is_null_ = true;
- return std::move(map_);
- }
-
- operator const std::map<Key, Value>&() const { return map_; }
-
- // Swaps the contents of this Map with another Map of the same type (including
- // nullness).
- void Swap(Map<Key, Value>* other) {
- std::swap(is_null_, other->is_null_);
- map_.swap(other->map_);
- }
-
- // Swaps the contents of this Map with an std::map containing keys and values
- // of the same type. Since std::map cannot represent the null state, the
- // std::map will be empty if Map is null. The Map will always be left in a
- // non-null state.
- void Swap(std::map<Key, Value>* other) {
- is_null_ = false;
- map_.swap(*other);
- }
-
- // Removes all contents from the Map and places them into parallel key/value
- // arrays. Each key will be copied from the source to the destination, and
- // values will be copied unless their type is designated move-only, in which
- // case they will be moved. Either way, the Map will be left in a null state.
- void DecomposeMapTo(mojo::Array<Key>* keys, mojo::Array<Value>* values) {
- std::vector<Key> key_vector;
- key_vector.reserve(map_.size());
- std::vector<Value> value_vector;
- value_vector.reserve(map_.size());
-
- for (auto& entry : map_) {
- key_vector.push_back(entry.first);
- value_vector.push_back(std::move(entry.second));
- }
-
- map_.clear();
- is_null_ = true;
-
- keys->Swap(&key_vector);
- values->Swap(&value_vector);
- }
-
- // Returns a new Map that contains a copy of the contents of this map. If the
- // key/value type defines a Clone() method, it will be used; otherwise copy
- // constructor/assignment will be used.
- //
- // Please note that calling this method will fail compilation if the key/value
- // type cannot be cloned (which usually means that it is a Mojo handle type or
- // a type containing Mojo handles).
- Map Clone() const {
- Map result;
- result.is_null_ = is_null_;
- for (auto it = map_.begin(); it != map_.end(); ++it) {
- result.map_.insert(std::make_pair(internal::Clone(it->first),
- internal::Clone(it->second)));
- }
- return result;
- }
-
- // Indicates whether the contents of this map are equal to those of another
- // Map (including nullness). If the key/value type defines an Equals() method,
- // it will be used; otherwise == operator will be used.
- bool Equals(const Map& other) const {
- if (is_null() != other.is_null())
- return false;
- if (size() != other.size())
- return false;
- auto i = begin();
- auto j = other.begin();
- while (i != end()) {
- if (!internal::Equals(i->first, j->first))
- return false;
- if (!internal::Equals(i->second, j->second))
- return false;
- ++i;
- ++j;
- }
- return true;
- }
-
- // Provide read-only iteration over map members in a way similar to STL
- // collections.
- ConstIterator begin() const { return map_.begin(); }
- Iterator begin() { return map_.begin(); }
-
- ConstIterator end() const { return map_.end(); }
- Iterator end() { return map_.end(); }
-
- // Returns the iterator pointing to the entry for |key|, if present, or else
- // returns end().
- ConstIterator find(const Key& key) const { return map_.find(key); }
- Iterator find(const Key& key) { return map_.find(key); }
-
- private:
- typedef std::map<Key, Value> Map::*Testable;
-
- public:
- // The Map may be used in boolean expressions to determine if it is non-null,
- // but is not implicitly convertible to an actual bool value (which would be
- // dangerous).
- operator Testable() const { return is_null_ ? 0 : &Map::map_; }
-
- private:
- // Forbid the == and != operators explicitly, otherwise Map will be converted
- // to Testable to do == or != comparison.
- template <typename T, typename U>
- bool operator==(const Map<T, U>& other) const = delete;
- template <typename T, typename U>
- bool operator!=(const Map<T, U>& other) const = delete;
-
- void Take(Map* other) {
- operator=(nullptr);
- Swap(other);
- }
-
- std::map<Key, Value> map_;
- bool is_null_;
-
- DISALLOW_COPY_AND_ASSIGN(Map);
-};
-
-// Copies the contents of an std::map to a new Map, optionally changing the
-// types of the keys and values along the way using TypeConverter.
-template <typename MojoKey,
- typename MojoValue,
- typename STLKey,
- typename STLValue>
-struct TypeConverter<Map<MojoKey, MojoValue>, std::map<STLKey, STLValue>> {
- static Map<MojoKey, MojoValue> Convert(
- const std::map<STLKey, STLValue>& input) {
- Map<MojoKey, MojoValue> result;
- for (auto& pair : input) {
- result.insert(TypeConverter<MojoKey, STLKey>::Convert(pair.first),
- TypeConverter<MojoValue, STLValue>::Convert(pair.second));
- }
- return result;
- }
-};
-
-// Copies the contents of a Map to an std::map, optionally changing the types of
-// the keys and values along the way using TypeConverter.
-template <typename MojoKey,
- typename MojoValue,
- typename STLKey,
- typename STLValue>
-struct TypeConverter<std::map<STLKey, STLValue>, Map<MojoKey, MojoValue>> {
- static std::map<STLKey, STLValue> Convert(
- const Map<MojoKey, MojoValue>& input) {
- std::map<STLKey, STLValue> result;
- if (!input.is_null()) {
- for (auto it = input.begin(); it != input.end(); ++it) {
- result.insert(std::make_pair(
- TypeConverter<STLKey, MojoKey>::Convert(it->first),
- TypeConverter<STLValue, MojoValue>::Convert(it->second)));
- }
- }
- return result;
- }
-};
+// TODO(yzshen): These conversion functions should be removed and callsites
+// should be revisited and changed to use the same map type.
+template <typename Key, typename Value>
+std::unordered_map<Key, Value> MapToUnorderedMap(
+ const std::map<Key, Value>& input) {
+ return std::unordered_map<Key, Value>(input.begin(), input.end());
+}
+
+template <typename Key, typename Value>
+std::unordered_map<Key, Value> MapToUnorderedMap(std::map<Key, Value>&& input) {
+ return std::unordered_map<Key, Value>(std::make_move_iterator(input.begin()),
+ std::make_move_iterator(input.end()));
+}
+
+template <typename Key, typename Value>
+std::map<Key, Value> UnorderedMapToMap(
+ const std::unordered_map<Key, Value>& input) {
+ return std::map<Key, Value>(input.begin(), input.end());
+}
+
+template <typename Key, typename Value>
+std::map<Key, Value> UnorderedMapToMap(std::unordered_map<Key, Value>&& input) {
+ return std::map<Key, Value>(std::make_move_iterator(input.begin()),
+ std::make_move_iterator(input.end()));
+}
} // namespace mojo
diff --git a/chromium/mojo/public/cpp/bindings/map_traits_standard.h b/chromium/mojo/public/cpp/bindings/map_traits_standard.h
deleted file mode 100644
index 0c768903ec9..00000000000
--- a/chromium/mojo/public/cpp/bindings/map_traits_standard.h
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2016 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.
-
-#ifndef MOJO_PUBLIC_CPP_BINDINGS_MAP_TRAITS_STANDARD_H_
-#define MOJO_PUBLIC_CPP_BINDINGS_MAP_TRAITS_STANDARD_H_
-
-#include "mojo/public/cpp/bindings/map.h"
-#include "mojo/public/cpp/bindings/map_traits.h"
-
-namespace mojo {
-
-template <typename K, typename V>
-struct MapTraits<Map<K, V>> {
- using Key = K;
- using Value = V;
- using Iterator = typename Map<K, V>::Iterator;
- using ConstIterator = typename Map<K, V>::ConstIterator;
-
- static bool IsNull(const Map<K, V>& input) { return input.is_null(); }
- static void SetToNull(Map<K, V>* output) { *output = nullptr; }
-
- static size_t GetSize(const Map<K, V>& input) { return input.size(); }
-
- static ConstIterator GetBegin(const Map<K, V>& input) {
- return input.begin();
- }
- static Iterator GetBegin(Map<K, V>& input) { return input.begin(); }
-
- static void AdvanceIterator(ConstIterator& iterator) { iterator++; }
- static void AdvanceIterator(Iterator& iterator) { iterator++; }
-
- static const K& GetKey(Iterator& iterator) { return iterator->first; }
- static const K& GetKey(ConstIterator& iterator) { return iterator->first; }
-
- static V& GetValue(Iterator& iterator) { return iterator->second; }
- static const V& GetValue(ConstIterator& iterator) { return iterator->second; }
-
- static bool Insert(Map<K, V>& input, const K& key, V&& value) {
- input.insert(key, std::forward<V>(value));
- return true;
- }
- static bool Insert(Map<K, V>& input, const K& key, const V& value) {
- input.insert(key, value);
- return true;
- }
-
- static void SetToEmpty(Map<K, V>* output) { output->SetToEmpty(); }
-};
-
-} // namespace mojo
-
-#endif // MOJO_PUBLIC_CPP_BINDINGS_MAP_TRAITS_STANDARD_H_
diff --git a/chromium/mojo/public/cpp/bindings/map_traits_wtf.h b/chromium/mojo/public/cpp/bindings/map_traits_wtf.h
deleted file mode 100644
index 805e4c987e3..00000000000
--- a/chromium/mojo/public/cpp/bindings/map_traits_wtf.h
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2016 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.
-
-#ifndef MOJO_PUBLIC_CPP_BINDINGS_MAP_TRAITS_WTF_H_
-#define MOJO_PUBLIC_CPP_BINDINGS_MAP_TRAITS_WTF_H_
-
-#include "base/logging.h"
-#include "mojo/public/cpp/bindings/map_traits.h"
-#include "mojo/public/cpp/bindings/wtf_map.h"
-
-namespace mojo {
-
-template <typename K, typename V>
-struct MapTraits<WTFMap<K, V>> {
- using Key = K;
- using Value = V;
- using Iterator = typename WTFMap<K, V>::Iterator;
- using ConstIterator = typename WTFMap<K, V>::ConstIterator;
-
- static bool IsNull(const WTFMap<K, V>& input) { return input.is_null(); }
- static void SetToNull(WTFMap<K, V>* output) { *output = nullptr; }
-
- static size_t GetSize(const WTFMap<K, V>& input) { return input.size(); }
-
- static ConstIterator GetBegin(const WTFMap<K, V>& input) {
- return input.begin();
- }
- static Iterator GetBegin(WTFMap<K, V>& input) { return input.begin(); }
-
- static void AdvanceIterator(ConstIterator& iterator) { ++iterator; }
- static void AdvanceIterator(Iterator& iterator) { ++iterator; }
-
- static const K& GetKey(Iterator& iterator) { return iterator->key; }
- static const K& GetKey(ConstIterator& iterator) { return iterator->key; }
-
- static V& GetValue(Iterator& iterator) { return iterator->value; }
- static const V& GetValue(ConstIterator& iterator) { return iterator->value; }
-
- static bool Insert(WTFMap<K, V>& input, const K& key, V&& value) {
- if (!WTFMap<K, V>::IsValidKey(key)) {
- LOG(ERROR) << "The key value is disallowed by WTF::HashMap: " << key;
- return false;
- }
- input.insert(key, std::forward<V>(value));
- return true;
- }
- static bool Insert(WTFMap<K, V>& input, const K& key, const V& value) {
- if (!WTFMap<K, V>::IsValidKey(key)) {
- LOG(ERROR) << "The key value is disallowed by WTF::HashMap: " << key;
- return false;
- }
- input.insert(key, value);
- return true;
- }
-
- static void SetToEmpty(WTFMap<K, V>* output) { output->SetToEmpty(); }
-};
-
-} // namespace mojo
-
-#endif // MOJO_PUBLIC_CPP_BINDINGS_MAP_TRAITS_WTF_H_
diff --git a/chromium/mojo/public/cpp/bindings/native_struct.h b/chromium/mojo/public/cpp/bindings/native_struct.h
index c9e263d277c..ac27250bcc4 100644
--- a/chromium/mojo/public/cpp/bindings/native_struct.h
+++ b/chromium/mojo/public/cpp/bindings/native_struct.h
@@ -5,7 +5,9 @@
#ifndef MOJO_PUBLIC_CPP_BINDINGS_NATIVE_STRUCT_H_
#define MOJO_PUBLIC_CPP_BINDINGS_NATIVE_STRUCT_H_
-#include "mojo/public/cpp/bindings/array.h"
+#include <vector>
+
+#include "base/optional.h"
#include "mojo/public/cpp/bindings/bindings_export.h"
#include "mojo/public/cpp/bindings/lib/native_struct_data.h"
#include "mojo/public/cpp/bindings/struct_ptr.h"
@@ -41,7 +43,7 @@ class MOJO_CPP_BINDINGS_EXPORT NativeStruct {
bool Equals(const NativeStruct& other) const;
size_t Hash(size_t seed) const;
- Array<uint8_t> data;
+ base::Optional<std::vector<uint8_t>> data;
};
} // namespace mojo
diff --git a/chromium/mojo/public/cpp/bindings/stl_converters.h b/chromium/mojo/public/cpp/bindings/stl_converters.h
deleted file mode 100644
index 92b2924e288..00000000000
--- a/chromium/mojo/public/cpp/bindings/stl_converters.h
+++ /dev/null
@@ -1,245 +0,0 @@
-// Copyright 2016 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.
-
-#ifndef MOJO_PUBLIC_CPP_BINDINGS_STL_CONVERTERS_H_
-#define MOJO_PUBLIC_CPP_BINDINGS_STL_CONVERTERS_H_
-
-#include <map>
-#include <string>
-#include <type_traits>
-#include <vector>
-
-#include "mojo/public/cpp/bindings/array.h"
-#include "mojo/public/cpp/bindings/map.h"
-#include "mojo/public/cpp/bindings/string.h"
-
-// Two functions are defined to facilitate conversion between
-// mojo::Array/Map/String and std::vector/map/string: mojo::UnwrapToSTLType()
-// recursively convert mojo types to STL types; mojo::WrapSTLType() does the
-// opposite. For example:
-// mojo::Array<mojo::Map<mojo::String, mojo::Array<int32_t>>> mojo_obj;
-//
-// std::vector<std::map<std::string, std::vector<int32_t>>> stl_obj =
-// mojo::UnwrapToSTLType(std::move(mojo_obj));
-//
-// mojo_obj = mojo::WrapSTLType(std::move(stl_obj));
-//
-// Notes:
-// - The conversion moves as much contents as possible. The two functions both
-// take an rvalue ref as input in order to avoid accidental copies.
-// - Because std::vector/map/string cannot express null, UnwrapToSTLType()
-// converts null mojo::Array/Map/String to empty.
-// - The recursive conversion stops at any types that are not the types listed
-// above. For example, unwrapping mojo::Array<StructContainingMojoMap> will
-// result in std::vector<StructContainingMojoMap>. It won't convert
-// mojo::Map inside the struct.
-
-namespace mojo {
-namespace internal {
-
-template <typename T>
-struct UnwrapTraits;
-
-template <typename T>
-struct UnwrapShouldGoDeeper {
- public:
- static const bool value =
- !std::is_same<T, typename UnwrapTraits<T>::Type>::value;
-};
-
-template <typename T>
-struct UnwrapTraits {
- public:
- using Type = T;
- static Type Unwrap(T input) { return input; }
-};
-
-template <typename T>
-struct UnwrapTraits<Array<T>> {
- public:
- using Type = std::vector<typename UnwrapTraits<T>::Type>;
-
- static Type Unwrap(Array<T> input) {
- return Helper<T>::Run(std::move(input));
- }
-
- private:
- template <typename U, bool should_go_deeper = UnwrapShouldGoDeeper<U>::value>
- struct Helper {};
-
- template <typename U>
- struct Helper<U, true> {
- public:
- static Type Run(Array<T> input) {
- Type output;
- output.reserve(input.size());
- for (size_t i = 0; i < input.size(); ++i)
- output.push_back(UnwrapTraits<T>::Unwrap(std::move(input[i])));
- return output;
- }
- };
-
- template <typename U>
- struct Helper<U, false> {
- public:
- static Type Run(Array<T> input) { return input.PassStorage(); }
- };
-};
-
-template <typename K, typename V>
-struct UnwrapTraits<Map<K, V>> {
- public:
- using Type =
- std::map<typename UnwrapTraits<K>::Type, typename UnwrapTraits<V>::Type>;
-
- static Type Unwrap(Map<K, V> input) {
- return Helper<K, V>::Run(std::move(input));
- }
-
- private:
- template <typename X,
- typename Y,
- bool should_go_deeper = UnwrapShouldGoDeeper<X>::value ||
- UnwrapShouldGoDeeper<Y>::value>
- struct Helper {};
-
- template <typename X, typename Y>
- struct Helper<X, Y, true> {
- public:
- static Type Run(Map<K, V> input) {
- std::map<K, V> input_storage = input.PassStorage();
- Type output;
- for (auto& pair : input_storage) {
- output.insert(
- std::make_pair(UnwrapTraits<K>::Unwrap(pair.first),
- UnwrapTraits<V>::Unwrap(std::move(pair.second))));
- }
- return output;
- }
- };
-
- template <typename X, typename Y>
- struct Helper<X, Y, false> {
- public:
- static Type Run(Map<K, V> input) { return input.PassStorage(); }
- };
-};
-
-template <>
-struct UnwrapTraits<String> {
- public:
- using Type = std::string;
-
- static std::string Unwrap(const String& input) { return input; }
-};
-
-template <typename T>
-struct WrapTraits;
-
-template <typename T>
-struct WrapShouldGoDeeper {
- public:
- static const bool value =
- !std::is_same<T, typename WrapTraits<T>::Type>::value;
-};
-
-template <typename T>
-struct WrapTraits {
- public:
- using Type = T;
-
- static T Wrap(T input) { return input; }
-};
-
-template <typename T>
-struct WrapTraits<std::vector<T>> {
- public:
- using Type = Array<typename WrapTraits<T>::Type>;
-
- static Type Wrap(std::vector<T> input) {
- return Helper<T>::Run(std::move(input));
- }
-
- private:
- template <typename U, bool should_go_deeper = WrapShouldGoDeeper<U>::value>
- struct Helper {};
-
- template <typename U>
- struct Helper<U, true> {
- public:
- static Type Run(std::vector<T> input) {
- std::vector<typename WrapTraits<T>::Type> output_storage;
- output_storage.reserve(input.size());
- for (auto& element : input)
- output_storage.push_back(WrapTraits<T>::Wrap(std::move(element)));
- return Type(std::move(output_storage));
- }
- };
-
- template <typename U>
- struct Helper<U, false> {
- public:
- static Type Run(std::vector<T> input) { return Type(std::move(input)); }
- };
-};
-
-template <typename K, typename V>
-struct WrapTraits<std::map<K, V>> {
- public:
- using Type = Map<typename WrapTraits<K>::Type, typename WrapTraits<V>::Type>;
-
- static Type Wrap(std::map<K, V> input) {
- return Helper<K, V>::Run(std::move(input));
- }
-
- private:
- template <typename X,
- typename Y,
- bool should_go_deeper =
- WrapShouldGoDeeper<X>::value || WrapShouldGoDeeper<Y>::value>
- struct Helper {};
-
- template <typename X, typename Y>
- struct Helper<X, Y, true> {
- public:
- static Type Run(std::map<K, V> input) {
- Type output;
- for (auto& pair : input) {
- output.insert(WrapTraits<K>::Wrap(pair.first),
- WrapTraits<V>::Wrap(std::move(pair.second)));
- }
- return output;
- }
- };
-
- template <typename X, typename Y>
- struct Helper<X, Y, false> {
- public:
- static Type Run(std::map<K, V> input) { return Type(std::move(input)); }
- };
-};
-
-template <>
-struct WrapTraits<std::string> {
- public:
- using Type = String;
-
- static String Wrap(const std::string& input) { return input; }
-};
-
-} // namespace internal
-
-template <typename T>
-typename internal::UnwrapTraits<T>::Type UnwrapToSTLType(T&& input) {
- return internal::UnwrapTraits<T>::Unwrap(std::move(input));
-}
-
-template <typename T>
-typename internal::WrapTraits<T>::Type WrapSTLType(T&& input) {
- return internal::WrapTraits<T>::Wrap(std::move(input));
-}
-
-} // namespace mojo
-
-#endif // MOJO_PUBLIC_CPP_BINDINGS_STL_CONVERTERS_H_
diff --git a/chromium/mojo/public/cpp/bindings/string.h b/chromium/mojo/public/cpp/bindings/string.h
deleted file mode 100644
index 892cc1c29ff..00000000000
--- a/chromium/mojo/public/cpp/bindings/string.h
+++ /dev/null
@@ -1,209 +0,0 @@
-// Copyright 2014 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.
-
-#ifndef MOJO_PUBLIC_CPP_BINDINGS_STRING_H_
-#define MOJO_PUBLIC_CPP_BINDINGS_STRING_H_
-
-#include <stddef.h>
-
-#include <functional>
-#include <string>
-
-#include "base/logging.h"
-#include "mojo/public/cpp/bindings/lib/array_internal.h"
-#include "mojo/public/cpp/bindings/lib/hash_util.h"
-#include "mojo/public/cpp/bindings/type_converter.h"
-
-namespace mojo {
-
-// A UTF-8 encoded character string that can be null. Provides functions that
-// are similar to std::string, along with access to the underlying std::string
-// object.
-class String {
- public:
- // Constructs an empty string.
- String() : is_null_(false) {}
- String(const std::string& str) : value_(str), is_null_(false) {}
- String(const char* chars) : is_null_(!chars) {
- if (chars)
- value_ = chars;
- }
- String(const char* chars, size_t num_chars)
- : value_(chars, num_chars), is_null_(false) {}
- String(const mojo::String& str)
- : value_(str.value_), is_null_(str.is_null_) {}
-
- template <size_t N>
- String(const char chars[N])
- : value_(chars, N - 1), is_null_(false) {}
-
- String(std::string&& other) : value_(std::move(other)), is_null_(false) {}
- String(String&& other) : is_null_(true) { Swap(&other); }
-
- template <typename U>
- static String From(const U& other) {
- return TypeConverter<String, U>::Convert(other);
- }
-
- template <typename U>
- U To() const {
- return TypeConverter<U, String>::Convert(*this);
- }
-
- String& operator=(const mojo::String& str) {
- value_ = str.value_;
- is_null_ = str.is_null_;
- return *this;
- }
- String& operator=(const std::string& str) {
- value_ = str;
- is_null_ = false;
- return *this;
- }
- String& operator=(const char* chars) {
- is_null_ = !chars;
- if (chars) {
- value_ = chars;
- } else {
- value_.clear();
- }
- return *this;
- }
-
- String& operator=(std::string&& other) {
- value_ = std::move(other);
- is_null_ = false;
- return *this;
- }
- String& operator=(String&& other) {
- is_null_ = true;
- value_.clear();
- Swap(&other);
- return *this;
- }
-
- bool is_null() const { return is_null_; }
-
- size_t size() const { return value_.size(); }
-
- const char* data() const { return value_.data(); }
-
- const char& at(size_t offset) const { return value_.at(offset); }
- const char& operator[](size_t offset) const { return value_[offset]; }
-
- const std::string& get() const { return value_; }
- operator const std::string&() const { return value_; }
-
- // Returns a const reference to the |std::string| managed by this class. If
- // the string is null, this will be an empty std::string.
- const std::string& storage() const { return value_; }
-
- // Passes the underlying storage and resets this string to null.
- std::string PassStorage() {
- is_null_ = true;
- return std::move(value_);
- }
-
- void Swap(String* other) {
- std::swap(is_null_, other->is_null_);
- value_.swap(other->value_);
- }
-
- void Swap(std::string* other) {
- is_null_ = false;
- value_.swap(*other);
- }
-
- private:
- typedef std::string String::*Testable;
-
- public:
- operator Testable() const { return is_null_ ? 0 : &String::value_; }
-
- private:
- std::string value_;
- bool is_null_;
-};
-
-inline bool operator==(const String& a, const String& b) {
- return a.is_null() == b.is_null() && a.get() == b.get();
-}
-inline bool operator==(const char* a, const String& b) {
- return !b.is_null() && a == b.get();
-}
-inline bool operator==(const String& a, const char* b) {
- return !a.is_null() && a.get() == b;
-}
-inline bool operator!=(const String& a, const String& b) {
- return !(a == b);
-}
-inline bool operator!=(const char* a, const String& b) {
- return !(a == b);
-}
-inline bool operator!=(const String& a, const char* b) {
- return !(a == b);
-}
-
-inline std::ostream& operator<<(std::ostream& out, const String& s) {
- return out << s.get();
-}
-
-inline bool operator<(const String& a, const String& b) {
- if (a.is_null())
- return !b.is_null();
- if (b.is_null())
- return false;
-
- return a.get() < b.get();
-}
-
-// TODO(darin): Add similar variants of operator<,<=,>,>=
-
-template <>
-struct TypeConverter<String, std::string> {
- static String Convert(const std::string& input) { return String(input); }
-};
-
-template <>
-struct TypeConverter<std::string, String> {
- static std::string Convert(const String& input) { return input; }
-};
-
-template <size_t N>
-struct TypeConverter<String, char[N]> {
- static String Convert(const char input[N]) {
- DCHECK(input);
- return String(input, N - 1);
- }
-};
-
-// Appease MSVC.
-template <size_t N>
-struct TypeConverter<String, const char[N]> {
- static String Convert(const char input[N]) {
- DCHECK(input);
- return String(input, N - 1);
- }
-};
-
-template <>
-struct TypeConverter<String, const char*> {
- // |input| may be null, in which case a null String will be returned.
- static String Convert(const char* input) { return String(input); }
-};
-
-} // namespace mojo
-
-namespace std {
-
-template <>
-struct hash<mojo::String> {
- size_t operator()(const mojo::String& value) const {
- return value.is_null() ? 0 : hash<std::string>()(value.get());
- }
-};
-
-} // namespace std
-
-#endif // MOJO_PUBLIC_CPP_BINDINGS_STRING_H_
diff --git a/chromium/mojo/public/cpp/bindings/string_traits_standard.h b/chromium/mojo/public/cpp/bindings/string_traits_standard.h
deleted file mode 100644
index 9b78d2473ec..00000000000
--- a/chromium/mojo/public/cpp/bindings/string_traits_standard.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2016 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.
-
-#ifndef MOJO_PUBLIC_CPP_BINDINGS_STRING_TRAITS_STANDARD_H_
-#define MOJO_PUBLIC_CPP_BINDINGS_STRING_TRAITS_STANDARD_H_
-
-#include "mojo/public/cpp/bindings/string.h"
-#include "mojo/public/cpp/bindings/string_traits.h"
-
-namespace mojo {
-
-template <>
-struct StringTraits<String> {
- static bool IsNull(const String& input) { return input.is_null(); }
- static void SetToNull(String* output) { *output = nullptr; }
-
- static size_t GetSize(const String& input) { return input.size(); }
-
- static const char* GetData(const String& input) { return input.data(); }
-
- static bool Read(StringDataView input, String* output) {
- String result(input.storage(), input.size());
- result.Swap(output);
- return true;
- }
-};
-
-} // namespace mojo
-
-#endif // MOJO_PUBLIC_CPP_BINDINGS_STRING_TRAITS_STANDARD_H_
diff --git a/chromium/mojo/public/cpp/bindings/strong_associated_binding.h b/chromium/mojo/public/cpp/bindings/strong_associated_binding.h
index 4d77a35ee8e..a1e299bb2d8 100644
--- a/chromium/mojo/public/cpp/bindings/strong_associated_binding.h
+++ b/chromium/mojo/public/cpp/bindings/strong_associated_binding.h
@@ -29,7 +29,10 @@ using StrongAssociatedBindingPtr =
base::WeakPtr<StrongAssociatedBinding<Interface>>;
// This connects an interface implementation strongly to an associated pipe.
-// When a connection error is detected the implementation is deleted.
+// When a connection error is detected the implementation is deleted. If the
+// task runner that a StrongAssociatedBinding is bound on is stopped, the
+// connection error handler will not be invoked and the implementation will not
+// be deleted.
//
// To use, call StrongAssociatedBinding<T>::Create() (see below) or the helper
// MakeStrongAssociatedBinding function:
diff --git a/chromium/mojo/public/cpp/bindings/strong_binding.h b/chromium/mojo/public/cpp/bindings/strong_binding.h
index 99d10956c6f..f4b4a061cd9 100644
--- a/chromium/mojo/public/cpp/bindings/strong_binding.h
+++ b/chromium/mojo/public/cpp/bindings/strong_binding.h
@@ -19,7 +19,6 @@
#include "mojo/public/cpp/bindings/filter_chain.h"
#include "mojo/public/cpp/bindings/interface_ptr.h"
#include "mojo/public/cpp/bindings/interface_request.h"
-#include "mojo/public/cpp/bindings/lib/router.h"
#include "mojo/public/cpp/bindings/message_header_validator.h"
#include "mojo/public/cpp/system/core.h"
@@ -32,7 +31,9 @@ template <typename Interface>
using StrongBindingPtr = base::WeakPtr<StrongBinding<Interface>>;
// This connects an interface implementation strongly to a pipe. When a
-// connection error is detected the implementation is deleted.
+// connection error is detected the implementation is deleted. If the task
+// runner that a StrongBinding is bound on is stopped, the connection error
+// handler will not be invoked and the implementation will not be deleted.
//
// To use, call StrongBinding<T>::Create() (see below) or the helper
// MakeStrongBinding function:
@@ -76,9 +77,6 @@ class StrongBinding {
Interface* impl() { return impl_.get(); }
- // Exposed for testing, should not generally be used.
- internal::Router* internal_router() { return binding_.internal_router(); }
-
// Sends a message on the underlying message pipe and runs the current
// message loop until its response is received. This can be used in tests to
// verify that no message was sent on a message pipe in response to some
diff --git a/chromium/mojo/public/cpp/bindings/struct_traits.h b/chromium/mojo/public/cpp/bindings/struct_traits.h
index a1379fe28c9..6cc070fc489 100644
--- a/chromium/mojo/public/cpp/bindings/struct_traits.h
+++ b/chromium/mojo/public/cpp/bindings/struct_traits.h
@@ -28,18 +28,17 @@ namespace mojo {
// wrapper type, or the following alternatives:
// - string:
// Value or reference of any type that has a StringTraits defined.
-// Supported by default: base::StringPiece, std::string, mojo::String,
+// Supported by default: base::StringPiece, std::string,
// WTF::String (in blink).
//
// - array:
// Value or reference of any type that has an ArrayTraits defined.
-// Supported by default: std::vector, CArray, mojo::Array, WTF::Vector
-// (in blink), mojo::WTFArray (in blink).
+// Supported by default: std::vector, CArray, WTF::Vector (in blink)
//
// - map:
// Value or reference of any type that has a MapTraits defined.
-// Supported by default: std::map, std::unordered_map, mojo::Map,
-// WTF::HashMap (in blink), mojo::WTFMap (in blink).
+// Supported by default: std::map, std::unordered_map,
+// WTF::HashMap (in blink).
//
// - struct:
// Value or reference of any type that has a StructTraits defined.
diff --git a/chromium/mojo/public/cpp/bindings/sync_call_restrictions.h b/chromium/mojo/public/cpp/bindings/sync_call_restrictions.h
index 1552ce79c93..ee7f006d5f6 100644
--- a/chromium/mojo/public/cpp/bindings/sync_call_restrictions.h
+++ b/chromium/mojo/public/cpp/bindings/sync_call_restrictions.h
@@ -16,11 +16,7 @@
#endif
namespace ui {
-class GpuService;
-}
-
-namespace aura {
-class GpuService;
+class Gpu;
}
namespace views {
@@ -55,8 +51,7 @@ class MOJO_CPP_BINDINGS_EXPORT SyncCallRestrictions {
private:
// DO NOT ADD ANY OTHER FRIEND STATEMENTS, talk to mojo/OWNERS first.
// BEGIN ALLOWED USAGE.
- friend class ui::GpuService; // http://crbug.com/620058
- friend class aura::GpuService; // http://crbug.com/620058
+ friend class ui::Gpu; // http://crbug.com/620058
// END ALLOWED USAGE.
// BEGIN USAGE THAT NEEDS TO BE FIXED.
diff --git a/chromium/mojo/public/cpp/bindings/tests/BUILD.gn b/chromium/mojo/public/cpp/bindings/tests/BUILD.gn
index 7326f2a4a31..71305b8efc7 100644
--- a/chromium/mojo/public/cpp/bindings/tests/BUILD.gn
+++ b/chromium/mojo/public/cpp/bindings/tests/BUILD.gn
@@ -6,8 +6,6 @@ source_set("tests") {
testonly = true
sources = [
- "array_common_test.h",
- "array_unittest.cc",
"associated_interface_unittest.cc",
"bind_task_runner_unittest.cc",
"binding_callback_unittest.cc",
@@ -23,8 +21,6 @@ source_set("tests") {
"handle_passing_unittest.cc",
"hash_unittest.cc",
"interface_ptr_unittest.cc",
- "map_common_test.h",
- "map_unittest.cc",
"message_queue.cc",
"message_queue.h",
"multiplex_router_unittest.cc",
@@ -32,11 +28,8 @@ source_set("tests") {
"request_response_unittest.cc",
"router_test_util.cc",
"router_test_util.h",
- "router_unittest.cc",
"sample_service_unittest.cc",
"serialization_warning_unittest.cc",
- "stl_converters_unittest.cc",
- "string_unittest.cc",
"struct_unittest.cc",
"sync_method_unittest.cc",
"type_conversion_unittest.cc",
@@ -48,12 +41,14 @@ source_set("tests") {
deps = [
":mojo_public_bindings_test_utils",
+ "//base/test:test_support",
"//mojo/edk/system",
"//mojo/public/cpp/bindings",
"//mojo/public/cpp/system",
"//mojo/public/cpp/test_support:test_utils",
"//mojo/public/interfaces/bindings/tests:test_associated_interfaces",
"//mojo/public/interfaces/bindings/tests:test_export_component",
+ "//mojo/public/interfaces/bindings/tests:test_exported_import",
"//mojo/public/interfaces/bindings/tests:test_interfaces",
"//mojo/public/interfaces/bindings/tests:test_interfaces_experimental",
"//mojo/public/interfaces/bindings/tests:test_struct_traits_interfaces",
@@ -81,20 +76,18 @@ if (!is_ios) {
testonly = true
sources = [
- "array_common_test.h",
"container_test_util.cc",
"container_test_util.h",
- "map_common_test.h",
"variant_test_util.h",
- "wtf_array_unittest.cc",
"wtf_hash_unittest.cc",
- "wtf_map_unittest.cc",
"wtf_types_unittest.cc",
]
deps = [
"//mojo/public/cpp/bindings",
"//mojo/public/cpp/system",
+ "//mojo/public/interfaces/bindings/tests:test_export_blink_component",
+ "//mojo/public/interfaces/bindings/tests:test_exported_import_blink",
"//mojo/public/interfaces/bindings/tests:test_interfaces",
"//mojo/public/interfaces/bindings/tests:test_interfaces_blink",
"//mojo/public/interfaces/bindings/tests:test_wtf_types",
@@ -129,6 +122,7 @@ source_set("perftests") {
deps = [
"//base/test:test_support",
+ "//mojo/edk/system",
"//mojo/edk/test:test_support",
"//mojo/public/cpp/bindings",
"//mojo/public/cpp/system",
diff --git a/chromium/mojo/public/cpp/bindings/thread_safe_interface_ptr.h b/chromium/mojo/public/cpp/bindings/thread_safe_interface_ptr.h
index 8f0e139ff97..605bddda137 100644
--- a/chromium/mojo/public/cpp/bindings/thread_safe_interface_ptr.h
+++ b/chromium/mojo/public/cpp/bindings/thread_safe_interface_ptr.h
@@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef MOJO_PUBLIC_CPP_BINDINGS_THREAD_SAFE_INTERFACE_PTR_BASE_H_
-#define MOJO_PUBLIC_CPP_BINDINGS_THREAD_SAFE_INTERFACE_PTR_BASE_H_
+#ifndef MOJO_PUBLIC_CPP_BINDINGS_THREAD_SAFE_INTERFACE_PTR_H_
+#define MOJO_PUBLIC_CPP_BINDINGS_THREAD_SAFE_INTERFACE_PTR_H_
#include <memory>
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -20,7 +21,7 @@ namespace mojo {
struct ThreadSafeInterfacePtrDeleter;
// ThreadSafeInterfacePtr and ThreadSafeAssociatedInterfacePtr are versions of
-// InterfacePtr and AssociatedInterfacePtr that let caller invoke
+// InterfacePtr and AssociatedInterfacePtr that let callers invoke
// interface methods from any threads. Callbacks are received on the thread that
// performed the interface call.
//
@@ -32,10 +33,15 @@ struct ThreadSafeInterfacePtrDeleter;
//
// Ex for ThreadSafeInterfacePtr:
// frob::FrobinatorPtr frobinator;
-// frob::FrobinatorImpl impl(GetProxy(&frobinator));
+// frob::FrobinatorImpl impl(MakeRequest(&frobinator));
// scoped_refptr<frob::ThreadSafeFrobinatorPtr> thread_safe_frobinator =
// frob::ThreadSafeFrobinatorPtr::Create(std::move(frobinator));
// (*thread_safe_frobinator)->FrobinateToTheMax();
+//
+// An alternate way is to create the ThreadSafeInterfacePtr unbound (not
+// associated with an InterfacePtr) and call Bind() at a later time when the
+// InterfacePtr becomes available. Note that you shouldn't call any interface
+// methods on the ThreadSafeInterfacePtr before it is bound.
template <typename Interface, template <typename> class InterfacePtrType>
class ThreadSafeInterfacePtrBase
@@ -48,13 +54,41 @@ class ThreadSafeInterfacePtrBase
static scoped_refptr<ThreadSafeInterfacePtrBase<Interface, InterfacePtrType>>
Create(InterfacePtrType<Interface> interface_ptr) {
+ scoped_refptr<ThreadSafeInterfacePtrBase> ptr(
+ new ThreadSafeInterfacePtrBase());
+ return ptr->Bind(std::move(interface_ptr)) ? ptr : nullptr;
+ }
+
+ // Creates a ThreadSafeInterfacePtrBase with no associated InterfacePtr.
+ // Call Bind() with the InterfacePtr once available, which must be called on
+ // the |bind_task_runner|.
+ // Providing the TaskRunner here allows you to post a task to
+ // |bind_task_runner| to do the bind and then immediately start calling
+ // methods on the returned interface.
+ static scoped_refptr<ThreadSafeInterfacePtrBase<Interface, InterfacePtrType>>
+ CreateUnbound(
+ const scoped_refptr<base::SingleThreadTaskRunner>& bind_task_runner) {
+ scoped_refptr<ThreadSafeInterfacePtrBase<Interface, InterfacePtrType>> ptr =
+ new ThreadSafeInterfacePtrBase();
+ ptr->interface_ptr_task_runner_ = bind_task_runner;
+ return ptr;
+ }
+
+ // Binds a ThreadSafeInterfacePtrBase previously created with CreateUnbound().
+ // This must be called on the thread that |interface_ptr| should be used.
+ // If created with CreateUnbound() that thread should be the same as the one
+ // provided at creation time.
+ bool Bind(InterfacePtrType<Interface> interface_ptr) {
+ DCHECK(!interface_ptr_task_runner_ ||
+ interface_ptr_task_runner_ == base::ThreadTaskRunnerHandle::Get());
if (!interface_ptr.is_bound()) {
- LOG(ERROR) << "Attempting to create a ThreadSafe[Associated]InterfacePtr "
- "from an unbound InterfacePtr.";
- return nullptr;
+ LOG(ERROR) << "Attempting to bind a ThreadSafe[Associated]InterfacePtr "
+ "from an unbound InterfacePtr.";
+ return false;
}
- return new ThreadSafeInterfacePtrBase(std::move(interface_ptr),
- base::ThreadTaskRunnerHandle::Get());
+ interface_ptr_ = std::move(interface_ptr);
+ interface_ptr_task_runner_ = base::ThreadTaskRunnerHandle::Get();
+ return true;
}
~ThreadSafeInterfacePtrBase() override {}
@@ -63,22 +97,16 @@ class ThreadSafeInterfacePtrBase
Interface* operator->() { return get(); }
Interface& operator*() { return *get(); }
- protected:
- ThreadSafeInterfacePtrBase(
- InterfacePtrType<Interface> interface_ptr,
- scoped_refptr<base::SingleThreadTaskRunner> task_runner)
- : interface_ptr_task_runner_(task_runner),
- proxy_(this),
- interface_ptr_(std::move(interface_ptr)),
- weak_ptr_factory_(this) {}
-
private:
friend class base::RefCountedThreadSafe<
ThreadSafeInterfacePtrBase<Interface, InterfacePtrType>>;
friend struct ThreadSafeInterfacePtrDeleter;
+ ThreadSafeInterfacePtrBase() : proxy_(this), weak_ptr_factory_(this) {}
+
void DeleteOnCorrectThread() const {
- if (!interface_ptr_task_runner_->BelongsToCurrentThread() &&
+ if (interface_ptr_task_runner_ &&
+ !interface_ptr_task_runner_->BelongsToCurrentThread() &&
interface_ptr_task_runner_->DeleteSoon(FROM_HERE, this)) {
return;
}
@@ -172,4 +200,4 @@ using ThreadSafeInterfacePtr =
} // namespace mojo
-#endif // MOJO_PUBLIC_CPP_BINDINGS_THREAD_SAFE_INTERFACE_PTR_BASE_H_
+#endif // MOJO_PUBLIC_CPP_BINDINGS_THREAD_SAFE_INTERFACE_PTR_H_
diff --git a/chromium/mojo/public/cpp/bindings/type_converter.h b/chromium/mojo/public/cpp/bindings/type_converter.h
index 1446ab375f5..e17ac861c3e 100644
--- a/chromium/mojo/public/cpp/bindings/type_converter.h
+++ b/chromium/mojo/public/cpp/bindings/type_converter.h
@@ -7,6 +7,8 @@
#include <stdint.h>
+#include <vector>
+
namespace mojo {
// Specialize the following class:
@@ -74,6 +76,9 @@ namespace mojo {
template <typename T, typename U>
struct TypeConverter;
+template <typename T, typename U>
+inline T ConvertTo(const U& obj);
+
// The following specialization is useful when you are converting between
// Array<POD> and std::vector<POD>.
template <typename T>
@@ -81,6 +86,18 @@ struct TypeConverter<T, T> {
static T Convert(const T& obj) { return obj; }
};
+template <typename T, typename Container>
+struct TypeConverter<std::vector<T>, Container> {
+ static std::vector<T> Convert(const Container& container) {
+ std::vector<T> output;
+ output.reserve(container.size());
+ for (const auto& obj : container) {
+ output.push_back(ConvertTo<T>(obj));
+ }
+ return output;
+ }
+};
+
// The following helper function is useful for shorthand. The compiler can infer
// the input type, so you can write:
// OutputType out = ConvertTo<OutputType>(input);
diff --git a/chromium/mojo/public/cpp/bindings/wtf_array.h b/chromium/mojo/public/cpp/bindings/wtf_array.h
deleted file mode 100644
index 46d9a6958bd..00000000000
--- a/chromium/mojo/public/cpp/bindings/wtf_array.h
+++ /dev/null
@@ -1,197 +0,0 @@
-// Copyright 2016 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.
-
-#ifndef MOJO_PUBLIC_CPP_BINDINGS_WTF_ARRAY_H_
-#define MOJO_PUBLIC_CPP_BINDINGS_WTF_ARRAY_H_
-
-#include <stddef.h>
-#include <utility>
-
-#include "base/macros.h"
-#include "mojo/public/cpp/bindings/lib/array_internal.h"
-#include "mojo/public/cpp/bindings/lib/bindings_internal.h"
-#include "mojo/public/cpp/bindings/lib/template_util.h"
-#include "mojo/public/cpp/bindings/lib/wtf_clone_equals_util.h"
-#include "mojo/public/cpp/bindings/type_converter.h"
-#include "third_party/WebKit/Source/wtf/Vector.h"
-
-namespace mojo {
-
-// Represents an array backed by WTF::Vector. Comparing with WTF::Vector,
-// mojo::WTFArray is move-only and can be null.
-// It is easy to convert between WTF::Vector<T> and mojo::WTFArray<T>:
-// - constructor WTFArray(WTF::Vector<T>&&) takes the contents of a
-// WTF::Vector<T>;
-// - method PassStorage() passes the underlying WTF::Vector.
-template <typename T>
-class WTFArray {
- public:
- // Constructs an empty array.
- WTFArray() : is_null_(false) {}
- // Constructs a null array.
- WTFArray(std::nullptr_t null_pointer) : is_null_(true) {}
-
- // Constructs a new non-null array of the specified size. The elements will
- // be value-initialized (meaning that they will be initialized by their
- // default constructor, if any, or else zero-initialized).
- explicit WTFArray(size_t size) : vec_(size), is_null_(false) {}
- ~WTFArray() {}
-
- // Moves the contents of |other| into this array.
- WTFArray(WTF::Vector<T>&& other) : vec_(std::move(other)), is_null_(false) {}
- WTFArray(WTFArray&& other) : is_null_(true) { Take(&other); }
-
- WTFArray& operator=(WTF::Vector<T>&& other) {
- vec_ = std::move(other);
- is_null_ = false;
- return *this;
- }
- WTFArray& operator=(WTFArray&& other) {
- Take(&other);
- return *this;
- }
-
- WTFArray& operator=(std::nullptr_t null_pointer) {
- is_null_ = true;
- vec_.clear();
- return *this;
- }
-
- // Creates a non-null array of the specified size. The elements will be
- // value-initialized (meaning that they will be initialized by their default
- // constructor, if any, or else zero-initialized).
- static WTFArray New(size_t size) { return WTFArray(size); }
-
- // Creates a new array with a copy of the contents of |other|.
- template <typename U>
- static WTFArray From(const U& other) {
- return TypeConverter<WTFArray, U>::Convert(other);
- }
-
- // Copies the contents of this array to a new object of type |U|.
- template <typename U>
- U To() const {
- return TypeConverter<U, WTFArray>::Convert(*this);
- }
-
- // Indicates whether the array is null (which is distinct from empty).
- bool is_null() const {
- // When the array is set to null, the underlying storage |vec_| shouldn't
- // contain any elements.
- DCHECK(!is_null_ || vec_.isEmpty());
- return is_null_;
- }
-
- // Indicates whether the array is empty (which is distinct from null).
- bool empty() const { return vec_.isEmpty() && !is_null_; }
-
- // Returns a reference to the first element of the array. Calling this on a
- // null or empty array causes undefined behavior.
- const T& front() const { return vec_.first(); }
- T& front() { return vec_.first(); }
-
- // Returns the size of the array, which will be zero if the array is null.
- size_t size() const { return vec_.size(); }
-
- // Returns a reference to the element at zero-based |offset|. Calling this on
- // an array with size less than |offset|+1 causes undefined behavior.
- const T& at(size_t offset) const { return vec_.at(offset); }
- const T& operator[](size_t offset) const { return at(offset); }
- T& at(size_t offset) { return vec_.at(offset); }
- T& operator[](size_t offset) { return at(offset); }
-
- // Resizes the array to |size| and makes it non-null. Otherwise, works just
- // like the resize method of |WTF::Vector|.
- void resize(size_t size) {
- is_null_ = false;
- vec_.resize(size);
- }
-
- // Sets the array to empty (even if previously it was null.)
- void SetToEmpty() { resize(0); }
-
- // Returns a const reference to the |WTF::Vector| managed by this class. If
- // the array is null, this will be an empty vector.
- const WTF::Vector<T>& storage() const { return vec_; }
-
- // Passes the underlying storage and resets this array to null.
- //
- // TODO(yzshen): Consider changing this to a rvalue-ref-qualified conversion
- // to WTF::Vector<T> after we move to MSVC 2015.
- WTF::Vector<T> PassStorage() {
- is_null_ = true;
- return std::move(vec_);
- }
-
- void Swap(WTFArray* other) {
- std::swap(is_null_, other->is_null_);
- vec_.swap(other->vec_);
- }
-
- // Swaps the contents of this array with the specified vector, making this
- // array non-null. Since the vector cannot represent null, it will just be
- // made empty if this array is null.
- void Swap(WTF::Vector<T>* other) {
- is_null_ = false;
- vec_.swap(*other);
- }
-
- // Returns a copy of the array where each value of the new array has been
- // "cloned" from the corresponding value of this array. If the element type
- // defines a Clone() method, it will be used; otherwise copy
- // constructor/assignment will be used.
- //
- // Please note that calling this method will fail compilation if the element
- // type cannot be cloned (which usually means that it is a Mojo handle type or
- // a type containing Mojo handles).
- WTFArray Clone() const {
- WTFArray result;
- result.is_null_ = is_null_;
- result.vec_ = internal::Clone(vec_);
- return result;
- }
-
- // Indicates whether the contents of this array are equal to |other|. A null
- // array is only equal to another null array. If the element type defines an
- // Equals() method, it will be used; otherwise == operator will be used.
- bool Equals(const WTFArray& other) const {
- if (is_null() != other.is_null())
- return false;
- return internal::Equals(vec_, other.vec_);
- }
-
- private:
- // TODO(dcheng): Use an explicit conversion operator.
- typedef WTF::Vector<T> WTFArray::*Testable;
-
- public:
- operator Testable() const {
- // When the array is set to null, the underlying storage |vec_| shouldn't
- // contain any elements.
- DCHECK(!is_null_ || vec_.isEmpty());
- return is_null_ ? 0 : &WTFArray::vec_;
- }
-
- private:
- // Forbid the == and != operators explicitly, otherwise WTFArray will be
- // converted to Testable to do == or != comparison.
- template <typename U>
- bool operator==(const WTFArray<U>& other) const = delete;
- template <typename U>
- bool operator!=(const WTFArray<U>& other) const = delete;
-
- void Take(WTFArray* other) {
- operator=(nullptr);
- Swap(other);
- }
-
- WTF::Vector<T> vec_;
- bool is_null_;
-
- DISALLOW_COPY_AND_ASSIGN(WTFArray);
-};
-
-} // namespace mojo
-
-#endif // MOJO_PUBLIC_CPP_BINDINGS_WTF_ARRAY_H_
diff --git a/chromium/mojo/public/cpp/bindings/wtf_map.h b/chromium/mojo/public/cpp/bindings/wtf_map.h
deleted file mode 100644
index 0aba9595172..00000000000
--- a/chromium/mojo/public/cpp/bindings/wtf_map.h
+++ /dev/null
@@ -1,200 +0,0 @@
-// Copyright 2016 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.
-
-#ifndef MOJO_PUBLIC_CPP_BINDINGS_WTF_MAP_H_
-#define MOJO_PUBLIC_CPP_BINDINGS_WTF_MAP_H_
-
-#include <stddef.h>
-#include <utility>
-
-#include "base/macros.h"
-#include "mojo/public/cpp/bindings/lib/template_util.h"
-#include "mojo/public/cpp/bindings/lib/wtf_clone_equals_util.h"
-#include "mojo/public/cpp/bindings/type_converter.h"
-#include "third_party/WebKit/Source/wtf/HashMap.h"
-#include "third_party/WebKit/Source/wtf/text/StringHash.h"
-
-namespace mojo {
-
-// Represents a map backed by WTF::HashMap. Comparing with WTF::HashMap,
-// mojo::WTFMap is move-only and can be null.
-//
-// It is easy to convert between WTF::HashMap<K, V> and mojo::WTFMap<K, V>:
-// - constructor WTFMap(WTF::HashMap<K, V>&&) takes the contents of a
-// WTF::HashMap<K, V>;
-// - method PassStorage() passes the underlying WTF::HashMap.
-//
-// NOTE: WTF::HashMap disallows certain key values. For integer types, those are
-// 0 and -1 (max value instead of -1 for unsigned). For string, that is null.
-template <typename Key, typename Value>
-class WTFMap {
- public:
- using Iterator = typename WTF::HashMap<Key, Value>::iterator;
- using ConstIterator = typename WTF::HashMap<Key, Value>::const_iterator;
-
- // Constructs an empty map.
- WTFMap() : is_null_(false) {}
- // Constructs a null map.
- WTFMap(std::nullptr_t null_pointer) : is_null_(true) {}
-
- ~WTFMap() {}
-
- WTFMap(WTF::HashMap<Key, Value>&& other)
- : map_(std::move(other)), is_null_(false) {}
- WTFMap(WTFMap&& other) : is_null_(true) { Take(&other); }
-
- WTFMap& operator=(WTF::HashMap<Key, Value>&& other) {
- is_null_ = false;
- map_ = std::move(other);
- return *this;
- }
- WTFMap& operator=(WTFMap&& other) {
- Take(&other);
- return *this;
- }
-
- WTFMap& operator=(std::nullptr_t null_pointer) {
- is_null_ = true;
- map_.clear();
- return *this;
- }
-
- static bool IsValidKey(const Key& key) {
- return WTF::HashMap<Key, Value>::isValidKey(key);
- }
-
- // Copies the contents of some other type of map into a new WTFMap using a
- // TypeConverter.
- template <typename U>
- static WTFMap From(const U& other) {
- return TypeConverter<WTFMap, U>::Convert(other);
- }
-
- // Copies the contents of the WTFMap into some other type of map.
- template <typename U>
- U To() const {
- return TypeConverter<U, WTFMap>::Convert(*this);
- }
-
- // Indicates whether the map is null (which is distinct from empty).
- bool is_null() const { return is_null_; }
-
- // Indicates whether the map is empty (which is distinct from null).
- bool empty() const { return map_.isEmpty() && !is_null_; }
-
- // Indicates the number of keys in the map, which will be zero if the map is
- // null.
- size_t size() const { return map_.size(); }
-
- // Inserts a key-value pair into the map. Like WTF::HashMap::add(), this does
- // not insert |value| if |key| is already a member of the map.
- void insert(const Key& key, const Value& value) {
- is_null_ = false;
- map_.add(key, value);
- }
- void insert(const Key& key, Value&& value) {
- is_null_ = false;
- map_.add(key, std::move(value));
- }
-
- // Returns a reference to the value associated with the specified key,
- // crashing the process if the key is not present in the map.
- Value& at(const Key& key) { return map_.find(key)->value; }
- const Value& at(const Key& key) const { return map_.find(key)->value; }
-
- // Returns a reference to the value associated with the specified key,
- // creating a new entry if the key is not already present in the map. A
- // newly-created value will be value-initialized (meaning that it will be
- // initialized by the default constructor of the value type, if any, or else
- // will be zero-initialized).
- Value& operator[](const Key& key) {
- is_null_ = false;
- if (!map_.contains(key))
- map_.add(key, Value());
- return at(key);
- }
-
- // Sets the map to empty (even if previously it was null).
- void SetToEmpty() {
- is_null_ = false;
- map_.clear();
- }
-
- // Returns a const reference to the WTF::HashMap managed by this class. If
- // this object is null, the return value will be an empty map.
- const WTF::HashMap<Key, Value>& storage() const { return map_; }
-
- // Passes the underlying storage and resets this map to null.
- WTF::HashMap<Key, Value> PassStorage() {
- is_null_ = true;
- return std::move(map_);
- }
-
- // Swaps the contents of this WTFMap with another WTFMap of the same type
- // (including nullness).
- void Swap(WTFMap<Key, Value>* other) {
- std::swap(is_null_, other->is_null_);
- map_.swap(other->map_);
- }
-
- // Swaps the contents of this WTFMap with an WTF::HashMap containing keys and
- // values of the same type. Since WTF::HashMap cannot represent the null
- // state, the WTF::HashMap will be empty if WTFMap is null. The WTFMap will
- // always be left in a non-null state.
- void Swap(WTF::HashMap<Key, Value>* other) {
- is_null_ = false;
- map_.swap(*other);
- }
-
- // Returns a new WTFMap that contains a copy of the contents of this map. If
- // the key/value type defines a Clone() method, it will be used; otherwise
- // copy constructor/assignment will be used.
- //
- // Please note that calling this method will fail compilation if the key/value
- // type cannot be cloned (which usually means that it is a Mojo handle type or
- // a type containing Mojo handles).
- WTFMap Clone() const {
- WTFMap result;
- result.is_null_ = is_null_;
- result.map_ = internal::Clone(map_);
- return result;
- }
-
- // Indicates whether the contents of this map are equal to those of another
- // WTFMap (including nullness). If the key/value type defines an Equals()
- // method, it will be used; otherwise == operator will be used.
- bool Equals(const WTFMap& other) const {
- if (is_null() != other.is_null())
- return false;
- return internal::Equals(map_, other.map_);
- }
-
- ConstIterator begin() const { return map_.begin(); }
- Iterator begin() { return map_.begin(); }
-
- ConstIterator end() const { return map_.end(); }
- Iterator end() { return map_.end(); }
-
- // Returns the iterator pointing to the entry for |key|, if present, or else
- // returns end().
- ConstIterator find(const Key& key) const { return map_.find(key); }
- Iterator find(const Key& key) { return map_.find(key); }
-
- explicit operator bool() const { return !is_null_; }
-
- private:
- void Take(WTFMap* other) {
- operator=(nullptr);
- Swap(other);
- }
-
- WTF::HashMap<Key, Value> map_;
- bool is_null_;
-
- DISALLOW_COPY_AND_ASSIGN(WTFMap);
-};
-
-} // namespace mojo
-
-#endif // MOJO_PUBLIC_CPP_BINDINGS_WTF_MAP_H_
diff --git a/chromium/mojo/public/cpp/system/platform_handle.cc b/chromium/mojo/public/cpp/system/platform_handle.cc
index e4a6088a2e3..42e4abac832 100644
--- a/chromium/mojo/public/cpp/system/platform_handle.cc
+++ b/chromium/mojo/public/cpp/system/platform_handle.cc
@@ -4,6 +4,11 @@
#include "mojo/public/cpp/system/platform_handle.h"
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+#include <mach/mach.h>
+#include "base/mac/mach_logging.h"
+#endif
+
namespace mojo {
namespace {
@@ -61,6 +66,13 @@ ScopedSharedBufferHandle WrapSharedMemoryHandle(
const base::SharedMemoryHandle& memory_handle,
size_t size,
bool read_only) {
+#if defined(OS_POSIX) && !(defined(OS_MACOSX) && !defined(OS_IOS))
+ if (memory_handle.fd == base::kInvalidPlatformFile)
+ return ScopedSharedBufferHandle();
+#else
+ if (!memory_handle.IsValid())
+ return ScopedSharedBufferHandle();
+#endif
MojoPlatformHandle platform_handle;
platform_handle.struct_size = sizeof(MojoPlatformHandle);
platform_handle.type = kPlatformSharedBufferHandleType;
@@ -91,6 +103,8 @@ MojoResult UnwrapSharedMemoryHandle(ScopedSharedBufferHandle handle,
base::SharedMemoryHandle* memory_handle,
size_t* size,
bool* read_only) {
+ if (!handle.is_valid())
+ return MOJO_RESULT_INVALID_ARGUMENT;
MojoPlatformHandle platform_handle;
platform_handle.struct_size = sizeof(MojoPlatformHandle);
@@ -126,4 +140,39 @@ MojoResult UnwrapSharedMemoryHandle(ScopedSharedBufferHandle handle,
return MOJO_RESULT_OK;
}
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+ScopedHandle WrapMachPort(mach_port_t port) {
+ kern_return_t kr =
+ mach_port_mod_refs(mach_task_self(), port, MACH_PORT_RIGHT_SEND, 1);
+ MACH_LOG_IF(ERROR, kr != KERN_SUCCESS, kr)
+ << "MachPortAttachmentMac mach_port_mod_refs";
+ if (kr != KERN_SUCCESS)
+ return ScopedHandle();
+
+ MojoPlatformHandle platform_handle;
+ platform_handle.struct_size = sizeof(MojoPlatformHandle);
+ platform_handle.type = MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT;
+ platform_handle.value = static_cast<uint64_t>(port);
+
+ MojoHandle mojo_handle;
+ MojoResult result = MojoWrapPlatformHandle(&platform_handle, &mojo_handle);
+ CHECK_EQ(result, MOJO_RESULT_OK);
+
+ return ScopedHandle(Handle(mojo_handle));
+}
+
+MojoResult UnwrapMachPort(ScopedHandle handle, mach_port_t* port) {
+ MojoPlatformHandle platform_handle;
+ platform_handle.struct_size = sizeof(MojoPlatformHandle);
+ MojoResult result =
+ MojoUnwrapPlatformHandle(handle.release().value(), &platform_handle);
+ if (result != MOJO_RESULT_OK)
+ return result;
+
+ CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT);
+ *port = static_cast<mach_port_t>(platform_handle.value);
+ return MOJO_RESULT_OK;
+}
+#endif // defined(OS_MACOSX) && !defined(OS_IOS)
+
} // namespace mojo
diff --git a/chromium/mojo/public/cpp/system/platform_handle.h b/chromium/mojo/public/cpp/system/platform_handle.h
index 4e33f1b1baf..801264efce6 100644
--- a/chromium/mojo/public/cpp/system/platform_handle.h
+++ b/chromium/mojo/public/cpp/system/platform_handle.h
@@ -76,6 +76,17 @@ UnwrapSharedMemoryHandle(ScopedSharedBufferHandle handle,
size_t* size,
bool* read_only);
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+// Wraps a mach_port_t as a Mojo handle. This takes a reference to the
+// Mach port.
+MOJO_CPP_SYSTEM_EXPORT ScopedHandle WrapMachPort(mach_port_t port);
+
+// Unwraps a mach_port_t from a Mojo handle. The caller gets ownership of the
+// Mach port.
+MOJO_CPP_SYSTEM_EXPORT MojoResult UnwrapMachPort(ScopedHandle handle,
+ mach_port_t* port);
+#endif // defined(OS_MACOSX) && !defined(OS_IOS)
+
} // namespace mojo
#endif // MOJO_PUBLIC_CPP_SYSTEM_PLATFORM_HANDLE_H_
diff --git a/chromium/mojo/public/cpp/system/watcher.cc b/chromium/mojo/public/cpp/system/watcher.cc
index d9319fb5bda..fc03c5a0a0e 100644
--- a/chromium/mojo/public/cpp/system/watcher.cc
+++ b/chromium/mojo/public/cpp/system/watcher.cc
@@ -7,45 +7,10 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/macros.h"
-#include "base/message_loop/message_loop.h"
#include "mojo/public/c/system/functions.h"
namespace mojo {
-class Watcher::MessageLoopObserver
- : public base::MessageLoop::DestructionObserver {
- public:
- explicit MessageLoopObserver(Watcher* watcher) : watcher_(watcher) {
- base::MessageLoop::current()->AddDestructionObserver(this);
- }
-
- ~MessageLoopObserver() override {
- StopObservingIfNecessary();
- }
-
- private:
- // base::MessageLoop::DestructionObserver:
- void WillDestroyCurrentMessageLoop() override {
- StopObservingIfNecessary();
- if (watcher_->IsWatching()) {
- // TODO(yzshen): Remove this notification. crbug.com/604762
- watcher_->OnHandleReady(MOJO_RESULT_ABORTED);
- }
- }
-
- void StopObservingIfNecessary() {
- if (is_observing_) {
- is_observing_ = false;
- base::MessageLoop::current()->RemoveDestructionObserver(this);
- }
- }
-
- bool is_observing_ = true;
- Watcher* watcher_;
-
- DISALLOW_COPY_AND_ASSIGN(MessageLoopObserver);
-};
-
Watcher::Watcher(scoped_refptr<base::SingleThreadTaskRunner> runner)
: task_runner_(std::move(runner)),
is_default_task_runner_(task_runner_ ==
@@ -72,7 +37,6 @@ MojoResult Watcher::Start(Handle handle,
DCHECK(!IsWatching());
DCHECK(!callback.is_null());
- message_loop_observer_.reset(new MessageLoopObserver(this));
callback_ = callback;
handle_ = handle;
MojoResult result = MojoWatch(handle_.value(), signals,
@@ -81,7 +45,6 @@ MojoResult Watcher::Start(Handle handle,
if (result != MOJO_RESULT_OK) {
handle_.set_value(kInvalidHandleValue);
callback_.Reset();
- message_loop_observer_.reset();
DCHECK(result == MOJO_RESULT_FAILED_PRECONDITION ||
result == MOJO_RESULT_INVALID_ARGUMENT);
return result;
@@ -99,7 +62,6 @@ void Watcher::Cancel() {
MojoResult result =
MojoCancelWatch(handle_.value(), reinterpret_cast<uintptr_t>(this));
- message_loop_observer_.reset();
// |result| may be MOJO_RESULT_INVALID_ARGUMENT if |handle_| has closed, but
// OnHandleReady has not yet been called.
DCHECK(result == MOJO_RESULT_INVALID_ARGUMENT || result == MOJO_RESULT_OK);
@@ -112,7 +74,6 @@ void Watcher::OnHandleReady(MojoResult result) {
ReadyCallback callback = callback_;
if (result == MOJO_RESULT_CANCELLED) {
- message_loop_observer_.reset();
handle_.set_value(kInvalidHandleValue);
callback_.Reset();
}
diff --git a/chromium/mojo/public/cpp/system/watcher.h b/chromium/mojo/public/cpp/system/watcher.h
index 3284154b2d8..815b73b3b50 100644
--- a/chromium/mojo/public/cpp/system/watcher.h
+++ b/chromium/mojo/public/cpp/system/watcher.h
@@ -5,8 +5,6 @@
#ifndef MOJO_PUBLIC_CPP_SYSTEM_WATCHER_H_
#define MOJO_PUBLIC_CPP_SYSTEM_WATCHER_H_
-#include <memory>
-
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
@@ -36,11 +34,6 @@ class MOJO_CPP_SYSTEM_EXPORT Watcher {
//
// |MOJO_RESULT_CANCELLED|: The handle has been closed and the watch has
// been cancelled implicitly.
- //
- // |MOJO_RESULT_ABORTED|: Notifications can no longer be delivered for this
- // watcher for some unspecified reason, e.g., the watching thread may
- // be shutting down soon. Note that it is still necessary to explicitly
- // Cancel() the watch in this case.
using ReadyCallback = base::Callback<void(MojoResult result)>;
explicit Watcher(scoped_refptr<base::SingleThreadTaskRunner> runner =
@@ -82,9 +75,6 @@ class MOJO_CPP_SYSTEM_EXPORT Watcher {
ReadyCallback ready_callback() const { return callback_; }
private:
- class MessageLoopObserver;
- friend class MessageLoopObserver;
-
void OnHandleReady(MojoResult result);
static void CallOnHandleReady(uintptr_t context,
@@ -101,8 +91,6 @@ class MOJO_CPP_SYSTEM_EXPORT Watcher {
// for the thread.
const bool is_default_task_runner_;
- std::unique_ptr<MessageLoopObserver> message_loop_observer_;
-
// A persistent weak reference to this Watcher which can be passed to the
// Dispatcher any time this object should be signalled. Safe to access (but
// not to dereference!) from any thread.
diff --git a/chromium/mojo/public/interfaces/bindings/BUILD.gn b/chromium/mojo/public/interfaces/bindings/BUILD.gn
index 706e3efd5fc..eab75c1e9bd 100644
--- a/chromium/mojo/public/interfaces/bindings/BUILD.gn
+++ b/chromium/mojo/public/interfaces/bindings/BUILD.gn
@@ -5,6 +5,7 @@
import("../../tools/bindings/mojom.gni")
mojom("bindings") {
+ visibility = []
sources = [
"interface_control_messages.mojom",
"pipe_control_messages.mojom",
diff --git a/chromium/mojo/public/interfaces/bindings/tests/BUILD.gn b/chromium/mojo/public/interfaces/bindings/tests/BUILD.gn
index 72d6ba268df..9b10db0064f 100644
--- a/chromium/mojo/public/interfaces/bindings/tests/BUILD.gn
+++ b/chromium/mojo/public/interfaces/bindings/tests/BUILD.gn
@@ -38,6 +38,15 @@ component("test_export_component") {
]
}
+if (!is_ios) {
+ component("test_export_blink_component") {
+ testonly = true
+ deps = [
+ ":test_export_blink",
+ ]
+ }
+}
+
mojom("test_export") {
testonly = true
sources = [
@@ -46,6 +55,33 @@ mojom("test_export") {
export_class_attribute = "MOJO_TEST_EXPORT"
export_define = "MOJO_TEST_IMPLEMENTATION=1"
export_header = "mojo/public/cpp/bindings/tests/mojo_test_export.h"
+ if (!is_ios) {
+ export_class_attribute_blink = "MOJO_TEST_BLINK_EXPORT"
+ export_define_blink = "MOJO_TEST_BLINK_IMPLEMENTATION=1"
+ export_header_blink =
+ "mojo/public/cpp/bindings/tests/mojo_test_blink_export.h"
+ }
+ visibility = [ ":test_export_component" ]
+ if (!is_ios) {
+ visibility_blink = [ ":test_export_blink_component" ]
+ }
+}
+
+mojom("test_exported_import") {
+ testonly = true
+ sources = [
+ "test_import.mojom",
+ ]
+ public_deps = [
+ ":test_export",
+ ]
+
+ overridden_deps = [ ":test_export" ]
+ component_deps = [ ":test_export_component" ]
+ if (!is_ios) {
+ overridden_deps_blink = [ ":test_export" ]
+ component_deps_blink = [ ":test_export_blink_component" ]
+ }
}
mojom("test_mojom_import") {
diff --git a/chromium/mojo/public/interfaces/bindings/tests/test_constants.mojom b/chromium/mojo/public/interfaces/bindings/tests/test_constants.mojom
index 462d5126a5a..272e6035a6f 100644
--- a/chromium/mojo/public/interfaces/bindings/tests/test_constants.mojom
+++ b/chromium/mojo/public/interfaces/bindings/tests/test_constants.mojom
@@ -42,12 +42,16 @@ const float kFloatInfinity = float.INFINITY;
const float kFloatNegativeInfinity = float.NEGATIVE_INFINITY;
const float kFloatNaN = float.NAN;
+const string kStringValue = "test string contents";
+
struct StructWithConstants {
const int8 kInt8Value = 5;
const float kFloatValue = 765.432;
+ const string kStringValue = "struct test string contents";
};
interface InterfaceWithConstants {
const uint32 kUint32Value = 20100722;
const double kDoubleValue = 12.34567;
+ const string kStringValue = "interface test string contents";
};
diff --git a/chromium/mojo/public/interfaces/bindings/tests/test_export.mojom b/chromium/mojo/public/interfaces/bindings/tests/test_export.mojom
index 9a532dd94d4..319a15b036d 100644
--- a/chromium/mojo/public/interfaces/bindings/tests/test_export.mojom
+++ b/chromium/mojo/public/interfaces/bindings/tests/test_export.mojom
@@ -16,3 +16,5 @@ struct StringPair {
struct StringPairContainer {
array<StringPair> pairs;
};
+
+interface ExportedInterface {};
diff --git a/chromium/mojo/public/interfaces/bindings/tests/test_import.mojom b/chromium/mojo/public/interfaces/bindings/tests/test_import.mojom
new file mode 100644
index 00000000000..42014c6809e
--- /dev/null
+++ b/chromium/mojo/public/interfaces/bindings/tests/test_import.mojom
@@ -0,0 +1,11 @@
+// Copyright 2016 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.
+
+module mojo.test.test_import;
+
+import "mojo/public/interfaces/bindings/tests/test_export.mojom";
+
+struct ImportingStruct {
+ mojo.test.test_export.StringPair strings;
+};
diff --git a/chromium/mojo/public/js/BUILD.gn b/chromium/mojo/public/js/BUILD.gn
index eda7e04d07e..5b2c715b13d 100644
--- a/chromium/mojo/public/js/BUILD.gn
+++ b/chromium/mojo/public/js/BUILD.gn
@@ -14,11 +14,11 @@ group("bindings") {
"bindings.js",
"buffer.js",
"codec.js",
- "connection.js",
"connector.js",
"constants.cc",
"constants.h",
"core.js",
+ "interface_types.js",
"router.js",
"support.js",
"threading.js",
diff --git a/chromium/mojo/public/js/bindings.js b/chromium/mojo/public/js/bindings.js
index 2fdcae39f30..06075b513f1 100644
--- a/chromium/mojo/public/js/bindings.js
+++ b/chromium/mojo/public/js/bindings.js
@@ -3,115 +3,261 @@
// found in the LICENSE file.
define("mojo/public/js/bindings", [
- "mojo/public/js/router",
"mojo/public/js/core",
-], function(router, core) {
-
- var Router = router.Router;
+ "mojo/public/js/interface_types",
+ "mojo/public/js/router",
+], function(core, types, router) {
- var kProxyProperties = Symbol("proxyProperties");
- var kStubProperties = Symbol("stubProperties");
+ // ---------------------------------------------------------------------------
- // Public proxy class properties that are managed at runtime by the JS
- // bindings. See ProxyBindings below.
- function ProxyProperties(receiver) {
- this.receiver = receiver;
+ function makeRequest(interfacePtr) {
+ var pipe = core.createMessagePipe();
+ interfacePtr.ptr.bind(new types.InterfacePtrInfo(pipe.handle0, 0));
+ return new types.InterfaceRequest(pipe.handle1);
}
- // TODO(hansmuller): remove then after 'Client=' has been removed from Mojom.
- ProxyProperties.prototype.getLocalDelegate = function() {
- return this.local && StubBindings(this.local).delegate;
- }
+ // ---------------------------------------------------------------------------
- // TODO(hansmuller): remove then after 'Client=' has been removed from Mojom.
- ProxyProperties.prototype.setLocalDelegate = function(impl) {
- if (this.local)
- StubBindings(this.local).delegate = impl;
- else
- throw new Error("no stub object");
- }
+ // Operations used to setup/configure an interface pointer. Exposed as the
+ // |ptr| field of generated interface pointer classes.
+ // |ptrInfoOrHandle| could be omitted and passed into bind() later.
+ function InterfacePtrController(interfaceType, ptrInfoOrHandle) {
+ this.version = 0;
- ProxyProperties.prototype.close = function() {
- this.connection.close();
- }
+ this.interfaceType_ = interfaceType;
+ this.router_ = null;
+ this.proxy_ = null;
- // Public stub class properties that are managed at runtime by the JS
- // bindings. See StubBindings below.
- function StubProperties(delegate) {
- this.delegate = delegate;
- }
+ // |router_| is lazily initialized. |handle_| is valid between bind() and
+ // the initialization of |router_|.
+ this.handle_ = null;
- StubProperties.prototype.close = function() {
- this.connection.close();
+ if (ptrInfoOrHandle)
+ this.bind(ptrInfoOrHandle);
}
- // The base class for generated proxy classes.
- function ProxyBase(receiver) {
- this[kProxyProperties] = new ProxyProperties(receiver);
+ InterfacePtrController.prototype.bind = function(ptrInfoOrHandle) {
+ this.reset();
- // TODO(hansmuller): Temporary, for Chrome backwards compatibility.
- if (receiver instanceof Router)
- this.receiver_ = receiver;
- }
+ if (ptrInfoOrHandle instanceof types.InterfacePtrInfo) {
+ this.version = ptrInfoOrHandle.version;
+ this.handle_ = ptrInfoOrHandle.handle;
+ } else {
+ this.handle_ = ptrInfoOrHandle;
+ }
+ };
- // The base class for generated stub classes.
- function StubBase(delegate) {
- this[kStubProperties] = new StubProperties(delegate);
- }
+ InterfacePtrController.prototype.isBound = function() {
+ return this.router_ !== null || this.handle_ !== null;
+ };
- // TODO(hansmuller): remove everything except the connection property doc
- // after 'Client=' has been removed from Mojom.
+ // Although users could just discard the object, reset() closes the pipe
+ // immediately.
+ InterfacePtrController.prototype.reset = function() {
+ this.version = 0;
+ if (this.router_) {
+ this.router_.close();
+ this.router_ = null;
- // Provides access to properties added to a proxy object without risking
- // Mojo interface name collisions. Unless otherwise specified, the initial
- // value of all properties is undefined.
- //
- // ProxyBindings(proxy).connection - The Connection object that links the
- // proxy for a remote Mojo service to an optional local stub for a local
- // service. The value of ProxyBindings(proxy).connection.remote == proxy.
+ this.proxy_ = null;
+ }
+ if (this.handle_) {
+ core.close(this.handle_);
+ this.handle_ = null;
+ }
+ };
+
+ InterfacePtrController.prototype.setConnectionErrorHandler
+ = function(callback) {
+ if (!this.isBound())
+ throw new Error("Cannot set connection error handler if not bound.");
+
+ this.configureProxyIfNecessary_();
+ this.router_.setErrorHandler(callback);
+ };
+
+ InterfacePtrController.prototype.passInterface = function() {
+ var result;
+ if (this.router_) {
+ // TODO(yzshen): Fix Router interface to support extracting handle.
+ result = new types.InterfacePtrInfo(
+ this.router_.connector_.handle_, this.version);
+ this.router_.connector_.handle_ = null;
+ } else {
+ // This also handles the case when this object is not bound.
+ result = new types.InterfacePtrInfo(this.handle_, this.version);
+ this.handle_ = null;
+ }
+
+ this.reset();
+ return result;
+ };
+
+ InterfacePtrController.prototype.getProxy = function() {
+ this.configureProxyIfNecessary_();
+ return this.proxy_;
+ };
+
+ InterfacePtrController.prototype.enableTestingMode = function() {
+ this.configureProxyIfNecessary_();
+ return this.router_.enableTestingMode();
+ };
+
+ InterfacePtrController.prototype.configureProxyIfNecessary_ = function() {
+ if (!this.handle_)
+ return;
+
+ this.router_ = new router.Router(this.handle_);
+ this.handle_ = null;
+ this.router_ .setPayloadValidators([this.interfaceType_.validateResponse]);
+
+ this.proxy_ = new this.interfaceType_.proxyClass(this.router_);
+ };
+
+ // TODO(yzshen): Implement the following methods.
+ // InterfacePtrController.prototype.queryVersion
+ // InterfacePtrController.prototype.requireVersion
+
+ // ---------------------------------------------------------------------------
+
+ // |request| could be omitted and passed into bind() later.
//
- // ProxyBindings(proxy).local - The "local" stub object whose delegate
- // implements the proxy's Mojo client interface.
+ // Example:
//
- // ProxyBindings(proxy).setLocalDelegate(impl) - Sets the implementation
- // delegate of the proxy's client stub object. This is just shorthand
- // for |StubBindings(ProxyBindings(proxy).local).delegate = impl|.
+ // // FooImpl implements mojom.Foo.
+ // function FooImpl() { ... }
+ // FooImpl.prototype.fooMethod1 = function() { ... }
+ // FooImpl.prototype.fooMethod2 = function() { ... }
//
- // ProxyBindings(proxy).getLocalDelegate() - Returns the implementation
- // delegate of the proxy's client stub object. This is just shorthand
- // for |StubBindings(ProxyBindings(proxy).local).delegate|.
+ // var fooPtr = new mojom.FooPtr();
+ // var request = makeRequest(fooPtr);
+ // var binding = new Binding(mojom.Foo, new FooImpl(), request);
+ // fooPtr.fooMethod1();
+ function Binding(interfaceType, impl, requestOrHandle) {
+ this.interfaceType_ = interfaceType;
+ this.impl_ = impl;
+ this.router_ = null;
+ this.stub_ = null;
- function ProxyBindings(proxy) {
- return (proxy instanceof ProxyBase) ? proxy[kProxyProperties] : proxy;
+ if (requestOrHandle)
+ this.bind(requestOrHandle);
}
- // TODO(hansmuller): remove the remote doc after 'Client=' has been
- // removed from Mojom.
+ Binding.prototype.isBound = function() {
+ return this.router_ !== null;
+ };
- // Provides access to properties added to a stub object without risking
- // Mojo interface name collisions. Unless otherwise specified, the initial
- // value of all properties is undefined.
- //
- // StubBindings(stub).delegate - The optional implementation delegate for
- // the Mojo interface stub.
- //
- // StubBindings(stub).connection - The Connection object that links an
- // optional proxy for a remote service to this stub. The value of
- // StubBindings(stub).connection.local == stub.
- //
- // StubBindings(stub).remote - A proxy for the the stub's Mojo client
- // service.
+ Binding.prototype.createInterfacePtrAndBind = function() {
+ var ptr = new this.interfaceType_.ptrClass();
+ // TODO(yzshen): Set the version of the interface pointer.
+ this.bind(makeRequest(ptr));
+ return ptr;
+ }
+
+ Binding.prototype.bind = function(requestOrHandle) {
+ this.close();
+
+ var handle = requestOrHandle instanceof types.InterfaceRequest ?
+ requestOrHandle.handle : requestOrHandle;
+ if (!core.isHandle(handle))
+ return;
+
+ this.stub_ = new this.interfaceType_.stubClass(this.impl_);
+ this.router_ = new router.Router(handle);
+ this.router_.setIncomingReceiver(this.stub_);
+ this.router_ .setPayloadValidators([this.interfaceType_.validateRequest]);
+ };
+
+ Binding.prototype.close = function() {
+ if (!this.isBound())
+ return;
+
+ this.router_.close();
+ this.router_ = null;
+ this.stub_ = null;
+ };
+
+ Binding.prototype.setConnectionErrorHandler
+ = function(callback) {
+ if (!this.isBound())
+ throw new Error("Cannot set connection error handler if not bound.");
+ this.router_.setErrorHandler(callback);
+ };
+
+ Binding.prototype.unbind = function() {
+ if (!this.isBound())
+ return new types.InterfaceRequest(null);
+
+ var result = new types.InterfaceRequest(this.router_.connector_.handle_);
+ this.router_.connector_.handle_ = null;
+ this.close();
+ return result;
+ };
+
+ Binding.prototype.enableTestingMode = function() {
+ return this.router_.enableTestingMode();
+ };
+
+ // ---------------------------------------------------------------------------
- function StubBindings(stub) {
- return stub instanceof StubBase ? stub[kStubProperties] : stub;
+ function BindingSetEntry(bindingSet, interfaceType, impl, requestOrHandle,
+ bindingId) {
+ this.bindingSet_ = bindingSet;
+ this.bindingId_ = bindingId;
+ this.binding_ = new Binding(interfaceType, impl, requestOrHandle);
+
+ this.binding_.setConnectionErrorHandler(function() {
+ this.bindingSet_.onConnectionError(bindingId);
+ }.bind(this));
+ }
+
+ BindingSetEntry.prototype.close = function() {
+ this.binding_.close();
+ };
+
+ function BindingSet(interfaceType) {
+ this.interfaceType_ = interfaceType;
+ this.nextBindingId_ = 0;
+ this.bindings_ = new Map();
+ this.errorHandler_ = null;
}
+ BindingSet.prototype.isEmpty = function() {
+ return this.bindings_.size == 0;
+ };
+
+ BindingSet.prototype.addBinding = function(impl, requestOrHandle) {
+ this.bindings_.set(
+ this.nextBindingId_,
+ new BindingSetEntry(this, this.interfaceType_, impl, requestOrHandle,
+ this.nextBindingId_));
+ ++this.nextBindingId_;
+ };
+
+ BindingSet.prototype.closeAllBindings = function() {
+ for (var entry of this.bindings_.values())
+ entry.close();
+ this.bindings_.clear();
+ };
+
+ BindingSet.prototype.setConnectionErrorHandler = function(callback) {
+ this.errorHandler_ = callback;
+ };
+
+ BindingSet.prototype.onConnectionError = function(bindingId) {
+ this.bindings_.delete(bindingId);
+
+ if (this.errorHandler_)
+ this.errorHandler_();
+ };
+
var exports = {};
- exports.EmptyProxy = ProxyBase;
- exports.EmptyStub = StubBase;
- exports.ProxyBase = ProxyBase;
- exports.ProxyBindings = ProxyBindings;
- exports.StubBase = StubBase;
- exports.StubBindings = StubBindings;
+ exports.InterfacePtrInfo = types.InterfacePtrInfo;
+ exports.InterfaceRequest = types.InterfaceRequest;
+ exports.makeRequest = makeRequest;
+ exports.InterfacePtrController = InterfacePtrController;
+ exports.Binding = Binding;
+ exports.BindingSet = BindingSet;
+
return exports;
});
diff --git a/chromium/mojo/public/js/codec.js b/chromium/mojo/public/js/codec.js
index 70df7585599..06a62436c17 100644
--- a/chromium/mojo/public/js/codec.js
+++ b/chromium/mojo/public/js/codec.js
@@ -3,9 +3,10 @@
// found in the LICENSE file.
define("mojo/public/js/codec", [
- "mojo/public/js/unicode",
"mojo/public/js/buffer",
-], function(unicode, buffer) {
+ "mojo/public/js/interface_types",
+ "mojo/public/js/unicode",
+], function(buffer, types, unicode) {
var kErrorUnsigned = "Passing negative value to unsigned";
var kErrorArray = "Passing non Array for array type";
@@ -802,33 +803,54 @@ define("mojo/public/js/codec", [
NullableHandle.encode = Handle.encode;
- function Interface() {
+ function Interface(cls) {
+ this.cls = cls;
}
- Interface.encodedSize = 8;
+ Interface.prototype.encodedSize = 8;
- Interface.decode = function(decoder) {
- var handle = decoder.decodeHandle();
- // Ignore the version field for now.
- decoder.readUint32();
+ Interface.prototype.decode = function(decoder) {
+ var interfacePtrInfo = new types.InterfacePtrInfo(
+ decoder.decodeHandle(), decoder.readUint32());
+ var interfacePtr = new this.cls();
+ interfacePtr.ptr.bind(interfacePtrInfo);
+ return interfacePtr;
+ };
- return handle;
+ Interface.prototype.encode = function(encoder, val) {
+ var interfacePtrInfo =
+ val ? val.ptr.passInterface() : new types.InterfacePtrInfo(null, 0);
+ encoder.encodeHandle(interfacePtrInfo.handle);
+ encoder.writeUint32(interfacePtrInfo.version);
};
- Interface.encode = function(encoder, val) {
- encoder.encodeHandle(val);
- // Set the version field to 0 for now.
- encoder.writeUint32(0);
+ function NullableInterface(cls) {
+ Interface.call(this, cls);
+ }
+
+ NullableInterface.prototype = Object.create(Interface.prototype);
+
+ function InterfaceRequest() {
+ }
+
+ InterfaceRequest.encodedSize = 4;
+
+ InterfaceRequest.decode = function(decoder) {
+ return new types.InterfaceRequest(decoder.decodeHandle());
+ };
+
+ InterfaceRequest.encode = function(encoder, val) {
+ encoder.encodeHandle(val ? val.handle : null);
};
- function NullableInterface() {
+ function NullableInterfaceRequest() {
}
- NullableInterface.encodedSize = Interface.encodedSize;
+ NullableInterfaceRequest.encodedSize = InterfaceRequest.encodedSize;
- NullableInterface.decode = Interface.decode;
+ NullableInterfaceRequest.decode = InterfaceRequest.decode;
- NullableInterface.encode = Interface.encode;
+ NullableInterfaceRequest.encode = InterfaceRequest.encode;
function MapOf(keyClass, valueClass) {
this.keyClass = keyClass;
@@ -888,6 +910,8 @@ define("mojo/public/js/codec", [
exports.NullableHandle = NullableHandle;
exports.Interface = Interface;
exports.NullableInterface = NullableInterface;
+ exports.InterfaceRequest = InterfaceRequest;
+ exports.NullableInterfaceRequest = NullableInterfaceRequest;
exports.MapOf = MapOf;
exports.NullableMapOf = NullableMapOf;
return exports;
diff --git a/chromium/mojo/public/js/connection.js b/chromium/mojo/public/js/connection.js
deleted file mode 100644
index 1ac88ed9e63..00000000000
--- a/chromium/mojo/public/js/connection.js
+++ /dev/null
@@ -1,196 +0,0 @@
-// Copyright 2014 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.
-
-define("mojo/public/js/connection", [
- "mojo/public/js/bindings",
- "mojo/public/js/connector",
- "mojo/public/js/core",
- "mojo/public/js/router",
-], function(bindings, connector, core, router) {
-
- var Router = router.Router;
- var EmptyProxy = bindings.EmptyProxy;
- var EmptyStub = bindings.EmptyStub;
- var ProxyBindings = bindings.ProxyBindings;
- var StubBindings = bindings.StubBindings;
- var TestConnector = connector.TestConnector;
- var TestRouter = router.TestRouter;
-
- // TODO(hansmuller): the proxy receiver_ property should be receiver$
-
- function BaseConnection(localStub, remoteProxy, router) {
- this.router_ = router;
- this.local = localStub;
- this.remote = remoteProxy;
-
- this.router_.setIncomingReceiver(localStub);
- this.router_.setErrorHandler(function() {
- if (StubBindings(this.local) &&
- StubBindings(this.local).connectionErrorHandler)
- StubBindings(this.local).connectionErrorHandler();
- }.bind(this));
- if (this.remote)
- this.remote.receiver_ = router;
-
- // Validate incoming messages: remote responses and local requests.
- var validateRequest = localStub && localStub.validator;
- var validateResponse = remoteProxy && remoteProxy.validator;
- var payloadValidators = [];
- if (validateRequest)
- payloadValidators.push(validateRequest);
- if (validateResponse)
- payloadValidators.push(validateResponse);
- this.router_.setPayloadValidators(payloadValidators);
- }
-
- BaseConnection.prototype.close = function() {
- this.router_.close();
- this.router_ = null;
- this.local = null;
- this.remote = null;
- };
-
- BaseConnection.prototype.encounteredError = function() {
- return this.router_.encounteredError();
- };
-
- function Connection(
- handle, localFactory, remoteFactory, routerFactory, connectorFactory) {
- var routerClass = routerFactory || Router;
- var router = new routerClass(handle, connectorFactory);
- var remoteProxy = remoteFactory && new remoteFactory(router);
- var localStub = localFactory && new localFactory(remoteProxy);
- BaseConnection.call(this, localStub, remoteProxy, router);
- }
-
- Connection.prototype = Object.create(BaseConnection.prototype);
-
- // The TestConnection subclass is only intended to be used in unit tests.
- function TestConnection(handle, localFactory, remoteFactory) {
- Connection.call(this,
- handle,
- localFactory,
- remoteFactory,
- TestRouter,
- TestConnector);
- }
-
- TestConnection.prototype = Object.create(Connection.prototype);
-
- // Return a handle for a message pipe that's connected to a proxy
- // for remoteInterface. Used by generated code for outgoing interface&
- // (request) parameters: the caller is given the generated proxy via
- // |proxyCallback(proxy)| and the generated code sends the handle
- // returned by this function.
- function bindProxy(proxyCallback, remoteInterface) {
- var messagePipe = core.createMessagePipe();
- if (messagePipe.result != core.RESULT_OK)
- throw new Error("createMessagePipe failed " + messagePipe.result);
-
- var proxy = new remoteInterface.proxyClass;
- var router = new Router(messagePipe.handle0);
- var connection = new BaseConnection(undefined, proxy, router);
- ProxyBindings(proxy).connection = connection;
- if (proxyCallback)
- proxyCallback(proxy);
-
- return messagePipe.handle1;
- }
-
- // Return a handle and proxy for a message pipe that's connected to a proxy
- // for remoteInterface. Used by generated code for outgoing interface&
- // (request) parameters
- function getProxy(remoteInterface) {
- var messagePipe = core.createMessagePipe();
- if (messagePipe.result != core.RESULT_OK)
- throw new Error("createMessagePipe failed " + messagePipe.result);
-
- var proxy = new remoteInterface.proxyClass;
- var router = new Router(messagePipe.handle0);
- var connection = new BaseConnection(undefined, proxy, router);
- ProxyBindings(proxy).connection = connection;
-
- return {
- requestHandle: messagePipe.handle1,
- proxy: proxy
- };
- }
-
- // Return a handle for a message pipe that's connected to a stub for
- // localInterface. Used by generated code for outgoing interface
- // parameters: the caller is given the generated stub via
- // |stubCallback(stub)| and the generated code sends the handle
- // returned by this function. The caller is responsible for managing
- // the lifetime of the stub and for setting it's implementation
- // delegate with: StubBindings(stub).delegate = myImpl;
- function bindImpl(stubCallback, localInterface) {
- var messagePipe = core.createMessagePipe();
- if (messagePipe.result != core.RESULT_OK)
- throw new Error("createMessagePipe failed " + messagePipe.result);
-
- var stub = new localInterface.stubClass;
- var router = new Router(messagePipe.handle0);
- var connection = new BaseConnection(stub, undefined, router);
- StubBindings(stub).connection = connection;
- if (stubCallback)
- stubCallback(stub);
-
- return messagePipe.handle1;
- }
-
- // Return a remoteInterface proxy for handle. Used by generated code
- // for converting incoming interface parameters to proxies.
- function bindHandleToProxy(handle, remoteInterface) {
- if (!core.isHandle(handle))
- throw new Error("Not a handle " + handle);
-
- var proxy = new remoteInterface.proxyClass;
- var router = new Router(handle);
- var connection = new BaseConnection(undefined, proxy, router);
- ProxyBindings(proxy).connection = connection;
- return proxy;
- }
-
- // Return a localInterface stub for handle. Used by generated code
- // for converting incoming interface& request parameters to localInterface
- // stubs. The caller can specify the stub's implementation of localInterface
- // like this: StubBindings(stub).delegate = myStubImpl.
- function bindHandleToStub(handle, localInterface) {
- if (!core.isHandle(handle))
- throw new Error("Not a handle " + handle);
-
- var stub = new localInterface.stubClass;
- var router = new Router(handle);
- var connection = new BaseConnection(stub, undefined, router);
- StubBindings(stub).connection = connection;
- return stub;
- }
-
- /**
- * Creates a messape pipe and links one end of the pipe to the given object.
- * @param {!Object} obj The object to create a handle for. Must be a subclass
- * of an auto-generated stub class.
- * @return {!MojoHandle} The other (not yet connected) end of the message
- * pipe.
- */
- function bindStubDerivedImpl(obj) {
- var pipe = core.createMessagePipe();
- var router = new Router(pipe.handle0);
- var connection = new BaseConnection(obj, undefined, router);
- obj.connection = connection;
- return pipe.handle1;
- }
-
- var exports = {};
- exports.Connection = Connection;
- exports.TestConnection = TestConnection;
-
- exports.bindProxy = bindProxy;
- exports.getProxy = getProxy;
- exports.bindImpl = bindImpl;
- exports.bindHandleToProxy = bindHandleToProxy;
- exports.bindHandleToStub = bindHandleToStub;
- exports.bindStubDerivedImpl = bindStubDerivedImpl;
- return exports;
-});
diff --git a/chromium/mojo/public/js/connector.js b/chromium/mojo/public/js/connector.js
index 674f36b3210..ee16be80ce6 100644
--- a/chromium/mojo/public/js/connector.js
+++ b/chromium/mojo/public/js/connector.js
@@ -82,6 +82,12 @@ define("mojo/public/js/connector", [
return this.error_;
};
+ Connector.prototype.waitForNextMessageForTesting = function() {
+ var wait = core.wait(this.handle_, core.HANDLE_SIGNAL_READABLE,
+ core.DEADLINE_INDEFINITE);
+ this.readMore_(wait.result);
+ };
+
Connector.prototype.readMore_ = function(result) {
for (;;) {
var read = core.readMessage(this.handle_,
@@ -98,29 +104,12 @@ define("mojo/public/js/connector", [
}
var messageBuffer = new buffer.Buffer(read.buffer);
var message = new codec.Message(messageBuffer, read.handles);
- if (this.incomingReceiver_) {
- this.incomingReceiver_.accept(message);
- }
+ if (this.incomingReceiver_)
+ this.incomingReceiver_.accept(message);
}
};
- // The TestConnector subclass is only intended to be used in unit tests. It
- // doesn't automatically listen for input messages. Instead, you need to
- // call waitForNextMessage to block and wait for the next incoming message.
- function TestConnector(handle) {
- Connector.call(this, handle);
- }
-
- TestConnector.prototype = Object.create(Connector.prototype);
-
- TestConnector.prototype.waitForNextMessage = function() {
- var wait = core.wait(this.handle_, core.HANDLE_SIGNAL_READABLE,
- core.DEADLINE_INDEFINITE);
- this.readMore_(wait.result);
- }
-
var exports = {};
exports.Connector = Connector;
- exports.TestConnector = TestConnector;
return exports;
});
diff --git a/chromium/mojo/public/js/constants.cc b/chromium/mojo/public/js/constants.cc
index d29f5cb3703..7c7b64e4198 100644
--- a/chromium/mojo/public/js/constants.cc
+++ b/chromium/mojo/public/js/constants.cc
@@ -9,10 +9,10 @@ namespace mojo {
const char kBindingsModuleName[] = "mojo/public/js/bindings";
const char kBufferModuleName[] = "mojo/public/js/buffer";
const char kCodecModuleName[] = "mojo/public/js/codec";
-const char kConnectionModuleName[] = "mojo/public/js/connection";
const char kConnectorModuleName[] = "mojo/public/js/connector";
-const char kUnicodeModuleName[] = "mojo/public/js/unicode";
+const char kInterfaceTypesModuleName[] = "mojo/public/js/interface_types";
const char kRouterModuleName[] = "mojo/public/js/router";
+const char kUnicodeModuleName[] = "mojo/public/js/unicode";
const char kValidatorModuleName[] = "mojo/public/js/validator";
} // namespace mojo
diff --git a/chromium/mojo/public/js/constants.h b/chromium/mojo/public/js/constants.h
index de75a90cf93..b8baa985dc6 100644
--- a/chromium/mojo/public/js/constants.h
+++ b/chromium/mojo/public/js/constants.h
@@ -11,10 +11,10 @@ namespace mojo {
extern const char kBindingsModuleName[];
extern const char kBufferModuleName[];
extern const char kCodecModuleName[];
-extern const char kConnectionModuleName[];
extern const char kConnectorModuleName[];
-extern const char kUnicodeModuleName[];
+extern const char kInterfaceTypesModuleName[];
extern const char kRouterModuleName[];
+extern const char kUnicodeModuleName[];
extern const char kValidatorModuleName[];
} // namespace mojo
diff --git a/chromium/mojo/public/js/interface_types.js b/chromium/mojo/public/js/interface_types.js
new file mode 100644
index 00000000000..01ea2d1dd46
--- /dev/null
+++ b/chromium/mojo/public/js/interface_types.js
@@ -0,0 +1,52 @@
+// Copyright 2016 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.
+
+define("mojo/public/js/interface_types", [
+ "mojo/public/js/core",
+], function(core) {
+
+ // ---------------------------------------------------------------------------
+
+ function InterfacePtrInfo(handle, version) {
+ this.handle = handle;
+ this.version = version;
+ }
+
+ InterfacePtrInfo.prototype.isValid = function() {
+ return core.isHandle(this.handle);
+ };
+
+ InterfacePtrInfo.prototype.close = function() {
+ if (!this.isValid())
+ return;
+
+ core.close(this.handle);
+ this.handle = null;
+ this.version = 0;
+ };
+
+ // ---------------------------------------------------------------------------
+
+ function InterfaceRequest(handle) {
+ this.handle = handle;
+ }
+
+ InterfaceRequest.prototype.isValid = function() {
+ return core.isHandle(this.handle);
+ };
+
+ InterfaceRequest.prototype.close = function() {
+ if (!this.isValid())
+ return;
+
+ core.close(this.handle);
+ this.handle = null;
+ };
+
+ var exports = {};
+ exports.InterfacePtrInfo = InterfacePtrInfo;
+ exports.InterfaceRequest = InterfaceRequest;
+
+ return exports;
+});
diff --git a/chromium/mojo/public/js/router.js b/chromium/mojo/public/js/router.js
index e3db0a6a788..9db12205219 100644
--- a/chromium/mojo/public/js/router.js
+++ b/chromium/mojo/public/js/router.js
@@ -3,11 +3,12 @@
// found in the LICENSE file.
define("mojo/public/js/router", [
+ "console",
"mojo/public/js/codec",
"mojo/public/js/core",
"mojo/public/js/connector",
"mojo/public/js/validator",
-], function(codec, core, connector, validator) {
+], function(console, codec, core, connector, validator) {
var Connector = connector.Connector;
var MessageReader = codec.MessageReader;
@@ -24,6 +25,7 @@ define("mojo/public/js/router", [
this.nextRequestID_ = 0;
this.completers_ = new Map();
this.payloadValidators_ = [];
+ this.testingController_ = null;
this.connector_.setIncomingReceiver({
accept: this.handleIncomingMessage_.bind(this),
@@ -36,6 +38,7 @@ define("mojo/public/js/router", [
Router.prototype.close = function() {
this.completers_.clear(); // Drop any responders.
this.connector_.close();
+ this.testingController_ = null;
};
Router.prototype.accept = function(message) {
@@ -81,6 +84,11 @@ define("mojo/public/js/router", [
return this.connector_.encounteredError();
};
+ Router.prototype.enableTestingMode = function() {
+ this.testingController_ = new RouterTestingController(this.connector_);
+ return this.testingController_;
+ };
+
Router.prototype.handleIncomingMessage_ = function(message) {
var noError = validator.validationError.NONE;
var messageValidator = new Validator(message);
@@ -95,6 +103,9 @@ define("mojo/public/js/router", [
};
Router.prototype.handleValidIncomingMessage_ = function(message) {
+ if (this.testingController_)
+ return;
+
if (message.expectsResponse()) {
if (this.incomingReceiver_) {
this.incomingReceiver_.acceptWithResponder(message, this);
@@ -107,17 +118,32 @@ define("mojo/public/js/router", [
var reader = new MessageReader(message);
var requestID = reader.requestID;
var completer = this.completers_.get(requestID);
- this.completers_.delete(requestID);
- completer.resolve(message);
+ if (completer) {
+ this.completers_.delete(requestID);
+ completer.resolve(message);
+ } else {
+ console.log("Unexpected response with request ID: " + requestID);
+ }
} else {
if (this.incomingReceiver_)
this.incomingReceiver_.accept(message);
}
- }
+ };
Router.prototype.handleInvalidIncomingMessage_ = function(message, error) {
- this.close();
- }
+ if (!this.testingController_) {
+ // TODO(yzshen): Consider notifying the embedder.
+ // TODO(yzshen): This should also trigger connection error handler.
+ // Consider making accept() return a boolean and let the connector deal
+ // with this, as the C++ code does.
+ console.log("Invalid message: " + validator.validationError[error]);
+
+ this.close();
+ return;
+ }
+
+ this.testingController_.onInvalidIncomingMessage(error);
+ };
Router.prototype.handleConnectionError_ = function(result) {
this.completers_.forEach(function(value) {
@@ -128,25 +154,30 @@ define("mojo/public/js/router", [
this.close();
};
- // The TestRouter subclass is only intended to be used in unit tests.
- // It defeats valid message handling and delgates invalid message handling.
+ // The RouterTestingController is used in unit tests. It defeats valid message
+ // handling and delgates invalid message handling.
- function TestRouter(handle, connectorFactory) {
- Router.call(this, handle, connectorFactory);
+ function RouterTestingController(connector) {
+ this.connector_ = connector;
+ this.invalidMessageHandler_ = null;
}
- TestRouter.prototype = Object.create(Router.prototype);
+ RouterTestingController.prototype.waitForNextMessage = function() {
+ this.connector_.waitForNextMessageForTesting();
+ };
- TestRouter.prototype.handleValidIncomingMessage_ = function() {
+ RouterTestingController.prototype.setInvalidIncomingMessageHandler =
+ function(callback) {
+ this.invalidMessageHandler_ = callback;
};
- TestRouter.prototype.handleInvalidIncomingMessage_ =
- function(message, error) {
- this.validationErrorHandler(error);
- };
+ RouterTestingController.prototype.onInvalidIncomingMessage =
+ function(error) {
+ if (this.invalidMessageHandler_)
+ this.invalidMessageHandler_(error);
+ };
var exports = {};
exports.Router = Router;
- exports.TestRouter = TestRouter;
return exports;
});
diff --git a/chromium/mojo/public/js/validation_unittests.js b/chromium/mojo/public/js/validation_unittests.js
index 0eb0e4dc5ac..b4744b9d7fb 100644
--- a/chromium/mojo/public/js/validation_unittests.js
+++ b/chromium/mojo/public/js/validation_unittests.js
@@ -7,25 +7,21 @@ define([
"file",
"gin/test/expect",
"mojo/public/interfaces/bindings/tests/validation_test_interfaces.mojom",
+ "mojo/public/js/bindings",
"mojo/public/js/buffer",
"mojo/public/js/codec",
- "mojo/public/js/connection",
- "mojo/public/js/connector",
"mojo/public/js/core",
"mojo/public/js/test/validation_test_input_parser",
- "mojo/public/js/router",
"mojo/public/js/validator",
], function(console,
file,
expect,
testInterface,
+ bindings,
buffer,
codec,
- connection,
- connector,
core,
parser,
- router,
validator) {
var noError = validator.validationError.NONE;
@@ -274,18 +270,23 @@ define([
testInterface.BoundsCheckTestInterface.validateResponse]);
}
- function testIntegratedMessageValidation(testFilesPattern,
- localFactory,
- remoteFactory) {
+ function testIntegratedMessageValidation(testFilesPattern, endpoint) {
var testFiles = getMessageTestFiles(testFilesPattern);
expect(testFiles.length).toBeGreaterThan(0);
var testMessagePipe = core.createMessagePipe();
expect(testMessagePipe.result).toBe(core.RESULT_OK);
- var testConnection = new connection.TestConnection(
- testMessagePipe.handle1, localFactory, remoteFactory);
+
+ endpoint.bind(testMessagePipe.handle1);
+ var testingController = endpoint.enableTestingMode();
+
+ var validationError;
+ testingController.setInvalidIncomingMessageHandler(function(error) {
+ validationError = error;
+ });
for (var i = 0; i < testFiles.length; i++) {
+ validationError = noError;
var testMessage = readTestMessage(testFiles[i]);
var handles = new Array(testMessage.handleCount);
@@ -296,42 +297,32 @@ define([
core.WRITE_MESSAGE_FLAG_NONE);
expect(writeMessageValue).toBe(core.RESULT_OK);
- var validationError = noError;
- testConnection.router_.validationErrorHandler = function(err) {
- validationError = err;
- };
-
- testConnection.router_.connector_.waitForNextMessage();
+ testingController.waitForNextMessage();
checkValidationResult(testFiles[i], validationError);
}
- testConnection.close();
expect(core.close(testMessagePipe.handle0)).toBe(core.RESULT_OK);
}
function testIntegratedMessageHeaderValidation() {
testIntegratedMessageValidation(
"integration_msghdr",
- testInterface.IntegrationTestInterface.stubClass,
- undefined);
+ new bindings.Binding(testInterface.IntegrationTestInterface, {}));
testIntegratedMessageValidation(
"integration_msghdr",
- undefined,
- testInterface.IntegrationTestInterface.proxyClass);
+ new testInterface.IntegrationTestInterfacePtr().ptr);
}
function testIntegratedRequestMessageValidation() {
testIntegratedMessageValidation(
"integration_intf_rqst",
- testInterface.IntegrationTestInterface.stubClass,
- undefined);
+ new bindings.Binding(testInterface.IntegrationTestInterface, {}));
}
function testIntegratedResponseMessageValidation() {
testIntegratedMessageValidation(
"integration_intf_resp",
- undefined,
- testInterface.IntegrationTestInterface.proxyClass);
+ new testInterface.IntegrationTestInterfacePtr().ptr);
}
expect(checkTestMessageParser()).toBeNull();
diff --git a/chromium/mojo/public/js/validator.js b/chromium/mojo/public/js/validator.js
index a3f4f005f5c..9f2b7cf4db1 100644
--- a/chromium/mojo/public/js/validator.js
+++ b/chromium/mojo/public/js/validator.js
@@ -42,12 +42,18 @@ define("mojo/public/js/validator", [
}
function isInterfaceClass(cls) {
- return cls === codec.Interface || cls === codec.NullableInterface;
+ return cls instanceof codec.Interface;
+ }
+
+ function isInterfaceRequestClass(cls) {
+ return cls === codec.InterfaceRequest ||
+ cls === codec.NullableInterfaceRequest;
}
function isNullable(type) {
return type === codec.NullableString || type === codec.NullableHandle ||
type === codec.NullableInterface ||
+ type === codec.NullableInterfaceRequest ||
type instanceof codec.NullableArrayOf ||
type instanceof codec.NullablePointerTo;
}
@@ -103,7 +109,7 @@ define("mojo/public/js/validator", [
return true;
};
- Validator.prototype.validateEnum = function(offset, enumClass, nullable) {
+ Validator.prototype.validateEnum = function(offset, enumClass) {
// Note: Assumes that enums are always 32 bits! But this matches
// mojom::generate::pack::PackedField::GetSizeForKind, so it should be okay.
var value = this.message.buffer.getInt32(offset);
@@ -119,6 +125,7 @@ define("mojo/public/js/validator", [
if (!this.claimHandle(index))
return validationError.ILLEGAL_HANDLE;
+
return validationError.NONE;
};
@@ -126,6 +133,10 @@ define("mojo/public/js/validator", [
return this.validateHandle(offset, nullable);
};
+ Validator.prototype.validateInterfaceRequest = function(offset, nullable) {
+ return this.validateHandle(offset, nullable);
+ };
+
Validator.prototype.validateStructHeader = function(offset, minNumBytes) {
if (!codec.isAligned(offset))
return validationError.MISALIGNED_OBJECT;
@@ -372,6 +383,9 @@ define("mojo/public/js/validator", [
if (isInterfaceClass(elementType))
return this.validateInterfaceElements(
elementsOffset, numElements, nullable);
+ if (isInterfaceRequestClass(elementType))
+ return this.validateInterfaceRequestElements(
+ elementsOffset, numElements, nullable);
if (isStringClass(elementType))
return this.validateArrayElements(
elementsOffset, numElements, codec.Uint8, nullable, [0], 0);
@@ -383,7 +397,8 @@ define("mojo/public/js/validator", [
elementsOffset, numElements, elementType.cls, nullable,
expectedDimensionSizes, currentDimension + 1);
if (isEnumClass(elementType))
- return this.validateEnum(elementsOffset, elementType.cls, nullable);
+ return this.validateEnumElements(elementsOffset, numElements,
+ elementType.cls);
return validationError.NONE;
};
@@ -406,7 +421,7 @@ define("mojo/public/js/validator", [
Validator.prototype.validateInterfaceElements =
function(offset, numElements, nullable) {
- var elementSize = codec.Interface.encodedSize;
+ var elementSize = codec.Interface.prototype.encodedSize;
for (var i = 0; i < numElements; i++) {
var elementOffset = offset + i * elementSize;
var err = this.validateInterface(elementOffset, nullable);
@@ -416,6 +431,18 @@ define("mojo/public/js/validator", [
return validationError.NONE;
};
+ Validator.prototype.validateInterfaceRequestElements =
+ function(offset, numElements, nullable) {
+ var elementSize = codec.InterfaceRequest.encodedSize;
+ for (var i = 0; i < numElements; i++) {
+ var elementOffset = offset + i * elementSize;
+ var err = this.validateInterfaceRequest(elementOffset, nullable);
+ if (err != validationError.NONE)
+ return err;
+ }
+ return validationError.NONE;
+ };
+
// The elementClass parameter is the element type of the element arrays.
Validator.prototype.validateArrayElements =
function(offset, numElements, elementClass, nullable,
@@ -445,6 +472,18 @@ define("mojo/public/js/validator", [
return validationError.NONE;
};
+ Validator.prototype.validateEnumElements =
+ function(offset, numElements, enumClass) {
+ var elementSize = codec.Enum.prototype.encodedSize;
+ for (var i = 0; i < numElements; i++) {
+ var elementOffset = offset + i * elementSize;
+ var err = this.validateEnum(elementOffset, enumClass);
+ if (err != validationError.NONE)
+ return err;
+ }
+ return validationError.NONE;
+ };
+
var exports = {};
exports.validationError = validationError;
exports.Validator = Validator;
diff --git a/chromium/mojo/public/tools/bindings/chromium_bindings_configuration.gni b/chromium/mojo/public/tools/bindings/chromium_bindings_configuration.gni
index 7d270fb4e65..5ebd05216f6 100644
--- a/chromium/mojo/public/tools/bindings/chromium_bindings_configuration.gni
+++ b/chromium/mojo/public/tools/bindings/chromium_bindings_configuration.gni
@@ -6,6 +6,9 @@ _typemap_imports = [
"//ash/public/interfaces/typemaps.gni",
"//cc/ipc/typemaps.gni",
"//chrome/browser/media/router/mojo/typemaps.gni",
+ "//chrome/common/extensions/typemaps.gni",
+ "//chrome/common/importer/typemaps.gni",
+ "//chrome/typemaps.gni",
"//components/arc/common/typemaps.gni",
"//components/metrics/public/cpp/typemaps.gni",
"//components/typemaps.gni",
@@ -14,7 +17,9 @@ _typemap_imports = [
"//content/common/typemaps.gni",
"//content/public/common/typemaps.gni",
"//device/bluetooth/public/interfaces/typemaps.gni",
+ "//device/gamepad/public/interfaces/typemaps.gni",
"//device/generic_sensor/public/interfaces/typemaps.gni",
+ "//device/usb/public/interfaces/typemaps.gni",
"//gpu/ipc/common/typemaps.gni",
"//media/capture/mojo/typemaps.gni",
"//media/mojo/interfaces/typemaps.gni",
@@ -22,7 +27,9 @@ _typemap_imports = [
"//mojo/public/cpp/bindings/tests/chromium_typemaps.gni",
"//net/interfaces/typemaps.gni",
"//services/service_manager/public/cpp/typemaps.gni",
+ "//services/ui/gpu/interfaces/typemaps.gni",
"//services/ui/public/interfaces/display/typemaps.gni",
+ "//services/ui/public/interfaces/ime/typemaps.gni",
"//services/video_capture/public/interfaces/typemaps.gni",
"//skia/public/interfaces/typemaps.gni",
"//third_party/WebKit/public/public_typemaps.gni",
diff --git a/chromium/mojo/public/tools/bindings/generators/cpp_templates/enum_macros.tmpl b/chromium/mojo/public/tools/bindings/generators/cpp_templates/enum_macros.tmpl
index 087f225517d..9400ca77041 100644
--- a/chromium/mojo/public/tools/bindings/generators/cpp_templates/enum_macros.tmpl
+++ b/chromium/mojo/public/tools/bindings/generators/cpp_templates/enum_macros.tmpl
@@ -45,7 +45,7 @@ inline bool IsKnownEnumValue({{enum_name}} value) {
{%- set enum_name = enum|get_name_for_kind(flatten_nested_kind=True) %}
struct {{enum_name}}_Data {
public:
- static bool const kIsExtensible = {% if enum.extensible %}true{% else %}false{% endif %};
+ static bool constexpr kIsExtensible = {% if enum.extensible %}true{% else %}false{% endif %};
static bool IsKnownValue(int32_t value) {
{%- if enum.fields %}
diff --git a/chromium/mojo/public/tools/bindings/generators/cpp_templates/interface_declaration.tmpl b/chromium/mojo/public/tools/bindings/generators/cpp_templates/interface_declaration.tmpl
index 091fe09a3ba..7f6497475a6 100644
--- a/chromium/mojo/public/tools/bindings/generators/cpp_templates/interface_declaration.tmpl
+++ b/chromium/mojo/public/tools/bindings/generators/cpp_templates/interface_declaration.tmpl
@@ -13,9 +13,9 @@ class {{export_attribute}} {{interface.name}}
: public {{interface.name}}InterfaceBase {
public:
static const char Name_[];
- static const uint32_t Version_ = {{interface.version}};
- static const bool PassesAssociatedKinds_ = {% if interface|passes_associated_kinds %}true{% else %}false{% endif %};
- static const bool HasSyncMethods_ = {% if interface|has_sync_methods %}true{% else %}false{% endif %};
+ static constexpr uint32_t Version_ = {{interface.version}};
+ static constexpr bool PassesAssociatedKinds_ = {% if interface|passes_associated_kinds %}true{% else %}false{% endif %};
+ static constexpr bool HasSyncMethods_ = {% if interface|has_sync_methods %}true{% else %}false{% endif %};
using Proxy_ = {{interface.name}}Proxy;
@@ -29,6 +29,13 @@ class {{export_attribute}} {{interface.name}}
using ResponseValidator_ = mojo::PassThroughFilter;
{%- endif %}
+{#--- Metadata #}
+ enum MethodMinVersions : uint32_t {
+{%- for method in interface.methods %}
+ k{{method.name}}MinVersion = {{method.min_version|default(0, true)}},
+{%- endfor %}
+ };
+
{#--- Enums #}
{%- for enum in interface.enums %}
using {{enum.name}} = {{enum|get_name_for_kind(flatten_nested_kind=True)}};
@@ -36,11 +43,7 @@ class {{export_attribute}} {{interface.name}}
{#--- Constants #}
{%- for constant in interface.constants %}
-{%- if constant.kind|is_integral_kind %}
- static const {{constant.kind|cpp_pod_type}} {{constant.name}} = {{constant|constant_value}};
-{%- else %}
- static const {{constant.kind|cpp_pod_type}} {{constant.name}};
-{%- endif %}
+ static {{constant|format_constant_declaration(nested=True)}};
{%- endfor %}
{#--- Methods #}
@@ -55,8 +58,8 @@ class {{export_attribute}} {{interface.name}}
{%- endif %}
using {{method.name}}Callback = {{interface_macros.declare_callback(method,
- for_blink, use_new_wrapper_types)}};
+ for_blink, use_once_callback)}};
{%- endif %}
- virtual void {{method.name}}({{interface_macros.declare_request_params("", method)}}) = 0;
+ virtual void {{method.name}}({{interface_macros.declare_request_params("", method, use_once_callback)}}) = 0;
{%- endfor %}
};
diff --git a/chromium/mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl b/chromium/mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl
index a60eea39f0d..97044cafabd 100644
--- a/chromium/mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl
+++ b/chromium/mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl
@@ -42,14 +42,11 @@ std::move(p_{{param.name}})
{#--- Begin #}
const char {{class_name}}::Name_[] = "{{namespace_as_string}}::{{class_name}}";
-const uint32_t {{class_name}}::Version_;
{#--- Constants #}
{%- for constant in interface.constants %}
-{%- if constant.kind|is_integral_kind %}
-const {{constant.kind|cpp_pod_type}} {{interface.name}}::{{constant.name}};
-{%- else %}
-const {{constant.kind|cpp_pod_type}} {{interface.name}}::{{constant.name}} = {{constant|constant_value}};
+{%- if constant.kind|is_string_kind %}
+const char {{interface.name}}::{{constant.name}}[] = {{constant|constant_value}};
{%- endif %}
{%- endfor %}
@@ -115,9 +112,13 @@ class {{class_name}}_{{method.name}}_ForwardToCallback
: public mojo::MessageReceiver {
public:
{{class_name}}_{{method.name}}_ForwardToCallback(
+{%- if use_once_callback %}
+ {{class_name}}::{{method.name}}Callback callback,
+{%- else %}
const {{class_name}}::{{method.name}}Callback& callback,
+{%- endif %}
scoped_refptr<mojo::AssociatedGroupController> group_controller)
- : callback_(callback),
+ : callback_(std::move(callback)),
serialization_context_(std::move(group_controller)) {
}
bool Accept(mojo::Message* message) override;
@@ -137,7 +138,7 @@ bool {{class_name}}_{{method.name}}_ForwardToCallback::Accept(
"&serialization_context_", desc)}}
if (!callback_.is_null()) {
mojo::internal::MessageDispatchContext context(message);
- callback_.Run({{pass_params(method.response_parameters)}});
+ std::move(callback_).Run({{pass_params(method.response_parameters)}});
}
return true;
}
@@ -184,7 +185,7 @@ bool {{proxy_name}}::{{method.name}}(
{%- endif %}
void {{proxy_name}}::{{method.name}}(
- {{interface_macros.declare_request_params("in_", method)}}) {
+ {{interface_macros.declare_request_params("in_", method, use_once_callback)}}) {
mojo::internal::SerializationContext serialization_context(
group_controller_);
{{struct_macros.get_serialized_size(params_struct, "in_%s",
@@ -202,7 +203,7 @@ void {{proxy_name}}::{{method.name}}(
{%- if method.response_parameters != None %}
mojo::MessageReceiver* responder =
new {{class_name}}_{{method.name}}_ForwardToCallback(
- callback, group_controller_);
+ std::move(callback), group_controller_);
if (!receiver_->AcceptWithResponder(builder.message(), responder))
delete responder;
{%- else %}
@@ -265,8 +266,7 @@ class {{class_name}}_{{method.name}}_ProxyToResponder {
void Run(
{{interface_macros.declare_responder_params(
- "in_", method.response_parameters, for_blink,
- use_new_wrapper_types)}});
+ "in_", method.response_parameters, for_blink)}});
uint64_t request_id_;
bool is_sync_;
@@ -279,8 +279,7 @@ class {{class_name}}_{{method.name}}_ProxyToResponder {
void {{class_name}}_{{method.name}}_ProxyToResponder::Run(
{{interface_macros.declare_responder_params(
- "in_", method.response_parameters, for_blink,
- use_new_wrapper_types)}}) {
+ "in_", method.response_parameters, for_blink)}}) {
{{struct_macros.get_serialized_size(response_params_struct, "in_%s",
"&serialization_context_")}}
mojo::internal::ResponseMessageBuilder builder(
@@ -362,7 +361,7 @@ bool {{class_name}}StubDispatch::AcceptWithResponder(
TRACE_EVENT0("mojom", "{{class_name}}::{{method.name}}");
mojo::internal::MessageDispatchContext context(message);
impl->{{method.name}}(
-{%- if method.parameters -%}{{pass_params(method.parameters)}}, {% endif -%}callback);
+{%- if method.parameters -%}{{pass_params(method.parameters)}}, {% endif -%}std::move(callback));
return true;
{%- else %}
break;
diff --git a/chromium/mojo/public/tools/bindings/generators/cpp_templates/interface_macros.tmpl b/chromium/mojo/public/tools/bindings/generators/cpp_templates/interface_macros.tmpl
index 4bec4c64f59..86492736333 100644
--- a/chromium/mojo/public/tools/bindings/generators/cpp_templates/interface_macros.tmpl
+++ b/chromium/mojo/public/tools/bindings/generators/cpp_templates/interface_macros.tmpl
@@ -5,39 +5,35 @@
{%- endfor %}
{%- endmacro %}
-{%- macro declare_responder_params(prefix, parameters, for_blink, use_new_wrapper_types) %}
+{%- macro declare_responder_params(prefix, parameters, for_blink) %}
{%- for param in parameters -%}
-{%- if (not param.kind|is_string_kind) or for_blink or
- use_new_wrapper_types -%}
{{param.kind|cpp_wrapper_param_type}} {{prefix}}{{param.name}}
-{%- else %}
-mojo::String {{prefix}}{{param.name}}
-{%- endif %}
{%- if not loop.last %}, {% endif %}
{%- endfor %}
{%- endmacro %}
-{%- macro declare_callback(method, for_blink, use_new_wrapper_types) -%}
+{%- macro declare_callback(method, for_blink, use_once_callback) -%}
+{%- if use_once_callback -%}
+base::OnceCallback<void(
+{%- else -%}
base::Callback<void(
+{%- endif -%}
{%- for param in method.response_parameters -%}
-{#- TODO(yzshen): For historical reasons, we use mojo::String here (instead of
- const mojo::String&) inconsistently. Preserve the behavior temporarily. #}
-{%- if (not param.kind|is_string_kind) or for_blink or
- use_new_wrapper_types -%}
{{param.kind|cpp_wrapper_param_type}}
-{%- else -%}
-mojo::String
-{%- endif %}
{%- if not loop.last %}, {% endif %}
{%- endfor -%}
)>
{%- endmacro -%}
-{%- macro declare_request_params(prefix, method) -%}
+{%- macro declare_request_params(prefix, method, use_once_callback) -%}
{{declare_params(prefix, method.parameters)}}
{%- if method.response_parameters != None -%}
-{%- if method.parameters %}, {% endif -%}
+{%- if method.parameters %}, {% endif -%}
+{%- if use_once_callback -%}
+{{method.name}}Callback callback
+{%- else -%}
const {{method.name}}Callback& callback
+{%- endif -%}
{%- endif -%}
{%- endmacro -%}
diff --git a/chromium/mojo/public/tools/bindings/generators/cpp_templates/interface_proxy_declaration.tmpl b/chromium/mojo/public/tools/bindings/generators/cpp_templates/interface_proxy_declaration.tmpl
index 91726e580db..ff2a1deedb6 100644
--- a/chromium/mojo/public/tools/bindings/generators/cpp_templates/interface_proxy_declaration.tmpl
+++ b/chromium/mojo/public/tools/bindings/generators/cpp_templates/interface_proxy_declaration.tmpl
@@ -8,7 +8,7 @@ class {{export_attribute}} {{interface.name}}Proxy
{%- if method.sync %}
bool {{method.name}}({{interface_macros.declare_sync_method_params("", method)}}) override;
{%- endif %}
- void {{method.name}}({{interface_macros.declare_request_params("", method)}}) override;
+ void {{method.name}}({{interface_macros.declare_request_params("", method, use_once_callback)}}) override;
{%- endfor %}
void set_group_controller(
diff --git a/chromium/mojo/public/tools/bindings/generators/cpp_templates/module-shared-internal.h.tmpl b/chromium/mojo/public/tools/bindings/generators/cpp_templates/module-shared-internal.h.tmpl
index f718276c2a9..964b25438e2 100644
--- a/chromium/mojo/public/tools/bindings/generators/cpp_templates/module-shared-internal.h.tmpl
+++ b/chromium/mojo/public/tools/bindings/generators/cpp_templates/module-shared-internal.h.tmpl
@@ -76,7 +76,7 @@ using {{enum|get_name_for_kind(flatten_nested_kind=True)}}_Data =
{%- for interface in interfaces %}
{%- for method in interface.methods %}
{%- set method_name = "k%s_%s_Name"|format(interface.name, method.name) %}
-const uint32_t {{method_name}} = {{method.ordinal}};
+constexpr uint32_t {{method_name}} = {{method.ordinal}};
{%- set struct = method.param_struct %}
{% include "struct_declaration.tmpl" %}
{%- if method.response_parameters != None %}
diff --git a/chromium/mojo/public/tools/bindings/generators/cpp_templates/module-shared.h.tmpl b/chromium/mojo/public/tools/bindings/generators/cpp_templates/module-shared.h.tmpl
index da99eb380be..dd13466de18 100644
--- a/chromium/mojo/public/tools/bindings/generators/cpp_templates/module-shared.h.tmpl
+++ b/chromium/mojo/public/tools/bindings/generators/cpp_templates/module-shared.h.tmpl
@@ -12,10 +12,10 @@ struct MojomTypeTraits<{{kind|get_qualified_name_for_kind}}DataView> {
using Data = {{kind|get_qualified_name_for_kind(internal=True)}};
{%- if kind|is_union_kind %}
using DataAsArrayElement = Data;
- static const MojomTypeCategory category = MojomTypeCategory::UNION;
+ static constexpr MojomTypeCategory category = MojomTypeCategory::UNION;
{%- else %}
using DataAsArrayElement = Pointer<Data>;
- static const MojomTypeCategory category = MojomTypeCategory::STRUCT;
+ static constexpr MojomTypeCategory category = MojomTypeCategory::STRUCT;
{%- endif %}
};
{%- endmacro %}
diff --git a/chromium/mojo/public/tools/bindings/generators/cpp_templates/module.cc.tmpl b/chromium/mojo/public/tools/bindings/generators/cpp_templates/module.cc.tmpl
index 4383acbd8fa..2c66a85f873 100644
--- a/chromium/mojo/public/tools/bindings/generators/cpp_templates/module.cc.tmpl
+++ b/chromium/mojo/public/tools/bindings/generators/cpp_templates/module.cc.tmpl
@@ -50,18 +50,16 @@ namespace {{variant}} {
{#--- Constants #}
{%- for constant in module.constants %}
-{%- if not constant.kind|is_integral_kind %}
-const {{constant.kind|cpp_pod_type}} {{constant.name}} = {{constant|constant_value}};
+{%- if constant.kind|is_string_kind %}
+const char {{constant.name}}[] = {{constant|constant_value}};
{%- endif %}
{%- endfor %}
{#--- Struct Constants #}
{%- for struct in structs %}
{%- for constant in struct.constants %}
-{%- if constant.kind|is_integral_kind %}
-const {{constant.kind|cpp_pod_type}} {{struct.name}}::{{constant.name}};
-{%- else %}
-const {{constant.kind|cpp_pod_type}} {{struct.name}}::{{constant.name}} = {{constant|constant_value}};
+{%- if constant.kind|is_string_kind %}
+const char {{struct.name}}::{{constant.name}}[] = {{constant|constant_value}};
{%- endif %}
{%- endfor %}
{%- endfor %}
diff --git a/chromium/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl b/chromium/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl
index 7fcc2888b8d..ab5668301cd 100644
--- a/chromium/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl
+++ b/chromium/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl
@@ -35,6 +35,7 @@ namespace {{variant}} {
#include <stdint.h>
+#include <limits>
#include <type_traits>
#include <utility>
@@ -45,11 +46,11 @@ namespace {{variant}} {
#include "mojo/public/cpp/bindings/associated_interface_request.h"
#include "mojo/public/cpp/bindings/interface_ptr.h"
#include "mojo/public/cpp/bindings/interface_request.h"
+#include "mojo/public/cpp/bindings/lib/clone_equals_util.h"
#include "mojo/public/cpp/bindings/lib/control_message_handler.h"
#include "mojo/public/cpp/bindings/lib/control_message_proxy.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"
#include "mojo/public/cpp/bindings/lib/union_accessor.h"
-#include "mojo/public/cpp/bindings/map.h"
#include "mojo/public/cpp/bindings/native_struct.h"
#include "mojo/public/cpp/bindings/no_interface.h"
#include "mojo/public/cpp/bindings/raw_ptr_impl_ref_traits.h"
@@ -66,14 +67,12 @@ namespace {{variant}} {
{%- endif %}
{%- endfor %}
{%- if not for_blink %}
-#include "mojo/public/cpp/bindings/array.h"
-#include "mojo/public/cpp/bindings/string.h"
+#include <string>
+#include <vector>
{%- else %}
{# hash_util.h includes template specializations that should be present for
every use of {Inlined}StructPtr. #}
#include "mojo/public/cpp/bindings/lib/wtf_hash_util.h"
-#include "mojo/public/cpp/bindings/wtf_array.h"
-#include "mojo/public/cpp/bindings/wtf_map.h"
#include "third_party/WebKit/Source/wtf/HashFunctions.h"
#include "third_party/WebKit/Source/wtf/Optional.h"
#include "third_party/WebKit/Source/wtf/text/WTFString.h"
@@ -98,13 +97,7 @@ using {{enum.name}} = {{enum.name}}; // Alias for definition in the parent name
{#--- Constants #}
{%- for constant in module.constants %}
-{#- To be consistent with constants defined inside interfaces, only make
- integral types compile-time constants. #}
-{%- if constant.kind|is_integral_kind %}
-const {{constant.kind|cpp_pod_type}} {{constant.name}} = {{constant|constant_value}};
-{%- else %}
-extern const {{constant.kind|cpp_pod_type}} {{constant.name}};
-{%- endif %}
+{{constant|format_constant_declaration}};
{%- endfor %}
{#--- Interface Forward Declarations -#}
diff --git a/chromium/mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl b/chromium/mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl
index 374b0976b18..60dca4010e0 100644
--- a/chromium/mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl
+++ b/chromium/mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl
@@ -15,7 +15,7 @@ bool {{class_name}}::Validate(
// the message comes from an older version.
const {{class_name}}* object = static_cast<const {{class_name}}*>(data);
- static const struct {
+ static constexpr struct {
uint32_t version;
uint32_t num_bytes;
} kVersionSizes[] = {
diff --git a/chromium/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl b/chromium/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl
index 4c5ed38c998..1f3ec1e2b1b 100644
--- a/chromium/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl
+++ b/chromium/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl
@@ -10,11 +10,7 @@ class {{export_attribute}} {{struct.name}} {
{#--- Constants #}
{%- for constant in struct.constants %}
-{%- if constant.kind|is_integral_kind %}
- static const {{constant.kind|cpp_pod_type}} {{constant.name}} = {{constant|constant_value}};
-{%- else %}
- static const {{constant.kind|cpp_pod_type}} {{constant.name}};
-{%- endif %}
+ static {{constant|format_constant_declaration(nested=True)}};
{%- endfor %}
static {{struct.name}}Ptr New();
@@ -50,8 +46,8 @@ class {{export_attribute}} {{struct.name}} {
size_t Hash(size_t seed) const;
{%- endif %}
-{%- set serialization_result_type = "mojo::WTFArray<uint8_t>"
- if for_blink else "mojo::Array<uint8_t>" %}
+{%- set serialization_result_type = "WTF::Vector<uint8_t>"
+ if for_blink else "std::vector<uint8_t>" %}
template <typename UserType>
static {{serialization_result_type}} Serialize(UserType* input) {
diff --git a/chromium/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl b/chromium/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl
index 1b5cafa01e4..eb73532d759 100644
--- a/chromium/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl
+++ b/chromium/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl
@@ -2,12 +2,21 @@
var k{{interface.name}}_{{method.name}}_Name = {{method.ordinal}};
{%- endfor %}
+ function {{interface.name}}Ptr(handleOrPtrInfo) {
+ this.ptr = new bindings.InterfacePtrController({{interface.name}},
+ handleOrPtrInfo);
+ }
+
function {{interface.name}}Proxy(receiver) {
- bindings.ProxyBase.call(this, receiver);
+ this.receiver_ = receiver;
}
- {{interface.name}}Proxy.prototype = Object.create(bindings.ProxyBase.prototype);
{%- for method in interface.methods %}
+ {{interface.name}}Ptr.prototype.{{method.name|stylize_method}} = function() {
+ return {{interface.name}}Proxy.prototype.{{method.name|stylize_method}}
+ .apply(this.ptr.getProxy(), arguments);
+ };
+
{{interface.name}}Proxy.prototype.{{method.name|stylize_method}} = function(
{%- for parameter in method.parameters -%}
{{parameter.name}}{% if not loop.last %}, {% endif %}
@@ -15,7 +24,7 @@
) {
var params = new {{interface.name}}_{{method.name}}_Params();
{%- for parameter in method.parameters %}
- params.{{parameter.name}} = {{parameter|js_proxy_method_parameter_value}};
+ params.{{parameter.name}} = {{parameter.name}};
{%- endfor %}
{%- if method.response_parameters == None %}
@@ -47,15 +56,13 @@
{%- endfor %}
function {{interface.name}}Stub(delegate) {
- bindings.StubBase.call(this, delegate);
+ this.delegate_ = delegate;
}
- {{interface.name}}Stub.prototype = Object.create(bindings.StubBase.prototype);
{%- for method in interface.methods %}
{%- set js_method_name = method.name|stylize_method %}
-{%- set delegate_expr = "bindings.StubBindings(this).delegate" %}
{{interface.name}}Stub.prototype.{{js_method_name}} = function({{method.parameters|map(attribute='name')|join(', ')}}) {
- return {{delegate_expr}} && {{delegate_expr}}.{{js_method_name}} && {{delegate_expr}}.{{js_method_name}}({{method.parameters|map('js_stub_method_parameter_value')|join(', ')}});
+ return this.delegate_ && this.delegate_.{{js_method_name}} && this.delegate_.{{js_method_name}}({{method.parameters|map(attribute='name')|join(', ')}});
}
{%- endfor %}
@@ -162,6 +169,7 @@ params.{{parameter.name}}{% if not loop.last %}, {% endif -%}
var {{interface.name}} = {
name: '{{namespace|replace(".","::")}}::{{interface.name}}',
+ ptrClass: {{interface.name}}Ptr,
proxyClass: {{interface.name}}Proxy,
stubClass: {{interface.name}}Stub,
validateRequest: validate{{interface.name}}Request,
diff --git a/chromium/mojo/public/tools/bindings/generators/js_templates/module.amd.tmpl b/chromium/mojo/public/tools/bindings/generators/js_templates/module.amd.tmpl
index 6d7a1a29187..d725139db81 100644
--- a/chromium/mojo/public/tools/bindings/generators/js_templates/module.amd.tmpl
+++ b/chromium/mojo/public/tools/bindings/generators/js_templates/module.amd.tmpl
@@ -5,13 +5,12 @@
define("{{module.path}}", [
"mojo/public/js/bindings",
"mojo/public/js/codec",
- "mojo/public/js/connection",
"mojo/public/js/core",
"mojo/public/js/validator",
{%- for import in imports %}
"{{import.module.path}}",
{%- endfor %}
-], function(bindings, codec, connection, core, validator
+], function(bindings, codec, core, validator
{%- for import in imports -%}
, {{import.unique_name}}
{%- endfor -%}
diff --git a/chromium/mojo/public/tools/bindings/generators/js_templates/module_definition.tmpl b/chromium/mojo/public/tools/bindings/generators/js_templates/module_definition.tmpl
index 86ea2ce257e..ddfef72bcc9 100644
--- a/chromium/mojo/public/tools/bindings/generators/js_templates/module_definition.tmpl
+++ b/chromium/mojo/public/tools/bindings/generators/js_templates/module_definition.tmpl
@@ -40,6 +40,7 @@
{%- endfor %}
{%- for interface in interfaces %}
exports.{{interface.name}} = {{interface.name}};
+ exports.{{interface.name}}Ptr = {{interface.name}}Ptr;
{#--- Interface Client #}
{%- if interface.client in interfaces|map(attribute='name') %}
exports.{{interface.name}}.client = {{interface.client}};
diff --git a/chromium/mojo/public/tools/bindings/generators/js_templates/validation_macros.tmpl b/chromium/mojo/public/tools/bindings/generators/js_templates/validation_macros.tmpl
index 3d0be6e95e3..d4e15a78596 100644
--- a/chromium/mojo/public/tools/bindings/generators/js_templates/validation_macros.tmpl
+++ b/chromium/mojo/public/tools/bindings/generators/js_templates/validation_macros.tmpl
@@ -6,7 +6,7 @@ if (err !== validator.validationError.NONE)
{%- macro _validate_field(field, offset, name) %}
{%- if field|is_string_pointer_field %}
// validate {{name}}
-err = messageValidator.validateStringPointer({{offset}}, {{field|validate_string_params}})
+err = messageValidator.validateStringPointer({{offset}}, {{field|validate_nullable_params}})
{{_check_err()}}
{%- elif field|is_array_pointer_field %}
// validate {{name}}
@@ -22,11 +22,15 @@ err = messageValidator.validateMapPointer({{offset}}, {{field|validate_map_param
{{_check_err()}}
{%- elif field|is_interface_field %}
// validate {{name}}
-err = messageValidator.validateInterface({{offset}}, {{field|validate_interface_params}});
+err = messageValidator.validateInterface({{offset}}, {{field|validate_nullable_params}});
{{_check_err()}}
-{%- elif field|is_handle_field or field|is_interface_request_field %}
+{%- elif field|is_interface_request_field %}
// validate {{name}}
-err = messageValidator.validateHandle({{offset}}, {{field|validate_handle_params}})
+err = messageValidator.validateInterfaceRequest({{offset}}, {{field|validate_nullable_params}})
+{{_check_err()}}
+{%- elif field|is_handle_field %}
+// validate {{name}}
+err = messageValidator.validateHandle({{offset}}, {{field|validate_nullable_params}})
{{_check_err()}}
{%- elif field|is_enum_field %}
// validate {{name}}
diff --git a/chromium/mojo/public/tools/bindings/generators/mojom_cpp_generator.py b/chromium/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
index 2cf791fab0f..be70d2f8fc5 100644
--- a/chromium/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
+++ b/chromium/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
@@ -36,7 +36,6 @@ _kind_to_cpp_literal_suffix = {
# generator library code so that filters can use the generator as context.
_current_typemap = {}
_for_blink = False
-_use_new_wrapper_types = False
# TODO(rockot, yzshen): The variant handling is kind of a hack currently. Make
# it right.
_variant = None
@@ -142,11 +141,6 @@ def DefaultValue(field):
if not IsTypemappedKind(field.kind):
return "%s::New()" % GetNameForKind(field.kind)
return ExpressionToText(field.default, kind=field.kind)
- if not _use_new_wrapper_types:
- if mojom.IsArrayKind(field.kind) or mojom.IsMapKind(field.kind):
- return "nullptr";
- if mojom.IsStringKind(field.kind):
- return "" if _for_blink else "nullptr"
return ""
def NamespaceToArray(namespace):
@@ -222,10 +216,16 @@ def GetNativeTypeName(typemapped_kind):
return _current_typemap[GetFullMojomNameForKind(typemapped_kind)]["typename"]
def GetCppPodType(kind):
- if mojom.IsStringKind(kind):
- return "char*"
return _kind_to_cpp_type[kind]
+def FormatConstantDeclaration(constant, nested=False):
+ if mojom.IsStringKind(constant.kind):
+ if nested:
+ return "const char %s[]" % constant.name
+ return "extern const char %s[]" % constant.name
+ return "constexpr %s %s = %s" % (GetCppPodType(constant.kind), constant.name,
+ ConstantValue(constant))
+
def GetCppWrapperType(kind, add_same_module_namespaces=False):
def _AddOptional(type_name):
pattern = "WTF::Optional<%s>" if _for_blink else "base::Optional<%s>"
@@ -245,24 +245,16 @@ def GetCppWrapperType(kind, add_same_module_namespaces=False):
return "%sPtr" % GetNameForKind(
kind, add_same_module_namespaces=add_same_module_namespaces)
if mojom.IsArrayKind(kind):
- pattern = None
- if _use_new_wrapper_types:
- pattern = "WTF::Vector<%s>" if _for_blink else "std::vector<%s>"
- if mojom.IsNullableKind(kind):
- pattern = _AddOptional(pattern)
- else:
- pattern = "mojo::WTFArray<%s>" if _for_blink else "mojo::Array<%s>"
+ pattern = "WTF::Vector<%s>" if _for_blink else "std::vector<%s>"
+ if mojom.IsNullableKind(kind):
+ pattern = _AddOptional(pattern)
return pattern % GetCppWrapperType(
kind.kind, add_same_module_namespaces=add_same_module_namespaces)
if mojom.IsMapKind(kind):
- pattern = None
- if _use_new_wrapper_types:
- pattern = ("WTF::HashMap<%s, %s>" if _for_blink else
- "std::unordered_map<%s, %s>")
- if mojom.IsNullableKind(kind):
- pattern = _AddOptional(pattern)
- else:
- pattern = "mojo::WTFMap<%s, %s>" if _for_blink else "mojo::Map<%s, %s>"
+ pattern = ("WTF::HashMap<%s, %s>" if _for_blink else
+ "std::unordered_map<%s, %s>")
+ if mojom.IsNullableKind(kind):
+ pattern = _AddOptional(pattern)
return pattern % (
GetCppWrapperType(
kind.key_kind,
@@ -285,8 +277,6 @@ def GetCppWrapperType(kind, add_same_module_namespaces=False):
if mojom.IsStringKind(kind):
if _for_blink:
return "WTF::String"
- if not _use_new_wrapper_types:
- return "mojo::String"
type_name = "std::string"
return _AddOptional(type_name) if mojom.IsNullableKind(kind) else type_name
if mojom.IsGenericHandleKind(kind):
@@ -311,9 +301,9 @@ def IsMoveOnlyKind(kind):
if mojom.IsStructKind(kind) or mojom.IsUnionKind(kind):
return True
if mojom.IsArrayKind(kind):
- return IsMoveOnlyKind(kind.kind) if _use_new_wrapper_types else True
+ return IsMoveOnlyKind(kind.kind)
if mojom.IsMapKind(kind):
- return IsMoveOnlyKind(kind.value_kind) if _use_new_wrapper_types else True
+ return IsMoveOnlyKind(kind.value_kind)
if mojom.IsAnyHandleOrInterfaceKind(kind):
return True
return False
@@ -433,13 +423,18 @@ def TranslateConstants(token, kind):
flatten_nested_kind=True)
if isinstance(token, mojom.BuiltinValue):
- if token.value == "double.INFINITY" or token.value == "float.INFINITY":
- return "INFINITY";
- if token.value == "double.NEGATIVE_INFINITY" or \
- token.value == "float.NEGATIVE_INFINITY":
- return "-INFINITY";
- if token.value == "double.NAN" or token.value == "float.NAN":
- return "NAN";
+ if token.value == "double.INFINITY":
+ return "std::numeric_limits<double>::infinity()"
+ if token.value == "float.INFINITY":
+ return "std::numeric_limits<float>::infinity()"
+ if token.value == "double.NEGATIVE_INFINITY":
+ return "-std::numeric_limits<double>::infinity()"
+ if token.value == "float.NEGATIVE_INFINITY":
+ return "-std::numeric_limits<float>::infinity()"
+ if token.value == "double.NAN":
+ return "std::numeric_limits<double>::quiet_NaN()"
+ if token.value == "float.NAN":
+ return "std::numeric_limits<float>::quiet_NaN()"
if (kind is not None and mojom.IsFloatKind(kind)):
return token if token.isdigit() else token + "f";
@@ -551,6 +546,7 @@ class Generator(generator.Generator):
"cpp_wrapper_type": GetCppWrapperType,
"default_value": DefaultValue,
"expression_to_text": ExpressionToText,
+ "format_constant_declaration": FormatConstantDeclaration,
"get_container_validate_params_ctor_args":
GetContainerValidateParamsCtorArgs,
"get_name_for_kind": GetNameForKind,
@@ -621,7 +617,7 @@ class Generator(generator.Generator):
"extra_traits_headers": self.GetExtraTraitsHeaders(),
"extra_public_headers": self.GetExtraPublicHeaders(),
"for_blink": self.for_blink,
- "use_new_wrapper_types": self.use_new_wrapper_types,
+ "use_once_callback": self.use_once_callback,
"export_attribute": self.export_attribute,
"export_header": self.export_header,
}
@@ -668,8 +664,8 @@ class Generator(generator.Generator):
_current_typemap = self.typemap
global _for_blink
_for_blink = self.for_blink
- global _use_new_wrapper_types
- _use_new_wrapper_types = self.use_new_wrapper_types
+ global _use_once_callback
+ _use_once_callback = self.use_once_callback
global _variant
_variant = self.variant
suffix = "-%s" % self.variant if self.variant else ""
diff --git a/chromium/mojo/public/tools/bindings/generators/mojom_js_generator.py b/chromium/mojo/public/tools/bindings/generators/mojom_js_generator.py
index e57f3305eba..0eedb314453 100644
--- a/chromium/mojo/public/tools/bindings/generators/mojom_js_generator.py
+++ b/chromium/mojo/public/tools/bindings/generators/mojom_js_generator.py
@@ -62,9 +62,10 @@ def JavaScriptDefaultValue(field):
return "null"
if mojom.IsMapKind(field.kind):
return "null"
- if mojom.IsInterfaceKind(field.kind) or \
- mojom.IsInterfaceRequestKind(field.kind):
- return _kind_to_javascript_default_value[mojom.MSGPIPE]
+ if mojom.IsInterfaceKind(field.kind):
+ return "new %sPtr()" % JavaScriptType(field.kind)
+ if mojom.IsInterfaceRequestKind(field.kind):
+ return "new bindings.InterfaceRequest()"
if mojom.IsAssociatedKind(field.kind):
return "null"
if mojom.IsEnumKind(field.kind):
@@ -124,10 +125,13 @@ def CodecType(kind):
element_type = ElementCodecType(kind.kind)
return "new codec.%s(%s%s)" % (array_type, element_type, array_length)
if mojom.IsInterfaceKind(kind):
- return "codec.%s" % ("NullableInterface" if mojom.IsNullableKind(kind)
- else "Interface")
+ return "new codec.%s(%sPtr)" % (
+ "NullableInterface" if mojom.IsNullableKind(kind) else "Interface",
+ JavaScriptType(kind))
if mojom.IsInterfaceRequestKind(kind):
- return CodecType(mojom.MSGPIPE)
+ return "codec.%s" % (
+ "NullableInterfaceRequest" if mojom.IsNullableKind(kind)
+ else "InterfaceRequest")
if mojom.IsAssociatedInterfaceKind(kind):
return "codec.AssociatedInterfaceNotSupported"
if mojom.IsAssociatedInterfaceRequestKind(kind):
@@ -148,7 +152,7 @@ def ElementCodecType(kind):
def JavaScriptDecodeSnippet(kind):
if (kind in mojom.PRIMITIVES or mojom.IsUnionKind(kind) or
- mojom.IsInterfaceKind(kind) or mojom.IsAssociatedKind(kind)):
+ mojom.IsAnyInterfaceKind(kind)):
return "decodeStruct(%s)" % CodecType(kind)
if mojom.IsStructKind(kind):
return "decodeStructPointer(%s)" % JavaScriptType(kind)
@@ -161,8 +165,6 @@ def JavaScriptDecodeSnippet(kind):
return "decodeArrayPointer(%s)" % CodecType(kind.kind)
if mojom.IsUnionKind(kind):
return "decodeUnion(%s)" % CodecType(kind)
- if mojom.IsInterfaceRequestKind(kind):
- return JavaScriptDecodeSnippet(mojom.MSGPIPE)
if mojom.IsEnumKind(kind):
return JavaScriptDecodeSnippet(mojom.INT32)
raise Exception("No decode snippet for %s" % kind)
@@ -170,7 +172,7 @@ def JavaScriptDecodeSnippet(kind):
def JavaScriptEncodeSnippet(kind):
if (kind in mojom.PRIMITIVES or mojom.IsUnionKind(kind) or
- mojom.IsInterfaceKind(kind) or mojom.IsAssociatedKind(kind)):
+ mojom.IsAnyInterfaceKind(kind)):
return "encodeStruct(%s, " % CodecType(kind)
if mojom.IsUnionKind(kind):
return "encodeStruct(%s, " % JavaScriptType(kind)
@@ -183,8 +185,6 @@ def JavaScriptEncodeSnippet(kind):
return "encodeArrayPointer(codec.PackedBool, ";
if mojom.IsArrayKind(kind):
return "encodeArrayPointer(%s, " % CodecType(kind.kind)
- if mojom.IsInterfaceRequestKind(kind):
- return JavaScriptEncodeSnippet(mojom.MSGPIPE)
if mojom.IsEnumKind(kind):
return JavaScriptEncodeSnippet(mojom.INT32)
raise Exception("No encode snippet for %s" % kind)
@@ -234,9 +234,7 @@ def JavaScriptValidateArrayParams(field):
def JavaScriptValidateEnumParams(field):
- nullable = JavaScriptNullableParam(field)
- enum_type = JavaScriptType(field.kind)
- return "%s, %s" % (enum_type, nullable)
+ return JavaScriptType(field.kind)
def JavaScriptValidateStructParams(field):
nullable = JavaScriptNullableParam(field)
@@ -258,42 +256,6 @@ def JavaScriptValidateMapParams(field):
(nullable, keys_type, values_type, values_nullable)
-def JavaScriptValidateStringParams(field):
- nullable = JavaScriptNullableParam(field)
- return "%s" % (nullable)
-
-
-def JavaScriptValidateHandleParams(field):
- nullable = JavaScriptNullableParam(field)
- return "%s" % (nullable)
-
-def JavaScriptValidateInterfaceParams(field):
- return JavaScriptValidateHandleParams(field)
-
-def JavaScriptProxyMethodParameterValue(parameter):
- name = parameter.name;
- if (mojom.IsInterfaceKind(parameter.kind)):
- type = JavaScriptType(parameter.kind)
- return "core.isHandle(%s) ? %s : connection.bindImpl" \
- "(%s, %s)" % (name, name, name, type)
- if (mojom.IsInterfaceRequestKind(parameter.kind)):
- type = JavaScriptType(parameter.kind.kind)
- return "core.isHandle(%s) ? %s : connection.bindProxy" \
- "(%s, %s)" % (name, name, name, type)
- return name;
-
-
-def JavaScriptStubMethodParameterValue(parameter):
- name = parameter.name;
- if (mojom.IsInterfaceKind(parameter.kind)):
- type = JavaScriptType(parameter.kind)
- return "connection.bindHandleToProxy(%s, %s)" % (name, type)
- if (mojom.IsInterfaceRequestKind(parameter.kind)):
- type = JavaScriptType(parameter.kind.kind)
- return "connection.bindHandleToStub(%s, %s)" % (name, type)
- return name;
-
-
def TranslateConstants(token):
if isinstance(token, (mojom.EnumValue, mojom.NamedValue)):
# Both variable and enum constants are constructed like:
@@ -384,8 +346,6 @@ class Generator(generator.Generator):
"is_string_pointer_field": IsStringPointerField,
"is_struct_pointer_field": IsStructPointerField,
"is_union_field": IsUnionField,
- "js_proxy_method_parameter_value": JavaScriptProxyMethodParameterValue,
- "js_stub_method_parameter_value": JavaScriptStubMethodParameterValue,
"js_type": JavaScriptType,
"payload_size": JavaScriptPayloadSize,
"stylize_method": generator.StudlyCapsToCamel,
@@ -393,10 +353,8 @@ class Generator(generator.Generator):
"union_encode_snippet": JavaScriptUnionEncodeSnippet,
"validate_array_params": JavaScriptValidateArrayParams,
"validate_enum_params": JavaScriptValidateEnumParams,
- "validate_handle_params": JavaScriptValidateHandleParams,
- "validate_interface_params": JavaScriptValidateInterfaceParams,
"validate_map_params": JavaScriptValidateMapParams,
- "validate_string_params": JavaScriptValidateStringParams,
+ "validate_nullable_params": JavaScriptNullableParam,
"validate_struct_params": JavaScriptValidateStructParams,
"validate_union_params": JavaScriptValidateUnionParams,
}
diff --git a/chromium/mojo/public/tools/bindings/mojom.gni b/chromium/mojo/public/tools/bindings/mojom.gni
index b4495b3ec2d..e7ed6ec7cda 100644
--- a/chromium/mojo/public/tools/bindings/mojom.gni
+++ b/chromium/mojo/public/tools/bindings/mojom.gni
@@ -49,9 +49,22 @@ foreach(configuration, _bindings_configurations) {
}
}
-# Generate C++/JavaScript/Java source files from mojom files. The output files
-# will go under the generated file directory tree with the same path as each
-# input file.
+# Generates targets for building C++, JavaScript and Java bindings from mojom
+# files. The output files will go under the generated file directory tree with
+# the same path as each input file.
+#
+# Other targets should depend on one of these generated targets (where "foo"
+# is the target name):
+#
+# foo
+# C++ and Javascript bindings. Other mojom targets should also depend on
+# this target.
+#
+# foo_blink
+# C++ bindings using Blink standard types.
+#
+# foo_java
+# Java bindings.
#
# Parameters:
#
@@ -74,14 +87,17 @@ foreach(configuration, _bindings_configurations) {
#
# visibility (optional)
#
-# use_new_wrapper_types (optional)
-# If set to true, mojom array/map/string will be mapped to STL (for
-# chromium variant) or WTF (for blink) types. Otherwise, they will be
-# mapped to mojo::Array/Map/String/etc.
-# Default value is true.
-# TODO(yzshen):
-# - convert all users to use the new mode;
-# - remove support for the old mode.
+# visibility_blink (optional)
+# The value to use for visibility for the blink variant. If unset,
+# |visibility| is used.
+#
+# use_once_callback (optional)
+# If set to true, generated classes will use base::OnceCallback instead of
+# base::RepeatingCallback.
+# Default value is false.
+# TODO(dcheng):
+# - Convert everything to use OnceCallback.
+# - Remove support for the old mode.
#
# cpp_only (optional)
# If set to true, only the C++ bindings targets will be generated.
@@ -102,6 +118,19 @@ foreach(configuration, _bindings_configurations) {
# export_define_blink (optional)
# export_header_blink (optional)
# These three parameters are the blink variants of the previous 3.
+#
+# The following parameters are used to correct component build dependencies.
+# They are needed so mojom-mojom dependencies follow the rule that dependencies
+# on a source set in another component are replaced by a dependency on the
+# containing component. The first two are for the chromium variant; the other
+# two are for the blink variant.
+# overridden_deps (optional)
+# The list of mojom deps to be overridden.
+# component_deps (optional)
+# The list of component deps to add to replace overridden_deps.
+# overridden_deps_blink (optional)
+# component_deps_blink (optional)
+# These two parameters are the blink variants of the previous two.
template("mojom") {
assert(
defined(invoker.sources) || defined(invoker.deps) ||
@@ -120,6 +149,16 @@ template("mojom") {
assert(defined(invoker.export_define_blink))
assert(defined(invoker.export_header_blink))
}
+ if (defined(invoker.overridden_deps) || defined(invoker.component_deps)) {
+ assert(defined(invoker.overridden_deps))
+ assert(defined(invoker.component_deps))
+ }
+
+ if (defined(invoker.overridden_deps_blink) ||
+ defined(invoker.component_deps_blink)) {
+ assert(defined(invoker.overridden_deps_blink))
+ assert(defined(invoker.component_deps_blink))
+ }
all_deps = []
if (defined(invoker.deps)) {
@@ -229,9 +268,6 @@ template("mojom") {
type_mappings_path =
"$target_gen_dir/${target_name}${variant_suffix}__type_mappings"
active_typemaps = []
- cpp_sources_suffix = "cpp_sources"
- cpp_sources_target_name =
- "${target_name}${variant_suffix}_${cpp_sources_suffix}"
enabled_sources = []
if (defined(invoker.sources)) {
generator_cpp_outputs = []
@@ -342,9 +378,8 @@ template("mojom") {
}
}
- if (!defined(invoker.use_new_wrapper_types) ||
- invoker.use_new_wrapper_types) {
- args += [ "--use_new_wrapper_types" ]
+ if (defined(invoker.use_once_callback) && invoker.use_once_callback) {
+ args += [ "--use_once_callback" ]
}
}
}
@@ -404,7 +439,11 @@ template("mojom") {
}
source_set("${target_name}${variant_suffix}") {
- if (defined(invoker.visibility)) {
+ if (defined(bindings_configuration.for_blink) &&
+ bindings_configuration.for_blink &&
+ defined(invoker.visibility_blink)) {
+ visibility = invoker.visibility_blink
+ } else if (defined(invoker.visibility)) {
visibility = invoker.visibility
}
if (defined(invoker.testonly)) {
@@ -413,37 +452,6 @@ template("mojom") {
if (defined(invoker.sources) && !defined(bindings_configuration.variant)) {
data = process_file_template(enabled_sources, generator_js_outputs)
}
-
- public_deps = [
- ":${cpp_sources_target_name}",
- "//mojo/public/cpp/bindings",
- ]
- if (defined(invoker.deps)) {
- foreach(dep, invoker.deps) {
- public_deps +=
- [ get_label_info(dep, "label_no_toolchain") + variant_suffix ]
- }
- }
- if (defined(invoker.public_deps)) {
- foreach(dep, invoker.public_deps) {
- public_deps +=
- [ get_label_info(dep, "label_no_toolchain") + variant_suffix ]
- }
- }
-
- deps = []
- if (defined(invoker.sources)) {
- public_deps += [ ":$generator_target_name" ]
- }
- }
-
- # The generated C++ source files. The main reason to introduce this target
- # is so that mojo/public/cpp/bindings can depend on mojom interfaces without
- # circular dependencies. It means that the target is missing the dependency
- # on mojo/public/cpp/bindings. No external targets should depend directly on
- # this target *except* mojo/public/cpp/bindings and other *_cpp_sources
- # targets.
- source_set(cpp_sources_target_name) {
defines = []
if (defined(invoker.testonly)) {
testonly = invoker.testonly
@@ -462,19 +470,44 @@ template("mojom") {
"//mojo/public/interfaces/bindings:bindings__generator",
"//mojo/public/interfaces/bindings:bindings_shared__generator",
]
- if (enabled_sources != []) {
- deps += [ ":$generator_target_name" ]
- }
public_deps = [
":$shared_cpp_sources_target_name",
"//base",
+ "//mojo/public/cpp/bindings",
]
+ if (enabled_sources != []) {
+ public_deps += [ ":$generator_target_name" ]
+ }
foreach(d, all_deps) {
# Resolve the name, so that a target //mojo/something becomes
- # //mojo/something:something and we can append cpp_sources_suffix to
+ # //mojo/something:something and we can append variant_suffix to
# get the cpp dependency name.
full_name = get_label_info("$d", "label_no_toolchain")
- public_deps += [ "${full_name}${variant_suffix}_${cpp_sources_suffix}" ]
+ public_deps += [ "${full_name}${variant_suffix}" ]
+ }
+ if (defined(bindings_configuration.for_blink) &&
+ bindings_configuration.for_blink) {
+ if (defined(invoker.overridden_deps_blink)) {
+ foreach(d, invoker.overridden_deps_blink) {
+ # Resolve the name, so that a target //mojo/something becomes
+ # //mojo/something:something and we can append variant_suffix
+ # to get the cpp dependency name.
+ full_name = get_label_info("$d", "label_no_toolchain")
+ public_deps -= [ "${full_name}${variant_suffix}" ]
+ }
+ public_deps += invoker.component_deps_blink
+ }
+ } else {
+ if (defined(invoker.overridden_deps)) {
+ foreach(d, invoker.overridden_deps) {
+ # Resolve the name, so that a target //mojo/something becomes
+ # //mojo/something:something and we can append variant_suffix
+ # to get the cpp dependency name.
+ full_name = get_label_info("$d", "label_no_toolchain")
+ public_deps -= [ "${full_name}${variant_suffix}" ]
+ }
+ public_deps += invoker.component_deps
+ }
}
foreach(typemap, active_typemaps) {
if (defined(typemap.public_headers)) {
diff --git a/chromium/mojo/public/tools/bindings/mojom_bindings_generator.py b/chromium/mojo/public/tools/bindings/mojom_bindings_generator.py
index fd77adcd994..78af6499de5 100755
--- a/chromium/mojo/public/tools/bindings/mojom_bindings_generator.py
+++ b/chromium/mojo/public/tools/bindings/mojom_bindings_generator.py
@@ -166,7 +166,7 @@ class MojomProcessor(object):
module, args.output_dir, typemap=self._typemap.get(language, {}),
variant=args.variant, bytecode_path=args.bytecode_path,
for_blink=args.for_blink,
- use_new_wrapper_types=args.use_new_wrapper_types,
+ use_once_callback=args.use_once_callback,
export_attribute=args.export_attribute,
export_header=args.export_header,
generate_non_variant_code=args.generate_non_variant_code)
@@ -196,7 +196,7 @@ class MojomProcessor(object):
with open(rel_filename.path) as f:
source = f.read()
except IOError as e:
- print "%s: Error: %s" % (e.rel_filename.path, e.strerror) + \
+ print "%s: Error: %s" % (rel_filename.path, e.strerror) + \
MakeImportStackMessage(imported_filename_stack + [rel_filename.path])
sys.exit(1)
@@ -289,9 +289,8 @@ def main():
help="Use WTF types as generated types for mojo "
"string/array/map.")
generate_parser.add_argument(
- "--use_new_wrapper_types", action="store_true",
- help="Map mojom array/map/string to STL (for chromium variant) or WTF "
- "(for blink variant) types directly.")
+ "--use_once_callback", action="store_true",
+ help="Use base::OnceCallback instead of base::RepeatingCallback.")
generate_parser.add_argument(
"--export_attribute", type=str, default="",
help="Optional attribute to specify on class declaration to export it "
diff --git a/chromium/mojo/public/tools/bindings/pylib/mojom/generate/generator.py b/chromium/mojo/public/tools/bindings/pylib/mojom/generate/generator.py
index f76cc2e197a..e4ab37357e8 100644
--- a/chromium/mojo/public/tools/bindings/pylib/mojom/generate/generator.py
+++ b/chromium/mojo/public/tools/bindings/pylib/mojom/generate/generator.py
@@ -37,7 +37,7 @@ class Generator(object):
# Pass |output_dir| to emit files to disk. Omit |output_dir| to echo all
# files to stdout.
def __init__(self, module, output_dir=None, typemap=None, variant=None,
- bytecode_path=None, for_blink=False, use_new_wrapper_types=False,
+ bytecode_path=None, for_blink=False, use_once_callback=False,
export_attribute=None, export_header=None,
generate_non_variant_code=False):
self.module = module
@@ -46,7 +46,7 @@ class Generator(object):
self.variant = variant
self.bytecode_path = bytecode_path
self.for_blink = for_blink
- self.use_new_wrapper_types = use_new_wrapper_types
+ self.use_once_callback = use_once_callback
self.export_attribute = export_attribute
self.export_header = export_header
self.generate_non_variant_code = generate_non_variant_code