| 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/host/in_process_native_runner.h" | 5 #include "mojo/runner/host/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/task_runner.h" | 10 #include "base/task_runner.h" |
| 11 #include "base/thread_task_runner_handle.h" | 11 #include "base/thread_task_runner_handle.h" |
| 12 #include "base/threading/platform_thread.h" | 12 #include "base/threading/platform_thread.h" |
| 13 #include "mojo/runner/host/native_application_support.h" | 13 #include "mojo/runner/host/native_application_support.h" |
| 14 #include "mojo/runner/host/out_of_process_native_runner.h" | 14 #include "mojo/runner/host/out_of_process_native_runner.h" |
| 15 #include "mojo/runner/init.h" |
| 15 | 16 |
| 16 namespace mojo { | 17 namespace mojo { |
| 17 namespace runner { | 18 namespace runner { |
| 18 | 19 |
| 19 InProcessNativeRunner::InProcessNativeRunner() : app_library_(nullptr) {} | 20 InProcessNativeRunner::InProcessNativeRunner() : app_library_(nullptr) {} |
| 20 | 21 |
| 21 InProcessNativeRunner::~InProcessNativeRunner() { | 22 InProcessNativeRunner::~InProcessNativeRunner() { |
| 22 // It is important to let the thread exit before unloading the DSO (when | 23 // It is important to let the thread exit before unloading the DSO (when |
| 23 // app_library_ is destructed), because the library may have registered | 24 // app_library_ is destructed), because the library may have registered |
| 24 // thread-local data and destructors to run on thread termination. | 25 // thread-local data and destructors to run on thread termination. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 50 } | 51 } |
| 51 | 52 |
| 52 void InProcessNativeRunner::Run() { | 53 void InProcessNativeRunner::Run() { |
| 53 DVLOG(2) << "Loading/running Mojo app in process from library: " | 54 DVLOG(2) << "Loading/running Mojo app in process from library: " |
| 54 << app_path_.value() | 55 << app_path_.value() |
| 55 << " thread id=" << base::PlatformThread::CurrentId(); | 56 << " thread id=" << base::PlatformThread::CurrentId(); |
| 56 | 57 |
| 57 // TODO(vtl): ScopedNativeLibrary doesn't have a .get() method! | 58 // TODO(vtl): ScopedNativeLibrary doesn't have a .get() method! |
| 58 base::NativeLibrary app_library = LoadNativeApplication(app_path_); | 59 base::NativeLibrary app_library = LoadNativeApplication(app_path_); |
| 59 app_library_.Reset(app_library); | 60 app_library_.Reset(app_library); |
| 61 CallLibraryEarlyInitialization(app_library); |
| 60 RunNativeApplication(app_library, application_request_.Pass()); | 62 RunNativeApplication(app_library, application_request_.Pass()); |
| 61 app_completed_callback_runner_.Run(); | 63 app_completed_callback_runner_.Run(); |
| 62 app_completed_callback_runner_.Reset(); | 64 app_completed_callback_runner_.Reset(); |
| 63 } | 65 } |
| 64 | 66 |
| 65 scoped_ptr<shell::NativeRunner> InProcessNativeRunnerFactory::Create( | 67 scoped_ptr<shell::NativeRunner> InProcessNativeRunnerFactory::Create( |
| 66 const base::FilePath& app_path) { | 68 const base::FilePath& app_path) { |
| 67 // Non-Mojo apps are always run in a new process. | 69 // Non-Mojo apps are always run in a new process. |
| 68 if (!app_path.MatchesExtension(FILE_PATH_LITERAL(".mojo"))) { | 70 if (!app_path.MatchesExtension(FILE_PATH_LITERAL(".mojo"))) { |
| 69 return make_scoped_ptr( | 71 return make_scoped_ptr( |
| 70 new OutOfProcessNativeRunner(launch_process_runner_)); | 72 new OutOfProcessNativeRunner(launch_process_runner_)); |
| 71 } | 73 } |
| 72 return make_scoped_ptr(new InProcessNativeRunner); | 74 return make_scoped_ptr(new InProcessNativeRunner); |
| 73 } | 75 } |
| 74 | 76 |
| 75 } // namespace runner | 77 } // namespace runner |
| 76 } // namespace mojo | 78 } // namespace mojo |
| OLD | NEW |