diff options
author | rockot <rockot@chromium.org> | 2016-03-14 22:57:59 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-15 05:59:39 +0000 |
commit | 27eb4409b17331235123e5e0a6837aa760203816 (patch) | |
tree | 1b6c8683bf086786b24428e0f7ab7d57aedb5f22 /mojo | |
parent | 7bdeb45f2e1c8b2bf9601cd3893946435bc30ae1 (diff) | |
download | chromium_src-27eb4409b17331235123e5e0a6837aa760203816.zip chromium_src-27eb4409b17331235123e5e0a6837aa760203816.tar.gz chromium_src-27eb4409b17331235123e5e0a6837aa760203816.tar.bz2 |
Reinstate wait-for-Initialize when Chrome is run in Mash
Mus Views needs to completely block the main thread during
initialization, including any pending tasks. This means
incoming messages on any other pipe will never be dispatched.
If ShellClient::Initialize is blocked, the pipe views is
waiting on will in turn never be able to signal, resulting
in an effective deadlock.
So we need to wait for Initialize before proceeding with the
rest of the main thread setup. This adds a temporary switch
to explicitly opt in to wait-for-Initialize behavior on
MojoShellConnection, and adds that switch when running in mash.
BUG=594636,594852
TEST=views_mus_unittests, mus_ws_unittests, and chrome --mash renders as well as it did before I broke it.
Review URL: https://codereview.chromium.org/1797153002
Cr-Commit-Position: refs/heads/master@{#381182}
Diffstat (limited to 'mojo')
-rw-r--r-- | mojo/edk/embedder/embedder.cc | 4 | ||||
-rw-r--r-- | mojo/shell/public/cpp/lib/shell_connection.cc | 7 | ||||
-rw-r--r-- | mojo/shell/public/cpp/shell_connection.h | 7 |
3 files changed, 16 insertions, 2 deletions
diff --git a/mojo/edk/embedder/embedder.cc b/mojo/edk/embedder/embedder.cc index e9a426a..d471c3a 100644 --- a/mojo/edk/embedder/embedder.cc +++ b/mojo/edk/embedder/embedder.cc @@ -58,8 +58,8 @@ void SetParentPipeHandleFromCommandLine() { ScopedPlatformHandle platform_channel = PlatformChannelPair::PassClientHandleFromParentProcess( *base::CommandLine::ForCurrentProcess()); - if (platform_channel.is_valid()) - SetParentPipeHandle(std::move(platform_channel)); + CHECK(platform_channel.is_valid()); + SetParentPipeHandle(std::move(platform_channel)); } void Init() { diff --git a/mojo/shell/public/cpp/lib/shell_connection.cc b/mojo/shell/public/cpp/lib/shell_connection.cc index 7c8b032..d1cba7e 100644 --- a/mojo/shell/public/cpp/lib/shell_connection.cc +++ b/mojo/shell/public/cpp/lib/shell_connection.cc @@ -32,6 +32,10 @@ ShellConnection::ShellConnection(mojo::ShellClient* client, ShellConnection::~ShellConnection() {} +void ShellConnection::set_initialize_handler(const base::Closure& callback) { + initialize_handler_ = callback; +} + void ShellConnection::SetAppTestConnectorForTesting( shell::mojom::ConnectorPtr connector) { pending_connector_request_ = nullptr; @@ -44,6 +48,9 @@ void ShellConnection::SetAppTestConnectorForTesting( void ShellConnection::Initialize(shell::mojom::IdentityPtr identity, uint32_t id, const InitializeCallback& callback) { + if (!initialize_handler_.is_null()) + initialize_handler_.Run(); + callback.Run(std::move(pending_connector_request_)); DCHECK(binding_.is_bound()); diff --git a/mojo/shell/public/cpp/shell_connection.h b/mojo/shell/public/cpp/shell_connection.h index 8c90ec7..a05f6f1 100644 --- a/mojo/shell/public/cpp/shell_connection.h +++ b/mojo/shell/public/cpp/shell_connection.h @@ -8,6 +8,7 @@ #include <utility> #include <vector> +#include "base/callback.h" #include "base/macros.h" #include "base/memory/scoped_vector.h" #include "mojo/public/cpp/bindings/binding.h" @@ -54,6 +55,9 @@ class ShellConnection : public shell::mojom::ShellClient { Connector* connector() { return connector_.get(); } + // TODO(rockot): Remove this. http://crbug.com/594852. + void set_initialize_handler(const base::Closure& callback); + // TODO(rockot): Remove this once we get rid of app tests. void SetAppTestConnectorForTesting(shell::mojom::ConnectorPtr connector); @@ -72,6 +76,9 @@ class ShellConnection : public shell::mojom::ShellClient { void OnConnectionError(); + // A callback called when Initialize() is run. + base::Closure initialize_handler_; + // We track the lifetime of incoming connection registries as it more // convenient for the client. ScopedVector<Connection> incoming_connections_; |