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 <utility> |
| 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/location.h" | 11 #include "base/location.h" |
10 #include "base/task_runner.h" | 12 #include "base/task_runner.h" |
11 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
12 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
13 #include "mojo/runner/host/native_application_support.h" | 15 #include "mojo/runner/host/native_application_support.h" |
14 #include "mojo/runner/host/out_of_process_native_runner.h" | 16 #include "mojo/runner/host/out_of_process_native_runner.h" |
15 #include "mojo/runner/init.h" | 17 #include "mojo/runner/init.h" |
16 | 18 |
(...skipping 14 matching lines...) Expand all Loading... |
31 } | 33 } |
32 | 34 |
33 void InProcessNativeRunner::Start( | 35 void InProcessNativeRunner::Start( |
34 const base::FilePath& app_path, | 36 const base::FilePath& app_path, |
35 bool start_sandboxed, | 37 bool start_sandboxed, |
36 InterfaceRequest<Application> application_request, | 38 InterfaceRequest<Application> application_request, |
37 const base::Closure& app_completed_callback) { | 39 const base::Closure& app_completed_callback) { |
38 app_path_ = app_path; | 40 app_path_ = app_path; |
39 | 41 |
40 DCHECK(!application_request_.is_pending()); | 42 DCHECK(!application_request_.is_pending()); |
41 application_request_ = application_request.Pass(); | 43 application_request_ = std::move(application_request); |
42 | 44 |
43 DCHECK(app_completed_callback_runner_.is_null()); | 45 DCHECK(app_completed_callback_runner_.is_null()); |
44 app_completed_callback_runner_ = base::Bind( | 46 app_completed_callback_runner_ = base::Bind( |
45 &base::TaskRunner::PostTask, base::ThreadTaskRunnerHandle::Get(), | 47 &base::TaskRunner::PostTask, base::ThreadTaskRunnerHandle::Get(), |
46 FROM_HERE, app_completed_callback); | 48 FROM_HERE, app_completed_callback); |
47 | 49 |
48 DCHECK(!thread_); | 50 DCHECK(!thread_); |
49 thread_.reset(new base::DelegateSimpleThread(this, "app_thread")); | 51 thread_.reset(new base::DelegateSimpleThread(this, "app_thread")); |
50 thread_->Start(); | 52 thread_->Start(); |
51 } | 53 } |
(...skipping 14 matching lines...) Expand all Loading... |
66 << " thread id=" << base::PlatformThread::CurrentId(); | 68 << " thread id=" << base::PlatformThread::CurrentId(); |
67 | 69 |
68 // TODO(vtl): ScopedNativeLibrary doesn't have a .get() method! | 70 // TODO(vtl): ScopedNativeLibrary doesn't have a .get() method! |
69 base::NativeLibrary app_library = LoadNativeApplication(app_path_); | 71 base::NativeLibrary app_library = LoadNativeApplication(app_path_); |
70 app_library_.Reset(app_library); | 72 app_library_.Reset(app_library); |
71 // This hangs on Windows in the component build, so skip it since it's | 73 // This hangs on Windows in the component build, so skip it since it's |
72 // unnecessary. | 74 // unnecessary. |
73 #if !(defined(COMPONENT_BUILD) && defined(OS_WIN)) | 75 #if !(defined(COMPONENT_BUILD) && defined(OS_WIN)) |
74 CallLibraryEarlyInitialization(app_library); | 76 CallLibraryEarlyInitialization(app_library); |
75 #endif | 77 #endif |
76 RunNativeApplication(app_library, application_request_.Pass()); | 78 RunNativeApplication(app_library, std::move(application_request_)); |
77 app_completed_callback_runner_.Run(); | 79 app_completed_callback_runner_.Run(); |
78 app_completed_callback_runner_.Reset(); | 80 app_completed_callback_runner_.Reset(); |
79 } | 81 } |
80 | 82 |
81 scoped_ptr<shell::NativeRunner> InProcessNativeRunnerFactory::Create( | 83 scoped_ptr<shell::NativeRunner> InProcessNativeRunnerFactory::Create( |
82 const base::FilePath& app_path) { | 84 const base::FilePath& app_path) { |
83 // Non-Mojo apps are always run in a new process. | 85 // Non-Mojo apps are always run in a new process. |
84 if (!app_path.MatchesExtension(FILE_PATH_LITERAL(".mojo"))) { | 86 if (!app_path.MatchesExtension(FILE_PATH_LITERAL(".mojo"))) { |
85 return make_scoped_ptr( | 87 return make_scoped_ptr( |
86 new OutOfProcessNativeRunner(launch_process_runner_)); | 88 new OutOfProcessNativeRunner(launch_process_runner_)); |
87 } | 89 } |
88 return make_scoped_ptr(new InProcessNativeRunner); | 90 return make_scoped_ptr(new InProcessNativeRunner); |
89 } | 91 } |
90 | 92 |
91 } // namespace runner | 93 } // namespace runner |
92 } // namespace mojo | 94 } // namespace mojo |
OLD | NEW |