summaryrefslogtreecommitdiff
path: root/chromium/gin
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-01-20 13:40:20 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-01-22 12:41:23 +0000
commit7961cea6d1041e3e454dae6a1da660b453efd238 (patch)
treec0eeb4a9ff9ba32986289c1653d9608e53ccb444 /chromium/gin
parentb7034d0803538058e5c9d904ef03cf5eab34f6ef (diff)
downloadqtwebengine-chromium-7961cea6d1041e3e454dae6a1da660b453efd238.tar.gz
BASELINE: Update Chromium to 78.0.3904.130
Change-Id: If185e0c0061b3437531c97c9c8c78f239352a68b Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/gin')
-rw-r--r--chromium/gin/converter.cc32
-rw-r--r--chromium/gin/converter.h18
-rw-r--r--chromium/gin/runner.cc3
-rw-r--r--chromium/gin/runner.h2
-rw-r--r--chromium/gin/shell/gin_main.cc2
-rw-r--r--chromium/gin/shell_runner_unittest.cc4
-rw-r--r--chromium/gin/v8_platform.cc40
7 files changed, 75 insertions, 26 deletions
diff --git a/chromium/gin/converter.cc b/chromium/gin/converter.cc
index bc95df46982..3498080ea5b 100644
--- a/chromium/gin/converter.cc
+++ b/chromium/gin/converter.cc
@@ -6,6 +6,7 @@
#include <stdint.h>
+#include "base/strings/string_util.h"
#include "v8/include/v8.h"
using v8::ArrayBuffer;
@@ -151,6 +152,29 @@ bool Converter<std::string>::FromV8(Isolate* isolate,
return true;
}
+Local<Value> Converter<base::string16>::ToV8(Isolate* isolate,
+ const base::string16& val) {
+ return String::NewFromTwoByte(isolate,
+ reinterpret_cast<const uint16_t*>(val.data()),
+ v8::NewStringType::kNormal, val.size())
+ .ToLocalChecked();
+}
+
+bool Converter<base::string16>::FromV8(Isolate* isolate,
+ Local<Value> val,
+ base::string16* out) {
+ if (!val->IsString())
+ return false;
+ Local<String> str = Local<String>::Cast(val);
+ int length = str->Length();
+ // Note that the reinterpret cast is because on Windows string16 is an alias
+ // to wstring, and hence has character type wchar_t not uint16_t.
+ str->Write(isolate,
+ reinterpret_cast<uint16_t*>(base::WriteInto(out, length + 1)), 0,
+ length);
+ return true;
+}
+
Local<Value> Converter<Local<Function>>::ToV8(Isolate* isolate,
Local<Function> val) {
return val.As<Value>();
@@ -240,6 +264,14 @@ v8::Local<v8::String> StringToSymbol(v8::Isolate* isolate,
.ToLocalChecked();
}
+v8::Local<v8::String> StringToSymbol(v8::Isolate* isolate,
+ const base::StringPiece16& val) {
+ return String::NewFromTwoByte(isolate,
+ reinterpret_cast<const uint16_t*>(val.data()),
+ v8::NewStringType::kInternalized, val.length())
+ .ToLocalChecked();
+}
+
std::string V8ToString(v8::Isolate* isolate, v8::Local<v8::Value> value) {
if (value.IsEmpty())
return std::string();
diff --git a/chromium/gin/converter.h b/chromium/gin/converter.h
index 48be87c458a..27b4d0acd01 100644
--- a/chromium/gin/converter.h
+++ b/chromium/gin/converter.h
@@ -12,6 +12,7 @@
#include <vector>
#include "base/logging.h"
+#include "base/strings/string16.h"
#include "base/strings/string_piece.h"
#include "gin/gin_export.h"
#include "v8/include/v8.h"
@@ -119,8 +120,17 @@ struct GIN_EXPORT Converter<std::string> {
std::string* out);
};
-template<>
-struct GIN_EXPORT Converter<v8::Local<v8::Function> > {
+template <>
+struct GIN_EXPORT Converter<base::string16> {
+ static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
+ const base::string16& val);
+ static bool FromV8(v8::Isolate* isolate,
+ v8::Local<v8::Value> val,
+ base::string16* out);
+};
+
+template <>
+struct GIN_EXPORT Converter<v8::Local<v8::Function>> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
v8::Local<v8::Function> val);
static bool FromV8(v8::Isolate* isolate,
@@ -263,6 +273,10 @@ GIN_EXPORT inline v8::Local<v8::String> StringToV8(
GIN_EXPORT v8::Local<v8::String> StringToSymbol(v8::Isolate* isolate,
const base::StringPiece& val);
+// This crashes when input.size() > v8::String::kMaxLength.
+GIN_EXPORT v8::Local<v8::String> StringToSymbol(v8::Isolate* isolate,
+ const base::StringPiece16& val);
+
template<typename T>
bool ConvertFromV8(v8::Isolate* isolate, v8::Local<v8::Value> input,
T* result) {
diff --git a/chromium/gin/runner.cc b/chromium/gin/runner.cc
index dd04c15db17..7ce76085296 100644
--- a/chromium/gin/runner.cc
+++ b/chromium/gin/runner.cc
@@ -6,8 +6,7 @@
namespace gin {
-Runner::Runner() : weak_factory_(this) {
-}
+Runner::Runner() {}
Runner::~Runner() = default;
diff --git a/chromium/gin/runner.h b/chromium/gin/runner.h
index 928275d595b..784687dd37d 100644
--- a/chromium/gin/runner.h
+++ b/chromium/gin/runner.h
@@ -53,7 +53,7 @@ class GIN_EXPORT Runner {
private:
friend class Scope;
- base::WeakPtrFactory<Runner> weak_factory_;
+ base::WeakPtrFactory<Runner> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(Runner);
};
diff --git a/chromium/gin/shell/gin_main.cc b/chromium/gin/shell/gin_main.cc
index 0f05ac7c9d1..a447d3b0388 100644
--- a/chromium/gin/shell/gin_main.cc
+++ b/chromium/gin/shell/gin_main.cc
@@ -14,7 +14,7 @@
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/task/single_thread_task_executor.h"
-#include "base/task/thread_pool/thread_pool.h"
+#include "base/task/thread_pool/thread_pool_instance.h"
#include "base/threading/thread_task_runner_handle.h"
#include "gin/array_buffer.h"
#include "gin/modules/console.h"
diff --git a/chromium/gin/shell_runner_unittest.cc b/chromium/gin/shell_runner_unittest.cc
index 9e277e29b47..c97015f61bf 100644
--- a/chromium/gin/shell_runner_unittest.cc
+++ b/chromium/gin/shell_runner_unittest.cc
@@ -5,7 +5,7 @@
#include "gin/shell_runner.h"
#include "base/compiler_specific.h"
-#include "base/test/scoped_task_environment.h"
+#include "base/test/task_environment.h"
#include "base/threading/thread_task_runner_handle.h"
#include "gin/array_buffer.h"
#include "gin/converter.h"
@@ -25,7 +25,7 @@ using v8::String;
namespace gin {
TEST(RunnerTest, Run) {
- base::test::ScopedTaskEnvironment scoped_task_environment;
+ base::test::SingleThreadTaskEnvironment task_environment;
std::string source = "this.result = 'PASS';\n";
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
diff --git a/chromium/gin/v8_platform.cc b/chromium/gin/v8_platform.cc
index 037beda0203..4725b6812eb 100644
--- a/chromium/gin/v8_platform.cc
+++ b/chromium/gin/v8_platform.cc
@@ -8,6 +8,7 @@
#include "base/allocator/partition_allocator/address_space_randomization.h"
#include "base/allocator/partition_allocator/page_allocator.h"
+#include "base/allocator/partition_allocator/random.h"
#include "base/bind.h"
#include "base/bit_cast.h"
#include "base/bits.h"
@@ -18,7 +19,7 @@
#include "base/system/sys_info.h"
#include "base/task/post_task.h"
#include "base/task/task_traits.h"
-#include "base/task/thread_pool/thread_pool.h"
+#include "base/task/thread_pool/thread_pool_instance.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "gin/per_isolate_data.h"
@@ -30,13 +31,13 @@ namespace {
base::LazyInstance<V8Platform>::Leaky g_v8_platform = LAZY_INSTANCE_INITIALIZER;
constexpr base::TaskTraits kLowPriorityTaskTraits = {
- base::TaskPriority::BEST_EFFORT};
+ base::ThreadPool(), base::TaskPriority::BEST_EFFORT};
constexpr base::TaskTraits kDefaultTaskTraits = {
- base::TaskPriority::USER_VISIBLE};
+ base::ThreadPool(), base::TaskPriority::USER_VISIBLE};
constexpr base::TaskTraits kBlockingTaskTraits = {
- base::TaskPriority::USER_BLOCKING};
+ base::ThreadPool(), base::TaskPriority::USER_BLOCKING};
void PrintStackTrace() {
base::debug::StackTrace trace;
@@ -206,7 +207,7 @@ class PageAllocator : public v8::PageAllocator {
size_t CommitPageSize() override { return base::kSystemPageSize; }
void SetRandomMmapSeed(int64_t seed) override {
- base::SetRandomPageBaseSeed(seed);
+ base::SetMmapSeedForTesting(seed);
}
void* GetRandomMmapAddr() override { return base::GetRandomPageBase(); }
@@ -230,12 +231,16 @@ class PageAllocator : public v8::PageAllocator {
DCHECK_LT(new_length, length);
uint8_t* release_base = reinterpret_cast<uint8_t*>(address) + new_length;
size_t release_size = length - new_length;
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
// On POSIX, we can unmap the trailing pages.
base::FreePages(release_base, release_size);
-#else // defined(OS_WIN)
- // On Windows, we can only de-commit the trailing pages.
+#elif defined(OS_WIN)
+ // On Windows, we can only de-commit the trailing pages. FreePages() will
+ // still free all pages in the region including the released tail, so it's
+ // safe to just decommit the tail.
base::DecommitSystemPages(release_base, release_size);
+#else
+#error Unsupported platform
#endif
return true;
}
@@ -412,28 +417,27 @@ int V8Platform::NumberOfWorkerThreads() {
}
void V8Platform::CallOnWorkerThread(std::unique_ptr<v8::Task> task) {
- base::PostTaskWithTraits(FROM_HERE, kDefaultTaskTraits,
- base::BindOnce(&v8::Task::Run, std::move(task)));
+ base::PostTask(FROM_HERE, kDefaultTaskTraits,
+ base::BindOnce(&v8::Task::Run, std::move(task)));
}
void V8Platform::CallBlockingTaskOnWorkerThread(
std::unique_ptr<v8::Task> task) {
- base::PostTaskWithTraits(FROM_HERE, kBlockingTaskTraits,
- base::BindOnce(&v8::Task::Run, std::move(task)));
+ base::PostTask(FROM_HERE, kBlockingTaskTraits,
+ base::BindOnce(&v8::Task::Run, std::move(task)));
}
void V8Platform::CallLowPriorityTaskOnWorkerThread(
std::unique_ptr<v8::Task> task) {
- base::PostTaskWithTraits(FROM_HERE, kLowPriorityTaskTraits,
- base::BindOnce(&v8::Task::Run, std::move(task)));
+ base::PostTask(FROM_HERE, kLowPriorityTaskTraits,
+ base::BindOnce(&v8::Task::Run, std::move(task)));
}
void V8Platform::CallDelayedOnWorkerThread(std::unique_ptr<v8::Task> task,
double delay_in_seconds) {
- base::PostDelayedTaskWithTraits(
- FROM_HERE, kDefaultTaskTraits,
- base::BindOnce(&v8::Task::Run, std::move(task)),
- base::TimeDelta::FromSecondsD(delay_in_seconds));
+ base::PostDelayedTask(FROM_HERE, kDefaultTaskTraits,
+ base::BindOnce(&v8::Task::Run, std::move(task)),
+ base::TimeDelta::FromSecondsD(delay_in_seconds));
}
void V8Platform::CallOnForegroundThread(v8::Isolate* isolate, v8::Task* task) {