| Index: shell/nacl/nacl_service_runner.cc
|
| diff --git a/shell/nacl/nacl_service_runner.cc b/shell/nacl/nacl_service_runner.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c8216d641a782e1bc7f791dbb49d0da64bc98c96
|
| --- /dev/null
|
| +++ b/shell/nacl/nacl_service_runner.cc
|
| @@ -0,0 +1,51 @@
|
| +// 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 "shell/nacl/nacl_service_runner.h"
|
| +
|
| +#include "mojo/nacl/monacl_sel_main.h"
|
| +#include "shell/context.h"
|
| +
|
| +namespace mojo {
|
| +namespace shell {
|
| +
|
| +NaClServiceRunner::NaClServiceRunner(Context* context) : context_(context) {
|
| +}
|
| +
|
| +NaClServiceRunner::~NaClServiceRunner() {
|
| + if (thread_) {
|
| + DCHECK(thread_->HasBeenStarted());
|
| + DCHECK(!thread_->HasBeenJoined());
|
| + thread_->Join();
|
| + }
|
| +}
|
| +
|
| +void NaClServiceRunner::Start(
|
| + const base::FilePath& app_path,
|
| + InterfaceRequest<Application> application_request) {
|
| + // TODO(ncbray) be more principled about finding the IRT.
|
| + irt_path_ = base::FilePath(
|
| + context_->ResolveShellFileURL("irt_x64/irt_core.nexe").GetContent());
|
| +
|
| + app_path_ = app_path;
|
| +
|
| + DCHECK(!application_request_.is_pending());
|
| + application_request_ = application_request.Pass();
|
| +
|
| + DCHECK(!thread_);
|
| + thread_.reset(new base::DelegateSimpleThread(this, "app_thread"));
|
| + thread_->Start();
|
| +}
|
| +
|
| +void NaClServiceRunner::Run() {
|
| + MojoHandle handle = application_request_.PassMessagePipe().release().value();
|
| +
|
| + // This function will never return - it will take the process down instead.
|
| + LaunchNaCl(app_path_.AsUTF8Unsafe().c_str(), irt_path_.AsUTF8Unsafe().c_str(),
|
| + 0, nullptr, handle);
|
| + NOTREACHED();
|
| +}
|
| +
|
| +} // namespace shell
|
| +} // namespace mojo
|
|
|