diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/chrome/browser/extensions/api/messaging | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/chrome/browser/extensions/api/messaging')
6 files changed, 56 insertions, 20 deletions
diff --git a/chromium/chrome/browser/extensions/api/messaging/native_message_host_chromeos.cc b/chromium/chrome/browser/extensions/api/messaging/native_message_host_chromeos.cc index ccfb4199428..a3422c55d05 100644 --- a/chromium/chrome/browser/extensions/api/messaging/native_message_host_chromeos.cc +++ b/chromium/chrome/browser/extensions/api/messaging/native_message_host_chromeos.cc @@ -15,7 +15,6 @@ #include "base/location.h" #include "base/single_thread_task_runner.h" #include "base/stl_util.h" -#include "base/task/post_task.h" #include "base/threading/thread_task_runner_handle.h" #include "base/values.h" #include "chrome/browser/browser_process.h" @@ -99,8 +98,7 @@ struct BuiltInHost { std::unique_ptr<NativeMessageHost> CreateIt2MeHost( content::BrowserContext* browser_context) { return remoting::CreateIt2MeNativeMessagingHostForChromeOS( - base::CreateSingleThreadTaskRunner({content::BrowserThread::IO}), - base::CreateSingleThreadTaskRunner({content::BrowserThread::UI}), + content::GetIOThreadTaskRunner({}), content::GetUIThreadTaskRunner({}), g_browser_process->policy_service()); } diff --git a/chromium/chrome/browser/extensions/api/messaging/native_message_process_host.cc b/chromium/chrome/browser/extensions/api/messaging/native_message_process_host.cc index 8d1911b6118..d1d51bfa74d 100644 --- a/chromium/chrome/browser/extensions/api/messaging/native_message_process_host.cc +++ b/chromium/chrome/browser/extensions/api/messaging/native_message_process_host.cc @@ -13,7 +13,6 @@ #include "base/files/file_path.h" #include "base/logging.h" #include "base/process/kill.h" -#include "base/task/post_task.h" #include "base/task/thread_pool.h" #include "build/build_config.h" #include "chrome/browser/extensions/api/messaging/native_messaging_host_manifest.h" @@ -60,7 +59,7 @@ NativeMessageProcessHost::NativeMessageProcessHost( const std::string& source_extension_id, const std::string& native_host_name, std::unique_ptr<NativeProcessLauncher> launcher) - : client_(NULL), + : client_(nullptr), source_extension_id_(source_extension_id), native_host_name_(native_host_name), launcher_(std::move(launcher)), @@ -72,8 +71,7 @@ NativeMessageProcessHost::NativeMessageProcessHost( write_pending_(false) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - task_runner_ = - base::CreateSingleThreadTaskRunner({content::BrowserThread::IO}); + task_runner_ = content::GetIOThreadTaskRunner({}); } NativeMessageProcessHost::~NativeMessageProcessHost() { diff --git a/chromium/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc b/chromium/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc index 428ba272fc3..3acc436a7ea 100644 --- a/chromium/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc +++ b/chromium/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc @@ -27,7 +27,6 @@ #include "base/run_loop.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" -#include "base/task/post_task.h" #include "base/test/scoped_feature_list.h" #include "base/test/test_timeouts.h" #include "base/threading/platform_thread.h" @@ -59,8 +58,6 @@ #include <unistd.h> #endif -using content::BrowserThread; - namespace { const char kTestMessage[] = "{\"text\": \"Hello.\"}"; @@ -125,8 +122,8 @@ class NativeMessagingTest : public ::testing::Test, void TearDown() override { if (native_message_host_) { - base::DeleteSoon(FROM_HERE, {BrowserThread::IO}, - native_message_host_.release()); + content::GetIOThreadTaskRunner({})->DeleteSoon( + FROM_HERE, native_message_host_.release()); } base::RunLoop().RunUntilIdle(); } diff --git a/chromium/chrome/browser/extensions/api/messaging/native_messaging_apitest.cc b/chromium/chrome/browser/extensions/api/messaging/native_messaging_apitest.cc index f25164371e1..7b83c3a74ff 100644 --- a/chromium/chrome/browser/extensions/api/messaging/native_messaging_apitest.cc +++ b/chromium/chrome/browser/extensions/api/messaging/native_messaging_apitest.cc @@ -23,11 +23,14 @@ #include "components/keep_alive_registry/keep_alive_types.h" #include "content/public/test/browser_test.h" #include "extensions/browser/process_manager.h" +#include "extensions/common/scoped_worker_based_extensions_channel.h" #include "extensions/test/result_catcher.h" namespace extensions { namespace { +using ContextType = ExtensionApiTest::ContextType; + class NativeMessagingApiTest : public ExtensionApiTest { protected: extensions::ScopedTestNativeMessagingHost test_host_; @@ -43,6 +46,48 @@ IN_PROC_BROWSER_TEST_F(NativeMessagingApiTest, UserLevelNativeMessaging) { ASSERT_TRUE(RunExtensionTest("native_messaging")) << message_; } +// TODO(crbug.com/1094027): Clean up duplicate test coverage. +class NativeMessagingLazyApiTest + : public NativeMessagingApiTest, + public testing::WithParamInterface<ContextType> { + public: + void SetUp() override { + NativeMessagingApiTest::SetUp(); + // Service Workers are currently only available on certain channels, so set + // the channel for those tests. + if (GetParam() == ContextType::kServiceWorker) + current_channel_ = std::make_unique<ScopedWorkerBasedExtensionsChannel>(); + } + + protected: + bool RunLazyTest(const std::string& extension_name) { + if (GetParam() == ContextType::kEventPage) { + return RunExtensionTest(extension_name); + } + return RunExtensionTestWithFlags( + extension_name, kFlagRunAsServiceWorkerBasedExtension, kFlagNone); + } + + std::unique_ptr<ScopedWorkerBasedExtensionsChannel> current_channel_; +}; + +INSTANTIATE_TEST_SUITE_P(EventPage, + NativeMessagingLazyApiTest, + ::testing::Values(ContextType::kEventPage)); +INSTANTIATE_TEST_SUITE_P(ServiceWorker, + NativeMessagingLazyApiTest, + ::testing::Values(ContextType::kServiceWorker)); + +IN_PROC_BROWSER_TEST_P(NativeMessagingLazyApiTest, NativeMessagingBasic) { + ASSERT_NO_FATAL_FAILURE(test_host_.RegisterTestHost(false)); + ASSERT_TRUE(RunLazyTest("native_messaging_lazy")) << message_; +} + +IN_PROC_BROWSER_TEST_P(NativeMessagingLazyApiTest, UserLevelNativeMessaging) { + ASSERT_NO_FATAL_FAILURE(test_host_.RegisterTestHost(true)); + ASSERT_TRUE(RunLazyTest("native_messaging_lazy")) << message_; +} + #if !defined(OS_CHROMEOS) class TestProcessManagerObserver : public ProcessManagerObserver { diff --git a/chromium/chrome/browser/extensions/api/messaging/native_messaging_launch_from_native.cc b/chromium/chrome/browser/extensions/api/messaging/native_messaging_launch_from_native.cc index 967ebb848e4..f675d66c911 100644 --- a/chromium/chrome/browser/extensions/api/messaging/native_messaging_launch_from_native.cc +++ b/chromium/chrome/browser/extensions/api/messaging/native_messaging_launch_from_native.cc @@ -11,7 +11,6 @@ #include "base/bind_helpers.h" #include "base/strings/strcat.h" #include "base/strings/string_util.h" -#include "base/task/post_task.h" #include "base/threading/sequenced_task_runner_handle.h" #include "base/timer/timer.h" #include "chrome/browser/browser_process.h" @@ -75,8 +74,8 @@ class NativeMessagingHostErrorReporter : public NativeMessageHost::Client { MovableScopedKeepAlive keep_alive( new ScopedKeepAlive(KeepAliveOrigin::NATIVE_MESSAGING_HOST_ERROR_REPORT, KeepAliveRestartOption::DISABLED)); - base::PostTask( - FROM_HERE, {content::BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&NativeMessagingHostErrorReporter::ReportOnIoThread, std::move(host), std::move(keep_alive))); } diff --git a/chromium/chrome/browser/extensions/api/messaging/native_process_launcher.cc b/chromium/chrome/browser/extensions/api/messaging/native_process_launcher.cc index 5b5b39a5567..439e74947e0 100644 --- a/chromium/chrome/browser/extensions/api/messaging/native_process_launcher.cc +++ b/chromium/chrome/browser/extensions/api/messaging/native_process_launcher.cc @@ -23,7 +23,6 @@ #include "base/path_service.h" #include "base/strings/strcat.h" #include "base/strings/stringprintf.h" -#include "base/task/post_task.h" #include "base/task/thread_pool.h" #include "base/values.h" #include "build/build_config.h" @@ -313,8 +312,8 @@ void NativeProcessLauncherImpl::Core::CallCallbackOnIOThread( void NativeProcessLauncherImpl::Core::PostErrorResult( const LaunchedCallback& callback, LaunchResult error) { - base::PostTask( - FROM_HERE, {content::BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&NativeProcessLauncherImpl::Core::CallCallbackOnIOThread, this, callback, error, base::Process(), base::File(), base::File())); @@ -325,8 +324,8 @@ void NativeProcessLauncherImpl::Core::PostResult( base::Process process, base::File read_file, base::File write_file) { - base::PostTask( - FROM_HERE, {content::BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&NativeProcessLauncherImpl::Core::CallCallbackOnIOThread, this, callback, RESULT_SUCCESS, std::move(process), std::move(read_file), std::move(write_file))); |