forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A method on ApplicationManager that allows a process that launches another process to register the launched process with the ApplicationManager. In the Shell, this creates an ApplicationInstance, OutOfProcessNativeRunner and ChildProcessHost. This change makes it possible for a ChildProcessHost to be created for an existing process rather than one it must launch. I think in a future CL I should refactor this class more to make the difference between the type the shell starts and the type someone else starts a bit clearer. Currently it just triggers on whether or not app_path_ is empty which I think is a bit brittle. Adds an apptest for this that: - exposes a service from the apptest - apptest starts a native exe ("driver") via the shell - native exe ("driver") starts another native exe ("target") via base::LaunchProcess - driver creates platform channel and passes one side to target and the other side to the shell via CreateInstanceForHandle - target connects to service exposed by the apptest. R=jam@chromium.org http://crbug.com/551253 Review URL: https://codereview.chromium.org/1434083002 Cr-Commit-Position: refs/heads/master@{#359502}
- Loading branch information
ben
authored and
Commit bot
committed
Nov 13, 2015
1 parent
6592c08
commit 0cfab1b
Showing
23 changed files
with
611 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Copyright 2015 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "mojo/runner/child/test_native_main.h" | ||
|
||
#include "base/debug/stack_trace.h" | ||
#include "base/message_loop/message_loop.h" | ||
#include "base/process/launch.h" | ||
#include "base/threading/thread.h" | ||
#include "build/build_config.h" | ||
#include "mojo/application/public/cpp/application_delegate.h" | ||
#include "mojo/application/public/cpp/application_impl.h" | ||
#include "mojo/message_pump/message_pump_mojo.h" | ||
#include "mojo/runner/child/runner_connection.h" | ||
#include "mojo/runner/init.h" | ||
#include "third_party/mojo/src/mojo/edk/embedder/embedder.h" | ||
#include "third_party/mojo/src/mojo/edk/embedder/process_delegate.h" | ||
|
||
namespace mojo { | ||
namespace runner { | ||
namespace { | ||
|
||
class ProcessDelegate : public mojo::embedder::ProcessDelegate { | ||
public: | ||
ProcessDelegate() {} | ||
~ProcessDelegate() override {} | ||
|
||
private: | ||
void OnShutdownComplete() override {} | ||
|
||
DISALLOW_COPY_AND_ASSIGN(ProcessDelegate); | ||
}; | ||
|
||
} // namespace | ||
|
||
int TestNativeMain(mojo::ApplicationDelegate* application_delegate) { | ||
mojo::runner::WaitForDebuggerIfNecessary(); | ||
|
||
#if !defined(OFFICIAL_BUILD) | ||
base::debug::EnableInProcessStackDumping(); | ||
#if defined(OS_WIN) | ||
base::RouteStdioToConsole(false); | ||
#endif | ||
#endif | ||
|
||
{ | ||
mojo::embedder::Init(); | ||
|
||
ProcessDelegate process_delegate; | ||
base::Thread io_thread("io_thread"); | ||
base::Thread::Options io_thread_options(base::MessageLoop::TYPE_IO, 0); | ||
CHECK(io_thread.StartWithOptions(io_thread_options)); | ||
|
||
mojo::embedder::InitIPCSupport( | ||
mojo::embedder::ProcessType::NONE, &process_delegate, | ||
io_thread.task_runner().get(), mojo::embedder::ScopedPlatformHandle()); | ||
|
||
mojo::InterfaceRequest<mojo::Application> application_request; | ||
scoped_ptr<mojo::runner::RunnerConnection> connection( | ||
mojo::runner::RunnerConnection::ConnectToRunner(&application_request)); | ||
|
||
base::MessageLoop loop(mojo::common::MessagePumpMojo::Create()); | ||
{ | ||
mojo::ApplicationImpl impl(application_delegate, | ||
application_request.Pass()); | ||
loop.Run(); | ||
} | ||
|
||
connection.reset(); | ||
|
||
mojo::embedder::ShutdownIPCSupport(); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
} // namespace runner | ||
} // namespace mojo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2015 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef MOJO_RUNNER_CHILD_TEST_NATIVE_MAIN_H_ | ||
#define MOJO_RUNNER_CHILD_TEST_NATIVE_MAIN_H_ | ||
|
||
namespace mojo { | ||
class ApplicationDelegate; | ||
namespace runner { | ||
|
||
int TestNativeMain(mojo::ApplicationDelegate* application_delegate); | ||
|
||
} // namespace runner | ||
} // namespace mojo | ||
|
||
#endif // MOJO_RUNNER_CHILD_TEST_NATIVE_MAIN_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.