From 590a50009a0ddd3413236f1e96d1fee96c898909 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sun, 9 Dec 2018 14:05:43 -0500 Subject: [PATCH 1/2] src: remove use of CallOnForegroundThread() The V8 platform's CallOnForegroundThread() method is deprecated. This commit replaces its use with GetForegroundTaskRunner() functionality instead. --- src/inspector/main_thread_interface.cc | 6 ++++-- src/inspector_agent.cc | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/inspector/main_thread_interface.cc b/src/inspector/main_thread_interface.cc index bb637d3a77f6fa..488f638c05f496 100644 --- a/src/inspector/main_thread_interface.cc +++ b/src/inspector/main_thread_interface.cc @@ -255,8 +255,10 @@ void MainThreadInterface::Post(std::unique_ptr request) { if (needs_notify) { CHECK_EQ(0, uv_async_send(&main_thread_request_->first)); if (isolate_ != nullptr && platform_ != nullptr) { - platform_->CallOnForegroundThread(isolate_, - new DispatchMessagesTask(this)); + std::shared_ptr taskrunner = + platform_->GetForegroundTaskRunner(isolate_); + taskrunner->PostTask(std::unique_ptr( + new DispatchMessagesTask(this))); isolate_->RequestInterrupt([](v8::Isolate* isolate, void* thread) { static_cast(thread)->DispatchMessages(); }, this); diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index 8949dfe2a7192c..5bb65182517731 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -40,6 +40,8 @@ using v8::Local; using v8::Message; using v8::Object; using v8::String; +using v8::Task; +using v8::TaskRunner; using v8::Value; using v8_inspector::StringBuffer; @@ -50,7 +52,7 @@ using v8_inspector::V8InspectorClient; static uv_sem_t start_io_thread_semaphore; static uv_async_t start_io_thread_async; -class StartIoTask : public v8::Task { +class StartIoTask : public Task { public: explicit StartIoTask(Agent* agent) : agent(agent) {} @@ -861,7 +863,9 @@ void Agent::RequestIoThreadStart() { uv_async_send(&start_io_thread_async); Isolate* isolate = parent_env_->isolate(); v8::Platform* platform = parent_env_->isolate_data()->platform(); - platform->CallOnForegroundThread(isolate, new StartIoTask(this)); + std::shared_ptr taskrunner = + platform->GetForegroundTaskRunner(isolate); + taskrunner->PostTask(std::unique_ptr(new StartIoTask(this))); isolate->RequestInterrupt(StartIoInterrupt, this); uv_async_send(&start_io_thread_async); } From ec50275b2bc95f67df2a46166f70ec3c9809ed52 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Tue, 11 Dec 2018 09:28:22 -0500 Subject: [PATCH 2/2] squash! use std::make_unique() --- src/inspector/main_thread_interface.cc | 3 +-- src/inspector_agent.cc | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/inspector/main_thread_interface.cc b/src/inspector/main_thread_interface.cc index 488f638c05f496..2ed6362df53fda 100644 --- a/src/inspector/main_thread_interface.cc +++ b/src/inspector/main_thread_interface.cc @@ -257,8 +257,7 @@ void MainThreadInterface::Post(std::unique_ptr request) { if (isolate_ != nullptr && platform_ != nullptr) { std::shared_ptr taskrunner = platform_->GetForegroundTaskRunner(isolate_); - taskrunner->PostTask(std::unique_ptr( - new DispatchMessagesTask(this))); + taskrunner->PostTask(std::make_unique(this)); isolate_->RequestInterrupt([](v8::Isolate* isolate, void* thread) { static_cast(thread)->DispatchMessages(); }, this); diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index 5bb65182517731..2ef964276177be 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -865,7 +865,7 @@ void Agent::RequestIoThreadStart() { v8::Platform* platform = parent_env_->isolate_data()->platform(); std::shared_ptr taskrunner = platform->GetForegroundTaskRunner(isolate); - taskrunner->PostTask(std::unique_ptr(new StartIoTask(this))); + taskrunner->PostTask(std::make_unique(this)); isolate->RequestInterrupt(StartIoInterrupt, this); uv_async_send(&start_io_thread_async); }