Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10878)

Unified Diff: chrome/test/base/mojo_test_connector.cc

Issue 2813293003: Fix Mash Browser Test Startup Race (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/base/mojo_test_connector.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/mojo_test_connector.cc
diff --git a/chrome/test/base/mojo_test_connector.cc b/chrome/test/base/mojo_test_connector.cc
index 72a35d68ec1b858c851efef58d61f970bc0eb98d..cac5b9ebe9652fe128f797d11393dc7e96b807e5 100644
--- a/chrome/test/base/mojo_test_connector.cc
+++ b/chrome/test/base/mojo_test_connector.cc
@@ -188,8 +188,8 @@ MojoTestConnector::MojoTestConnector(
std::unique_ptr<base::Value> catalog_contents)
: service_process_launcher_delegate_(
new ServiceProcessLauncherDelegateImpl),
- background_service_manager_(service_process_launcher_delegate_.get(),
- std::move(catalog_contents)) {}
+ background_service_manager_(nullptr),
+ catalog_contents_(std::move(catalog_contents)) {}
service_manager::mojom::ServiceRequest MojoTestConnector::Init() {
// In single-process test mode, browser code will initialize the EDK and IPC.
@@ -207,7 +207,15 @@ service_manager::mojom::ServiceRequest MojoTestConnector::Init() {
service_manager::mojom::ServicePtr service;
service_manager::mojom::ServiceRequest request(&service);
- background_service_manager_.RegisterService(
+
+ // BackgroundServiceManager must be created after mojo::edk::Init() as it
+ // attempts to create mojo pipes for the provided catalog on a separate
+ // thread.
+ background_service_manager_ =
+ base::MakeUnique<service_manager::BackgroundServiceManager>(
+ service_process_launcher_delegate_.get(),
+ std::move(catalog_contents_));
+ background_service_manager_->RegisterService(
service_manager::Identity(kTestRunnerName,
service_manager::mojom::kRootUserID),
std::move(service), nullptr);
@@ -220,7 +228,7 @@ std::unique_ptr<content::TestState> MojoTestConnector::PrepareForTest(
base::CommandLine* command_line,
base::TestLauncher::LaunchOptions* test_launch_options) {
auto test_state =
- base::MakeUnique<MojoTestState>(&background_service_manager_);
+ base::MakeUnique<MojoTestState>(background_service_manager_.get());
test_state->Init(command_line, test_launch_options);
return test_state;
}
« no previous file with comments | « chrome/test/base/mojo_test_connector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698