Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: mojo/shell/runner/host/in_process_native_runner.cc

Issue 1675153002: ApplicationImpl->ShellConnection, mojom::Application->mojom::ShellClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ci2
Patch Set: . Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/shell/runner/host/in_process_native_runner.h" 5 #include "mojo/shell/runner/host/in_process_native_runner.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 17 matching lines...) Expand all
28 if (thread_) { 28 if (thread_) {
29 DCHECK(thread_->HasBeenStarted()); 29 DCHECK(thread_->HasBeenStarted());
30 DCHECK(!thread_->HasBeenJoined()); 30 DCHECK(!thread_->HasBeenJoined());
31 thread_->Join(); 31 thread_->Join();
32 } 32 }
33 } 33 }
34 34
35 void InProcessNativeRunner::Start( 35 void InProcessNativeRunner::Start(
36 const base::FilePath& app_path, 36 const base::FilePath& app_path,
37 bool start_sandboxed, 37 bool start_sandboxed,
38 InterfaceRequest<mojom::Application> application_request, 38 InterfaceRequest<mojom::ShellClient> request,
39 const base::Callback<void(base::ProcessId)>& pid_available_callback, 39 const base::Callback<void(base::ProcessId)>& pid_available_callback,
40 const base::Closure& app_completed_callback) { 40 const base::Closure& app_completed_callback) {
41 app_path_ = app_path; 41 app_path_ = app_path;
42 42
43 DCHECK(!application_request_.is_pending()); 43 DCHECK(!request_.is_pending());
44 application_request_ = std::move(application_request); 44 request_ = std::move(request);
45 45
46 DCHECK(app_completed_callback_runner_.is_null()); 46 DCHECK(app_completed_callback_runner_.is_null());
47 app_completed_callback_runner_ = base::Bind( 47 app_completed_callback_runner_ = base::Bind(
48 &base::TaskRunner::PostTask, base::ThreadTaskRunnerHandle::Get(), 48 &base::TaskRunner::PostTask, base::ThreadTaskRunnerHandle::Get(),
49 FROM_HERE, app_completed_callback); 49 FROM_HERE, app_completed_callback);
50 50
51 DCHECK(!thread_); 51 DCHECK(!thread_);
52 thread_.reset(new base::DelegateSimpleThread(this, "app_thread")); 52 thread_.reset(new base::DelegateSimpleThread(this, "app_thread"));
53 thread_->Start(); 53 thread_->Start();
54 pid_available_callback.Run(base::kNullProcessId); 54 pid_available_callback.Run(base::kNullProcessId);
55 } 55 }
56 56
57 void InProcessNativeRunner::InitHost( 57 void InProcessNativeRunner::InitHost(
58 ScopedHandle channel, 58 ScopedHandle channel,
59 InterfaceRequest<mojom::Application> application_request) { 59 InterfaceRequest<mojom::ShellClient> request) {
60 NOTREACHED(); // Can't host another process in this runner. 60 NOTREACHED(); // Can't host another process in this runner.
61 } 61 }
62 62
63 void InProcessNativeRunner::Run() { 63 void InProcessNativeRunner::Run() {
64 DVLOG(2) << "Loading/running Mojo app in process from library: " 64 DVLOG(2) << "Loading/running Mojo app in process from library: "
65 << app_path_.value() 65 << app_path_.value()
66 << " thread id=" << base::PlatformThread::CurrentId(); 66 << " thread id=" << base::PlatformThread::CurrentId();
67 67
68 // TODO(vtl): ScopedNativeLibrary doesn't have a .get() method! 68 // TODO(vtl): ScopedNativeLibrary doesn't have a .get() method!
69 base::NativeLibrary app_library = LoadNativeApplication(app_path_); 69 base::NativeLibrary app_library = LoadNativeApplication(app_path_);
70 app_library_.Reset(app_library); 70 app_library_.Reset(app_library);
71 // This hangs on Windows in the component build, so skip it since it's 71 // This hangs on Windows in the component build, so skip it since it's
72 // unnecessary. 72 // unnecessary.
73 #if !(defined(COMPONENT_BUILD) && defined(OS_WIN)) 73 #if !(defined(COMPONENT_BUILD) && defined(OS_WIN))
74 CallLibraryEarlyInitialization(app_library); 74 CallLibraryEarlyInitialization(app_library);
75 #endif 75 #endif
76 RunNativeApplication(app_library, std::move(application_request_)); 76 RunNativeApplication(app_library, std::move(request_));
77 app_completed_callback_runner_.Run(); 77 app_completed_callback_runner_.Run();
78 app_completed_callback_runner_.Reset(); 78 app_completed_callback_runner_.Reset();
79 } 79 }
80 80
81 scoped_ptr<NativeRunner> InProcessNativeRunnerFactory::Create( 81 scoped_ptr<NativeRunner> InProcessNativeRunnerFactory::Create(
82 const base::FilePath& app_path) { 82 const base::FilePath& app_path) {
83 // Non-Mojo apps are always run in a new process. 83 // Non-Mojo apps are always run in a new process.
84 if (!app_path.MatchesExtension(FILE_PATH_LITERAL(".mojo"))) { 84 if (!app_path.MatchesExtension(FILE_PATH_LITERAL(".mojo"))) {
85 return make_scoped_ptr( 85 return make_scoped_ptr(
86 new OutOfProcessNativeRunner(launch_process_runner_)); 86 new OutOfProcessNativeRunner(launch_process_runner_));
87 } 87 }
88 return make_scoped_ptr(new InProcessNativeRunner); 88 return make_scoped_ptr(new InProcessNativeRunner);
89 } 89 }
90 90
91 } // namespace shell 91 } // namespace shell
92 } // namespace mojo 92 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/runner/host/in_process_native_runner.h ('k') | mojo/shell/runner/host/native_application_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698