diff options
author | Hidehiko Abe <hidehiko@chromium.org> | 2019-03-28 15:15:30 +0900 |
---|---|---|
committer | Qijiang Fan <fqj@chromium.org> | 2020-01-07 19:58:34 +0900 |
commit | 1cedaefedb63833985136e3e6fabfe4326c39657 (patch) | |
tree | d5f365fc1205e755ac3af64dc4e118eb89ea1d23 /libchrome_tools | |
parent | fd0c4e3a5548c31368bf253b27748dccd5fd1361 (diff) | |
download | platform_external_libchrome-1cedaefedb63833985136e3e6fabfe4326c39657.tar.gz platform_external_libchrome-1cedaefedb63833985136e3e6fabfe4326c39657.tar.bz2 platform_external_libchrome-1cedaefedb63833985136e3e6fabfe4326c39657.zip |
libchrome: Uprev libchrome to r576279.
BUG=chromium:909719
TEST=None
Change-Id: Ia0de6a705cd666985675c2885ab7d2ef938c94a6
Diffstat (limited to 'libchrome_tools')
44 files changed, 2111 insertions, 1088 deletions
diff --git a/libchrome_tools/include_generator.py b/libchrome_tools/include_generator.py index efffd3952..4c115de25 100755 --- a/libchrome_tools/include_generator.py +++ b/libchrome_tools/include_generator.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Copyright (C) 2018 The Android Open Source Project # diff --git a/libchrome_tools/jni_registration_generator_helper.sh b/libchrome_tools/jni_registration_generator_helper.sh new file mode 100755 index 000000000..bc200d0a1 --- /dev/null +++ b/libchrome_tools/jni_registration_generator_helper.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# +# Copyright (C) 2018 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generates jni. + +set -e + +args=() +files=() + +jni_generator='' + +for arg in "$@"; do + case "${arg}" in + --jni_generator=*) + jni_generator=${arg#'--jni_generator='} + ;; + --*) + args=("${args[@]}" "${arg}") + ;; + *) + files=("${files[@]}" "${arg}") + ;; + esac +done + +"${jni_generator}" --sources_files=<(printf "%q\n" "${files[@]}") "${args[@]}" diff --git a/libchrome_tools/mojom_generate_type_mappings.py b/libchrome_tools/mojom_generate_type_mappings.py new file mode 100644 index 000000000..0c8023c40 --- /dev/null +++ b/libchrome_tools/mojom_generate_type_mappings.py @@ -0,0 +1,93 @@ +#!/usr/bin/python + +# Copyright (C) 2018 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Drives mojom typemapping generator. + +Usage: + +% python libchrome_tools/mojom_generate_type_mappings.py \ + --output ${output_type_mapping_file_path} \ + ${list of .typemap files} +""" + +import argparse +import os +import subprocess +import sys + +from build import gn_helpers + +_GENERATE_TYPE_MAPPINGS_PATH = os.path.join( + os.path.dirname(__file__), + '../mojo/public/tools/bindings/generate_type_mappings.py') + +def _read_typemap_config(path): + """Reads .typemap file. + + Args: + path: File path to the .typemap location. + + Returns: + A dictionary holding values in .typemap file. + """ + + with open(path) as f: + # gn_helpers does not handle comment lines. + content = [line for line in f if not line.strip().startswith('#')] + return gn_helpers.FromGNArgs(''.join(content)) + + +def _generate_type_mappings(input_paths, output): + """Generates __type_mappings file from given .typemap files. + + Builds a command line to run generate_type_mappings.py, and executes it. + + Args: + input_paths: a list of file paths for .typemap files. + output: a path to output __type_mappings file. + """ + command = [sys.executable, _GENERATE_TYPE_MAPPINGS_PATH, '--output', output] + + # TODO(hidehiko): Add dependency handling. + + for path in input_paths: + typemap_config = _read_typemap_config(path) + command.append('--start-typemap') + for public_header in typemap_config.get('public_headers', []): + command.append('public_headers=' + public_header) + for traits_header in typemap_config.get('traits_headers', []): + command.append('traits_headers=' + traits_header) + for type_mapping in typemap_config.get('type_mappings', []): + command.append('type_mappings=' + type_mapping) + + subprocess.check_call(command) + + +def _parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('--output', help='Output file path') + parser.add_argument('input_paths', metavar="INPUT-PATH", nargs='+', + help='Input typemap files.') + return parser.parse_args() + + +def main(): + args = _parse_args() + _generate_type_mappings(args.input_paths, args.output) + + +if __name__ == '__main__': + main() diff --git a/libchrome_tools/mojom_source_generator.sh b/libchrome_tools/mojom_source_generator.sh deleted file mode 100755 index 683024186..000000000 --- a/libchrome_tools/mojom_source_generator.sh +++ /dev/null @@ -1,115 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2017 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generates mojo sources given a list of .mojom files and args. -# Usage: $0 --mojom_bindings_generator=<abs_path> --package=<package_directory> -# --output_dir=<output_directory> -# [<extra_args_for_bindings_generator>] <list_of_mojom_files> - -set -e - -args=() -files=() - -mojom_bindings_generator="" -package="" -output_dir="" -generators="" -private_mojo_root="$(pwd)/external/libchrome" - -# Given a path to directory or file, return the absolute path. -get_abs_path() { - if [[ -d $1 ]] ; then - cd "$1" - filename="" - else - filepath=$1 - dir="${filepath%/*}" - cd "${dir}" - filename="${filepath#${dir}/}" - fi - absdir=`pwd` - cd - > /dev/null - echo "${absdir}/${filename}" -} - -for arg in "$@"; do - case "${arg}" in - --mojom_bindings_generator=*) - mojom_bindings_generator="${arg#'--mojom_bindings_generator='}" - mojom_bindings_generator="$(get_abs_path ${mojom_bindings_generator})" - ;; - --package=*) - package="${arg#'--package='}" - ;; - --output_dir=*) - output_dir="${arg#'--output_dir='}" - output_dir="$(get_abs_path ${output_dir})" - ;; - --typemap=*) - typemap="${arg#'--typemap='}" - typemap="$(get_abs_path ${typemap})" - args=("${args[@]}" "--typemap=${typemap}") - ;; - --bytecode_path=*) - bytecode_path="${arg#'--bytecode_path='}" - bytecode_path="$(get_abs_path ${bytecode_path})" - ;; - --generators=*) - generators="${arg#'--generators='}" - ;; - --*) - args=("${args[@]}" "${arg}") - ;; - *) - files=("${files[@]}" "$(get_abs_path ${arg})") - ;; - esac -done - -cd "${package}" -"${mojom_bindings_generator}" --use_bundled_pylibs precompile \ - -o "${output_dir}" - -for file in "${files[@]}"; do - # Java source generations depends on zipfile that assumes the output directory - # already exists. So, we need to create the directory beforehand. - rel_path="${file#`pwd`/}" - rel_dir="${rel_path%/*}" - - mkdir -p "${output_dir}/${rel_dir}" - - # The calls to mojom_bindings_generator below uses -I option to include the - # libmojo root directory as part of searchable directory for imports. With - # this, we can have a mojo file located in some arbitrary directories that - # imports a mojo file under external/libchrome. - "${mojom_bindings_generator}" --use_bundled_pylibs generate \ - -o "${output_dir}" "${args[@]}" \ - --bytecode_path="${bytecode_path}" \ - -I "${private_mojo_root}:${private_mojo_root}" \ - --generators=${generators} "${file}" - if [[ "${generators}" =~ .*c\+\+.* ]] ; then - "${mojom_bindings_generator}" --use_bundled_pylibs generate \ - -o "${output_dir}" \ - --generate_non_variant_code "${args[@]}" \ - -I "${private_mojo_root}:${private_mojo_root}" \ - --bytecode_path="${bytecode_path}" --generators=${generators} \ - "${file}" - fi - if [[ "${generators}" =~ .*java.* ]] ; then - unzip -qo -d "${output_dir}"/src "${output_dir}/${rel_path}".srcjar - fi -done diff --git a/libchrome_tools/patch/0001-Use-qualified-base-make_optional-in-optional_unittes.patch b/libchrome_tools/patch/0001-Use-qualified-base-make_optional-in-optional_unittes.patch new file mode 100644 index 000000000..f053d7557 --- /dev/null +++ b/libchrome_tools/patch/0001-Use-qualified-base-make_optional-in-optional_unittes.patch @@ -0,0 +1,102 @@ +From d2e73f1115bfed906f2a10dc69aebced6774bac3 Mon Sep 17 00:00:00 2001 +From: tzik <tzik@chromium.org> +Date: Wed, 17 Oct 2018 12:38:46 +0000 +Subject: [PATCH] Use qualified base::make_optional in optional_unittest.cc + +Unqualified usage of make_optional causes a compile error if: + - It's compiler in C++17 mode and <optional> is included. + - The parameter of make_optional is in std namespace, such as + std::string. +As std::make_optional is pulled by ADL rule and conflicts to +base::make_optional in this situation. + +This CL replaces them with qualified base::make_optional, and +replaces others for consistency. + +Change-Id: I2045e9eac0e4466dce266112eab5bf7c8555c2ef +Reviewed-on: https://chromium-review.googlesource.com/c/1282512 +Reviewed-by: Daniel Cheng <dcheng@chromium.org> +Reviewed-by: Hidehiko Abe <hidehiko@chromium.org> +Commit-Queue: Taiju Tsuiki <tzik@chromium.org> +Cr-Commit-Position: refs/heads/master@{#600361} +--- + base/optional_unittest.cc | 25 +++++++++++++++---------- + 1 file changed, 15 insertions(+), 10 deletions(-) + +diff --git a/base/optional_unittest.cc b/base/optional_unittest.cc +index 7bdb46b76173..365e99da41df 100644 +--- a/base/optional_unittest.cc ++++ b/base/optional_unittest.cc +@@ -1899,34 +1899,39 @@ TEST(OptionalTest, NotEqualsNull) { + + TEST(OptionalTest, MakeOptional) { + { +- Optional<float> o = make_optional(32.f); ++ // Use qualified base::make_optional here and elsewhere to avoid the name ++ // confliction to std::make_optional. ++ // The name conflict happens only for types in std namespace, such as ++ // std::string. The other qualified base::make_optional usages are just for ++ // consistency. ++ Optional<float> o = base::make_optional(32.f); + EXPECT_TRUE(o); + EXPECT_EQ(32.f, *o); + + float value = 3.f; +- o = make_optional(std::move(value)); ++ o = base::make_optional(std::move(value)); + EXPECT_TRUE(o); + EXPECT_EQ(3.f, *o); + } + + { +- Optional<std::string> o = make_optional(std::string("foo")); ++ Optional<std::string> o = base::make_optional(std::string("foo")); + EXPECT_TRUE(o); + EXPECT_EQ("foo", *o); + + std::string value = "bar"; +- o = make_optional(std::move(value)); ++ o = base::make_optional(std::move(value)); + EXPECT_TRUE(o); + EXPECT_EQ(std::string("bar"), *o); + } + + { +- Optional<TestObject> o = make_optional(TestObject(3, 0.1)); ++ Optional<TestObject> o = base::make_optional(TestObject(3, 0.1)); + EXPECT_TRUE(!!o); + EXPECT_TRUE(TestObject(3, 0.1) == *o); + + TestObject value = TestObject(0, 0.42); +- o = make_optional(std::move(value)); ++ o = base::make_optional(std::move(value)); + EXPECT_TRUE(!!o); + EXPECT_TRUE(TestObject(0, 0.42) == *o); + EXPECT_EQ(TestObject::State::MOVED_FROM, value.state()); +@@ -1945,7 +1950,7 @@ TEST(OptionalTest, MakeOptional) { + bool c; + }; + +- Optional<Test> o = make_optional<Test>(1, 2.0, true); ++ Optional<Test> o = base::make_optional<Test>(1, 2.0, true); + EXPECT_TRUE(!!o); + EXPECT_EQ(1, o->a); + EXPECT_EQ(2.0, o->b); +@@ -1953,11 +1958,11 @@ TEST(OptionalTest, MakeOptional) { + } + + { +- auto str1 = make_optional<std::string>({'1', '2', '3'}); ++ auto str1 = base::make_optional<std::string>({'1', '2', '3'}); + EXPECT_EQ("123", *str1); + +- auto str2 = +- make_optional<std::string>({'a', 'b', 'c'}, std::allocator<char>()); ++ auto str2 = base::make_optional<std::string>({'a', 'b', 'c'}, ++ std::allocator<char>()); + EXPECT_EQ("abc", *str2); + } + } +-- +2.20.0.405.gbc1bbc6f85-goog + diff --git a/libchrome_tools/patch/580fcef.patch b/libchrome_tools/patch/580fcef.patch new file mode 100644 index 000000000..cff82bc63 --- /dev/null +++ b/libchrome_tools/patch/580fcef.patch @@ -0,0 +1,112 @@ +From 580fcef90ab970ad37ea9f7059373f773b3e55d2 Mon Sep 17 00:00:00 2001 +From: Jakub Pawlowski <jpawlowski@google.com> +Date: Fri, 03 Aug 2018 08:46:10 +0000 +Subject: [PATCH] Fix data_types_definition.tmpl + +This template can generate code that does not compile, if there are +multiple fields with different versions where at least one has version 0 +and end up being laid out in a way that does not match the ordinal order + +Sample Mojo file: +// Describes ARC package. +struct ArcPackageInfo { + string package_name; + int32 package_version; + int64 last_backup_android_id; + int64 last_backup_time; + bool sync; // true if package installation should be synced + [MinVersion=11] bool system; // true if package is system package. + // true if package registers VPNService intent. + [MinVersion=25] bool vpn_provider; +}; + +Sample badly generated code (no closing "}" for last if): + + @SuppressWarnings("unchecked") + public static ArcPackageInfo decode(org.chromium.mojo.bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + decoder0.increaseStackDepth(); + ArcPackageInfo result; + try { + org.chromium.mojo.bindings.DataHeader mainDataHeader = decoder0.readAndValidateDataHeader(VERSION_ARRAY); + final int elementsOrVersion = mainDataHeader.elementsOrVersion; + result = new ArcPackageInfo(elementsOrVersion); + { + + result.packageName = decoder0.readString(8, false); + } + { + + result.packageVersion = decoder0.readInt(16); + } + { + + result.sync = decoder0.readBoolean(20, 0); + } + if (elementsOrVersion >= 11) { + { + + result.system = decoder0.readBoolean(20, 1); + } + } + if (elementsOrVersion >= 25) { + { + + result.vpnProvider = decoder0.readBoolean(20, 2); + } + } + if (elementsOrVersion >= 0) { + { + + result.lastBackupAndroidId = decoder0.readLong(24); + } + { + + result.lastBackupTime = decoder0.readLong(32); + } + } finally { + decoder0.decreaseStackDepth(); + } + return result; + } + +Change-Id: I4c1b573a71b20cc6a0828a2cceff6bbfbb4ac5bc +Reviewed-on: https://chromium-review.googlesource.com/1158702 +Reviewed-by: Luis Hector Chavez <lhchavez@chromium.org> +Reviewed-by: Ken Rockot <rockot@chromium.org> +Commit-Queue: Jakub x Jakub Pawlowski <jpawlowski@google.com> +Cr-Commit-Position: refs/heads/master@{#580480} +--- + +diff --git a/mojo/public/tools/bindings/generators/java_templates/data_types_definition.tmpl b/mojo/public/tools/bindings/generators/java_templates/data_types_definition.tmpl +index 59c6fee..7af57bd 100644 +--- a/mojo/public/tools/bindings/generators/java_templates/data_types_definition.tmpl ++++ b/mojo/public/tools/bindings/generators/java_templates/data_types_definition.tmpl +@@ -175,6 +175,7 @@ + org.chromium.mojo.bindings.DataHeader mainDataHeader = decoder0.readAndValidateDataHeader(VERSION_ARRAY); + final int elementsOrVersion = mainDataHeader.elementsOrVersion; + result = new {{struct|name}}(elementsOrVersion); ++ + {%- set prev_ver = [0] %} + {%- for byte in struct.bytes %} + {%- for packed_field in byte.packed_fields %} +@@ -183,7 +184,9 @@ + } + {%- endif %} + {%- set _ = prev_ver.append(packed_field.min_version) %} ++{%- if prev_ver[-1] != 0 %} + if (elementsOrVersion >= {{packed_field.min_version}}) { ++{%- endif %} + {%- endif %} + { + {{decode('result.' ~ packed_field.field|name, packed_field.field.kind, 8+packed_field.offset, packed_field.bit)|indent(16)}} +@@ -193,6 +196,7 @@ + {%- if prev_ver[-1] != 0 %} + } + {%- endif %} ++ + } finally { + decoder0.decreaseStackDepth(); + } diff --git a/libchrome_tools/patch/8fbafc9.patch b/libchrome_tools/patch/8fbafc9.patch new file mode 100644 index 000000000..d872f9e79 --- /dev/null +++ b/libchrome_tools/patch/8fbafc9.patch @@ -0,0 +1,25 @@ +From 8fbafc974b92d26780d7e2a8c36856ff689e8f6b Mon Sep 17 00:00:00 2001 +From: Jakub Pawlowski <jpawlowski@google.com> +Date: Thu, 27 Sep 2018 19:10:56 +0000 +Subject: [PATCH] Add missing include for condition variable in base/test/test_mock_time_task_runner.h + +Change-Id: Ia6b77632aab5df842c8878fba6fc96bf405a28de +Reviewed-on: https://chromium-review.googlesource.com/1249488 +Reviewed-by: Luis Hector Chavez <lhchavez@chromium.org> +Reviewed-by: Gabriel Charette <gab@chromium.org> +Commit-Queue: Gabriel Charette <gab@chromium.org> +Cr-Commit-Position: refs/heads/master@{#594806} +--- + +diff --git a/base/test/test_mock_time_task_runner.h b/base/test/test_mock_time_task_runner.h +index dd7274c..dcfbcbd 100644 +--- a/base/test/test_mock_time_task_runner.h ++++ b/base/test/test_mock_time_task_runner.h +@@ -17,6 +17,7 @@ + #include "base/macros.h" + #include "base/run_loop.h" + #include "base/single_thread_task_runner.h" ++#include "base/synchronization/condition_variable.h" + #include "base/synchronization/lock.h" + #include "base/test/test_pending_task.h" + #include "base/threading/thread_checker_impl.h" diff --git a/libchrome_tools/patch/ContextUtils.patch b/libchrome_tools/patch/ContextUtils.patch new file mode 100644 index 000000000..6e1a484f7 --- /dev/null +++ b/libchrome_tools/patch/ContextUtils.patch @@ -0,0 +1,18 @@ +diff --git a/base/android/java/src/org/chromium/base/ContextUtils.java b/base/android/java/src/org/chromium/base/ContextUtils.java +index 8284cd1..c648e01 100644 +--- a/base/android/java/src/org/chromium/base/ContextUtils.java ++++ b/base/android/java/src/org/chromium/base/ContextUtils.java +@@ -100,9 +100,10 @@ public class ContextUtils { + // that use Robolectric and set the application context manually. Instead of changing all + // tests that do so, the call was put here instead. + // TODO(mheikal): Require param to be of type Application +- if (appContext instanceof Application) { +- ApplicationStatus.initialize((Application) appContext); +- } ++ // Disabled on libchrome ++ // if (appContext instanceof Application) { ++ // ApplicationStatus.initialize((Application) appContext); ++ // } + initJavaSideApplicationContext(appContext); + Holder.sSharedPreferences = fetchAppSharedPreferences(); + } diff --git a/libchrome_tools/patch/ThreadLocalStorage-Add-a-function-to-destroy-pthread.patch b/libchrome_tools/patch/ThreadLocalStorage-Add-a-function-to-destroy-pthread.patch new file mode 100644 index 000000000..2c214379b --- /dev/null +++ b/libchrome_tools/patch/ThreadLocalStorage-Add-a-function-to-destroy-pthread.patch @@ -0,0 +1,63 @@ +From 28a638ff22f598f6aa9388db6a4cf13fe9f11644 Mon Sep 17 00:00:00 2001 +From: Hirokazu Honda <hiroh@google.com> +Date: Wed, 1 Aug 2018 17:03:18 +0900 +Subject: [PATCH] ThreadLocalStorage: Add a function to destroy pthread key + used in libchrome + +MojoProcessSupport needs to destroy pthread key which is globally used in libchrome. The key is +stored in a local variable in thread_local_storage.cc. +This adds a function to destroy the key so that MojoProcessSupport can do it. + +Bug: 110722333 +Test: No crash in opening DRMInfo.app +Test: PlayStore still works +Test: cheets_ContainerSmokeTest and cheets_LoginScreen +Change-Id: Ib10c83deb5f7ef141d4ab9883e0d2c31d422a1b1 +--- + base/threading/thread_local_storage.cc | 11 +++++++++++ + base/threading/thread_local_storage.h | 7 +++++++ + 2 files changed, 18 insertions(+) + +diff --git a/base/threading/thread_local_storage.cc b/base/threading/thread_local_storage.cc +index 48c1dd5..90ae69e 100644 +--- a/base/threading/thread_local_storage.cc ++++ b/base/threading/thread_local_storage.cc +@@ -247,6 +247,17 @@ void PlatformThreadLocalStorage::OnThreadExit() { + void PlatformThreadLocalStorage::OnThreadExit(void* value) { + OnThreadExitInternal(static_cast<TlsVectorEntry*>(value)); + } ++ ++// static ++void PlatformThreadLocalStorage::ForceFreeTLS() { ++ PlatformThreadLocalStorage::TLSKey key = ++ base::subtle::NoBarrier_AtomicExchange( ++ &g_native_tls_key, ++ PlatformThreadLocalStorage::TLS_KEY_OUT_OF_INDEXES); ++ if (key == PlatformThreadLocalStorage::TLS_KEY_OUT_OF_INDEXES) ++ return; ++ PlatformThreadLocalStorage::FreeTLS(key); ++} + #endif // defined(OS_WIN) + + } // namespace internal +diff --git a/base/threading/thread_local_storage.h b/base/threading/thread_local_storage.h +index fd2a789..c5c7759 100644 +--- a/base/threading/thread_local_storage.h ++++ b/base/threading/thread_local_storage.h +@@ -75,6 +75,13 @@ class BASE_EXPORT PlatformThreadLocalStorage { + // GetTLSValue() to retrieve the value of slot as it has already been reset + // in Posix. + static void OnThreadExit(void* value); ++ // Normally, Chrome runs as a process, so freeing the TLS is not needed since ++ // the OS will perform that while it's reclaiming the process' memory upon ++ // termination. If, however, this code is used inside a library that is ++ // dynamically loaded and unloaded, the consumer is responsible for calling ++ // this after all Chrome threads have stopped and prior to unloading the ++ // library. ++ static void ForceFreeTLS(); + #endif + }; + +-- +2.18.0.345.g5c9ce644c3-goog + diff --git a/libchrome_tools/patch/alignof_int64.patch b/libchrome_tools/patch/alignof_int64.patch new file mode 100644 index 000000000..121def4d3 --- /dev/null +++ b/libchrome_tools/patch/alignof_int64.patch @@ -0,0 +1,88 @@ +From 5177b28400e03d8666dfb3e65c3016b5062ce0f7 Mon Sep 17 00:00:00 2001 +From: Chih-Hung Hsieh <chh@google.com> +Date: Thu, 15 Nov 2018 16:07:02 -0800 +Subject: [PATCH] Update asserts in mojo about int64_t's alignment + +The purpose of these asserts is to check that the options structs are aligned +sufficiently that an int64_t (or similar) could be added to them. The asserts +were added in https://codereview.chromium.org/295383012 + +However, the alignment of int64_t on 32-bit x86 is actually 4 bytes, not 8. So +how did this ever work? Before Clang r345419, the alignof() operator (which is what +MOJO_ALIGNOF maps to) would return the *preferred alignment* of a type, not +the *ABI alignment*. That's not what the C and C++ standards specify, so the +bug was fixed and the asserts started firing. (See also +https://llvm.org/pr26547) + +To fix the build, change the asserts to check that int64_t requires 8 bytes +alignment *or less*. + +Bug: 900406 +Bug: 119634736 +Change-Id: Icf80cea80ac31082423faab8c192420d0b98d515 +Reviewed-on: https://chromium-review.googlesource.com/c/1318971 +Commit-Queue: Ken Rockot <rockot@google.com> +Reviewed-by: Ken Rockot <rockot@google.com> +Cr-Commit-Position: refs/heads/master@{#605699} +--- + mojo/core/options_validation_unittest.cc | 2 +- + mojo/public/c/system/buffer.h | 2 +- + mojo/public/c/system/data_pipe.h | 2 +- + mojo/public/c/system/message_pipe.h | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/mojo/core/options_validation_unittest.cc b/mojo/core/options_validation_unittest.cc +index 52e0032..b4b02dc 100644 +--- a/mojo/core/options_validation_unittest.cc ++++ b/mojo/core/options_validation_unittest.cc +@@ -18,7 +18,7 @@ namespace { + + using TestOptionsFlags = uint32_t; + +-static_assert(MOJO_ALIGNOF(int64_t) == 8, "int64_t has weird alignment"); ++static_assert(MOJO_ALIGNOF(int64_t) <= 8, "int64_t has weird alignment"); + struct MOJO_ALIGNAS(8) TestOptions { + uint32_t struct_size; + TestOptionsFlags flags; +diff --git a/mojo/public/c/system/buffer.h b/mojo/public/c/system/buffer.h +index 2cc5427..83b198b 100644 +--- a/mojo/public/c/system/buffer.h ++++ b/mojo/public/c/system/buffer.h +@@ -30,7 +30,7 @@ struct MOJO_ALIGNAS(8) MojoCreateSharedBufferOptions { + // See |MojoCreateSharedBufferFlags|. + MojoCreateSharedBufferFlags flags; + }; +-MOJO_STATIC_ASSERT(MOJO_ALIGNOF(int64_t) == 8, "int64_t has weird alignment"); ++MOJO_STATIC_ASSERT(MOJO_ALIGNOF(int64_t) <= 8, "int64_t has weird alignment"); + MOJO_STATIC_ASSERT(sizeof(MojoCreateSharedBufferOptions) == 8, + "MojoCreateSharedBufferOptions has wrong size"); + +diff --git a/mojo/public/c/system/data_pipe.h b/mojo/public/c/system/data_pipe.h +index 3702cdb..c72f553 100644 +--- a/mojo/public/c/system/data_pipe.h ++++ b/mojo/public/c/system/data_pipe.h +@@ -40,7 +40,7 @@ struct MOJO_ALIGNAS(8) MojoCreateDataPipeOptions { + // system-dependent capacity of at least one element in size. + uint32_t capacity_num_bytes; + }; +-MOJO_STATIC_ASSERT(MOJO_ALIGNOF(int64_t) == 8, "int64_t has weird alignment"); ++MOJO_STATIC_ASSERT(MOJO_ALIGNOF(int64_t) <= 8, "int64_t has weird alignment"); + MOJO_STATIC_ASSERT(sizeof(MojoCreateDataPipeOptions) == 16, + "MojoCreateDataPipeOptions has wrong size"); + +diff --git a/mojo/public/c/system/message_pipe.h b/mojo/public/c/system/message_pipe.h +index 9f222f9..0f642dd 100644 +--- a/mojo/public/c/system/message_pipe.h ++++ b/mojo/public/c/system/message_pipe.h +@@ -35,7 +35,7 @@ struct MOJO_ALIGNAS(8) MojoCreateMessagePipeOptions { + // See |MojoCreateMessagePipeFlags|. + MojoCreateMessagePipeFlags flags; + }; +-MOJO_STATIC_ASSERT(MOJO_ALIGNOF(int64_t) == 8, "int64_t has weird alignment"); ++MOJO_STATIC_ASSERT(MOJO_ALIGNOF(int64_t) <= 8, "int64_t has weird alignment"); + MOJO_STATIC_ASSERT(sizeof(MojoCreateMessagePipeOptions) == 8, + "MojoCreateMessagePipeOptions has wrong size"); + +-- +2.20.0.rc0.387.gc7a69e6b6c-goog + diff --git a/libchrome_tools/patch/allocator_shim.patch b/libchrome_tools/patch/allocator_shim.patch index e87f614ec..f5fe9e801 100644 --- a/libchrome_tools/patch/allocator_shim.patch +++ b/libchrome_tools/patch/allocator_shim.patch @@ -2,7 +2,7 @@ --- a/base/allocator/allocator_shim.cc +++ b/base/allocator/allocator_shim.cc -@@ -299,7 +299,7 @@ ALWAYS_INLINE void ShimFreeDefiniteSize( +@@ -285,7 +285,7 @@ ALWAYS_INLINE void ShimFreeDefiniteSize(void* ptr, size_t size, void* context) { #include "base/allocator/allocator_shim_override_cpp_symbols.h" #endif diff --git a/libchrome_tools/patch/buildflag_header.patch b/libchrome_tools/patch/buildflag_header.patch index 69cc417b7..55abdc044 100644 --- a/libchrome_tools/patch/buildflag_header.patch +++ b/libchrome_tools/patch/buildflag_header.patch @@ -2,26 +2,50 @@ # Instead, in libchrome, these are checked in. --- /dev/null -+++ b/base/allocator/features.h -@@ -0,0 +1,15 @@ -+// Generated by build/write_buildflag_header.py -+// From "allocator_features" ++++ b/base/allocator/buildflags.h +@@ -0,0 +1,5 @@ ++#ifndef BASE_ALLOCATOR_BUILDFLAGS_H_ ++#define BASE_ALLOCATOR_BUILDFLAGS_H_ ++#include "build/buildflag.h" ++#define BUILDFLAG_INTERNAL_USE_ALLOCATOR_SHIM() (0) ++#endif // BASE_ALLOCATOR_BUILDFLAGS_H_ +--- /dev/null ++++ b/base/android/java/src/org/chromium/base/BuildConfig.java +@@ -0,0 +1,21 @@ ++// 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 BASE_ALLOCATOR_FEATURES_H_ -+#define BASE_ALLOCATOR_FEATURES_H_ ++package org.chromium.base; + -+#include "build/buildflag.h" ++/** ++ * Build configuration. Generated on a per-target basis. ++ */ ++public class BuildConfig { ++ ++ ++ public static final String FIREBASE_APP_ID = ""; + -+#if defined(__APPLE__) || defined(ANDROID) -+#define BUILDFLAG_INTERNAL_USE_EXPERIMENTAL_ALLOCATOR_SHIM() (0) -+#else -+#define BUILDFLAG_INTERNAL_USE_EXPERIMENTAL_ALLOCATOR_SHIM() (1) -+#endif ++ public static final boolean DCHECK_IS_ON = false; + -+#endif // BASE_ALLOCATOR_FEATURES_H_ ++ // The ID of the android string resource that stores the product version. ++ // This layer of indirection is necessary to make the resource dependency ++ // optional for android_apk targets/base_java (ex. for cronet). ++ public static final int R_STRING_PRODUCT_VERSION = 0; ++} --- /dev/null -+++ b/base/debug/debugging_flags.h -@@ -0,0 +1,8 @@ ++++ b/base/cfi_buildflags.h +@@ -0,0 +1,7 @@ ++// Generated by build/write_buildflag_header.py ++// From "base_debugging_flags" ++#ifndef BASE_CFI_BUILDFLAGS_H_ ++#define BASE_CFI_BUILDFLAGS_H_ ++#include "build/buildflag.h" ++#define BUILDFLAG_INTERNAL_CFI_ICALL_CHECK() (0) ++#endif // BASE_CFI_BUILDFLAGS_H_ +--- /dev/null ++++ b/base/debug/debugging_buildflags.h +@@ -0,0 +1,12 @@ +// Generated by build/write_buildflag_header.py +// From "base_debugging_flags" +#ifndef BASE_DEBUG_DEBUGGING_FLAGS_H_ @@ -29,4 +53,45 @@ +#include "build/buildflag.h" +#define BUILDFLAG_INTERNAL_ENABLE_PROFILING() (0) +#define BUILDFLAG_INTERNAL_ENABLE_MEMORY_TASK_PROFILER() (0) ++#define BUILDFLAG_INTERNAL_CAN_UNWIND_WITH_FRAME_POINTERS() (0) ++#define BUILDFLAG_INTERNAL_ENABLE_LOCATION_SOURCE() (0) ++#define BUILDFLAG_INTERNAL_CFI_ENFORCEMENT_TRAP() (0) ++#define BUILDFLAG_INTERNAL_ENABLE_MUTEX_PRIORITY_INHERITANCE() (0) +#endif // BASE_DEBUG_DEBUGGING_FLAGS_H_ +--- /dev/null ++++ b/base/memory/protected_memory_buildflags.h +@@ -0,0 +1,7 @@ ++// Generated by build/write_buildflag_header.py ++// From "base_debugging_flags" ++#ifndef BASE_PROTECTED_MEMORY_BUILDFLAGS_H_ ++#define BASE_PROTECTED_MEMORY_BUILDFLAGS_H_ ++#include "build/buildflag.h" ++#define BUILDFLAG_INTERNAL_USE_LLD() (0) ++#endif // BASE_PROTECTED_MEMORY_BUILDFLAGS_H_ +--- /dev/null ++++ b/base/synchronization/synchronization_buildflags.h +@@ -0,0 +1,4 @@ ++#ifndef BASE_SYNCHRONIZATION_BUILDFLAGS_H_ ++#define BASE_SYNCHRONIZATION_BUILDFLAGS_H_ ++#include "build/buildflag.h" ++#endif // BASE_SYNCHRONIZATION_BUILDFLAGS_H_ +--- /dev/null ++++ b/ipc/ipc_buildflags.h +@@ -0,0 +1,8 @@ ++#ifndef CPP_IPC_BUILDFLAGS_H_ ++#define CPP_IPC_BUILDFLAGS_H_ ++ ++#include <build/buildflag.h> ++ ++#define BUILDFLAG_INTERNAL_IPC_MESSAGE_LOG_ENABLED() (0) ++ ++#endif // CPP_IPC_BUILDFLAGS_H_ +--- /dev/null ++++ b/mojo/public/cpp/bindings/mojo_buildflags.h +@@ -0,0 +1,6 @@ ++#ifndef CPP_MOJO_BUILD_FLAGS_H_ ++#define CPP_MOJO_BUILD_FLAGS_H_ ++ ++#include <build/buildflag.h> ++#define BUILDFLAG_INTERNAL_MOJO_TRACE_ENABLED() (0) ++#endif // CPP_MOJO_BUILD_FLAGS_H_ diff --git a/libchrome_tools/patch/c7ce19d.patch b/libchrome_tools/patch/c7ce19d.patch new file mode 100644 index 000000000..1d6b9d968 --- /dev/null +++ b/libchrome_tools/patch/c7ce19d.patch @@ -0,0 +1,28 @@ +From c7ce19d52a7e6f3e69e66107650992765da559b7 Mon Sep 17 00:00:00 2001 +From: Jakub Pawlowski <jpawlowski@google.com> +Date: Mon, 06 Aug 2018 03:06:46 +0000 +Subject: [PATCH] Make LAZY_INSTANCE_INITIALIZER -Wmissing-field-initializers friendly + +If libbase is compiled with -Wmissing-field-initializers this is causing +warning to be generated. + +Change-Id: I446160d4c94bb59dd23f2f151004a8bfaeae832d +Reviewed-on: https://chromium-review.googlesource.com/1161927 +Reviewed-by: Gabriel Charette <gab@chromium.org> +Commit-Queue: Luis Hector Chavez <lhchavez@chromium.org> +Cr-Commit-Position: refs/heads/master@{#580794} +--- + +diff --git a/base/lazy_instance.h b/base/lazy_instance.h +index 36d3158..4449373 100644 +--- a/base/lazy_instance.h ++++ b/base/lazy_instance.h +@@ -55,7 +55,7 @@ + + // LazyInstance uses its own struct initializer-list style static + // initialization, which does not require a constructor. +-#define LAZY_INSTANCE_INITIALIZER {0} ++#define LAZY_INSTANCE_INITIALIZER {} + + namespace base { + diff --git a/libchrome_tools/patch/dmg_fp.patch b/libchrome_tools/patch/dmg_fp.patch index 50427716c..95cc67d00 100644 --- a/libchrome_tools/patch/dmg_fp.patch +++ b/libchrome_tools/patch/dmg_fp.patch @@ -3,18 +3,18 @@ --- a/base/strings/string_number_conversions.cc +++ b/base/strings/string_number_conversions.cc -@@ -15,7 +15,6 @@ - #include "base/logging.h" +@@ -16,7 +16,6 @@ #include "base/numerics/safe_math.h" #include "base/scoped_clear_errno.h" + #include "base/strings/utf_string_conversions.h" -#include "base/third_party/dmg_fp/dmg_fp.h" namespace base { -@@ -369,10 +368,18 @@ string16 SizeTToString16(size_t value) { +@@ -361,20 +360,35 @@ string16 NumberToString16(unsigned long long value) { } - std::string DoubleToString(double value) { + std::string NumberToString(double value) { - // According to g_fmt.cc, it is sufficient to declare a buffer of size 32. - char buffer[32]; - dmg_fp::g_fmt(buffer, value); @@ -33,17 +33,39 @@ + return ret; } - bool StringToInt(const StringPiece& input, int* output) { -@@ -416,14 +423,10 @@ bool StringToSizeT(const StringPiece16& + base::string16 NumberToString16(double value) { +- // According to g_fmt.cc, it is sufficient to declare a buffer of size 32. +- char buffer[32]; +- dmg_fp::g_fmt(buffer, value); ++ auto tmp = std::to_string(value); ++ base::string16 ret(tmp.c_str(), tmp.c_str() + tmp.length()); + +- // The number will be ASCII. This creates the string using the "input +- // iterator" variant which promotes from 8-bit to 16-bit via "=". +- return base::string16(&buffer[0], &buffer[strlen(buffer)]); ++ // If this returned an integer, don't do anything. ++ if (ret.find('.') == std::string::npos) { ++ return ret; ++ } ++ // Otherwise, it has an annoying tendency to leave trailing zeros. ++ size_t len = ret.size(); ++ while (len >= 2 && ret[len - 1] == '0' && ret[len - 2] != '.') { ++ --len; ++ } ++ ret.erase(len); ++ return ret; + } + + bool StringToInt(StringPiece input, int* output) { +@@ -418,14 +432,10 @@ bool StringToSizeT(StringPiece16 input, size_t* output) { } bool StringToDouble(const std::string& input, double* output) { - // Thread-safe? It is on at least Mac, Linux, and Windows. - ScopedClearErrno clear_errno; - -- char* endptr = NULL; + char* endptr = nullptr; - *output = dmg_fp::strtod(input.c_str(), &endptr); -+ char* endptr = nullptr; + *output = strtod(input.c_str(), &endptr); // Cases to return false: @@ -51,7 +73,7 @@ // - If the input string is empty, there was nothing to parse. // - If endptr does not point to the end of the string, there are either // characters remaining in the string after a parsed number, or the string -@@ -431,10 +434,11 @@ bool StringToDouble(const std::string& i +@@ -433,10 +443,11 @@ bool StringToDouble(const std::string& input, double* output) { // expected end given the string's stated length to correctly catch cases // where the string contains embedded NUL characters. // - If the first character is a space, there was leading whitespace @@ -66,27 +88,9 @@ } // Note: if you need to add String16ToDouble, first ask yourself if it's ---- a/base/strings/string_number_conversions.h -+++ b/base/strings/string_number_conversions.h -@@ -54,6 +54,7 @@ BASE_EXPORT string16 Uint64ToString16(ui - BASE_EXPORT std::string SizeTToString(size_t value); - BASE_EXPORT string16 SizeTToString16(size_t value); - -+// Deprecated: prefer std::to_string(double) instead. - // DoubleToString converts the double to a string format that ignores the - // locale. If you want to use locale specific formatting, use ICU. - BASE_EXPORT std::string DoubleToString(double value); -@@ -91,6 +92,7 @@ BASE_EXPORT bool StringToUint64(const St - BASE_EXPORT bool StringToSizeT(const StringPiece& input, size_t* output); - BASE_EXPORT bool StringToSizeT(const StringPiece16& input, size_t* output); - -+// Deprecated: prefer std::stod() instead. - // For floating-point conversions, only conversions of input strings in decimal - // form are defined to work. Behavior with strings representing floating-point - // numbers in hexadecimal, and strings representing non-finite values (such as --- a/base/strings/string_number_conversions_unittest.cc +++ b/base/strings/string_number_conversions_unittest.cc -@@ -752,20 +752,8 @@ TEST(StringNumberConversionsTest, String +@@ -754,20 +754,8 @@ TEST(StringNumberConversionsTest, StringToDouble) { {"9e999", HUGE_VAL, false}, {"9e1999", HUGE_VAL, false}, {"9e19999", HUGE_VAL, false}, @@ -109,7 +113,7 @@ {"1e-2", 0.01, true}, {"42 ", 42.0, false}, {" 1e-2", 0.01, false}, -@@ -795,7 +783,8 @@ TEST(StringNumberConversionsTest, String +@@ -797,7 +785,8 @@ TEST(StringNumberConversionsTest, StringToDouble) { for (size_t i = 0; i < arraysize(cases); ++i) { double output; errno = 1; @@ -119,7 +123,7 @@ if (cases[i].success) EXPECT_EQ(1, errno) << i; // confirm that errno is unchanged. EXPECT_DOUBLE_EQ(cases[i].output, output); -@@ -816,13 +805,13 @@ TEST(StringNumberConversionsTest, Double +@@ -818,13 +807,13 @@ TEST(StringNumberConversionsTest, DoubleToString) { double input; const char* expected; } cases[] = { @@ -139,18 +143,18 @@ }; for (size_t i = 0; i < arraysize(cases); ++i) { -@@ -833,12 +822,12 @@ TEST(StringNumberConversionsTest, Double +@@ -836,12 +825,12 @@ TEST(StringNumberConversionsTest, DoubleToString) { const char input_bytes[8] = {0, 0, 0, 0, '\xee', '\x6d', '\x73', '\x42'}; double input = 0; memcpy(&input, input_bytes, arraysize(input_bytes)); -- EXPECT_EQ("1335179083776", DoubleToString(input)); -+ EXPECT_EQ("1335179083776.0", DoubleToString(input)); +- EXPECT_EQ("1335179083776", NumberToString(input)); ++ EXPECT_EQ("1335179083776.0", NumberToString(input)); const char input_bytes2[8] = {0, 0, 0, '\xa0', '\xda', '\x6c', '\x73', '\x42'}; input = 0; memcpy(&input, input_bytes2, arraysize(input_bytes2)); -- EXPECT_EQ("1334890332160", DoubleToString(input)); -+ EXPECT_EQ("1334890332160.0", DoubleToString(input)); +- EXPECT_EQ("1334890332160", NumberToString(input)); ++ EXPECT_EQ("1334890332160.0", NumberToString(input)); } TEST(StringNumberConversionsTest, HexEncode) { diff --git a/libchrome_tools/patch/file_path_mojom.patch b/libchrome_tools/patch/file_path_mojom.patch new file mode 100644 index 000000000..b61d62649 --- /dev/null +++ b/libchrome_tools/patch/file_path_mojom.patch @@ -0,0 +1,19 @@ +diff --git a/mojo/public/mojom/base/file_path.mojom b/mojo/public/mojom/base/file_path.mojom +index 674d8cd..097b37e 100644 +--- a/mojo/public/mojom/base/file_path.mojom ++++ b/mojo/public/mojom/base/file_path.mojom +@@ -5,7 +5,13 @@ + module mojo_base.mojom; + + struct FilePath { +- [EnableIf=file_path_is_string] ++ // In chrome, ninja have a goal that can define file_path_is_string for a set ++ // of mojom files. ++ // In android we don't have such ability ,one would have to add ++ // "--enable_feature file_path_is_string" to all targets generating pickle ++ // files, headers and sources, and also in all project including them. ++ // Faster solution was to just remove this "EnableIf" definition in libchrome. ++ // [EnableIf=file_path_is_string] + string path; + + // This duplicates the contents of mojo_base.mojom.String16. String16 isn't diff --git a/libchrome_tools/patch/file_posix.patch b/libchrome_tools/patch/file_posix.patch index c7428e347..6fe3af80c 100644 --- a/libchrome_tools/patch/file_posix.patch +++ b/libchrome_tools/patch/file_posix.patch @@ -2,7 +2,7 @@ --- a/base/files/file_posix.cc +++ b/base/files/file_posix.cc -@@ -185,7 +185,9 @@ int64_t File::Seek(Whence whence, int64_ +@@ -189,7 +189,9 @@ int64_t File::Seek(Whence whence, int64_t offset) { SCOPED_FILE_TRACE_WITH_SIZE("Seek", offset); @@ -13,3 +13,12 @@ static_assert(sizeof(int64_t) == sizeof(off64_t), "off64_t must be 64 bits"); return lseek64(file_.get(), static_cast<off64_t>(offset), static_cast<int>(whence)); +@@ -275,7 +277,7 @@ int File::Write(int64_t offset, const char* data, int size) { + int bytes_written = 0; + int rv; + do { +-#if defined(OS_ANDROID) ++#if _FILE_OFFSET_BITS != 64 || defined(__BIONIC__) + // In case __USE_FILE_OFFSET64 is not used, we need to call pwrite64() + // instead of pwrite(). + static_assert(sizeof(int64_t) == sizeof(off64_t),
\ No newline at end of file diff --git a/libchrome_tools/patch/handle_table.patch b/libchrome_tools/patch/handle_table.patch new file mode 100644 index 000000000..354fac81d --- /dev/null +++ b/libchrome_tools/patch/handle_table.patch @@ -0,0 +1,176 @@ +diff --git a/mojo/core/handle_table.cc b/mojo/core/handle_table.cc +index 62419a9..e039c71 100644 +--- a/mojo/core/handle_table.cc ++++ b/mojo/core/handle_table.cc +@@ -8,35 +8,35 @@ + + #include <limits> + +-#include "base/trace_event/memory_dump_manager.h" ++// #include "base/trace_event/memory_dump_manager.h" + + namespace mojo { + namespace core { + + namespace { + +-const char* GetNameForDispatcherType(Dispatcher::Type type) { +- switch (type) { +- case Dispatcher::Type::UNKNOWN: +- return "unknown"; +- case Dispatcher::Type::MESSAGE_PIPE: +- return "message_pipe"; +- case Dispatcher::Type::DATA_PIPE_PRODUCER: +- return "data_pipe_producer"; +- case Dispatcher::Type::DATA_PIPE_CONSUMER: +- return "data_pipe_consumer"; +- case Dispatcher::Type::SHARED_BUFFER: +- return "shared_buffer"; +- case Dispatcher::Type::WATCHER: +- return "watcher"; +- case Dispatcher::Type::PLATFORM_HANDLE: +- return "platform_handle"; +- case Dispatcher::Type::INVITATION: +- return "invitation"; +- } +- NOTREACHED(); +- return "unknown"; +-} ++// const char* GetNameForDispatcherType(Dispatcher::Type type) { ++// switch (type) { ++// case Dispatcher::Type::UNKNOWN: ++// return "unknown"; ++// case Dispatcher::Type::MESSAGE_PIPE: ++// return "message_pipe"; ++// case Dispatcher::Type::DATA_PIPE_PRODUCER: ++// return "data_pipe_producer"; ++// case Dispatcher::Type::DATA_PIPE_CONSUMER: ++// return "data_pipe_consumer"; ++// case Dispatcher::Type::SHARED_BUFFER: ++// return "shared_buffer"; ++// case Dispatcher::Type::WATCHER: ++// return "watcher"; ++// case Dispatcher::Type::PLATFORM_HANDLE: ++// return "platform_handle"; ++// case Dispatcher::Type::INVITATION: ++// return "invitation"; ++// } ++// NOTREACHED(); ++// return "unknown"; ++// } + + } // namespace + +@@ -158,38 +158,38 @@ void HandleTable::GetActiveHandlesForTest(std::vector<MojoHandle>* handles) { + } + + // MemoryDumpProvider implementation. +-bool HandleTable::OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, +- base::trace_event::ProcessMemoryDump* pmd) { +- // Create entries for all relevant dispatcher types to ensure they are present +- // in the final dump. +- std::map<Dispatcher::Type, int> handle_count; +- handle_count[Dispatcher::Type::MESSAGE_PIPE]; +- handle_count[Dispatcher::Type::DATA_PIPE_PRODUCER]; +- handle_count[Dispatcher::Type::DATA_PIPE_CONSUMER]; +- handle_count[Dispatcher::Type::SHARED_BUFFER]; +- handle_count[Dispatcher::Type::WATCHER]; +- handle_count[Dispatcher::Type::PLATFORM_HANDLE]; +- handle_count[Dispatcher::Type::INVITATION]; +- +- // Count the number of each dispatcher type. +- { +- base::AutoLock lock(GetLock()); +- for (const auto& entry : handles_) { +- ++handle_count[entry.second.dispatcher->GetType()]; +- } +- } +- +- for (const auto& entry : handle_count) { +- base::trace_event::MemoryAllocatorDump* inner_dump = +- pmd->CreateAllocatorDump(std::string("mojo/") + +- GetNameForDispatcherType(entry.first)); +- inner_dump->AddScalar( +- base::trace_event::MemoryAllocatorDump::kNameObjectCount, +- base::trace_event::MemoryAllocatorDump::kUnitsObjects, entry.second); +- } +- +- return true; +-} ++// bool HandleTable::OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, ++// base::trace_event::ProcessMemoryDump* pmd) { ++// // Create entries for all relevant dispatcher types to ensure they are present ++// // in the final dump. ++// std::map<Dispatcher::Type, int> handle_count; ++// handle_count[Dispatcher::Type::MESSAGE_PIPE]; ++// handle_count[Dispatcher::Type::DATA_PIPE_PRODUCER]; ++// handle_count[Dispatcher::Type::DATA_PIPE_CONSUMER]; ++// handle_count[Dispatcher::Type::SHARED_BUFFER]; ++// handle_count[Dispatcher::Type::WATCHER]; ++// handle_count[Dispatcher::Type::PLATFORM_HANDLE]; ++// handle_count[Dispatcher::Type::INVITATION]; ++ ++// // Count the number of each dispatcher type. ++// { ++// base::AutoLock lock(GetLock()); ++// for (const auto& entry : handles_) { ++// ++handle_count[entry.second.dispatcher->GetType()]; ++// } ++// } ++ ++// for (const auto& entry : handle_count) { ++// base::trace_event::MemoryAllocatorDump* inner_dump = ++// pmd->CreateAllocatorDump(std::string("mojo/") + ++// GetNameForDispatcherType(entry.first)); ++// inner_dump->AddScalar( ++// base::trace_event::MemoryAllocatorDump::kNameObjectCount, ++// base::trace_event::MemoryAllocatorDump::kUnitsObjects, entry.second); ++// } ++ ++// return true; ++// } + + HandleTable::Entry::Entry() {} + +diff --git a/mojo/core/handle_table.h b/mojo/core/handle_table.h +index 234bdac..2e0edf7 100644 +--- a/mojo/core/handle_table.h ++++ b/mojo/core/handle_table.h +@@ -13,7 +13,7 @@ + #include "base/gtest_prod_util.h" + #include "base/macros.h" + #include "base/synchronization/lock.h" +-#include "base/trace_event/memory_dump_provider.h" ++// #include "base/trace_event/memory_dump_provider.h" + #include "mojo/core/dispatcher.h" + #include "mojo/core/system_impl_export.h" + #include "mojo/public/c/system/types.h" +@@ -21,11 +21,10 @@ + namespace mojo { + namespace core { + +-class MOJO_SYSTEM_IMPL_EXPORT HandleTable +- : public base::trace_event::MemoryDumpProvider { ++class MOJO_SYSTEM_IMPL_EXPORT HandleTable { + public: + HandleTable(); +- ~HandleTable() override; ++ ~HandleTable(); + + // HandleTable is thread-hostile. All access should be gated by GetLock(). + base::Lock& GetLock(); +@@ -58,11 +57,11 @@ class MOJO_SYSTEM_IMPL_EXPORT HandleTable + void GetActiveHandlesForTest(std::vector<MojoHandle>* handles); + + private: +- FRIEND_TEST_ALL_PREFIXES(HandleTableTest, OnMemoryDump); ++ // FRIEND_TEST_ALL_PREFIXES(HandleTableTest, OnMemoryDump); + + // MemoryDumpProvider implementation. +- bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, +- base::trace_event::ProcessMemoryDump* pmd) override; ++ // bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, ++ // base::trace_event::ProcessMemoryDump* pmd) override; + + struct Entry { + Entry(); diff --git a/libchrome_tools/patch/hash.patch b/libchrome_tools/patch/hash.patch index 71e13d70e..34a74d68c 100644 --- a/libchrome_tools/patch/hash.patch +++ b/libchrome_tools/patch/hash.patch @@ -2,7 +2,7 @@ --- a/base/hash.cc +++ b/base/hash.cc -@@ -4,19 +4,13 @@ +@@ -4,10 +4,12 @@ #include "base/hash.h" @@ -11,18 +11,11 @@ -// Note: This algorithm is also in Blink under Source/wtf/StringHasher.h. -extern "C" uint32_t SuperFastHash(const char* data, int len); +#include <functional> - - namespace base { - --uint32_t SuperFastHash(const char* data, size_t length) { -- if (length > static_cast<size_t>(std::numeric_limits<int>::max())) { -- NOTREACHED(); -- return 0; -- } -- return ::SuperFastHash(data, static_cast<int>(length)); ++ +uint32_t SuperFastHash(const char* data, size_t len) { + std::hash<std::string> hash_fn; + return hash_fn(std::string(data, len)); - } ++} + + namespace base { - } // namespace base diff --git a/libchrome_tools/patch/jni_registration_generator.patch b/libchrome_tools/patch/jni_registration_generator.patch new file mode 100644 index 000000000..e385c6522 --- /dev/null +++ b/libchrome_tools/patch/jni_registration_generator.patch @@ -0,0 +1,13 @@ +diff --git a/base/android/jni_generator/jni_registration_generator.py b/base/android/jni_generator/jni_registration_generator.py +index dec56ee..8c545f6 100755 +--- a/base/android/jni_generator/jni_registration_generator.py ++++ b/base/android/jni_generator/jni_registration_generator.py +@@ -316,7 +316,7 @@ def main(argv): + help='The output file path.') + arg_parser.add_argument('--no_register_java', + help='A list of Java files which should be ignored ' +- 'by the parser.') ++ 'by the parser.', default=[]) + args = arg_parser.parse_args(build_utils.ExpandFileArgs(argv[1:])) + args.sources_files = build_utils.ParseGnList(args.sources_files) + diff --git a/libchrome_tools/patch/lazy_instance.patch b/libchrome_tools/patch/lazy_instance.patch deleted file mode 100644 index d144137a6..000000000 --- a/libchrome_tools/patch/lazy_instance.patch +++ /dev/null @@ -1,18 +0,0 @@ -# LAZY_INSTANCE_INITIALIZER will be embedded into the users of libchrome, -# and could cause compile warning. - ---- a/base/lazy_instance.h -+++ b/base/lazy_instance.h -@@ -48,7 +48,11 @@ - // initialization, as base's LINKER_INITIALIZED requires a constructor and on - // some compilers (notably gcc 4.4) this still ends up needing runtime - // initialization. --#define LAZY_INSTANCE_INITIALIZER {0} -+#ifdef __clang__ -+ #define LAZY_INSTANCE_INITIALIZER {} -+#else -+ #define LAZY_INSTANCE_INITIALIZER {0, 0} -+#endif - - namespace base { - diff --git a/libchrome_tools/patch/logging.patch b/libchrome_tools/patch/logging.patch index 8deece9b8..3a42e4c82 100644 --- a/libchrome_tools/patch/logging.patch +++ b/libchrome_tools/patch/logging.patch @@ -1,19 +1,17 @@ +diff --git a/base/logging.cc b/base/logging.cc +index 8eabda0..112afb8 100644 --- a/base/logging.cc +++ b/base/logging.cc -@@ -71,7 +71,11 @@ typedef pthread_mutex_t* MutexHandle; - #include "base/posix/safe_strerror.h" +@@ -58,7 +58,7 @@ typedef HANDLE MutexHandle; + #include <zircon/syscalls.h> #endif -#if defined(OS_ANDROID) -+#if !defined(OS_ANDROID) -+#include "base/files/file_path.h" -+#endif -+ +#if defined(OS_ANDROID) || defined(__ANDROID__) #include <android/log.h> #endif -@@ -358,21 +362,23 @@ bool BaseInitLoggingImpl(const LoggingSe +@@ -407,21 +407,23 @@ bool BaseInitLoggingImpl(const LoggingSettings& settings) { // Can log only to the system debug log. CHECK_EQ(settings.logging_dest & ~LOG_TO_SYSTEM_DEBUG_LOG, 0); #endif @@ -52,16 +50,16 @@ } g_logging_destination = settings.logging_dest; -@@ -668,7 +674,7 @@ LogMessage::~LogMessage() { - - asl_send(asl_client.get(), asl_message.get()); +@@ -755,7 +757,7 @@ LogMessage::~LogMessage() { + str_newline.c_str()); + #endif // defined(USE_ASL) } -#elif defined(OS_ANDROID) +#elif defined(OS_ANDROID) || defined(__ANDROID__) android_LogPriority priority = (severity_ < 0) ? ANDROID_LOG_VERBOSE : ANDROID_LOG_UNKNOWN; switch (severity_) { -@@ -685,7 +691,16 @@ LogMessage::~LogMessage() { +@@ -772,7 +774,16 @@ LogMessage::~LogMessage() { priority = ANDROID_LOG_FATAL; break; } diff --git a/libchrome_tools/patch/macros.patch b/libchrome_tools/patch/macros.patch index f57ec8867..0d608bb30 100644 --- a/libchrome_tools/patch/macros.patch +++ b/libchrome_tools/patch/macros.patch @@ -1,6 +1,8 @@ +diff --git a/base/macros.h b/base/macros.h +index 3064a1b..8685117 100644 --- a/base/macros.h +++ b/base/macros.h -@@ -12,19 +12,32 @@ +@@ -12,6 +12,13 @@ #include <stddef.h> // For size_t. @@ -11,6 +13,12 @@ + +// We define following macros conditionally as they may be defined by another libraries. + + // Distinguish mips32. + #if defined(__mips__) && (_MIPS_SIM == _ABIO32) && !defined(__mips32__) + #define __mips32__ +@@ -23,23 +30,31 @@ + #endif + // Put this in the declarations for a class to be uncopyable. +#if !defined(DISALLOW_COPY) #define DISALLOW_COPY(TypeName) \ @@ -19,24 +27,19 @@ // Put this in the declarations for a class to be unassignable. +#if !defined(DISALLOW_ASSIGN) - #define DISALLOW_ASSIGN(TypeName) \ - void operator=(const TypeName&) = delete + #define DISALLOW_ASSIGN(TypeName) TypeName& operator=(const TypeName&) = delete +#endif - // A macro to disallow the copy constructor and operator= functions. - // This should be used in the private: declarations for a class. + // Put this in the declarations for a class to be uncopyable and unassignable. +#if !defined(DISALLOW_COPY_AND_ASSIGN) #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName&) = delete; \ - void operator=(const TypeName&) = delete + DISALLOW_COPY(TypeName); \ + DISALLOW_ASSIGN(TypeName) +#endif // A macro to disallow all the implicit constructors, namely the // default constructor, copy constructor and operator= functions. -@@ -32,9 +45,11 @@ - // This should be used in the private: declarations for a class - // that wants to prevent anyone from instantiating it. This is - // especially useful for classes containing only static methods. + // This is especially useful for classes containing only static methods. +#if !defined(DISALLOW_IMPLICIT_CONSTRUCTORS) #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ TypeName() = delete; \ @@ -45,10 +48,10 @@ // The arraysize(arr) macro returns the # of elements in an array arr. The // expression is a compile-time constant, and therefore can be used in defining -@@ -45,8 +60,10 @@ - // This template function declaration is used in defining arraysize. - // Note that the function doesn't need an implementation, as we only - // use its type. +@@ -53,8 +68,10 @@ + // + // DEPRECATED, please use base::size(array) instead. + // TODO(https://crbug.com/837308): Replace existing arraysize usages. +#if !defined(arraysize) template <typename T, size_t N> char (&ArraySizeHelper(T (&array)[N]))[N]; #define arraysize(array) (sizeof(ArraySizeHelper(array))) @@ -56,14 +59,14 @@ // Used to explicitly mark the return value of a function as unused. If you are // really sure you don't want to do anything with the return value of a function -@@ -79,8 +96,10 @@ enum LinkerInitialized { LINKER_INITIALI - // Use these to declare and define a static local variable (static T;) so that - // it is leaked so that its destructors are not called at exit. If you need - // thread-safe initialization, use base/lazy_instance.h instead. +@@ -83,8 +100,10 @@ namespace base { + // return *instance; + // } + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +#if !defined(CR_DEFINE_STATIC_LOCAL) #define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \ static type& name = *new type arguments +#endif - } // base - + // Workaround for MSVC, which expands __VA_ARGS__ as one macro argument. To + // work around this bug, wrap the entire expression in this macro... diff --git a/libchrome_tools/patch/memory_linux.patch b/libchrome_tools/patch/memory_linux.patch new file mode 100644 index 000000000..09afb42d1 --- /dev/null +++ b/libchrome_tools/patch/memory_linux.patch @@ -0,0 +1,17 @@ +# this file used to have a bunch of __libc_* extern definitions, android complains only about this one as missing + +diff --git a/base/process/memory_linux.cc b/base/process/memory_linux.cc +index 171753c..11e482b 100644 +--- a/base/process/memory_linux.cc ++++ b/base/process/memory_linux.cc +@@ -22,6 +22,10 @@ + #include "third_party/tcmalloc/gperftools-2.0/chromium/src/gperftools/tcmalloc.h" + #endif + ++extern "C" { ++void* __libc_malloc(size_t size); ++} ++ + namespace base { + + size_t g_oom_size = 0U; diff --git a/libchrome_tools/patch/message_loop.patch b/libchrome_tools/patch/message_loop.patch index 0ab36300e..c06107a94 100644 --- a/libchrome_tools/patch/message_loop.patch +++ b/libchrome_tools/patch/message_loop.patch @@ -1,13 +1,23 @@ --- a/base/message_loop/message_loop.h +++ b/base/message_loop/message_loop.h -@@ -565,7 +565,9 @@ class BASE_EXPORT MessageLoopForIO : pub - // Returns the MessageLoopForIO of the current thread. - static MessageLoopForIO* current() { - MessageLoop* loop = MessageLoop::current(); -- DCHECK(loop); -+ DCHECK(loop) << "Can't call MessageLoopForIO::current() when no message " -+ "loop was created for this thread. Use " -+ " MessageLoop::current() or MessageLoopForIO::IsCurrent()."; - DCHECK_EQ(MessageLoop::TYPE_IO, loop->type()); - return static_cast<MessageLoopForIO*>(loop); - } +@@ -28,6 +28,11 @@ + #include "base/time/time.h" + #include "build/build_config.h" + ++// Just in libchrome ++namespace brillo { ++class BaseMessageLoop; ++} ++ + namespace base { + + class ThreadTaskRunnerHandle; +@@ -214,6 +219,8 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate, + void BindToCurrentThread(); + + private: ++ //only in libchrome ++ friend class brillo::BaseMessageLoop; + friend class internal::IncomingTaskQueue; + friend class MessageLoopCurrent; + friend class MessageLoopCurrentForIO; diff --git a/libchrome_tools/patch/message_loop_unittest.patch b/libchrome_tools/patch/message_loop_unittest.patch new file mode 100644 index 000000000..cc5b5de95 --- /dev/null +++ b/libchrome_tools/patch/message_loop_unittest.patch @@ -0,0 +1,125 @@ +diff --git a/base/message_loop/message_loop_unittest.cc b/base/message_loop/message_loop_unittest.cc +index 1a21fc5..7743479 100644 +--- a/base/message_loop/message_loop_unittest.cc ++++ b/base/message_loop/message_loop_unittest.cc +@@ -22,7 +22,8 @@ + #include "base/run_loop.h" + #include "base/single_thread_task_runner.h" + #include "base/synchronization/waitable_event.h" +-#include "base/task_scheduler/task_scheduler.h" ++// Unsupported in libchrome ++// #include "base/task_scheduler/task_scheduler.h" + #include "base/test/gtest_util.h" + #include "base/test/test_simple_task_runner.h" + #include "base/test/test_timeouts.h" +@@ -260,7 +261,8 @@ void PostNTasks(int posts_remaining) { + + enum class TaskSchedulerAvailability { + NO_TASK_SCHEDULER, +- WITH_TASK_SCHEDULER, ++ // Unsupported in libchrome. ++ // WITH_TASK_SCHEDULER, + }; + + std::string TaskSchedulerAvailabilityToString( +@@ -268,8 +270,9 @@ std::string TaskSchedulerAvailabilityToString( + switch (availability) { + case TaskSchedulerAvailability::NO_TASK_SCHEDULER: + return "NoTaskScheduler"; +- case TaskSchedulerAvailability::WITH_TASK_SCHEDULER: +- return "WithTaskScheduler"; ++ // Unsupported in libchrome. ++ // case TaskSchedulerAvailability::WITH_TASK_SCHEDULER: ++ // return "WithTaskScheduler"; + } + NOTREACHED(); + return "Unknown"; +@@ -282,11 +285,16 @@ class MessageLoopTest + ~MessageLoopTest() override = default; + + void SetUp() override { ++ // Unsupported in libchrome. ++#if 0 + if (GetParam() == TaskSchedulerAvailability::WITH_TASK_SCHEDULER) + TaskScheduler::CreateAndStartWithDefaultParams("MessageLoopTest"); ++#endif + } + + void TearDown() override { ++ // Unsupported in libchrome. ++#if 0 + if (GetParam() == TaskSchedulerAvailability::WITH_TASK_SCHEDULER) { + // Failure to call FlushForTesting() could result in task leaks as tasks + // are skipped on shutdown. +@@ -295,6 +303,7 @@ class MessageLoopTest + base::TaskScheduler::GetInstance()->JoinForTesting(); + base::TaskScheduler::SetInstance(nullptr); + } ++#endif + } + + static std::string ParamInfoToString( +@@ -776,13 +785,18 @@ class MessageLoopTypedTest + ~MessageLoopTypedTest() = default; + + void SetUp() override { ++// Unsupported in libchrome. ++#if 0 + if (GetTaskSchedulerAvailability() == + TaskSchedulerAvailability::WITH_TASK_SCHEDULER) { + TaskScheduler::CreateAndStartWithDefaultParams("MessageLoopTypedTest"); + } ++#endif + } + + void TearDown() override { ++// Unsupported in libchrome. ++#if 0 + if (GetTaskSchedulerAvailability() == + TaskSchedulerAvailability::WITH_TASK_SCHEDULER) { + // Failure to call FlushForTesting() could result in task leaks as tasks +@@ -792,6 +806,7 @@ class MessageLoopTypedTest + base::TaskScheduler::GetInstance()->JoinForTesting(); + base::TaskScheduler::SetInstance(nullptr); + } ++#endif + } + + static std::string ParamInfoToString( +@@ -1769,8 +1784,10 @@ INSTANTIATE_TEST_CASE_P( + TaskSchedulerAvailability::NO_TASK_SCHEDULER), + MessageLoopTypedTestParams( + MessageLoop::TYPE_UI, +- TaskSchedulerAvailability::NO_TASK_SCHEDULER), +- MessageLoopTypedTestParams( ++ TaskSchedulerAvailability::NO_TASK_SCHEDULER) ++// Unsupported in libchrome. ++#if 0 ++ ,MessageLoopTypedTestParams( + MessageLoop::TYPE_DEFAULT, + TaskSchedulerAvailability::WITH_TASK_SCHEDULER), + MessageLoopTypedTestParams( +@@ -1778,7 +1795,9 @@ INSTANTIATE_TEST_CASE_P( + TaskSchedulerAvailability::WITH_TASK_SCHEDULER), + MessageLoopTypedTestParams( + MessageLoop::TYPE_UI, +- TaskSchedulerAvailability::WITH_TASK_SCHEDULER)), ++ TaskSchedulerAvailability::WITH_TASK_SCHEDULER) ++#endif ++ ), + MessageLoopTypedTest::ParamInfoToString); + + #if defined(OS_WIN) +@@ -2210,8 +2229,10 @@ TEST_P(MessageLoopTest, SequenceLocalStorageDifferentMessageLoops) { + INSTANTIATE_TEST_CASE_P( + , + MessageLoopTest, +- ::testing::Values(TaskSchedulerAvailability::NO_TASK_SCHEDULER, +- TaskSchedulerAvailability::WITH_TASK_SCHEDULER), ++ ::testing::Values(TaskSchedulerAvailability::NO_TASK_SCHEDULER ++ // Unsupported in libchrome ++ //, TaskSchedulerAvailability::WITH_TASK_SCHEDULER ++ ), + MessageLoopTest::ParamInfoToString); + + namespace { diff --git a/libchrome_tools/patch/message_pump_for_ui.patch b/libchrome_tools/patch/message_pump_for_ui.patch new file mode 100644 index 000000000..1cf6aa0d4 --- /dev/null +++ b/libchrome_tools/patch/message_pump_for_ui.patch @@ -0,0 +1,28 @@ +diff --git a/base/message_loop/message_pump_for_ui.h b/base/message_loop/message_pump_for_ui.h +index 6ee02b0..c661166 100644 +--- a/base/message_loop/message_pump_for_ui.h ++++ b/base/message_loop/message_pump_for_ui.h +@@ -18,9 +18,9 @@ + #include "base/message_loop/message_pump.h" + #elif defined(OS_NACL) || defined(OS_AIX) + // No MessagePumpForUI, see below. +-#elif defined(USE_GLIB) ++#elif defined(USE_GLIB) && !defined(ANDROID) + #include "base/message_loop/message_pump_glib.h" +-#elif defined(OS_LINUX) || defined(OS_BSD) ++#elif defined(OS_LINUX) || defined(OS_BSD)|| defined(ANDROID) + #include "base/message_loop/message_pump_libevent.h" + #elif defined(OS_FUCHSIA) + #include "base/message_loop/message_pump_fuchsia.h" +@@ -42,9 +42,9 @@ using MessagePumpForUI = MessagePump; + #elif defined(OS_NACL) || defined(OS_AIX) + // Currently NaCl and AIX don't have a MessagePumpForUI. + // TODO(abarth): Figure out if we need this. +-#elif defined(USE_GLIB) ++#elif defined(USE_GLIB) && !defined(ANDROID) + using MessagePumpForUI = MessagePumpGlib; +-#elif defined(OS_LINUX) || defined(OS_BSD) ++#elif defined(OS_LINUX) || defined(OS_BSD) || defined(ANDROID) + using MessagePumpForUI = MessagePumpLibevent; + #elif defined(OS_FUCHSIA) + using MessagePumpForUI = MessagePumpFuchsia; diff --git a/libchrome_tools/patch/mojo-Add-a-way-to-create-thread-safe-interfaces-in-Java.patch b/libchrome_tools/patch/mojo-Add-a-way-to-create-thread-safe-interfaces-in-Java.patch new file mode 100644 index 000000000..761029392 --- /dev/null +++ b/libchrome_tools/patch/mojo-Add-a-way-to-create-thread-safe-interfaces-in-Java.patch @@ -0,0 +1,137 @@ +From 225f21f660b943ff9ade13b0d114e8ba3b3036d5 Mon Sep 17 00:00:00 2001 +From: Luis Hector Chavez <lhchavez@google.com> +Date: Fri, 20 Jul 2018 09:39:22 -0700 +Subject: [PATCH] Mojo: Add a way to create thread-safe interfaces in Java + +This change adds Interface.Manager.buildThreadSafeProxy(), which is +roughly analogous to mojo::ThreadSafeInterfacePtr<T>. Given that Java +does not have move-only semantics, the Proxy object that is passed is +unbound and a new object is returned. + +Bug: 810084 +Test: cheets_ContainerSmokeTest in Chrome OS +Change-Id: I6565f9e526e3fa8f8cb222cb8cd11e95bb57f7d3 +Reviewed-on: https://chromium-review.googlesource.com/1147320 +Reviewed-by: Ken Rockot <rockot@chromium.org> +Commit-Queue: Luis Hector Chavez <lhchavez@chromium.org> +Cr-Commit-Position: refs/heads/master@{#577429} +--- + .../org/chromium/mojo/bindings/Interface.java | 88 +++++++++++++++++++ + 1 file changed, 88 insertions(+) + +diff --git a/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java +index e3be8b3..f7d3f80 100644 +--- a/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java ++++ b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java +@@ -20,6 +20,7 @@ import org.chromium.mojo.system.MojoException; + import org.chromium.mojo.system.Pair; + + import java.io.Closeable; ++import java.util.concurrent.Executor; + + /** + * Base class for mojo generated interfaces. +@@ -317,6 +318,67 @@ public interface Interface extends ConnectionErrorHandler, Closeable { + + } + ++ /** ++ * A {@link MessageReceiverWithResponder} implementation that forwards all calls to the thread ++ * the ThreadSafeForwarder was created. ++ */ ++ class ThreadSafeForwarder implements MessageReceiverWithResponder { ++ ++ /** ++ * The {@link MessageReceiverWithResponder} that will receive a serialized message for ++ * each method call. ++ */ ++ private final MessageReceiverWithResponder mMessageReceiver; ++ ++ /** ++ * The {@link Executor} to forward all tasks to. ++ */ ++ private final Executor mExecutor; ++ ++ /** ++ * Constructor. ++ * ++ * @param core the Core implementation used to create pipes and access the async waiter. ++ * @param messageReceiver the message receiver to send message to. ++ */ ++ public ThreadSafeForwarder(Core core, MessageReceiverWithResponder messageReceiver) { ++ mMessageReceiver = messageReceiver; ++ mExecutor = ExecutorFactory.getExecutorForCurrentThread(core); ++ } ++ ++ /** ++ * @see org.chromium.mojo.bindings.MessageReceiver#close() ++ */ ++ @Override ++ public void close() { ++ mExecutor.execute(() -> { ++ mMessageReceiver.close(); ++ }); ++ } ++ ++ /** ++ * @see org.chromium.mojo.bindings.MessageReceiver#accept() ++ */ ++ @Override ++ public boolean accept(Message message) { ++ mExecutor.execute(() -> { ++ mMessageReceiver.accept(message); ++ }); ++ return true; ++ } ++ ++ /** ++ * @see org.chromium.mojo.bindings.MessageReceiverWithResponder#acceptWithResponder() ++ */ ++ @Override ++ public boolean acceptWithResponder(Message message, MessageReceiver responder) { ++ mExecutor.execute(() -> { ++ mMessageReceiver.acceptWithResponder(message, responder); ++ }); ++ return true; ++ } ++ } ++ + /** + * The |Manager| object enables building of proxies and stubs for a given interface. + * +@@ -385,6 +447,32 @@ public interface Interface extends ConnectionErrorHandler, Closeable { + return new InterfaceRequest<I>(handle); + } + ++ /** ++ * Constructs a thread-safe Proxy forwarding the calls to the given message receiver. ++ * All calls can be performed from any thread and are posted to the {@link Executor} that ++ * is associated with the thread on which this method was called on. ++ * ++ * The original Proxy object is unbound. ++ */ ++ public final P buildThreadSafeProxy(P proxy) { ++ HandlerImpl handlerImpl = (HandlerImpl) proxy.getProxyHandler(); ++ Core core = handlerImpl.getCore(); ++ int version = handlerImpl.getVersion(); ++ ++ Router router = new RouterImpl(handlerImpl.passHandle()); ++ // Close the original proxy now that its handle has been passed. ++ proxy.close(); ++ ++ proxy = buildProxy( ++ core, new ThreadSafeForwarder(core, new AutoCloseableRouter(core, router))); ++ DelegatingConnectionErrorHandler handlers = new DelegatingConnectionErrorHandler(); ++ handlers.addConnectionErrorHandler(proxy); ++ router.setErrorHandler(handlers); ++ router.start(); ++ ((HandlerImpl) proxy.getProxyHandler()).setVersion(version); ++ return proxy; ++ } ++ + /** + * Binds the implementation to the given |router|. + */ +-- +2.19.0.605.g01d371f741-goog + diff --git a/libchrome_tools/patch/mojo.patch b/libchrome_tools/patch/mojo.patch index 723fe3769..8040fbe9e 100644 --- a/libchrome_tools/patch/mojo.patch +++ b/libchrome_tools/patch/mojo.patch @@ -1,277 +1,15 @@ # Local patches for libmojo. ---- a/mojo/android/system/base_run_loop.cc -+++ b/mojo/android/system/base_run_loop.cc -@@ -6,9 +6,10 @@ - - #include <jni.h> - --#include "base/android/base_jni_registrar.h" -+// Removed unused headers. TODO(hidehiko): Upstream. -+// #include "base/android/base_jni_registrar.h" - #include "base/android/jni_android.h" --#include "base/android/jni_registrar.h" -+// #include "base/android/jni_registrar.h" - #include "base/bind.h" - #include "base/logging.h" - #include "base/message_loop/message_loop.h" -@@ -79,4 +80,3 @@ bool RegisterBaseRunLoop(JNIEnv* env) { - - } // namespace android - } // namespace mojo -- ---- a/mojo/android/system/core_impl.cc -+++ b/mojo/android/system/core_impl.cc -@@ -7,10 +7,11 @@ - #include <stddef.h> - #include <stdint.h> - --#include "base/android/base_jni_registrar.h" -+// Removed unused headers. TODO(hidehiko): Upstream. -+// #include "base/android/base_jni_registrar.h" - #include "base/android/jni_android.h" --#include "base/android/jni_registrar.h" --#include "base/android/library_loader/library_loader_hooks.h" -+// #include "base/android/jni_registrar.h" -+// #include "base/android/library_loader/library_loader_hooks.h" - #include "base/android/scoped_java_ref.h" - #include "jni/CoreImpl_jni.h" - #include "mojo/public/c/system/core.h" ---- a/mojo/android/system/watcher_impl.cc -+++ b/mojo/android/system/watcher_impl.cc -@@ -7,10 +7,11 @@ - #include <stddef.h> - #include <stdint.h> - --#include "base/android/base_jni_registrar.h" -+// Removed unused headers. TODO(hidehiko): Upstream. -+// #include "base/android/base_jni_registrar.h" - #include "base/android/jni_android.h" --#include "base/android/jni_registrar.h" --#include "base/android/library_loader/library_loader_hooks.h" -+// #include "base/android/jni_registrar.h" -+// #include "base/android/library_loader/library_loader_hooks.h" - #include "base/android/scoped_java_ref.h" - #include "base/bind.h" - #include "jni/WatcherImpl_jni.h" ---- a/mojo/common/common_custom_types_struct_traits.h -+++ b/mojo/common/common_custom_types_struct_traits.h -@@ -63,19 +63,6 @@ struct StructTraits<common::mojom::Ungue - }; - - template <> --struct StructTraits<common::mojom::TimeDeltaDataView, base::TimeDelta> { -- static int64_t microseconds(const base::TimeDelta& delta) { -- return delta.InMicroseconds(); -- } -- -- static bool Read(common::mojom::TimeDeltaDataView data, -- base::TimeDelta* delta) { -- *delta = base::TimeDelta::FromMicroseconds(data.microseconds()); -- return true; -- } --}; -- --template <> - struct StructTraits<common::mojom::FileDataView, base::File> { - static bool IsNull(const base::File& file) { return !file.IsValid(); } - ---- a/mojo/common/time.mojom -+++ b/mojo/common/time.mojom -@@ -4,12 +4,18 @@ - - module mojo.common.mojom; - --[Native] --struct Time; -+struct Time { -+ // The internal value is expressed in terms of microseconds since a fixed but -+ // intentionally unspecified epoch. -+ int64 internal_value; -+}; - - struct TimeDelta { - int64 microseconds; - }; - --[Native] --struct TimeTicks; -+struct TimeTicks { -+ // The internal value is expressed in terms of microseconds since a fixed but -+ // intentionally unspecified epoch. -+ int64 internal_value; -+}; ---- a/mojo/edk/embedder/platform_channel_pair_posix.cc -+++ b/mojo/edk/embedder/platform_channel_pair_posix.cc -@@ -35,7 +35,7 @@ namespace edk { - - namespace { - --#if defined(OS_ANDROID) -+#if defined(OS_ANDROID) || defined(__ANDROID__) - enum { - // Leave room for any other descriptors defined in content for example. - // TODO(jcivelli): consider changing base::GlobalDescriptors to generate a -@@ -102,7 +102,7 @@ ScopedPlatformHandle - PlatformChannelPair::PassClientHandleFromParentProcessFromString( - const std::string& value) { - int client_fd = -1; --#if defined(OS_ANDROID) -+#if defined(OS_ANDROID) || defined(__ANDROID__) - base::GlobalDescriptors::Key key = -1; - if (value.empty() || !base::StringToUint(value, &key)) { - LOG(ERROR) << "Missing or invalid --" << kMojoPlatformChannelHandleSwitch; -@@ -142,7 +142,7 @@ void PlatformChannelPair::PrepareToPassC - std::string - PlatformChannelPair::PrepareToPassClientHandleToChildProcessAsString( - HandlePassingInformation* handle_passing_info) const { --#if defined(OS_ANDROID) -+#if defined(OS_ANDROID) || defined(__ANDROID__) - int fd = client_handle_.get().handle; - handle_passing_info->push_back( - std::pair<int, int>(fd, kAndroidClientHandleDescriptor)); ---- a/mojo/edk/system/ports/node.cc -+++ b/mojo/edk/system/ports/node.cc -@@ -803,7 +803,7 @@ scoped_refptr<Port> Node::GetPort_Locked - if (iter == ports_.end()) - return nullptr; - --#if defined(OS_ANDROID) && defined(ARCH_CPU_ARM64) -+#if (defined(OS_ANDROID) || defined(__ANDROID__)) && defined(ARCH_CPU_ARM64) - // Workaround for https://crbug.com/665869. - base::subtle::MemoryBarrier(); - #endif ---- a/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java -+++ b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java -@@ -206,7 +206,13 @@ public interface Interface extends Conne - == RunOutput.Tag.QueryVersionResult) { - mVersion = response.output.getQueryVersionResult().version; - } -- callback.call(mVersion); -+ try { -+ callback.call(mVersion); -+ } catch (RuntimeException e) { -+ // TODO(lhchavez): Remove this hack. See b/28986534 for details. -+ android.util.Log.wtf("org.chromium.mojo.bindings.Interface", -+ "Uncaught runtime exception", e); -+ } - } - }); - } ---- a/mojo/public/java/bindings/src/org/chromium/mojo/bindings/RouterImpl.java -+++ b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/RouterImpl.java -@@ -171,20 +171,23 @@ public class RouterImpl implements Route - assert messageWithHeader.getHeader().hasFlag(MessageHeader.MESSAGE_EXPECTS_RESPONSE_FLAG); - - // Compute a request id for being able to route the response. -- long requestId = mNextRequestId++; -- // Reserve 0 in case we want it to convey special meaning in the future. -- if (requestId == 0) { -- requestId = mNextRequestId++; -- } -- if (mResponders.containsKey(requestId)) { -- throw new IllegalStateException("Unable to find a new request identifier."); -- } -- messageWithHeader.setRequestId(requestId); -- if (!mConnector.accept(messageWithHeader)) { -- return false; -+ // TODO(lhchavez): Remove this hack. See b/28986534 for details. -+ synchronized (mResponders) { -+ long requestId = mNextRequestId++; -+ // Reserve 0 in case we want it to convey special meaning in the future. -+ if (requestId == 0) { -+ requestId = mNextRequestId++; -+ } -+ if (mResponders.containsKey(requestId)) { -+ throw new IllegalStateException("Unable to find a new request identifier."); -+ } -+ messageWithHeader.setRequestId(requestId); -+ if (!mConnector.accept(messageWithHeader)) { -+ return false; -+ } -+ // Only keep the responder is the message has been accepted. -+ mResponders.put(requestId, responder); - } -- // Only keep the responder is the message has been accepted. -- mResponders.put(requestId, responder); - return true; - } - -@@ -227,11 +230,15 @@ public class RouterImpl implements Route - return false; - } else if (header.hasFlag(MessageHeader.MESSAGE_IS_RESPONSE_FLAG)) { - long requestId = header.getRequestId(); -- MessageReceiver responder = mResponders.get(requestId); -- if (responder == null) { -- return false; -+ MessageReceiver responder; -+ // TODO(lhchavez): Remove this hack. See b/28986534 for details. -+ synchronized (mResponders) { -+ responder = mResponders.get(requestId); -+ if (responder == null) { -+ return false; -+ } -+ mResponders.remove(requestId); - } -- mResponders.remove(requestId); - return responder.accept(message); - } else { - if (mIncomingMessageReceiver != null) { ---- a/mojo/public/tools/bindings/generators/java_templates/interface_definition.tmpl -+++ b/mojo/public/tools/bindings/generators/java_templates/interface_definition.tmpl -@@ -113,7 +113,12 @@ try { - {% else %} - {{request_struct|name}}.deserialize(messageWithHeader.getPayload()); - {% endif %} -- getImpl().{{method|name}}({{run_callback('data', method.parameters)}}{% if with_response %}{% if method.parameters %}, {% endif %}new {{response_struct|name}}ProxyToResponder(getCore(), receiver, header.getRequestId()){% endif %}); -+ try { -+ getImpl().{{method|name}}({{run_callback('data', method.parameters)}}{% if with_response %}{% if method.parameters %}, {% endif %}new {{response_struct|name}}ProxyToResponder(getCore(), receiver, header.getRequestId()){% endif %}); -+ } catch (RuntimeException e) { -+ // TODO(lhchavez): Remove this hack. See b/28814913 for details. -+ android.util.Log.wtf("{{namespace}}.{{interface.name}}", "Uncaught runtime exception", e); -+ } - return true; - } - {% endif %} -@@ -241,7 +246,12 @@ class {{interface|name}}_Internal { - {% if method.response_parameters|length %} - {{response_struct|name}} response = {{response_struct|name}}.deserialize(messageWithHeader.getPayload()); - {% endif %} -- mCallback.call({{run_callback('response', method.response_parameters)}}); -+ try { -+ mCallback.call({{run_callback('response', method.response_parameters)}}); -+ } catch (RuntimeException e) { -+ // TODO(lhchavez): Remove this hack. See b/28814913 for details. -+ android.util.Log.wtf("{{namespace}}.{{interface.name}}", "Uncaught runtime exception", e); -+ } - return true; - } catch (org.chromium.mojo.bindings.DeserializationException e) { - return false; --- a/base/android/jni_android.cc +++ b/base/android/jni_android.cc -@@ -10,7 +10,8 @@ - - #include "base/android/build_info.h" - #include "base/android/jni_string.h" --#include "base/android/jni_utils.h" -+// Removed unused headers. TODO(hidehiko): Upstream. -+// #include "base/android/jni_utils.h" - #include "base/debug/debugging_flags.h" - #include "base/lazy_instance.h" - #include "base/logging.h" -@@ -240,7 +241,16 @@ void CheckException(JNIEnv* env) { +@@ -253,7 +253,11 @@ void CheckException(JNIEnv* env) { } // Now, feel good about it and die. - LOG(FATAL) << "Please include Java exception stack in crash report"; + // TODO(lhchavez): Remove this hack. See b/28814913 for details. -+ // We're using BuildInfo's java_exception_info() instead of storing the -+ // exception info a few lines above to avoid extra copies. It will be -+ // truncated to 1024 bytes anyways. -+ const char* exception_string = -+ base::android::BuildInfo::GetInstance()->java_exception_info(); -+ if (exception_string) -+ LOG(FATAL) << exception_string; ++ if (java_throwable) ++ LOG(FATAL) << GetJavaExceptionInfo(env, java_throwable); + else + LOG(FATAL) << "Unhandled exception"; } @@ -279,288 +17,22 @@ std::string GetJavaExceptionInfo(JNIEnv* env, jthrowable java_throwable) { --- a/build/android/gyp/util/build_utils.py +++ b/build/android/gyp/util/build_utils.py -@@ -20,7 +20,13 @@ import zipfile +@@ -25,8 +25,16 @@ import zipfile # Some clients do not add //build/android/gyp to PYTHONPATH. import md5_check # pylint: disable=relative-import --sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) +-sys.path.append(os.path.join(os.path.dirname(__file__), +- os.pardir, os.pardir, os.pardir)) +# pylib conflicts with mojo/public/tools/bindings/pylib. Prioritize +# build/android/pylib. +# PYTHONPATH wouldn't help in this case, because soong put source files under +# temp directory for each build, so the abspath is unknown until the +# execution. -+# sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) -+sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) - from pylib.constants import host_paths - - sys.path.append(os.path.join(os.path.dirname(__file__), -@@ -581,4 +587,3 @@ def CallAndWriteDepfileIfStale(function, - output_paths=output_paths, - force=force, - pass_changes=True) -- ---- a/build/android/pylib/constants/__init__.py -+++ b/build/android/pylib/constants/__init__.py -@@ -96,7 +96,7 @@ DEVICE_PERF_OUTPUT_DIR = ( - SCREENSHOTS_DIR = os.path.join(DIR_SOURCE_ROOT, 'out_screenshots') - - ANDROID_SDK_VERSION = version_codes.MARSHMALLOW --ANDROID_SDK_BUILD_TOOLS_VERSION = '25.0.2' -+ANDROID_SDK_BUILD_TOOLS_VERSION = '24.0.2' - ANDROID_SDK_ROOT = os.path.join(DIR_SOURCE_ROOT, - 'third_party', 'android_tools', 'sdk') - ANDROID_SDK_TOOLS = os.path.join(ANDROID_SDK_ROOT, ---- /dev/null -+++ b/gen/mojo/common/common_custom_types__type_mappings -@@ -0,0 +1,193 @@ -+{ -+ "c++": { -+ "mojo.common.mojom.Value": { -+ "hashable": false, -+ "typename": "std::unique_ptr<base::Value>", -+ "traits_headers": [ -+ "ipc/ipc_message_utils.h", -+ "mojo/common/values_struct_traits.h" -+ ], -+ "copyable_pass_by_value": false, -+ "move_only": true, -+ "nullable_is_same_type": true, -+ "non_copyable_non_movable": false, -+ "public_headers": [ -+ "base/values.h" -+ ] -+ }, -+ "mojo.common.mojom.UnguessableToken": { -+ "hashable": false, -+ "typename": "base::UnguessableToken", -+ "traits_headers": [ -+ "mojo/common/common_custom_types_struct_traits.h" -+ ], -+ "copyable_pass_by_value": false, -+ "move_only": false, -+ "nullable_is_same_type": false, -+ "non_copyable_non_movable": false, -+ "public_headers": [ -+ "base/unguessable_token.h" -+ ] -+ }, -+ "mojo.common.mojom.TextDirection": { -+ "hashable": false, -+ "typename": "base::i18n::TextDirection", -+ "traits_headers": [ -+ "mojo/common/common_custom_types_struct_traits.h" -+ ], -+ "copyable_pass_by_value": false, -+ "move_only": false, -+ "nullable_is_same_type": false, -+ "non_copyable_non_movable": false, -+ "public_headers": [ -+ "base/i18n/rtl.h" -+ ] -+ }, -+ "mojo.common.mojom.ListValue": { -+ "hashable": false, -+ "typename": "std::unique_ptr<base::ListValue>", -+ "traits_headers": [ -+ "ipc/ipc_message_utils.h", -+ "mojo/common/values_struct_traits.h" -+ ], -+ "copyable_pass_by_value": false, -+ "move_only": true, -+ "nullable_is_same_type": true, -+ "non_copyable_non_movable": false, -+ "public_headers": [ -+ "base/values.h" -+ ] -+ }, -+ "mojo.common.mojom.String16": { -+ "hashable": false, -+ "typename": "base::string16", -+ "traits_headers": [ -+ "mojo/common/common_custom_types_struct_traits.h" -+ ], -+ "copyable_pass_by_value": false, -+ "move_only": false, -+ "nullable_is_same_type": false, -+ "non_copyable_non_movable": false, -+ "public_headers": [ -+ "base/strings/string16.h" -+ ] -+ }, -+ "mojo.common.mojom.Time": { -+ "hashable": false, -+ "typename": "base::Time", -+ "traits_headers": [ -+ "ipc/ipc_message_utils.h", -+ "mojo/common/common_custom_types_struct_traits.h" -+ ], -+ "copyable_pass_by_value": true, -+ "move_only": false, -+ "nullable_is_same_type": false, -+ "non_copyable_non_movable": false, -+ "public_headers": [ -+ "base/time/time.h" -+ ] -+ }, -+ "mojo.common.mojom.TimeDelta": { -+ "hashable": false, -+ "typename": "base::TimeDelta", -+ "traits_headers": [ -+ "ipc/ipc_message_utils.h", -+ "mojo/common/common_custom_types_struct_traits.h" -+ ], -+ "copyable_pass_by_value": true, -+ "move_only": false, -+ "nullable_is_same_type": false, -+ "non_copyable_non_movable": false, -+ "public_headers": [ -+ "base/time/time.h" -+ ] -+ }, -+ "mojo.common.mojom.TimeTicks": { -+ "hashable": false, -+ "typename": "base::TimeTicks", -+ "traits_headers": [ -+ "ipc/ipc_message_utils.h", -+ "mojo/common/common_custom_types_struct_traits.h" -+ ], -+ "copyable_pass_by_value": true, -+ "move_only": false, -+ "nullable_is_same_type": false, -+ "non_copyable_non_movable": false, -+ "public_headers": [ -+ "base/time/time.h" -+ ] -+ }, -+ "mojo.common.mojom.LegacyListValue": { -+ "hashable": false, -+ "typename": "base::ListValue", -+ "traits_headers": [ -+ "ipc/ipc_message_utils.h", -+ "mojo/common/values_struct_traits.h" -+ ], -+ "copyable_pass_by_value": false, -+ "move_only": false, -+ "nullable_is_same_type": false, -+ "non_copyable_non_movable": true, -+ "public_headers": [ -+ "base/values.h" -+ ] -+ }, -+ "mojo.common.mojom.File": { -+ "hashable": false, -+ "typename": "base::File", -+ "traits_headers": [ -+ "mojo/common/common_custom_types_struct_traits.h" -+ ], -+ "copyable_pass_by_value": false, -+ "move_only": true, -+ "nullable_is_same_type": true, -+ "non_copyable_non_movable": false, -+ "public_headers": [ -+ "base/files/file.h" -+ ] -+ }, -+ "mojo.common.mojom.FilePath": { -+ "hashable": false, -+ "typename": "base::FilePath", -+ "traits_headers": [ -+ "ipc/ipc_message_utils.h" -+ ], -+ "copyable_pass_by_value": false, -+ "move_only": false, -+ "nullable_is_same_type": false, -+ "non_copyable_non_movable": false, -+ "public_headers": [ -+ "base/files/file_path.h" -+ ] -+ }, -+ "mojo.common.mojom.DictionaryValue": { -+ "hashable": false, -+ "typename": "std::unique_ptr<base::DictionaryValue>", -+ "traits_headers": [ -+ "ipc/ipc_message_utils.h", -+ "mojo/common/values_struct_traits.h" -+ ], -+ "copyable_pass_by_value": false, -+ "move_only": true, -+ "nullable_is_same_type": true, -+ "non_copyable_non_movable": false, -+ "public_headers": [ -+ "base/values.h" -+ ] -+ }, -+ "mojo.common.mojom.Version": { -+ "hashable": false, -+ "typename": "base::Version", -+ "traits_headers": [ -+ "mojo/common/common_custom_types_struct_traits.h" -+ ], -+ "copyable_pass_by_value": false, -+ "move_only": false, -+ "nullable_is_same_type": false, -+ "non_copyable_non_movable": false, -+ "public_headers": [ -+ "base/version.h" -+ ] -+ } -+ } -+} ---- /dev/null -+++ b/mojo/common/time_struct_traits.h -@@ -0,0 +1,55 @@ -+// 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. -+ -+#ifndef MOJO_COMMON_TIME_STRUCT_TRAITS_H_ -+#define MOJO_COMMON_TIME_STRUCT_TRAITS_H_ -+ -+#include "base/time/time.h" -+#include "mojo/common/time.mojom-shared.h" -+ -+namespace mojo { -+ -+template <> -+struct StructTraits<common::mojom::TimeDataView, base::Time> { -+ static int64_t internal_value(const base::Time& time) { -+ return time.since_origin().InMicroseconds(); -+ } ++#sys.path.append(os.path.join(os.path.dirname(__file__), ++# os.pardir, os.pardir, os.pardir)) ++sys.path.insert(0, os.path.join(os.path.dirname(__file__), ++ os.pardir, os.pardir)) + -+ static bool Read(common::mojom::TimeDataView data, base::Time* time) { -+ *time = -+ base::Time() + base::TimeDelta::FromMicroseconds(data.internal_value()); -+ return true; -+ } -+}; -+ -+template <> -+struct StructTraits<common::mojom::TimeDeltaDataView, base::TimeDelta> { -+ static int64_t microseconds(const base::TimeDelta& delta) { -+ return delta.InMicroseconds(); -+ } -+ -+ static bool Read(common::mojom::TimeDeltaDataView data, -+ base::TimeDelta* delta) { -+ *delta = base::TimeDelta::FromMicroseconds(data.microseconds()); -+ return true; -+ } -+}; -+ -+template <> -+struct StructTraits<common::mojom::TimeTicksDataView, base::TimeTicks> { -+ static int64_t internal_value(const base::TimeTicks& time) { -+ return time.since_origin().InMicroseconds(); -+ } -+ -+ static bool Read(common::mojom::TimeTicksDataView data, -+ base::TimeTicks* time) { -+ *time = base::TimeTicks() + -+ base::TimeDelta::FromMicroseconds(data.internal_value()); -+ return true; -+ } -+}; -+ -+} // namespace mojo -+ -+#endif // MOJO_COMMON_TIME_STRUCT_TRAITS_H_ + import gn_helpers + + # Definition copied from pylib/constants/__init__.py to avoid adding diff --git a/libchrome_tools/patch/mojom_disable_trace_and_mem_dump.patch b/libchrome_tools/patch/mojom_disable_trace_and_mem_dump.patch new file mode 100644 index 000000000..9724e1d35 --- /dev/null +++ b/libchrome_tools/patch/mojom_disable_trace_and_mem_dump.patch @@ -0,0 +1,299 @@ +diff --git a/mojo/core/core.cc b/mojo/core/core.cc +index 8422ec2..3ffa640 100644 +--- a/mojo/core/core.cc ++++ b/mojo/core/core.cc +@@ -21,7 +21,7 @@ + #include "base/strings/string_piece.h" + #include "base/threading/thread_task_runner_handle.h" + #include "base/time/time.h" +-#include "base/trace_event/memory_dump_manager.h" ++// #include "base/trace_event/memory_dump_manager.h" + #include "build/build_config.h" + #include "mojo/core/channel.h" + #include "mojo/core/configuration.h" +@@ -127,8 +127,8 @@ void RunMojoProcessErrorHandler(ProcessDisconnectHandler* disconnect_handler, + + Core::Core() { + handles_.reset(new HandleTable); +- base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( +- handles_.get(), "MojoHandleTable", nullptr); ++ // base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( ++ // handles_.get(), "MojoHandleTable", nullptr); + } + + Core::~Core() { +@@ -142,8 +142,8 @@ Core::~Core() { + base::BindOnce(&Core::PassNodeControllerToIOThread, + base::Passed(&node_controller_))); + } +- base::trace_event::MemoryDumpManager::GetInstance() +- ->UnregisterAndDeleteDumpProviderSoon(std::move(handles_)); ++ // base::trace_event::MemoryDumpManager::GetInstance() ++ // ->UnregisterAndDeleteDumpProviderSoon(std::move(handles_)); + } + + void Core::SetIOTaskRunner(scoped_refptr<base::TaskRunner> io_task_runner) { +diff --git a/mojo/core/user_message_impl.cc b/mojo/core/user_message_impl.cc +index d4a4da1..9cb8284 100644 +--- a/mojo/core/user_message_impl.cc ++++ b/mojo/core/user_message_impl.cc +@@ -13,10 +13,10 @@ + #include "base/no_destructor.h" + #include "base/numerics/safe_conversions.h" + #include "base/numerics/safe_math.h" +-#include "base/trace_event/memory_allocator_dump.h" +-#include "base/trace_event/memory_dump_manager.h" +-#include "base/trace_event/memory_dump_provider.h" +-#include "base/trace_event/trace_event.h" ++// #include "base/trace_event/memory_allocator_dump.h" ++// #include "base/trace_event/memory_dump_manager.h" ++// #include "base/trace_event/memory_dump_provider.h" ++// #include "base/trace_event/trace_event.h" + #include "mojo/core/core.h" + #include "mojo/core/node_channel.h" + #include "mojo/core/node_controller.h" +@@ -271,36 +271,36 @@ void DecrementMessageCount() { + base::subtle::NoBarrier_AtomicIncrement(&g_message_count, -1); + } + +-class MessageMemoryDumpProvider : public base::trace_event::MemoryDumpProvider { +- public: +- MessageMemoryDumpProvider() { +- base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( +- this, "MojoMessages", nullptr); +- } +- +- ~MessageMemoryDumpProvider() override { +- base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( +- this); +- } +- +- private: +- // base::trace_event::MemoryDumpProvider: +- bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, +- base::trace_event::ProcessMemoryDump* pmd) override { +- auto* dump = pmd->CreateAllocatorDump("mojo/messages"); +- dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectCount, +- base::trace_event::MemoryAllocatorDump::kUnitsObjects, +- base::subtle::NoBarrier_Load(&g_message_count)); +- return true; +- } +- +- DISALLOW_COPY_AND_ASSIGN(MessageMemoryDumpProvider); +-}; +- +-void EnsureMemoryDumpProviderExists() { +- static base::NoDestructor<MessageMemoryDumpProvider> provider; +- ALLOW_UNUSED_LOCAL(provider); +-} ++// class MessageMemoryDumpProvider : public base::trace_event::MemoryDumpProvider { ++// public: ++// MessageMemoryDumpProvider() { ++// base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( ++// this, "MojoMessages", nullptr); ++// } ++ ++// ~MessageMemoryDumpProvider() override { ++// base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( ++// this); ++// } ++ ++// private: ++// // base::trace_event::MemoryDumpProvider: ++// bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, ++// base::trace_event::ProcessMemoryDump* pmd) override { ++// auto* dump = pmd->CreateAllocatorDump("mojo/messages"); ++// dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectCount, ++// base::trace_event::MemoryAllocatorDump::kUnitsObjects, ++// base::subtle::NoBarrier_Load(&g_message_count)); ++// return true; ++// } ++ ++// DISALLOW_COPY_AND_ASSIGN(MessageMemoryDumpProvider); ++// }; ++ ++// void EnsureMemoryDumpProviderExists() { ++// static base::NoDestructor<MessageMemoryDumpProvider> provider; ++// ALLOW_UNUSED_LOCAL(provider); ++// } + + } // namespace + +@@ -648,7 +648,7 @@ void UserMessageImpl::FailHandleSerializationForTesting(bool fail) { + + UserMessageImpl::UserMessageImpl(ports::UserMessageEvent* message_event) + : ports::UserMessage(&kUserMessageTypeInfo), message_event_(message_event) { +- EnsureMemoryDumpProviderExists(); ++ // EnsureMemoryDumpProviderExists(); + IncrementMessageCount(); + } + +@@ -667,7 +667,7 @@ UserMessageImpl::UserMessageImpl(ports::UserMessageEvent* message_event, + header_size_(header_size), + user_payload_(user_payload), + user_payload_size_(user_payload_size) { +- EnsureMemoryDumpProviderExists(); ++ // EnsureMemoryDumpProviderExists(); + IncrementMessageCount(); + } + +diff --git a/mojo/public/cpp/bindings/lib/message_dumper.cc b/mojo/public/cpp/bindings/lib/message_dumper.cc +index f187e45..35696bb 100644 +--- a/mojo/public/cpp/bindings/lib/message_dumper.cc ++++ b/mojo/public/cpp/bindings/lib/message_dumper.cc +@@ -22,33 +22,33 @@ base::FilePath& DumpDirectory() { + return *dump_directory; + } + +-void WriteMessage(uint32_t identifier, +- const mojo::MessageDumper::MessageEntry& entry) { +- static uint64_t num = 0; +- +- if (!entry.interface_name) +- return; +- +- base::FilePath message_directory = +- DumpDirectory() +- .AppendASCII(entry.interface_name) +- .AppendASCII(base::NumberToString(identifier)); +- +- if (!base::DirectoryExists(message_directory) && +- !base::CreateDirectory(message_directory)) { +- LOG(ERROR) << "Failed to create" << message_directory.value(); +- return; +- } +- +- std::string filename = +- base::NumberToString(num++) + "." + entry.method_name + ".mojomsg"; +- base::FilePath path = message_directory.AppendASCII(filename); +- base::File file(path, +- base::File::FLAG_WRITE | base::File::FLAG_CREATE_ALWAYS); +- +- file.WriteAtCurrentPos(reinterpret_cast<const char*>(entry.data_bytes.data()), +- static_cast<int>(entry.data_bytes.size())); +-} ++// void WriteMessage(uint32_t identifier, ++// const mojo::MessageDumper::MessageEntry& entry) { ++// static uint64_t num = 0; ++ ++// if (!entry.interface_name) ++// return; ++ ++// base::FilePath message_directory = ++// DumpDirectory() ++// .AppendASCII(entry.interface_name) ++// .AppendASCII(base::NumberToString(identifier)); ++ ++// if (!base::DirectoryExists(message_directory) && ++// !base::CreateDirectory(message_directory)) { ++// LOG(ERROR) << "Failed to create" << message_directory.value(); ++// return; ++// } ++ ++// std::string filename = ++// base::NumberToString(num++) + "." + entry.method_name + ".mojomsg"; ++// base::FilePath path = message_directory.AppendASCII(filename); ++// base::File file(path, ++// base::File::FLAG_WRITE | base::File::FLAG_CREATE_ALWAYS); ++ ++// file.WriteAtCurrentPos(reinterpret_cast<const char*>(entry.data_bytes.data()), ++// static_cast<int>(entry.data_bytes.size())); ++// } + + } // namespace + +@@ -71,17 +71,17 @@ MessageDumper::MessageDumper() : identifier_(base::RandUint64()) {} + MessageDumper::~MessageDumper() {} + + bool MessageDumper::Accept(mojo::Message* message) { +- MessageEntry entry(message->data(), message->data_num_bytes(), +- message->interface_name(), message->method_name()); ++ // MessageEntry entry(message->data(), message->data_num_bytes(), ++ // "unknown interface", "unknown name"); + +- static base::NoDestructor<scoped_refptr<base::TaskRunner>> task_runner( +- base::CreateSequencedTaskRunnerWithTraits( +- {base::MayBlock(), base::TaskPriority::USER_BLOCKING, +- base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})); ++ // static base::NoDestructor<scoped_refptr<base::TaskRunner>> task_runner( ++ // base::CreateSequencedTaskRunnerWithTraits( ++ // {base::MayBlock(), base::TaskPriority::USER_BLOCKING, ++ // base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})); + +- (*task_runner) +- ->PostTask(FROM_HERE, +- base::BindOnce(&WriteMessage, identifier_, std::move(entry))); ++ // (*task_runner) ++ // ->PostTask(FROM_HERE, ++ // base::BindOnce(&WriteMessage, identifier_, std::move(entry))); + return true; + } + +diff --git a/mojo/public/cpp/system/file_data_pipe_producer.cc b/mojo/public/cpp/system/file_data_pipe_producer.cc +index 842fe8f..6038bbe 100644 +--- a/mojo/public/cpp/system/file_data_pipe_producer.cc ++++ b/mojo/public/cpp/system/file_data_pipe_producer.cc +@@ -266,13 +266,15 @@ void FileDataPipeProducer::WriteFromPath(const base::FilePath& path, + + void FileDataPipeProducer::InitializeNewRequest(CompletionCallback callback) { + DCHECK(!file_sequence_state_); +- auto file_task_runner = base::CreateSequencedTaskRunnerWithTraits( +- {base::MayBlock(), base::TaskPriority::BACKGROUND}); +- file_sequence_state_ = new FileSequenceState( +- std::move(producer_), file_task_runner, +- base::BindOnce(&FileDataPipeProducer::OnWriteComplete, +- weak_factory_.GetWeakPtr(), std::move(callback)), +- base::SequencedTaskRunnerHandle::Get(), std::move(observer_)); ++ ++ LOG(FATAL) << "unsupported in libchrome"; ++ // auto file_task_runner = base::CreateSequencedTaskRunnerWithTraits( ++ // {base::MayBlock(), base::TaskPriority::BACKGROUND}); ++ // file_sequence_state_ = new FileSequenceState( ++ // std::move(producer_), file_task_runner, ++ // base::BindOnce(&FileDataPipeProducer::OnWriteComplete, ++ // weak_factory_.GetWeakPtr(), std::move(callback)), ++ // base::SequencedTaskRunnerHandle::Get(), std::move(observer_)); + } + + void FileDataPipeProducer::OnWriteComplete( +diff --git a/mojo/public/tools/bindings/mojom_bindings_generator.py b/mojo/public/tools/bindings/mojom_bindings_generator.py +index affbe79..57a8031 100755 +--- a/mojo/public/tools/bindings/mojom_bindings_generator.py ++++ b/mojo/public/tools/bindings/mojom_bindings_generator.py +@@ -174,7 +174,8 @@ class MojomProcessor(object): + MakeImportStackMessage(imported_filename_stack + [rel_filename.path]) + sys.exit(1) + +- tree = _UnpickleAST(_GetPicklePath(rel_filename, args.output_dir)) ++ tree = _UnpickleAST(_FindPicklePath(rel_filename, args.gen_directories + ++ [args.output_dir])) + dirname = os.path.dirname(rel_filename.path) + + # Process all our imports first and collect the module object for each. +@@ -256,6 +257,16 @@ def _Generate(args, remaining_args): + return 0 + + ++def _FindPicklePath(rel_filename, search_dirs): ++ filename, _ = os.path.splitext(rel_filename.relative_path()) ++ pickle_path = filename + '.p' ++ for search_dir in search_dirs: ++ path = os.path.join(search_dir, pickle_path) ++ if os.path.isfile(path): ++ return path ++ raise Exception("%s: Error: Could not find file in %r" % (pickle_path, search_dirs)) ++ ++ + def _GetPicklePath(rel_filename, output_dir): + filename, _ = os.path.splitext(rel_filename.relative_path()) + pickle_path = filename + '.p' +@@ -402,6 +413,9 @@ def main(): + metavar="GENERATORS", + default="c++,javascript,java", + help="comma-separated list of generators") ++ generate_parser.add_argument( ++ "--gen_dir", dest="gen_directories", action="append", metavar="directory", ++ default=[], help="add a directory to be searched for the syntax trees.") + generate_parser.add_argument( + "-I", dest="import_directories", action="append", metavar="directory", + default=[], diff --git a/libchrome_tools/patch/observer_list_unittest.patch b/libchrome_tools/patch/observer_list_unittest.patch new file mode 100644 index 000000000..8b1c5b5ae --- /dev/null +++ b/libchrome_tools/patch/observer_list_unittest.patch @@ -0,0 +1,65 @@ +diff --git a/base/observer_list_unittest.cc b/base/observer_list_unittest.cc +index 1470b90..50d7e7e 100644 +--- a/base/observer_list_unittest.cc ++++ b/base/observer_list_unittest.cc +@@ -17,9 +17,11 @@ + #include "base/run_loop.h" + #include "base/sequenced_task_runner.h" + #include "base/single_thread_task_runner.h" ++#include "base/strings/string_piece.h" + #include "base/synchronization/waitable_event.h" +-#include "base/task_scheduler/post_task.h" +-#include "base/task_scheduler/task_scheduler.h" ++// TaskScheduler not supported in libchrome ++// #include "base/task_scheduler/post_task.h" ++// #include "base/task_scheduler/task_scheduler.h" + #include "base/test/gtest_util.h" + #include "base/test/scoped_task_environment.h" + #include "base/threading/platform_thread.h" +@@ -690,6 +692,8 @@ class SequenceVerificationObserver : public Foo { + } // namespace + + // Verify that observers are notified on the correct sequence. ++// TaskScheduler not supported in libchrome ++#if 0 + TEST(ObserverListThreadSafeTest, NotificationOnValidSequence) { + test::ScopedTaskEnvironment scoped_task_environment; + +@@ -717,9 +721,12 @@ TEST(ObserverListThreadSafeTest, NotificationOnValidSequence) { + EXPECT_TRUE(observer_1.called_on_valid_sequence()); + EXPECT_TRUE(observer_2.called_on_valid_sequence()); + } ++#endif + + // Verify that when an observer is added to a NOTIFY_ALL ObserverListThreadSafe + // from a notification, it is itself notified. ++// TaskScheduler not supported in libchrome ++#if 0 + TEST(ObserverListThreadSafeTest, AddObserverFromNotificationNotifyAll) { + test::ScopedTaskEnvironment scoped_task_environment; + auto observer_list = MakeRefCounted<ObserverListThreadSafe<Foo>>(); +@@ -737,6 +744,7 @@ TEST(ObserverListThreadSafeTest, AddObserverFromNotificationNotifyAll) { + + EXPECT_EQ(1, observer_added_from_notification.GetValue()); + } ++#endif + + namespace { + +@@ -769,6 +777,8 @@ class RemoveWhileNotificationIsRunningObserver : public Foo { + + // Verify that there is no crash when an observer is removed while it is being + // notified. ++// TaskScheduler not supported in libchrome ++#if 0 + TEST(ObserverListThreadSafeTest, RemoveWhileNotificationIsRunning) { + auto observer_list = MakeRefCounted<ObserverListThreadSafe<Foo>>(); + RemoveWhileNotificationIsRunningObserver observer; +@@ -793,6 +803,7 @@ TEST(ObserverListThreadSafeTest, RemoveWhileNotificationIsRunning) { + + observer.Unblock(); + } ++#endif + + TEST(ObserverListTest, Existing) { + ObserverList<Foo> observer_list(ObserverListPolicy::EXISTING_ONLY); diff --git a/libchrome_tools/patch/path_service.patch b/libchrome_tools/patch/path_service.patch index 75b30dc04..466635dce 100644 --- a/libchrome_tools/patch/path_service.patch +++ b/libchrome_tools/patch/path_service.patch @@ -31,15 +31,16 @@ } --- a/base/files/file_util_posix.cc +++ b/base/files/file_util_posix.cc -@@ -533,6 +533,8 @@ bool GetTempDir(FilePath* path) { - } else { +@@ -594,6 +594,9 @@ bool GetTempDir(FilePath* path) { + #if defined(OS_ANDROID) - return PathService::Get(base::DIR_CACHE, path); + return PathService::Get(DIR_CACHE, path); +#elif defined(__ANDROID__) -+ *path = FilePath("/data/local/tmp"); ++ *path = FilePath("/data/local/tmp"); ++ return true; #else - *path = FilePath("/tmp"); - #endif + *path = FilePath("/tmp"); + return true; --- a/base/json/json_reader_unittest.cc +++ b/base/json/json_reader_unittest.cc @@ -567,7 +567,7 @@ TEST(JSONReaderTest, Reading) { diff --git a/libchrome_tools/patch/shared_memory_handle.patch b/libchrome_tools/patch/shared_memory_handle.patch new file mode 100644 index 000000000..fb2efafe7 --- /dev/null +++ b/libchrome_tools/patch/shared_memory_handle.patch @@ -0,0 +1,22 @@ +diff --git a/base/memory/shared_memory_handle.h b/base/memory/shared_memory_handle.h +index dd3d47a..7367188 100644 +--- a/base/memory/shared_memory_handle.h ++++ b/base/memory/shared_memory_handle.h +@@ -146,7 +146,7 @@ class BASE_EXPORT SharedMemoryHandle { + int Release(); + #endif + +-#if defined(OS_ANDROID) ++#if defined(OS_ANDROID) || defined(__ANDROID__) + // Marks the current file descriptor as read-only, for the purpose of + // mapping. This is independent of the region's read-only status. + void SetReadOnly() { read_only_ = true; } +@@ -218,7 +218,7 @@ class BASE_EXPORT SharedMemoryHandle { + bool ownership_passes_to_ipc_ = false; + }; + }; +-#elif defined(OS_ANDROID) ++#elif defined(OS_ANDROID) || defined(__ANDROID__) + friend class SharedMemory; + + FileDescriptor file_descriptor_; diff --git a/libchrome_tools/patch/shared_memory_mapping.patch b/libchrome_tools/patch/shared_memory_mapping.patch new file mode 100644 index 000000000..f5362f0d5 --- /dev/null +++ b/libchrome_tools/patch/shared_memory_mapping.patch @@ -0,0 +1,33 @@ +diff --git a/base/memory/shared_memory_mapping.cc b/base/memory/shared_memory_mapping.cc +index 005e3fc..2b42928 100644 +--- a/base/memory/shared_memory_mapping.cc ++++ b/base/memory/shared_memory_mapping.cc +@@ -7,7 +7,8 @@ + #include <utility> + + #include "base/logging.h" +-#include "base/memory/shared_memory_tracker.h" ++// Unsupported in libchrome ++// #include "base/memory/shared_memory_tracker.h" + #include "base/unguessable_token.h" + #include "build/build_config.h" + +@@ -62,14 +63,15 @@ SharedMemoryMapping::SharedMemoryMapping(void* memory, + size_t mapped_size, + const UnguessableToken& guid) + : memory_(memory), size_(size), mapped_size_(mapped_size), guid_(guid) { +- SharedMemoryTracker::GetInstance()->IncrementMemoryUsage(*this); ++ // Unsupported in libchrome. ++ // SharedMemoryTracker::GetInstance()->IncrementMemoryUsage(*this); + } + + void SharedMemoryMapping::Unmap() { + if (!IsValid()) + return; +- +- SharedMemoryTracker::GetInstance()->DecrementMemoryUsage(*this); ++ // Unsupported in libchrome. ++ // SharedMemoryTracker::GetInstance()->DecrementMemoryUsage(*this); + #if defined(OS_WIN) + if (!UnmapViewOfFile(memory_)) + DPLOG(ERROR) << "UnmapViewOfFile"; diff --git a/libchrome_tools/patch/shared_memory_posix.patch b/libchrome_tools/patch/shared_memory_posix.patch index abae9f455..169bbc8fb 100644 --- a/libchrome_tools/patch/shared_memory_posix.patch +++ b/libchrome_tools/patch/shared_memory_posix.patch @@ -1,6 +1,8 @@ +diff --git a/base/memory/shared_memory_posix.cc b/base/memory/shared_memory_posix.cc +index e1289e7e1da0..aa718957cf26 100644 --- a/base/memory/shared_memory_posix.cc +++ b/base/memory/shared_memory_posix.cc -@@ -27,6 +27,8 @@ +@@ -29,6 +30,8 @@ #if defined(OS_ANDROID) #include "base/os_compat_android.h" @@ -9,25 +11,25 @@ #include "third_party/ashmem/ashmem.h" #endif -@@ -96,7 +98,7 @@ bool SharedMemory::CreateAndMapAnonymous +@@ -80,7 +83,7 @@ bool SharedMemory::CreateAndMapAnonymous(size_t size) { return CreateAnonymous(size) && Map(size); } -#if !defined(OS_ANDROID) +#if !defined(OS_ANDROID) && !defined(__ANDROID__) - // static - bool SharedMemory::GetSizeFromSharedMemoryHandle( - const SharedMemoryHandle& handle, -@@ -255,7 +257,7 @@ bool SharedMemory::Open(const std::strin - return PrepareMapFile(std::move(fp), std::move(readonly_fd), &mapped_file_, - &readonly_mapped_file_); + + // Chromium mostly only uses the unique/private shmem as specified by + // "name == L"". The exception is in the StatsTable. +@@ -252,7 +255,7 @@ bool SharedMemory::Open(const std::string& name, bool read_only) { + FileDescriptor(readonly_mapped_file, false), 0, shm_.GetGUID()); + return result; } -#endif // !defined(OS_ANDROID) +#endif // !defined(OS_ANDROID) && !defined(__ANDROID__) bool SharedMemory::MapAt(off_t offset, size_t bytes) { - if (mapped_file_ == -1) -@@ -267,7 +269,7 @@ bool SharedMemory::MapAt(off_t offset, s + if (!shm_.IsValid()) +@@ -264,7 +267,7 @@ bool SharedMemory::MapAt(off_t offset, size_t bytes) { if (memory_) return false; @@ -36,21 +38,53 @@ // On Android, Map can be called with a size and offset of zero to use the // ashmem-determined size. if (bytes == 0) { -@@ -332,7 +334,7 @@ void SharedMemory::Close() { - } +@@ -277,19 +280,19 @@ bool SharedMemory::MapAt(off_t offset, size_t bytes) { + + // Sanity check. This shall catch invalid uses of the SharedMemory APIs + // but will not protect against direct mmap() attempts. +- if (shm_.IsReadOnly()) { +- // Use a DCHECK() to call writable mappings with read-only descriptors +- // in debug builds immediately. Return an error for release builds +- // or during unit-testing (assuming a ScopedLogAssertHandler was installed). +- DCHECK(read_only_) +- << "Trying to map a region writable with a read-only descriptor."; +- if (!read_only_) { +- return false; +- } +- if (!shm_.SetRegionReadOnly()) { // Ensure the region is read-only. +- return false; +- } +- } ++ // if (shm_.IsReadOnly()) { ++ // // Use a DCHECK() to call writable mappings with read-only descriptors ++ // // in debug builds immediately. Return an error for release builds ++ // // or during unit-testing (assuming a ScopedLogAssertHandler was installed). ++ // DCHECK(read_only_) ++ // << "Trying to map a region writable with a read-only descriptor."; ++ // if (!read_only_) { ++ // return false; ++ // } ++ // if (!shm_.SetRegionReadOnly()) { // Ensure the region is read-only. ++ // return false; ++ // } ++ // } + #endif + + memory_ = mmap(nullptr, bytes, PROT_READ | (read_only_ ? 0 : PROT_WRITE), +@@ -334,7 +339,7 @@ SharedMemoryHandle SharedMemory::TakeHandle() { + return handle_copy; } -#if !defined(OS_ANDROID) +#if !defined(OS_ANDROID) && !defined(__ANDROID__) - // For the given shmem named |mem_name|, return a filename to mmap() - // (and possibly create). Modifies |filename|. Return false on - // error, or true of we are happy. -@@ -355,7 +357,7 @@ bool SharedMemory::FilePathForMemoryName - *path = temp_dir.AppendASCII(name_base + ".shmem." + mem_name); - return true; + void SharedMemory::Close() { + if (shm_.IsValid()) { + shm_.Close(); +@@ -374,6 +379,6 @@ SharedMemoryHandle SharedMemory::GetReadOnlyHandle() const { + CHECK(readonly_shm_.IsValid()); + return readonly_shm_.Duplicate(); } -#endif // !defined(OS_ANDROID) +#endif // !defined(OS_ANDROID) && !defined(__ANDROID__) - bool SharedMemory::ShareToProcessCommon(ProcessHandle process, - SharedMemoryHandle* new_handle, + } // namespace base diff --git a/libchrome_tools/patch/ssl.patch b/libchrome_tools/patch/ssl.patch index f4a2f8f83..d502081e0 100644 --- a/libchrome_tools/patch/ssl.patch +++ b/libchrome_tools/patch/ssl.patch @@ -79,48 +79,4 @@ namespace crypto { ---- a/crypto/signature_verifier.h -+++ b/crypto/signature_verifier.h -@@ -54,9 +54,9 @@ class CRYPTO_EXPORT SignatureVerifier { - // subjectPublicKey BIT STRING } - bool VerifyInit(SignatureAlgorithm signature_algorithm, - const uint8_t* signature, -- size_t signature_len, -+ int signature_len, - const uint8_t* public_key_info, -- size_t public_key_info_len); -+ int public_key_info_len); - - // Initiates a RSA-PSS signature verification operation. This should be - // followed by one or more VerifyUpdate calls and a VerifyFinal call. -@@ -76,14 +76,14 @@ class CRYPTO_EXPORT SignatureVerifier { - // subjectPublicKey BIT STRING } - bool VerifyInitRSAPSS(HashAlgorithm hash_alg, - HashAlgorithm mask_hash_alg, -- size_t salt_len, -+ int salt_len, - const uint8_t* signature, -- size_t signature_len, -+ int signature_len, - const uint8_t* public_key_info, -- size_t public_key_info_len); -+ int public_key_info_len); - - // Feeds a piece of the data to the signature verifier. -- void VerifyUpdate(const uint8_t* data_part, size_t data_part_len); -+ void VerifyUpdate(const uint8_t* data_part, int data_part_len); - - // Concludes a signature verification operation. Returns true if the - // signature is valid. Returns false if the signature is invalid or an -@@ -94,9 +94,9 @@ class CRYPTO_EXPORT SignatureVerifier { - bool CommonInit(int pkey_type, - const EVP_MD* digest, - const uint8_t* signature, -- size_t signature_len, -+ int signature_len, - const uint8_t* public_key_info, -- size_t public_key_info_len, -+ int public_key_info_len, - EVP_PKEY_CTX** pkey_ctx); - - void Reset(); + diff --git a/libchrome_tools/patch/statfs_f_type.patch b/libchrome_tools/patch/statfs_f_type.patch index 989380b5d..f4b8df4dd 100644 --- a/libchrome_tools/patch/statfs_f_type.patch +++ b/libchrome_tools/patch/statfs_f_type.patch @@ -26,7 +26,7 @@ break; --- a/base/sys_info_posix.cc +++ b/base/sys_info_posix.cc -@@ -85,7 +85,10 @@ bool IsStatsZeroIfUnlimited(const base:: +@@ -90,7 +90,10 @@ bool IsStatsZeroIfUnlimited(const base::FilePath& path) { if (HANDLE_EINTR(statfs(path.value().c_str(), &stats)) != 0) return false; diff --git a/libchrome_tools/patch/subprocess.patch b/libchrome_tools/patch/subprocess.patch index ff1d02d3d..bbd819ff4 100644 --- a/libchrome_tools/patch/subprocess.patch +++ b/libchrome_tools/patch/subprocess.patch @@ -1,19 +1,19 @@ --- a/base/process/process_metrics_unittest.cc +++ b/base/process/process_metrics_unittest.cc -@@ -549,6 +549,9 @@ MULTIPROCESS_TEST_MAIN(ChildMain) { +@@ -569,6 +569,9 @@ MULTIPROCESS_TEST_MAIN(ChildMain) { } // namespace +// ARC note: don't compile as SpawnMultiProcessTestChild brings in a lot of +// extra dependency. +#if !defined(OS_ANDROID) && !defined(__ANDROID__) && !defined(__ANDROID_HOST__) - TEST(ProcessMetricsTest, GetOpenFdCount) { + TEST(ProcessMetricsTest, GetChildOpenFdCount) { ScopedTempDir temp_dir; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); -@@ -562,9 +565,23 @@ TEST(ProcessMetricsTest, GetOpenFdCount) +@@ -582,9 +585,23 @@ TEST(ProcessMetricsTest, GetChildOpenFdCount) { std::unique_ptr<ProcessMetrics> metrics( - ProcessMetrics::CreateProcessMetrics(spawn_child.process.Handle())); + ProcessMetrics::CreateProcessMetrics(child.Handle())); - EXPECT_EQ(0, metrics->GetOpenFdCount()); + // Try a couple times to observe the child with 0 fds open. + // Sometimes we've seen that the child can have 1 remaining @@ -28,25 +28,25 @@ + PlatformThread::Sleep(TimeDelta::FromMilliseconds(1)); + } + EXPECT_EQ(0, open_fds); - ASSERT_TRUE(spawn_child.process.Terminate(0, true)); + ASSERT_TRUE(child.Terminate(0, true)); } +#endif // !defined(__ANDROID__) + #endif // defined(OS_LINUX) - } // namespace debug + #if defined(OS_ANDROID) || defined(OS_LINUX) --- a/base/test/multiprocess_test.cc +++ b/base/test/multiprocess_test.cc -@@ -12,7 +12,7 @@ +@@ -13,7 +13,7 @@ namespace base { -#if !defined(OS_ANDROID) +#if !defined(OS_ANDROID) && !defined(__ANDROID__) && !defined(__ANDROID_HOST__) - SpawnChildResult SpawnMultiProcessTestChild( - const std::string& procname, - const CommandLine& base_command_line, -@@ -41,7 +41,7 @@ bool TerminateMultiProcessTestChild(cons + Process SpawnMultiProcessTestChild(const std::string& procname, + const CommandLine& base_command_line, + const LaunchOptions& options) { +@@ -39,7 +39,7 @@ bool TerminateMultiProcessTestChild(const Process& process, return process.Terminate(exit_code, wait); } @@ -54,18 +54,18 @@ +#endif // !OS_ANDROID && !__ANDROID__ && !__ANDROID_HOST__ CommandLine GetMultiProcessTestChildBaseCommandLine() { - CommandLine cmd_line = *CommandLine::ForCurrentProcess(); -@@ -54,6 +54,8 @@ CommandLine GetMultiProcessTestChildBase - MultiProcessTest::MultiProcessTest() { - } + base::ScopedAllowBlockingForTesting allow_blocking; +@@ -52,6 +52,8 @@ CommandLine GetMultiProcessTestChildBaseCommandLine() { + + MultiProcessTest::MultiProcessTest() = default; +// Don't compile on ARC. +#if 0 - SpawnChildResult MultiProcessTest::SpawnChild(const std::string& procname) { + Process MultiProcessTest::SpawnChild(const std::string& procname) { LaunchOptions options; #if defined(OS_WIN) -@@ -67,6 +69,7 @@ SpawnChildResult MultiProcessTest::Spawn - const LaunchOptions& options) { +@@ -64,6 +66,7 @@ Process MultiProcessTest::SpawnChildWithOptions(const std::string& procname, + const LaunchOptions& options) { return SpawnMultiProcessTestChild(procname, MakeCmdLine(procname), options); } +#endif diff --git a/libchrome_tools/patch/task_annotator.patch b/libchrome_tools/patch/task_annotator.patch new file mode 100644 index 000000000..52d21c6e7 --- /dev/null +++ b/libchrome_tools/patch/task_annotator.patch @@ -0,0 +1,12 @@ +diff --git a/base/debug/task_annotator.h b/base/debug/task_annotator.h +index fedca7d..9ff5c7b 100644 +--- a/base/debug/task_annotator.h ++++ b/base/debug/task_annotator.h +@@ -20,6 +20,7 @@ class BASE_EXPORT TaskAnnotator { + public: + class ObserverForTesting { + public: ++ virtual ~ObserverForTesting() = default; + // Invoked just before RunTask() in the scope in which the task is about to + // be executed. + virtual void BeforeRunTask(const PendingTask* pending_task) = 0; diff --git a/libchrome_tools/patch/task_scheduler.patch b/libchrome_tools/patch/task_scheduler.patch deleted file mode 100644 index c32520ba4..000000000 --- a/libchrome_tools/patch/task_scheduler.patch +++ /dev/null @@ -1,152 +0,0 @@ -# libchrome does not support TaskScheduler. - ---- a/base/threading/sequenced_worker_pool.cc -+++ b/base/threading/sequenced_worker_pool.cc -@@ -27,8 +27,12 @@ - #include "base/strings/stringprintf.h" - #include "base/synchronization/condition_variable.h" - #include "base/synchronization/lock.h" -+// Don't enable the redirect to TaskScheduler on Arc++ to avoid pulling a bunch -+// of dependencies. Some code also #ifdef'ed below. -+#if 0 - #include "base/task_scheduler/post_task.h" - #include "base/task_scheduler/task_scheduler.h" -+#endif - #include "base/threading/platform_thread.h" - #include "base/threading/sequenced_task_runner_handle.h" - #include "base/threading/simple_thread.h" -@@ -755,10 +759,13 @@ bool SequencedWorkerPool::Inner::PostTas - if (optional_token_name) - sequenced.sequence_token_id = LockedGetNamedTokenID(*optional_token_name); - -+ // See on top of the file why we don't compile this on Arc++. -+#if 0 - if (g_all_pools_state == AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER) { - if (!PostTaskToTaskScheduler(std::move(sequenced), delay)) - return false; - } else { -+#endif - SequencedWorkerPool::WorkerShutdown shutdown_behavior = - sequenced.shutdown_behavior; - pending_tasks_.insert(std::move(sequenced)); -@@ -767,7 +774,9 @@ bool SequencedWorkerPool::Inner::PostTas - blocking_shutdown_pending_task_count_++; - - create_thread_id = PrepareToStartAdditionalThreadIfHelpful(); -+#if 0 - } -+#endif - } - - // Use != REDIRECTED_TO_TASK_SCHEDULER instead of == USE_WORKER_POOL to ensure -@@ -802,6 +811,10 @@ bool SequencedWorkerPool::Inner::PostTas - bool SequencedWorkerPool::Inner::PostTaskToTaskScheduler( - SequencedTask sequenced, - const TimeDelta& delay) { -+#if 1 -+ NOTREACHED(); -+ return false; -+#else - DCHECK_EQ(AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER, g_all_pools_state); - - lock_.AssertAcquired(); -@@ -832,12 +845,17 @@ bool SequencedWorkerPool::Inner::PostTas - return GetTaskSchedulerTaskRunner(sequenced.sequence_token_id, traits) - ->PostDelayedTask(sequenced.posted_from, std::move(sequenced.task), - delay); -+#endif - } - - scoped_refptr<TaskRunner> - SequencedWorkerPool::Inner::GetTaskSchedulerTaskRunner( - int sequence_token_id, - const TaskTraits& traits) { -+#if 1 -+ NOTREACHED(); -+ return scoped_refptr<TaskRunner>(); -+#else - DCHECK_EQ(AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER, g_all_pools_state); - - lock_.AssertAcquired(); -@@ -871,16 +889,19 @@ SequencedWorkerPool::Inner::GetTaskSched - } - - return task_runner; -+#endif - } - - bool SequencedWorkerPool::Inner::RunsTasksOnCurrentThread() const { - AutoLock lock(lock_); - if (g_all_pools_state == AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER) { -+#if 0 - if (!runs_tasks_on_verifier_) { - runs_tasks_on_verifier_ = CreateTaskRunnerWithTraits( - TaskTraits().MayBlock().WithBaseSyncPrimitives().WithPriority( - task_priority_)); - } -+#endif - return runs_tasks_on_verifier_->RunsTasksOnCurrentThread(); - } else { - return ContainsKey(threads_, PlatformThread::CurrentId()); -@@ -1467,6 +1488,9 @@ void SequencedWorkerPool::EnableForProce - // static - void SequencedWorkerPool::EnableWithRedirectionToTaskSchedulerForProcess( - TaskPriority max_task_priority) { -+#if 1 -+ NOTREACHED(); -+#else - // TODO(fdoray): Uncomment this line. It is initially commented to avoid a - // revert of the CL that adds debug::DumpWithoutCrashing() in case of - // waterfall failures. -@@ -1474,6 +1498,7 @@ void SequencedWorkerPool::EnableWithRedi - DCHECK(TaskScheduler::GetInstance()); - g_all_pools_state = AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER; - g_max_task_priority = max_task_priority; -+#endif - } - - // static -@@ -1623,8 +1648,12 @@ void SequencedWorkerPool::FlushForTestin - DCHECK(!RunsTasksOnCurrentThread()); - base::ThreadRestrictions::ScopedAllowWait allow_wait; - if (g_all_pools_state == AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER) { -+#if 1 -+ NOTREACHED(); -+#else - // TODO(gab): Remove this if http://crbug.com/622400 fails. - TaskScheduler::GetInstance()->FlushForTesting(); -+#endif - } else { - inner_->CleanupForTesting(); - } ---- a/base/trace_event/trace_log.cc -+++ b/base/trace_event/trace_log.cc -@@ -27,7 +27,10 @@ - #include "base/strings/string_tokenizer.h" - #include "base/strings/stringprintf.h" - #include "base/sys_info.h" -+// post_task.h pulls in a lot of code not needed on Arc++. -+#if 0 - #include "base/task_scheduler/post_task.h" -+#endif - #include "base/threading/platform_thread.h" - #include "base/threading/thread_id_name_manager.h" - #include "base/threading/thread_task_runner_handle.h" -@@ -968,6 +971,7 @@ void TraceLog::FinishFlush(int generatio - } - - if (use_worker_thread_) { -+#if 0 - base::PostTaskWithTraits( - FROM_HERE, base::TaskTraits() - .MayBlock() -@@ -978,6 +982,9 @@ void TraceLog::FinishFlush(int generatio - Passed(&previous_logged_events), flush_output_callback, - argument_filter_predicate)); - return; -+#else -+ NOTREACHED(); -+#endif - } - - ConvertTraceEventsToTraceFormat(std::move(previous_logged_events), diff --git a/libchrome_tools/patch/time.patch b/libchrome_tools/patch/time.patch deleted file mode 100644 index 496e68f30..000000000 --- a/libchrome_tools/patch/time.patch +++ /dev/null @@ -1,19 +0,0 @@ -# Cherry-pick from r488841. - ---- a/base/time/time.h -+++ b/base/time/time.h -@@ -341,6 +341,14 @@ class TimeBase { - // provided operators. - int64_t ToInternalValue() const { return us_; } - -+ // The amount of time since the origin (or "zero") point. This is a syntactic -+ // convenience to aid in code readability, mainly for debugging/testing use -+ // cases. -+ // -+ // Warning: While the Time subclass has a fixed origin point, the origin for -+ // the other subclasses can vary each time the application is restarted. -+ TimeDelta since_origin() const { return TimeDelta::FromMicroseconds(us_); } -+ - TimeClass& operator=(TimeClass other) { - us_ = other.us_; - return *(static_cast<TimeClass*>(this)); diff --git a/libchrome_tools/patch/trace_event.patch b/libchrome_tools/patch/trace_event.patch new file mode 100644 index 000000000..43dc0524f --- /dev/null +++ b/libchrome_tools/patch/trace_event.patch @@ -0,0 +1,191 @@ +--- a/base/trace_event/trace_event.h ++++ b/base/trace_event/trace_event.h +@@ -5,6 +5,43 @@ + #ifndef BASE_TRACE_EVENT_TRACE_EVENT_H_ + #define BASE_TRACE_EVENT_TRACE_EVENT_H_ + ++// Replace with stub implementation. ++#if 1 ++#include "base/trace_event/common/trace_event_common.h" ++#include "base/trace_event/heap_profiler.h" ++ ++// To avoid -Wunused-* errors, eat expression by macro. ++namespace libchrome_internal { ++template <typename... Args> void Ignore(Args&&... args) {} ++} ++#define INTERNAL_IGNORE(...) \ ++ (false ? libchrome_internal::Ignore(__VA_ARGS__) : (void) 0) ++ ++// Body is effectively empty. ++#define INTERNAL_TRACE_EVENT_ADD_SCOPED(...) INTERNAL_IGNORE(__VA_ARGS__) ++#define INTERNAL_TRACE_TASK_EXECUTION(...) ++#define INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_FLOW(...) \ ++ INTERNAL_IGNORE(__VA_ARGS__) ++#define TRACE_ID_MANGLE(val) (val) ++ ++namespace base { ++namespace trace_event { ++ ++class TraceLog { ++ public: ++ static TraceLog* GetInstance() { ++ static TraceLog instance; ++ return &instance; ++ } ++ ++ pid_t process_id() { return 0; } ++ void SetCurrentThreadBlocksMessageLoop() {} ++}; ++ ++} // namespace trace_event ++} // namespace base ++#else ++ + // This header file defines implementation details of how the trace macros in + // trace_event_common.h collect and store trace events. Anything not + // implementation-specific should go in trace_event_common.h instead of here. +@@ -1115,4 +1152,5 @@ template<typename IDType> class TraceSco + } // namespace trace_event + } // namespace base + ++#endif + #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ +--- a/base/trace_event/heap_profiler.h ++++ b/base/trace_event/heap_profiler.h +@@ -5,6 +5,22 @@ + #ifndef BASE_TRACE_EVENT_HEAP_PROFILER_H + #define BASE_TRACE_EVENT_HEAP_PROFILER_H + ++// Replace with stub implementation. ++#if 1 ++#define TRACE_HEAP_PROFILER_API_SCOPED_TASK_EXECUTION \ ++ trace_event_internal::HeapProfilerScopedTaskExecutionTracker ++ ++namespace trace_event_internal { ++ ++class HeapProfilerScopedTaskExecutionTracker { ++ public: ++ explicit HeapProfilerScopedTaskExecutionTracker(const char*) {} ++}; ++ ++} // namespace trace_event_internal ++ ++#else ++ + #include "base/compiler_specific.h" + #include "base/trace_event/heap_profiler_allocation_context_tracker.h" + +@@ -86,4 +102,5 @@ class BASE_EXPORT HeapProfilerScopedIgno + + } // namespace trace_event_internal + ++#endif + #endif // BASE_TRACE_EVENT_HEAP_PROFILER_H +--- a/base/test/test_pending_task.h ++++ b/base/test/test_pending_task.h +@@ -10,7 +10,8 @@ + #include "base/callback.h" + #include "base/location.h" + #include "base/time/time.h" +-#include "base/trace_event/trace_event_argument.h" ++// Unsupported in libchrome. ++// #include "base/trace_event/trace_event_argument.h" + + namespace base { + +@@ -58,10 +59,13 @@ struct TestPendingTask { + TimeDelta delay; + TestNestability nestability; + ++// Unsupported in libchrome. ++#if 0 + // Functions for using test pending task with tracing, useful in unit + // testing. + void AsValueInto(base::trace_event::TracedValue* state) const; + std::unique_ptr<base::trace_event::ConvertableToTraceFormat> AsValue() const; ++#endif + std::string ToString() const; + + private: +--- a/base/test/test_pending_task.cc ++++ b/base/test/test_pending_task.cc +@@ -38,6 +38,8 @@ bool TestPendingTask::ShouldRunBefore(co + + TestPendingTask::~TestPendingTask() {} + ++// Unsupported in libchrome. ++#if 0 + void TestPendingTask::AsValueInto(base::trace_event::TracedValue* state) const { + state->SetInteger("run_at", GetTimeToRun().ToInternalValue()); + state->SetString("posting_function", location.ToString()); +@@ -61,10 +63,14 @@ TestPendingTask::AsValue() const { + AsValueInto(state.get()); + return std::move(state); + } ++#endif + + std::string TestPendingTask::ToString() const { + std::string output("TestPendingTask("); ++// Unsupported in libchrome. ++#if 0 + AsValue()->AppendAsTraceFormat(&output); ++#endif + output += ")"; + return output; + } +---- a/base/threading/thread_id_name_manager.cc ++++ b/base/threading/thread_id_name_manager.cc +@@ -12,7 +12,8 @@ + #include "base/no_destructor.h" + #include "base/strings/string_util.h" + #include "base/threading/thread_local.h" +-#include "base/trace_event/heap_profiler_allocation_context_tracker.h" ++// Unsupported in libchrome. ++// #include "base/trace_event/heap_profiler_allocation_context_tracker.h" + + namespace base { + namespace { +@@ -94,8 +95,9 @@ void ThreadIdNameManager::SetName(const std::string& name) { + // call GetName(which holds a lock) during the first allocation because it can + // cause a deadlock when the first allocation happens in the + // ThreadIdNameManager itself when holding the lock. +- trace_event::AllocationContextTracker::SetCurrentThreadName( +- leaked_str->c_str()); ++ // Unsupported in libchrome. ++ // trace_event::AllocationContextTracker::SetCurrentThreadName( ++ // leaked_str->c_str()); + } + + const char* ThreadIdNameManager::GetName(PlatformThreadId id) { +--- a/base/memory/shared_memory_posix.cc ++++ b/base/memory/shared_memory_posix.cc +@@ -16,7 +16,8 @@ + #include "base/logging.h" + #include "base/macros.h" + #include "base/memory/shared_memory_helper.h" +-#include "base/memory/shared_memory_tracker.h" ++// Unsupported in libchrome. ++// #include "base/memory/shared_memory_tracker.h" + #include "base/posix/eintr_wrapper.h" + #include "base/posix/safe_strerror.h" + #include "base/process/process_metrics.h" +@@ -302,7 +305,8 @@ bool SharedMemory::MapAt(off_t offset, size_t bytes) { + DCHECK_EQ(0U, + reinterpret_cast<uintptr_t>(memory_) & + (SharedMemory::MAP_MINIMUM_ALIGNMENT - 1)); +- SharedMemoryTracker::GetInstance()->IncrementMemoryUsage(*this); ++ // Unsupported in libchrome. ++ // SharedMemoryTracker::GetInstance()->IncrementMemoryUsage(*this); + } else { + memory_ = nullptr; + } +@@ -314,7 +318,8 @@ bool SharedMemory::Unmap() { + if (!memory_) + return false; + +- SharedMemoryTracker::GetInstance()->DecrementMemoryUsage(*this); ++ // Unsupported in libchrome. ++ // SharedMemoryTracker::GetInstance()->DecrementMemoryUsage(*this); + munmap(memory_, mapped_size_); + memory_ = nullptr; + mapped_size_ = 0; diff --git a/libchrome_tools/patch/valgrind.patch b/libchrome_tools/patch/valgrind.patch deleted file mode 100644 index 7a7722c3a..000000000 --- a/libchrome_tools/patch/valgrind.patch +++ /dev/null @@ -1,33 +0,0 @@ -# On Android, use system valgrind, instead of ones checked in to the Chromium -# repository. - ---- a/base/third_party/valgrind/memcheck.h -+++ b/base/third_party/valgrind/memcheck.h -@@ -1,4 +1,6 @@ -- -+#ifdef ANDROID -+ #include "memcheck/memcheck.h" -+#else - /* - ---------------------------------------------------------------- - -@@ -277,3 +279,4 @@ typedef - - #endif - -+#endif ---- a/base/third_party/valgrind/valgrind.h -+++ b/base/third_party/valgrind/valgrind.h -@@ -1,3 +1,6 @@ -+#ifdef ANDROID -+ #include "include/valgrind.h" -+#else - /* -*- c -*- - ---------------------------------------------------------------- - -@@ -4790,3 +4793,5 @@ VALGRIND_PRINTF_BACKTRACE(const char *fo - #undef PLAT_ppc64_aix5 - - #endif /* __VALGRIND_H */ -+ -+#endif diff --git a/libchrome_tools/patch/values.patch b/libchrome_tools/patch/values.patch new file mode 100644 index 000000000..7e36b490c --- /dev/null +++ b/libchrome_tools/patch/values.patch @@ -0,0 +1,63 @@ +# we don't support trace_event on libchrome + +--- a/base/values.cc ++++ b/base/values.cc +@@ -18,7 +18,8 @@ + #include "base/stl_util.h" + #include "base/strings/string_util.h" + #include "base/strings/utf_string_conversions.h" +-#include "base/trace_event/memory_usage_estimator.h" ++// Unsupported in libchrome ++// #include "base/trace_event/memory_usage_estimator.h" + + namespace base { + +@@ -632,20 +633,21 @@ bool Value::Equals(const Value* other) const { + return *this == *other; + } + +-size_t Value::EstimateMemoryUsage() const { +- switch (type_) { +- case Type::STRING: +- return base::trace_event::EstimateMemoryUsage(string_value_); +- case Type::BINARY: +- return base::trace_event::EstimateMemoryUsage(binary_value_); +- case Type::DICTIONARY: +- return base::trace_event::EstimateMemoryUsage(dict_); +- case Type::LIST: +- return base::trace_event::EstimateMemoryUsage(list_); +- default: +- return 0; +- } +-} ++// Unsupported in libchrome ++// size_t Value::EstimateMemoryUsage() const { ++// switch (type_) { ++// case Type::STRING: ++// return base::trace_event::EstimateMemoryUsage(string_value_); ++// case Type::BINARY: ++// return base::trace_event::EstimateMemoryUsage(binary_value_); ++// case Type::DICTIONARY: ++// return base::trace_event::EstimateMemoryUsage(dict_); ++// case Type::LIST: ++// return base::trace_event::EstimateMemoryUsage(list_); ++// default: ++// return 0; ++// } ++// } + + void Value::InternalMoveConstructFrom(Value&& that) { + type_ = that.type_; + +--- a/base/values.h ++++ b/base/values.h +@@ -352,7 +352,7 @@ class BASE_EXPORT Value { + + // Estimates dynamic memory usage. + // See base/trace_event/memory_usage_estimator.h for more info. +- size_t EstimateMemoryUsage() const; ++ // size_t EstimateMemoryUsage() const; + + protected: + // TODO(crbug.com/646113): Make these private once DictionaryValue and + diff --git a/libchrome_tools/update_libchrome.py b/libchrome_tools/update_libchrome.py index 2c51f151e..b2f8a92d5 100644 --- a/libchrome_tools/update_libchrome.py +++ b/libchrome_tools/update_libchrome.py @@ -44,6 +44,15 @@ _TOOLS_DIR = os.path.dirname(os.path.realpath(__file__)) _LIBCHROME_ROOT = os.path.dirname(_TOOLS_DIR) +# Files in this list or in the directory listed here will be just copied. +# Paths ends with '/' is interpreted as directory. +_IMPORT_LIST = [ + 'mojo/', + 'third_party/ply/', + 'third_party/markupsafe/', + 'third_party/jinja2/', +] + # Files which are in the repository, but should not be imported from Chrome # repository. _IMPORT_BLACKLIST = [ @@ -56,22 +65,32 @@ _IMPORT_BLACKLIST = [ 'SConstruct', 'libmojo.pc.in', 'testrunner.cc', + '*/DEPS', + + # No Chromium OWNERS should be imported. + '*/OWNERS', - # libchrome_tools is out of the update target. + # libchrome_tools and soong are out of the update target. 'libchrome_tools/*', + 'soong/*', + + # No internal directories. + 'mojo/internal/*', # Those files should be generated. Please see also buildflag_header.patch. - 'base/allocator/features.h', - 'base/debug/debugging_flags.h', + 'base/allocator/buildflags.h', + 'base/android/java/src/org/chromium/base/BuildConfig.java', + 'base/cfi_buildflags.h', + 'base/debug/debugging_buildflags.h', + 'base/memory/protected_memory_buildflags.h', + 'base/synchronization/synchronization_buildflags.h', 'gen/*', - - # Local patch to support time.mojom. - # TODO(hidehiko): Remove this after roll to ToT Chrome. - 'mojo/common/time_struct_traits.h', + 'ipc/ipc_buildflags.h', # Blacklist several third party libraries; system libraries should be used. 'base/third_party/libevent/*', 'base/third_party/symbolize/*', + 'testing/gmock/*', 'testing/gtest/*', 'third_party/ashmem/*', @@ -79,14 +98,40 @@ _IMPORT_BLACKLIST = [ 'third_party/protobuf/*', ] -def _find_target_files(): +def _find_target_files(chromium_root): """Returns target files to be upreved.""" + # Files in the repository should be updated. output = subprocess.check_output( ['git', 'ls-tree', '-r', '--name-only', '--full-name', 'HEAD'], cwd=_LIBCHROME_ROOT).decode('utf-8') + + # Files in _IMPORT_LIST are copied in the following section, so + # exclude them from candidates, here, so that files deleted in chromium + # repository will be deleted on update. + candidates = [ + path for path in output.splitlines() + if not any(path.startswith(import_path) for import_path in _IMPORT_LIST)] + + # All files listed in _IMPORT_LIST should be imported, too. + for import_path in _IMPORT_LIST: + import_root = os.path.join(chromium_root, import_path) + + # If it is a file, just add to the candidates. + if os.path.isfile(import_root): + candidates.append(import_path) + continue + + # If it is a directory, traverse all files in the directory recursively + # and add all of them to candidates. + for dirpath, dirnames, filenames in os.walk(import_root): + for filename in filenames: + filepath = os.path.join(dirpath, filename) + candidates.append(os.path.relpath(filepath, chromium_root)) + + # Apply blacklist. exclude_pattern = re.compile('|'.join( '(?:%s)' % fnmatch.translate(pattern) for pattern in _IMPORT_BLACKLIST)) - return [filepath for filepath in output.splitlines() + return [filepath for filepath in candidates if not exclude_pattern.match(filepath)] @@ -99,7 +144,7 @@ def _clean_existing_dir(output_root): os.makedirs(output_root, mode=0o755, exist_ok=True) for path in os.listdir(output_root): target_path = os.path.join(output_root, path) - if (not os.path.isdir(target_path) or path in ('.git', 'libchrome_tools')): + if (not os.path.isdir(target_path) or path in ('.git', 'libchrome_tools', 'soong')): continue shutil.rmtree(target_path) @@ -111,10 +156,11 @@ def _import_files(chromium_root, output_root): chromium_root: Path to the Chromium's repository. output_root: Path to the output directory. """ - for filepath in _find_target_files(): + for filepath in _find_target_files(chromium_root): + source_path = os.path.join(chromium_root, filepath) target_path = os.path.join(output_root, filepath) os.makedirs(os.path.dirname(target_path), mode=0o755, exist_ok=True) - shutil.copy2(os.path.join(chromium_root, filepath), target_path) + shutil.copy2(source_path, target_path) def _apply_patch_files(patch_root, output_root): |