Chromium Code Reviews| 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..016bfefd9720df4cd4c903bf4892153004048955 |
| --- /dev/null |
| +++ b/shell/nacl/nacl_service_runner.cc |
| @@ -0,0 +1,53 @@ |
| +// 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) |
|
jamesr
2015/01/28 23:11:30
looks oddly wrapped - did you 'git cl format' ?
Nick Bray (chromium)
2015/01/29 22:31:35
Done.
The code in the NaCl repo is too far gone t
|
| + : 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, NULL, handle); |
|
jamesr
2015/01/28 23:11:30
nullptr ?
Nick Bray (chromium)
2015/01/29 22:31:35
Done.
|
| + NOTREACHED(); |
| +} |
| + |
| +} // namespace shell |
| +} // namespace mojo |