Commit 4671e20b authored by Karolina Soltys's avatar Karolina Soltys Committed by Commit Bot

[scheduler] Making MessageLoop backend variant dependent on Finch config.

We want to A/B test two different backends for MessageLoop: (old) MessageLoopImpl and
(new) SequenceManager, as part of an ongoing effort to get rid of MessageLoop
completely. In order to use Finch, we move its initialisation before that of
MessageLoop in all builds and tests.

Bug: 891670
Change-Id: I808f72b6cf36238f7a2380568a0898ed6c0f5557

Forcing due to fuschia_x64 tests failing because of infrastructure flakiness.
NOTRY=true

Change-Id: I808f72b6cf36238f7a2380568a0898ed6c0f5557
Reviewed-on: https://chromium-review.googlesource.com/c/1333770
Commit-Queue: Karolina Soltys <ksolt@chromium.org>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Reviewed-by: default avatarAlex Clarke <alexclarke@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610876}
parent 6ca0cdcb
......@@ -12,6 +12,7 @@
#include "base/callback_helpers.h"
#include "base/compiler_specific.h"
#include "base/debug/task_annotator.h"
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop_impl.h"
......@@ -183,10 +184,15 @@ std::unique_ptr<MessageLoop> MessageLoop::CreateUnbound(
return WrapUnique(new MessageLoop(type, std::move(pump_factory)));
}
const Feature kMessageLoopUsesSequenceManager{"MessageLoopUsesSequenceManager",
FEATURE_DISABLED_BY_DEFAULT};
MessageLoop::MessageLoop(Type type, MessagePumpFactoryCallback pump_factory)
: MessageLoop(type,
std::move(pump_factory),
BackendType::MESSAGE_LOOP_IMPL) {}
FeatureList::IsEnabled(kMessageLoopUsesSequenceManager)
? BackendType::SEQUENCE_MANAGER
: BackendType::MESSAGE_LOOP_IMPL) {}
MessageLoop::MessageLoop(Type type,
MessagePumpFactoryCallback pump_factory,
......
......@@ -858,6 +858,12 @@ int ContentMainRunnerImpl::Run(bool start_service_manager_only) {
// BrowserMain() which may elect to promote it (e.g. to BrowserThread::IO).
if (process_type.empty()) {
startup_data_ = std::make_unique<StartupDataImpl>();
if (delegate_->ShouldCreateFeatureList()) {
DCHECK(!field_trial_list_);
field_trial_list_ = SetUpFieldTrialsAndFeatureList();
}
startup_data_->thread = BrowserProcessSubThread::CreateIOThread();
main_params.startup_data = startup_data_.get();
......@@ -883,11 +889,6 @@ int ContentMainRunnerImpl::Run(bool start_service_manager_only) {
if (!base::MessageLoopCurrentForUI::IsSet())
main_message_loop_ = std::make_unique<base::MessageLoopForUI>();
if (delegate_->ShouldCreateFeatureList()) {
DCHECK(!field_trial_list_);
field_trial_list_ = SetUpFieldTrialsAndFeatureList();
}
delegate_->PostEarlyInitialization(main_params.ui_task != nullptr);
if (GetContentClient()->browser()->ShouldCreateTaskScheduler()) {
......
......@@ -21,12 +21,12 @@
namespace {
int RunHelper(base::TestSuite* testSuite) {
base::FeatureList::InitializeInstance(std::string(), std::string());
#if defined(USE_OZONE)
base::MessageLoopForUI main_loop;
#else
base::MessageLoopForIO message_loop;
#endif
base::FeatureList::InitializeInstance(std::string(), std::string());
gpu::GLTestHelper::InitializeGLDefault();
::gles2::Initialize();
......
......@@ -12,13 +12,12 @@
#include "ui/gl/init/gl_factory.h"
static int RunHelper(base::TestSuite* test_suite) {
base::FeatureList::InitializeInstance(std::string(), std::string());
#if defined(USE_OZONE)
base::MessageLoopForUI main_loop;
#else
base::MessageLoopForIO message_loop;
#endif
base::FeatureList::InitializeInstance(std::string(), std::string());
CHECK(gl::init::InitializeGLOneOff());
return test_suite->Run();
}
......
......@@ -182,6 +182,7 @@ void PpapiDispatcher::OnMsgInitializeNaClDispatcher(
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
logging::InitLogging(settings);
base::FeatureList::ClearInstanceForTesting();
base::FeatureList::InitializeInstance(
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kEnableFeatures),
......
......@@ -150,8 +150,8 @@ void PrintJsonFileInfo() {
int main(int argc, char* argv[]) {
base::TestSuite test_suite(argc, argv);
base::MessageLoopForIO message_loop;
base::FeatureList::InitializeInstance(std::string(), std::string());
base::MessageLoopForIO message_loop;
if (!base::CommandLine::InitializedForCurrentProcess()) {
if (!base::CommandLine::Init(argc, argv)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment