Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "shell/out_of_process_native_runner.h" | 5 #include "shell/out_of_process_native_runner.h" |
| 6 | 6 |
| 7 #include <string> | |
| 8 | |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| 9 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/strings/string_util.h" | |
| 11 #include "shell/child_controller.mojom.h" | 14 #include "shell/child_controller.mojom.h" |
| 12 #include "shell/child_process_host.h" | 15 #include "shell/child_process_host.h" |
| 13 #include "shell/in_process_native_runner.h" | 16 #include "shell/in_process_native_runner.h" |
| 14 | 17 |
| 15 namespace shell { | 18 namespace shell { |
| 16 | 19 |
| 17 OutOfProcessNativeRunner::OutOfProcessNativeRunner(Context* context) | 20 OutOfProcessNativeRunner::OutOfProcessNativeRunner(Context* context) |
| 18 : context_(context) { | 21 : context_(context) { |
| 19 } | 22 } |
| 20 | 23 |
| 21 OutOfProcessNativeRunner::~OutOfProcessNativeRunner() { | 24 OutOfProcessNativeRunner::~OutOfProcessNativeRunner() { |
| 22 if (child_process_host_) { | 25 if (child_process_host_) { |
| 23 // TODO(vtl): Race condition: If |ChildProcessHost::DidStart()| hasn't been | 26 // TODO(vtl): Race condition: If |ChildProcessHost::DidStart()| hasn't been |
| 24 // called yet, we shouldn't call |Join()| here. (Until |DidStart()|, we may | 27 // called yet, we shouldn't call |Join()| here. (Until |DidStart()|, we may |
| 25 // not have a child process to wait on.) Probably we should fix |Join()|. | 28 // not have a child process to wait on.) Probably we should fix |Join()|. |
| 26 child_process_host_->Join(); | 29 child_process_host_->Join(); |
| 27 } | 30 } |
| 28 } | 31 } |
| 29 | 32 |
| 30 void OutOfProcessNativeRunner::Start( | 33 void OutOfProcessNativeRunner::Start( |
| 31 const base::FilePath& app_path, | 34 const base::FilePath& app_path, |
| 32 mojo::InterfaceRequest<mojo::Application> application_request, | 35 mojo::InterfaceRequest<mojo::Application> application_request, |
| 33 const base::Closure& app_completed_callback) { | 36 const base::Closure& app_completed_callback) { |
| 34 app_path_ = app_path; | 37 app_path_ = app_path; |
| 35 | 38 |
| 36 DCHECK(app_completed_callback_.is_null()); | 39 DCHECK(app_completed_callback_.is_null()); |
| 37 app_completed_callback_ = app_completed_callback; | 40 app_completed_callback_ = app_completed_callback; |
| 38 | 41 |
| 39 child_process_host_.reset(new ChildProcessHost(context_)); | 42 child_process_host_.reset(new ChildProcessHost(context_)); |
| 40 child_process_host_->Start(); | 43 bool require_32_bit = false; |
| 44 if (EndsWith(app_path.value(), "nacl_content_handler_nonsfi.mojo", true)) | |
| 45 require_32_bit = true; | |
|
Sean Klein
2015/09/14 18:10:34
I am fully aware this is kind of hacky -- mojo peo
Mark Seaborn
2015/09/14 18:38:59
I think it's up to an owner of this code whether t
Sean Klein
2015/09/15 18:37:50
Modified to check ELF header of content handler. A
Mark Seaborn
2015/09/15 19:42:58
Yes, checking for "\x7fELF" would be good, to ensu
| |
| 46 child_process_host_->Start(require_32_bit); | |
| 41 | 47 |
| 42 // TODO(vtl): |app_path.AsUTF8Unsafe()| is unsafe. | 48 // TODO(vtl): |app_path.AsUTF8Unsafe()| is unsafe. |
| 43 child_process_host_->StartApp( | 49 child_process_host_->StartApp( |
| 44 app_path.AsUTF8Unsafe(), application_request.Pass(), | 50 app_path.AsUTF8Unsafe(), application_request.Pass(), |
| 45 base::Bind(&OutOfProcessNativeRunner::AppCompleted, | 51 base::Bind(&OutOfProcessNativeRunner::AppCompleted, |
| 46 base::Unretained(this))); | 52 base::Unretained(this))); |
| 47 } | 53 } |
| 48 | 54 |
| 49 void OutOfProcessNativeRunner::AppCompleted(int32_t result) { | 55 void OutOfProcessNativeRunner::AppCompleted(int32_t result) { |
| 50 DVLOG(2) << "OutOfProcessNativeRunner::AppCompleted(" << result << ")"; | 56 DVLOG(2) << "OutOfProcessNativeRunner::AppCompleted(" << result << ")"; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 61 | 67 |
| 62 scoped_ptr<NativeRunner> OutOfProcessNativeRunnerFactory::Create( | 68 scoped_ptr<NativeRunner> OutOfProcessNativeRunnerFactory::Create( |
| 63 const Options& options) { | 69 const Options& options) { |
| 64 if (options.force_in_process) | 70 if (options.force_in_process) |
| 65 return make_scoped_ptr(new InProcessNativeRunner(context_)); | 71 return make_scoped_ptr(new InProcessNativeRunner(context_)); |
| 66 | 72 |
| 67 return make_scoped_ptr(new OutOfProcessNativeRunner(context_)); | 73 return make_scoped_ptr(new OutOfProcessNativeRunner(context_)); |
| 68 } | 74 } |
| 69 | 75 |
| 70 } // namespace shell | 76 } // namespace shell |
| OLD | NEW |