| 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 "mojo/runner/in_process_native_runner.h" | 5 #include "mojo/runner/in_process_native_runner.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| 11 #include "base/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
| 12 #include "mojo/runner/native_application_support.h" | 12 #include "mojo/runner/native_application_support.h" |
| 13 #include "mojo/runner/out_of_process_native_runner.h" |
| 13 | 14 |
| 14 namespace mojo { | 15 namespace mojo { |
| 15 namespace runner { | 16 namespace runner { |
| 16 | 17 |
| 17 InProcessNativeRunner::InProcessNativeRunner(Context* context) | 18 InProcessNativeRunner::InProcessNativeRunner(Context* context) |
| 18 : app_library_(nullptr) {} | 19 : app_library_(nullptr) {} |
| 19 | 20 |
| 20 InProcessNativeRunner::~InProcessNativeRunner() { | 21 InProcessNativeRunner::~InProcessNativeRunner() { |
| 21 // It is important to let the thread exit before unloading the DSO (when | 22 // It is important to let the thread exit before unloading the DSO (when |
| 22 // app_library_ is destructed), because the library may have registered | 23 // app_library_ is destructed), because the library may have registered |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 << " thread id=" << base::PlatformThread::CurrentId(); | 55 << " thread id=" << base::PlatformThread::CurrentId(); |
| 55 | 56 |
| 56 // TODO(vtl): ScopedNativeLibrary doesn't have a .get() method! | 57 // TODO(vtl): ScopedNativeLibrary doesn't have a .get() method! |
| 57 base::NativeLibrary app_library = LoadNativeApplication(app_path_); | 58 base::NativeLibrary app_library = LoadNativeApplication(app_path_); |
| 58 app_library_.Reset(app_library); | 59 app_library_.Reset(app_library); |
| 59 RunNativeApplication(app_library, application_request_.Pass()); | 60 RunNativeApplication(app_library, application_request_.Pass()); |
| 60 app_completed_callback_runner_.Run(); | 61 app_completed_callback_runner_.Run(); |
| 61 app_completed_callback_runner_.Reset(); | 62 app_completed_callback_runner_.Reset(); |
| 62 } | 63 } |
| 63 | 64 |
| 64 scoped_ptr<shell::NativeRunner> InProcessNativeRunnerFactory::Create() { | 65 scoped_ptr<shell::NativeRunner> InProcessNativeRunnerFactory::Create( |
| 66 const base::FilePath& app_path) { |
| 67 // Non-Mojo apps are always run in a new process. |
| 68 if (!app_path.MatchesExtension(FILE_PATH_LITERAL(".mojo"))) |
| 69 return make_scoped_ptr(new OutOfProcessNativeRunner(context_)); |
| 65 return make_scoped_ptr(new InProcessNativeRunner(context_)); | 70 return make_scoped_ptr(new InProcessNativeRunner(context_)); |
| 66 } | 71 } |
| 67 | 72 |
| 68 } // namespace runner | 73 } // namespace runner |
| 69 } // namespace mojo | 74 } // namespace mojo |
| OLD | NEW |