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

Unified Diff: mojo/shell/runner/child/runner_connection.cc

Issue 1738663002: Hook embedded shell up to MojoShellConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 | « mojo/shell/runner/child/runner_connection.h ('k') | mojo/shell/runner/host/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/runner/child/runner_connection.cc
diff --git a/mojo/shell/runner/child/runner_connection.cc b/mojo/shell/runner/child/runner_connection.cc
index 313c00a338d7bdade01b3a465639378835f78a0b..900ee2c9da06c80467fea269876e284fcaeab130 100644
--- a/mojo/shell/runner/child/runner_connection.cc
+++ b/mojo/shell/runner/child/runner_connection.cc
@@ -96,7 +96,8 @@ class RunnerConnectionImpl : public RunnerConnection {
// Returns true if a connection to the runner has been established and
// |request| has been modified, false if no connection was established.
bool WaitForApplicationRequest(InterfaceRequest<mojom::ShellClient>* request,
- ScopedMessagePipeHandle handle);
+ ScopedMessagePipeHandle handle,
+ bool exit_on_error);
ChildControllerImpl* controller() const { return controller_.get(); }
@@ -141,12 +142,14 @@ class ChildControllerImpl : public mojom::ChildController {
static void Create(RunnerConnectionImpl* connection,
const GotApplicationRequestCallback& callback,
ScopedMessagePipeHandle runner_handle,
- const Blocker::Unblocker& unblocker) {
+ const Blocker::Unblocker& unblocker,
+ bool exit_on_error) {
DCHECK(connection);
DCHECK(!connection->controller());
scoped_ptr<ChildControllerImpl> impl(
- new ChildControllerImpl(connection, callback, unblocker));
+ new ChildControllerImpl(connection, callback, unblocker,
+ exit_on_error));
impl->Bind(std::move(runner_handle));
@@ -162,7 +165,16 @@ class ChildControllerImpl : public mojom::ChildController {
// A connection error means the connection to the shell is lost. This is not
// recoverable.
DLOG(ERROR) << "Connection error to the shell.";
- _exit(1);
+ if (exit_on_error_) {
+ _exit(1);
+ } else if (on_app_complete_.is_null()) {
+ // If we failed before we could even get a ShellClient request from the
+ // shell, signal failure to the RunnerConnection, as it's still blocking
+ // on a response.
+ unblocker_.Unblock(
+ base::Bind(&ChildControllerImpl::ReturnApplicationRequestOnMainThread,
+ callback_, nullptr));
+ }
}
// |mojom::ChildController| methods:
@@ -184,11 +196,13 @@ class ChildControllerImpl : public mojom::ChildController {
private:
ChildControllerImpl(RunnerConnectionImpl* connection,
const GotApplicationRequestCallback& callback,
- const Blocker::Unblocker& unblocker)
+ const Blocker::Unblocker& unblocker,
+ bool exit_on_error)
: connection_(connection),
callback_(callback),
unblocker_(unblocker),
- binding_(this) {}
+ binding_(this),
+ exit_on_error_(exit_on_error) {}
static void ReturnApplicationRequestOnMainThread(
const GotApplicationRequestCallback& callback,
@@ -204,12 +218,15 @@ class ChildControllerImpl : public mojom::ChildController {
Binding<ChildController> binding_;
+ bool exit_on_error_;
+
DISALLOW_COPY_AND_ASSIGN(ChildControllerImpl);
};
bool RunnerConnectionImpl::WaitForApplicationRequest(
InterfaceRequest<mojom::ShellClient>* request,
- ScopedMessagePipeHandle handle) {
+ ScopedMessagePipeHandle handle,
+ bool exit_on_error) {
// If a valid message pipe to the runner was not provided, look for one on the
// command line.
if (!handle.is_valid()) {
@@ -232,11 +249,11 @@ bool RunnerConnectionImpl::WaitForApplicationRequest(
FROM_HERE,
base::Bind(
&ChildControllerImpl::Create, base::Unretained(this),
- base::Bind(&OnGotApplicationRequest, base::Unretained(request)),
- base::Passed(&handle), blocker.GetUnblocker()));
+ base::Bind(&OnGotApplicationRequest, request), base::Passed(&handle),
+ blocker.GetUnblocker(), exit_on_error));
blocker.Block();
- return true;
+ return request->is_pending();
}
} // namespace
@@ -246,9 +263,11 @@ RunnerConnection::~RunnerConnection() {}
// static
RunnerConnection* RunnerConnection::ConnectToRunner(
InterfaceRequest<mojom::ShellClient>* request,
- ScopedMessagePipeHandle handle) {
+ ScopedMessagePipeHandle handle,
+ bool exit_on_error) {
RunnerConnectionImpl* connection = new RunnerConnectionImpl;
- if (!connection->WaitForApplicationRequest(request, std::move(handle))) {
+ if (!connection->WaitForApplicationRequest(
+ request, std::move(handle), exit_on_error)) {
delete connection;
return nullptr;
}
« no previous file with comments | « mojo/shell/runner/child/runner_connection.h ('k') | mojo/shell/runner/host/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698