summaryrefslogtreecommitdiffstats
path: root/libchrome_tools
diff options
context:
space:
mode:
authorJakub Pawlowski <jpawlowski@google.com>2017-04-05 09:22:29 -0700
committerJakub Pawlowski <jpawlowski@google.com>2018-10-12 19:25:59 +0200
commite280f12834190c543be1ad4fddf6a642f65b998a (patch)
treea398a922d546c95123c3cc6e78091bef5378969b /libchrome_tools
parent23b27ba5c54bf6368980117d91bc51c4495e2c50 (diff)
downloadplatform_external_libchrome-e280f12834190c543be1ad4fddf6a642f65b998a.tar.gz
platform_external_libchrome-e280f12834190c543be1ad4fddf6a642f65b998a.tar.bz2
platform_external_libchrome-e280f12834190c543be1ad4fddf6a642f65b998a.zip
Uprev libchrome to r576279 (1/many)
This patch brings the latest and greatest features of libchrome to android. It contains ~2600 patches. Reason for uprev: libbluetooth want to use some of the most recent features avaliable. Test: libchrome_test Change-Id: Iccdec267948daab29e6328694f4c7d2f71ea26ca Merged-In: Iccdec267948daab29e6328694f4c7d2f71ea26ca
Diffstat (limited to 'libchrome_tools')
-rwxr-xr-xlibchrome_tools/jni_registration_generator_helper.sh40
-rwxr-xr-xlibchrome_tools/mojom_source_generator.sh144
-rw-r--r--libchrome_tools/patch/580fcef.patch112
-rw-r--r--libchrome_tools/patch/8fbafc9.patch25
-rw-r--r--libchrome_tools/patch/ContextUtils.patch18
-rw-r--r--libchrome_tools/patch/ThreadLocalStorage-Add-a-function-to-destroy-pthread.patch63
-rw-r--r--libchrome_tools/patch/allocator_shim.patch2
-rw-r--r--libchrome_tools/patch/buildflag_header.patch95
-rw-r--r--libchrome_tools/patch/c7ce19d.patch28
-rw-r--r--libchrome_tools/patch/dmg_fp.patch74
-rw-r--r--libchrome_tools/patch/file_path_mojom.patch19
-rw-r--r--libchrome_tools/patch/file_posix.patch11
-rw-r--r--libchrome_tools/patch/handle_table.patch176
-rw-r--r--libchrome_tools/patch/hash.patch17
-rw-r--r--libchrome_tools/patch/jni_registration_generator.patch13
-rw-r--r--libchrome_tools/patch/lazy_instance.patch18
-rw-r--r--libchrome_tools/patch/logging.patch20
-rw-r--r--libchrome_tools/patch/macros.patch45
-rw-r--r--libchrome_tools/patch/memory_linux.patch17
-rw-r--r--libchrome_tools/patch/message_loop.patch32
-rw-r--r--libchrome_tools/patch/message_loop_unittest.patch125
-rw-r--r--libchrome_tools/patch/message_pump_for_ui.patch28
-rw-r--r--libchrome_tools/patch/mojo-Add-a-way-to-handle-unhandled-RuntimeExceptions.patch129
-rw-r--r--libchrome_tools/patch/mojo-Avoid-a-crash-when-NodeController-pending-invit.patch44
-rw-r--r--libchrome_tools/patch/mojo.patch507
-rw-r--r--libchrome_tools/patch/mojom_disable_trace_and_mem_dump.patch299
-rw-r--r--libchrome_tools/patch/observer_list_unittest.patch65
-rw-r--r--libchrome_tools/patch/path_service.patch13
-rw-r--r--libchrome_tools/patch/shared_memory_handle.patch22
-rw-r--r--libchrome_tools/patch/shared_memory_mapping.patch33
-rw-r--r--libchrome_tools/patch/shared_memory_posix.patch74
-rw-r--r--libchrome_tools/patch/ssl.patch46
-rw-r--r--libchrome_tools/patch/statfs_f_type.patch2
-rw-r--r--libchrome_tools/patch/subprocess.patch36
-rw-r--r--libchrome_tools/patch/task_annotator.patch12
-rw-r--r--libchrome_tools/patch/task_scheduler.patch121
-rw-r--r--libchrome_tools/patch/time.patch19
-rw-r--r--libchrome_tools/patch/trace_event.patch28
-rw-r--r--libchrome_tools/patch/values.patch63
-rw-r--r--libchrome_tools/update_libchrome.py20
40 files changed, 1468 insertions, 1187 deletions
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_source_generator.sh b/libchrome_tools/mojom_source_generator.sh
deleted file mode 100755
index a0feb1f65..000000000
--- a/libchrome_tools/mojom_source_generator.sh
+++ /dev/null
@@ -1,144 +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=()
-includes=()
-gen_dirs=()
-
-mojom_bindings_generator=""
-package=""
-output_dir=""
-generators=""
-
-# 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+=("--typemap=${typemap}")
- ;;
- --bytecode_path=*)
- bytecode_path="${arg#'--bytecode_path='}"
- bytecode_path="$(get_abs_path ${bytecode_path})"
- ;;
- --generators=*)
- generators="${arg#'--generators='}"
- ;;
- --srcjar=*)
- srcjar="${arg#'--srcjar='}"
- srcjar="$(get_abs_path ${srcjar})"
- ;;
- -I=*)
- includes+=("$(get_abs_path "${arg#'-I='}")")
- ;;
- --*)
- args+=("${arg}")
- ;;
- *.mojom)
- # Add all .mojom files directly as files.
- files+=("$(get_abs_path ${arg})")
- ;;
- *.p)
- # Get the gen/ dir of any pickle (.p) file so that the bindings
- # generator
- # can get the correct path.
- gen_dirs+=("$(get_abs_path "${arg}" | sed -e 's@/gen/.*$@/gen@')")
- esac
-done
-
-# Add the current package as include path, and then rewrite all the include
-# paths so that the bindings generator can relativize the paths correctly.
-includes+=("$(pwd)/${package}")
-includes=($(printf -- "%q\n" "${includes[@]}" | sed -e 's/.*/-I=&:&/'))
-
-# Remove duplicates from the list of gen/ directories that contain the pickle
-# files.
-if [[ "${#gen_dirs[@]}" -ge 1 ]]; then
- gen_dirs=($(printf -- "--gen_dir=%q\n" "${gen_dirs[@]}" | sort -u))
-fi
-
-"${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`/$package/}"
- rel_dir="${rel_path%/*}"
-
- mkdir -p "${output_dir}/${rel_dir}"
-
- "${mojom_bindings_generator}" --use_bundled_pylibs generate \
- -o "${output_dir}" "${args[@]}" \
- --bytecode_path="${bytecode_path}" \
- "${gen_dirs[@]}" \
- -d "${package}" \
- "${includes[@]}" \
- --generators="${generators}" "${file}"
- if [[ "${generators}" =~ .*c\+\+.* ]] ; then
- "${mojom_bindings_generator}" --use_bundled_pylibs generate \
- -o "${output_dir}" \
- --generate_non_variant_code "${args[@]}" \
- "${gen_dirs[@]}" \
- -d "${package}" \
- "${includes[@]}" \
- --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
-
-if [[ -n "${srcjar}" ]] ; then
- (cd "${output_dir}/src" && \
- find . -name '*.java' -print | zip --quiet "${srcjar}" -@)
-fi
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/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-handle-unhandled-RuntimeExceptions.patch b/libchrome_tools/patch/mojo-Add-a-way-to-handle-unhandled-RuntimeExceptions.patch
deleted file mode 100644
index f5ac205ce..000000000
--- a/libchrome_tools/patch/mojo-Add-a-way-to-handle-unhandled-RuntimeExceptions.patch
+++ /dev/null
@@ -1,129 +0,0 @@
-From 4256ecec730fdf5a41f34e11c0641e072971cb8c Mon Sep 17 00:00:00 2001
-From: Luis Hector Chavez <lhchavez@google.com>
-Date: Mon, 18 Jun 2018 20:14:56 +0000
-Subject: [PATCH] [mojo] Add a way to handle unhandled RuntimeExceptions
-
-This change makes it possible to allow interfaces to globally handle
-unhandled RuntimeExceptions, in their bindings or in the callbacks.
-
- delegate can now forward the unhandled exceptions to the crash
- server.
-
-Bug: 810087
-Test: Android-on-Chrome OS has the same behavior as before
-Test: Android-on-Chrome OS, when setting the DefaultExceptionHandler's
-Change-Id: I2b7455a0344a109e1d2416a74ad4a0b98cd007f0
-Reviewed-on: https://chromium-review.googlesource.com/1101898
-Reviewed-by: Ken Rockot <rockot@chromium.org>
-Commit-Queue: Luis Hector Chavez <lhchavez@chromium.org>
-Cr-Commit-Position: refs/heads/master@{#568128}
----
- mojo/public/java/BUILD.gn | 1 +
- .../org/chromium/mojo/bindings/Connector.java | 12 +++-
- .../mojo/bindings/ExceptionHandler.java | 59 +++++++++++++++++++
- 3 files changed, 70 insertions(+), 2 deletions(-)
- create mode 100644 mojo/public/java/bindings/src/org/chromium/mojo/bindings/ExceptionHandler.java
-
-diff --git a/mojo/public/java/BUILD.gn b/mojo/public/java/BUILD.gn
-index 14951f4f0959..259e09cf7c07 100644
---- a/mojo/public/java/BUILD.gn
-+++ b/mojo/public/java/BUILD.gn
-@@ -41,6 +41,7 @@ android_library("bindings_java") {
- "bindings/src/org/chromium/mojo/bindings/DelegatingConnectionErrorHandler.java",
- "bindings/src/org/chromium/mojo/bindings/DeserializationException.java",
- "bindings/src/org/chromium/mojo/bindings/Encoder.java",
-+ "bindings/src/org/chromium/mojo/bindings/ExceptionHandler.java",
- "bindings/src/org/chromium/mojo/bindings/ExecutorFactory.java",
- "bindings/src/org/chromium/mojo/bindings/HandleOwner.java",
- "bindings/src/org/chromium/mojo/bindings/InterfaceControlMessagesHelper.java",
-diff --git a/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Connector.java b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Connector.java
-index 3a6d67112ce0..45f1fc7462e8 100644
---- a/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Connector.java
-+++ b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Connector.java
-@@ -201,8 +201,16 @@ public class Connector implements MessageReceiver, HandleOwner<MessagePipeHandle
- ReadMessageResult readResult = result.getValue();
- assert readResult != null;
- if (receiver != null) {
-- boolean accepted = receiver.accept(
-- new Message(ByteBuffer.wrap(readResult.mData), readResult.mHandles));
-+ boolean accepted;
-+ try {
-+ accepted = receiver.accept(
-+ new Message(ByteBuffer.wrap(readResult.mData), readResult.mHandles));
-+ } catch (RuntimeException e) {
-+ // The DefaultExceptionHandler will decide whether any uncaught exception will
-+ // close the connection or not.
-+ accepted =
-+ ExceptionHandler.DefaultExceptionHandler.getInstance().handleException(e);
-+ }
- return new ResultAnd<Boolean>(result.getMojoResult(), accepted);
- }
- return new ResultAnd<Boolean>(result.getMojoResult(), false);
-diff --git a/mojo/public/java/bindings/src/org/chromium/mojo/bindings/ExceptionHandler.java b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/ExceptionHandler.java
-new file mode 100644
-index 000000000000..8961d22d3ee4
---- /dev/null
-+++ b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/ExceptionHandler.java
-@@ -0,0 +1,59 @@
-+// Copyright 2018 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.
-+
-+package org.chromium.mojo.bindings;
-+
-+/**
-+ * An {@link ExceptionHandler} is notified of any {@link RuntimeException} happening in the
-+ * bindings or any of the callbacks.
-+ */
-+public interface ExceptionHandler {
-+ /**
-+ * Receives a notification that an unhandled {@link RuntimeException} has been thrown in an
-+ * {@link Interface} implementation or one of the {@link Callbacks} internal classes.
-+ *
-+ * Normal implementations should either throw the exception or return whether the connection
-+ * should be kept alive or terminated.
-+ */
-+ public boolean handleException(RuntimeException e);
-+
-+ /**
-+ * The default ExceptionHandler, which simply throws the exception upon receiving it. It can
-+ * also delegate the handling of the exceptions to another instance of ExceptionHandler.
-+ */
-+ public static class DefaultExceptionHandler implements ExceptionHandler {
-+ private ExceptionHandler mDelegate;
-+
-+ @Override
-+ public boolean handleException(RuntimeException e) {
-+ if (mDelegate != null) {
-+ return mDelegate.handleException(e);
-+ }
-+ throw e;
-+ }
-+
-+ private DefaultExceptionHandler() {}
-+
-+ /**
-+ * Static class that implements the initialization-on-demand holder idiom.
-+ */
-+ private static class LazyHolder {
-+ static final DefaultExceptionHandler INSTANCE = new DefaultExceptionHandler();
-+ }
-+
-+ /**
-+ * Gets the singleton instance for the DefaultExceptionHandler.
-+ */
-+ public static DefaultExceptionHandler getInstance() {
-+ return LazyHolder.INSTANCE;
-+ }
-+
-+ /**
-+ * Sets a delegate ExceptionHandler, in case throwing an exception is not desirable.
-+ */
-+ public void setDelegate(ExceptionHandler exceptionHandler) {
-+ mDelegate = exceptionHandler;
-+ }
-+ }
-+}
---
-2.18.0.203.gfac676dfb9-goog
-
diff --git a/libchrome_tools/patch/mojo-Avoid-a-crash-when-NodeController-pending-invit.patch b/libchrome_tools/patch/mojo-Avoid-a-crash-when-NodeController-pending-invit.patch
deleted file mode 100644
index 082d17eba..000000000
--- a/libchrome_tools/patch/mojo-Avoid-a-crash-when-NodeController-pending-invit.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-From 30a0b449c8f7036c300d808db96b391220b7698f Mon Sep 17 00:00:00 2001
-From: Luis Hector Chavez <lhchavez@google.com>
-Date: Wed, 23 May 2018 00:39:19 +0000
-Subject: [PATCH] [mojo]: Avoid a crash when NodeController pending invitations
- diverge
-
-This change avoids a crash when NodeController::pending_broker_clients_
-and NodeController::pending_invitations_ diverge. This might happen with
-complex enough node topologies, where there is a node that proxies
-invitations to a set of other nodes.
-
-BUG=845709
-
-Change-Id: Ia678f464fafb69628600ec00dac19da3b6868fe0
-Reviewed-on: https://chromium-review.googlesource.com/1069728
-Reviewed-by: Ken Rockot <rockot@chromium.org>
-Commit-Queue: Luis Hector Chavez <lhchavez@chromium.org>
-Cr-Commit-Position: refs/heads/master@{#560857}
----
- mojo/edk/system/node_controller.cc | 10 +++++++---
- 1 file changed, 7 insertions(+), 3 deletions(-)
-
-diff --git a/mojo/edk/system/node_controller.cc b/mojo/edk/system/node_controller.cc
-index 73b16b1..e608f0c 100644
---- a/mojo/edk/system/node_controller.cc
-+++ b/mojo/edk/system/node_controller.cc
-@@ -1102,8 +1102,13 @@ void NodeController::OnAcceptBrokerClient(const ports::NodeName& from_node,
- while (!pending_broker_clients.empty()) {
- const ports::NodeName& child_name = pending_broker_clients.front();
- auto it = pending_children_.find(child_name);
-- DCHECK(it != pending_children_.end());
-- broker->AddBrokerClient(child_name, it->second->CopyRemoteProcessHandle());
-+ // If for any reason we don't have a pending invitation for the invitee,
-+ // there's nothing left to do: we've already swapped the relevant state into
-+ // the stack.
-+ if (it != pending_children_.end()) {
-+ broker->AddBrokerClient(child_name,
-+ it->second->CopyRemoteProcessHandle());
-+ }
- pending_broker_clients.pop();
- }
-
---
-2.17.0.921.gf22659ad46-goog
diff --git a/libchrome_tools/patch/mojo.patch b/libchrome_tools/patch/mojo.patch
index d86b73538..8040fbe9e 100644
--- a/libchrome_tools/patch/mojo.patch
+++ b/libchrome_tools/patch/mojo.patch
@@ -1,230 +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/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/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";
}
@@ -232,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 39a4ead16..000000000
--- a/libchrome_tools/patch/task_scheduler.patch
+++ /dev/null
@@ -1,121 +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();
- }
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
index 514ef53bb..43dc0524f 100644
--- a/libchrome_tools/patch/trace_event.patch
+++ b/libchrome_tools/patch/trace_event.patch
@@ -133,19 +133,19 @@
output += ")";
return output;
}
---- a/base/threading/thread_id_name_manager.cc
+---- a/base/threading/thread_id_name_manager.cc
+++ b/base/threading/thread_id_name_manager.cc
-@@ -10,7 +10,8 @@
- #include "base/logging.h"
- #include "base/memory/singleton.h"
+@@ -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 {
-@@ -80,8 +81,9 @@ void ThreadIdNameManager::SetName(Platfo
+@@ -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.
@@ -153,15 +153,15 @@
- leaked_str->c_str());
+ // Unsupported in libchrome.
+ // trace_event::AllocationContextTracker::SetCurrentThreadName(
-+ // leaked_str->c_str());
++ // leaked_str->c_str());
}
const char* ThreadIdNameManager::GetName(PlatformThreadId id) {
--- a/base/memory/shared_memory_posix.cc
+++ b/base/memory/shared_memory_posix.cc
-@@ -15,7 +15,8 @@
- #include "base/files/scoped_file.h"
+@@ -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.
@@ -169,7 +169,7 @@
#include "base/posix/eintr_wrapper.h"
#include "base/posix/safe_strerror.h"
#include "base/process/process_metrics.h"
-@@ -288,7 +291,8 @@ bool SharedMemory::MapAt(off_t offset, s
+@@ -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));
@@ -177,15 +177,15 @@
+ // Unsupported in libchrome.
+ // SharedMemoryTracker::GetInstance()->IncrementMemoryUsage(*this);
} else {
- memory_ = NULL;
+ memory_ = nullptr;
}
-@@ -301,7 +305,8 @@ bool SharedMemory::Unmap() {
+@@ -314,7 +318,8 @@ bool SharedMemory::Unmap() {
+ if (!memory_)
return false;
- munmap(memory_, mapped_size_);
- SharedMemoryTracker::GetInstance()->DecrementMemoryUsage(*this);
+ // Unsupported in libchrome.
+ // SharedMemoryTracker::GetInstance()->DecrementMemoryUsage(*this);
- memory_ = NULL;
+ munmap(memory_, mapped_size_);
+ memory_ = nullptr;
mapped_size_ = 0;
- return true;
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 e6155a07d..b2f8a92d5 100644
--- a/libchrome_tools/update_libchrome.py
+++ b/libchrome_tools/update_libchrome.py
@@ -48,8 +48,6 @@ _LIBCHROME_ROOT = os.path.dirname(_TOOLS_DIR)
# Paths ends with '/' is interpreted as directory.
_IMPORT_LIST = [
'mojo/',
- 'third_party/catapult/LICENSE',
- 'third_party/catapult/devil/',
'third_party/ply/',
'third_party/markupsafe/',
'third_party/jinja2/',
@@ -67,24 +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.
+ # 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/*',
+ '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/*',
@@ -138,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)