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

Side by Side Diff: chrome/app/mash/mash_runner.cc

Issue 1743473002: Change Mojo URLs to structured names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@18collapse
Patch Set: . Created 4 years, 9 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
« no previous file with comments | « chrome/app/mash/chrome_mash_manifest.json ('k') | components/filesystem/apptest_manifest.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/app/mash/mash_runner.h" 5 #include "chrome/app/mash/mash_runner.h"
6 6
7 #include "ash/mus/sysui_application.h" 7 #include "ash/mus/sysui_application.h"
8 #include "base/at_exit.h" 8 #include "base/at_exit.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/debug/debugger.h" 11 #include "base/debug/debugger.h"
12 #include "base/i18n/icu_util.h" 12 #include "base/i18n/icu_util.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/process/launch.h" 15 #include "base/process/launch.h"
16 #include "components/mus/mus_app.h" 16 #include "components/mus/mus_app.h"
17 #include "components/resource_provider/resource_provider_app.h" 17 #include "components/resource_provider/resource_provider_app.h"
18 #include "content/public/common/content_switches.h" 18 #include "content/public/common/content_switches.h"
19 #include "mash/quick_launch/quick_launch_application.h" 19 #include "mash/quick_launch/quick_launch_application.h"
20 #include "mash/shell/shell_application_delegate.h" 20 #include "mash/shell/shell_application_delegate.h"
21 #include "mash/wm/window_manager_application.h" 21 #include "mash/wm/window_manager_application.h"
22 #include "mojo/common/mojo_scheme_register.h"
23 #include "mojo/public/cpp/bindings/binding_set.h" 22 #include "mojo/public/cpp/bindings/binding_set.h"
24 #include "mojo/shell/background/background_shell.h" 23 #include "mojo/shell/background/background_shell.h"
25 #include "mojo/shell/identity.h" 24 #include "mojo/shell/identity.h"
26 #include "mojo/shell/native_runner_delegate.h" 25 #include "mojo/shell/native_runner_delegate.h"
27 #include "mojo/shell/public/cpp/connector.h" 26 #include "mojo/shell/public/cpp/connector.h"
28 #include "mojo/shell/public/cpp/shell_client.h" 27 #include "mojo/shell/public/cpp/shell_client.h"
29 #include "mojo/shell/public/cpp/shell_connection.h" 28 #include "mojo/shell/public/cpp/shell_connection.h"
30 #include "mojo/shell/public/interfaces/shell_client_factory.mojom.h" 29 #include "mojo/shell/public/interfaces/shell_client_factory.mojom.h"
31 #include "mojo/shell/runner/common/switches.h" 30 #include "mojo/shell/runner/common/switches.h"
32 #include "mojo/shell/runner/host/child_process_base.h" 31 #include "mojo/shell/runner/host/child_process_base.h"
33 #include "url/gurl.h"
34 #include "url/url_util.h"
35 32
36 #if defined(OS_LINUX) 33 #if defined(OS_LINUX)
37 #include "components/font_service/font_service_app.h" 34 #include "components/font_service/font_service_app.h"
38 #endif 35 #endif
39 36
40 using mojo::shell::mojom::ShellClientFactory; 37 using mojo::shell::mojom::ShellClientFactory;
41 38
42 namespace { 39 namespace {
43 40
44 // kProcessType used to identify child processes. 41 // kProcessType used to identify child processes.
(...skipping 14 matching lines...) Expand all
59 } 56 }
60 57
61 // mojo::InterfaceFactory<ShellClientFactory> 58 // mojo::InterfaceFactory<ShellClientFactory>
62 void Create(mojo::Connection* connection, 59 void Create(mojo::Connection* connection,
63 mojo::InterfaceRequest<ShellClientFactory> request) override { 60 mojo::InterfaceRequest<ShellClientFactory> request) override {
64 shell_client_factory_bindings_.AddBinding(this, std::move(request)); 61 shell_client_factory_bindings_.AddBinding(this, std::move(request));
65 } 62 }
66 63
67 // ShellClientFactory: 64 // ShellClientFactory:
68 void CreateShellClient(mojo::shell::mojom::ShellClientRequest request, 65 void CreateShellClient(mojo::shell::mojom::ShellClientRequest request,
69 const mojo::String& mojo_url) override { 66 const mojo::String& mojo_name) override {
70 const GURL url = GURL(std::string(mojo_url));
71 if (shell_client_) { 67 if (shell_client_) {
72 LOG(ERROR) << "request to create additional app " << url; 68 LOG(ERROR) << "request to create additional app " << mojo_name;
73 return; 69 return;
74 } 70 }
75 shell_client_ = CreateShellClient(url); 71 shell_client_ = CreateShellClient(mojo_name);
76 if (shell_client_) { 72 if (shell_client_) {
77 shell_connection_.reset( 73 shell_connection_.reset(
78 new mojo::ShellConnection(shell_client_.get(), std::move(request))); 74 new mojo::ShellConnection(shell_client_.get(), std::move(request)));
79 return; 75 return;
80 } 76 }
81 LOG(ERROR) << "unknown url " << url; 77 LOG(ERROR) << "unknown name " << mojo_name;
82 NOTREACHED(); 78 NOTREACHED();
83 } 79 }
84 80
85 private: 81 private:
86 // TODO(sky): move this into mash. 82 // TODO(sky): move this into mash.
87 scoped_ptr<mojo::ShellClient> CreateShellClient(const GURL& url) { 83 scoped_ptr<mojo::ShellClient> CreateShellClient(const std::string& name) {
88 if (url == GURL("mojo:ash_sysui")) 84 if (name == "mojo:ash_sysui")
89 return make_scoped_ptr(new ash::sysui::SysUIApplication); 85 return make_scoped_ptr(new ash::sysui::SysUIApplication);
90 if (url == GURL("mojo:desktop_wm")) 86 if (name == "mojo:desktop_wm")
91 return make_scoped_ptr(new mash::wm::WindowManagerApplication); 87 return make_scoped_ptr(new mash::wm::WindowManagerApplication);
92 if (url == GURL("mojo:mash_shell")) 88 if (name == "mojo:mash_shell")
93 return make_scoped_ptr(new mash::shell::ShellApplicationDelegate); 89 return make_scoped_ptr(new mash::shell::ShellApplicationDelegate);
94 if (url == GURL("mojo:mus")) 90 if (name == "mojo:mus")
95 return make_scoped_ptr(new mus::MandolineUIServicesApp); 91 return make_scoped_ptr(new mus::MandolineUIServicesApp);
96 if (url == GURL("mojo:quick_launch")) 92 if (name == "mojo:quick_launch")
97 return make_scoped_ptr(new mash::quick_launch::QuickLaunchApplication); 93 return make_scoped_ptr(new mash::quick_launch::QuickLaunchApplication);
98 if (url == GURL("mojo:resource_provider")) { 94 if (name == "mojo:resource_provider") {
99 return make_scoped_ptr( 95 return make_scoped_ptr(
100 new resource_provider::ResourceProviderApp("mojo:resource_provider")); 96 new resource_provider::ResourceProviderApp("mojo:resource_provider"));
101 } 97 }
102 #if defined(OS_LINUX) 98 #if defined(OS_LINUX)
103 if (url == GURL("mojo:font_service")) 99 if (name == "mojo:font_service")
104 return make_scoped_ptr(new font_service::FontServiceApp); 100 return make_scoped_ptr(new font_service::FontServiceApp);
105 #endif 101 #endif
106 return nullptr; 102 return nullptr;
107 } 103 }
108 104
109 mojo::BindingSet<ShellClientFactory> shell_client_factory_bindings_; 105 mojo::BindingSet<ShellClientFactory> shell_client_factory_bindings_;
110 scoped_ptr<mojo::ShellClient> shell_client_; 106 scoped_ptr<mojo::ShellClient> shell_client_;
111 scoped_ptr<mojo::ShellConnection> shell_connection_; 107 scoped_ptr<mojo::ShellConnection> shell_connection_;
112 108
113 DISALLOW_COPY_AND_ASSIGN(DefaultShellClient); 109 DISALLOW_COPY_AND_ASSIGN(DefaultShellClient);
(...skipping 21 matching lines...) Expand all
135 class NativeRunnerDelegateImpl : public mojo::shell::NativeRunnerDelegate { 131 class NativeRunnerDelegateImpl : public mojo::shell::NativeRunnerDelegate {
136 public: 132 public:
137 NativeRunnerDelegateImpl() {} 133 NativeRunnerDelegateImpl() {}
138 ~NativeRunnerDelegateImpl() override {} 134 ~NativeRunnerDelegateImpl() override {}
139 135
140 private: 136 private:
141 // mojo::shell::NativeRunnerDelegate: 137 // mojo::shell::NativeRunnerDelegate:
142 void AdjustCommandLineArgumentsForTarget( 138 void AdjustCommandLineArgumentsForTarget(
143 const mojo::shell::Identity& target, 139 const mojo::shell::Identity& target,
144 base::CommandLine* command_line) override { 140 base::CommandLine* command_line) override {
145 if (target.url() != GURL("exe:chrome")) { 141 if (target.name() != "exe:chrome") {
146 if (target.url() == GURL("exe:chrome_mash")) 142 if (target.name() == "exe:chrome_mash")
147 ChangeChromeMashToChrome(command_line); 143 ChangeChromeMashToChrome(command_line);
148 command_line->AppendSwitchASCII(switches::kProcessType, kMashChild); 144 command_line->AppendSwitchASCII(switches::kProcessType, kMashChild);
149 #if defined(OS_WIN) 145 #if defined(OS_WIN)
150 command_line->AppendArg(switches::kPrefetchArgumentOther); 146 command_line->AppendArg(switches::kPrefetchArgumentOther);
151 #endif 147 #endif
152 return; 148 return;
153 } 149 }
154 150
155 base::CommandLine::StringVector argv(command_line->argv()); 151 base::CommandLine::StringVector argv(command_line->argv());
156 auto iter = 152 auto iter =
(...skipping 25 matching lines...) Expand all
182 // in chrome. 178 // in chrome.
183 NativeRunnerDelegateImpl native_runner_delegate; 179 NativeRunnerDelegateImpl native_runner_delegate;
184 mojo::shell::BackgroundShell background_shell; 180 mojo::shell::BackgroundShell background_shell;
185 scoped_ptr<mojo::shell::BackgroundShell::InitParams> init_params( 181 scoped_ptr<mojo::shell::BackgroundShell::InitParams> init_params(
186 new mojo::shell::BackgroundShell::InitParams); 182 new mojo::shell::BackgroundShell::InitParams);
187 init_params->native_runner_delegate = &native_runner_delegate; 183 init_params->native_runner_delegate = &native_runner_delegate;
188 background_shell.Init(std::move(init_params)); 184 background_shell.Init(std::move(init_params));
189 shell_client_.reset(new DefaultShellClient); 185 shell_client_.reset(new DefaultShellClient);
190 shell_connection_.reset(new mojo::ShellConnection( 186 shell_connection_.reset(new mojo::ShellConnection(
191 shell_client_.get(), 187 shell_client_.get(),
192 background_shell.CreateShellClientRequest(GURL("exe:chrome_mash")))); 188 background_shell.CreateShellClientRequest("exe:chrome_mash")));
193 shell_connection_->WaitForInitialize(); 189 shell_connection_->WaitForInitialize();
194 shell_connection_->connector()->Connect("mojo:mash_shell"); 190 shell_connection_->connector()->Connect("mojo:mash_shell");
195 base::MessageLoop::current()->Run(); 191 base::MessageLoop::current()->Run();
196 } 192 }
197 193
198 void MashRunner::RunChild() { 194 void MashRunner::RunChild() {
199 base::i18n::InitializeICU(); 195 base::i18n::InitializeICU();
200 mojo::shell::ChildProcessMain( 196 mojo::shell::ChildProcessMain(
201 base::Bind(&MashRunner::StartChildApp, base::Unretained(this))); 197 base::Bind(&MashRunner::StartChildApp, base::Unretained(this)));
202 } 198 }
(...skipping 15 matching lines...) Expand all
218 // TODO(sky): wire this up correctly. 214 // TODO(sky): wire this up correctly.
219 logging::LoggingSettings settings; 215 logging::LoggingSettings settings;
220 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; 216 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
221 logging::InitLogging(settings); 217 logging::InitLogging(settings);
222 // To view log output with IDs and timestamps use "adb logcat -v threadtime". 218 // To view log output with IDs and timestamps use "adb logcat -v threadtime".
223 logging::SetLogItems(false, // Process ID 219 logging::SetLogItems(false, // Process ID
224 false, // Thread ID 220 false, // Thread ID
225 false, // Timestamp 221 false, // Timestamp
226 false); // Tick count 222 false); // Tick count
227 223
228 mojo::RegisterMojoSchemes();
229 // TODO(sky): use MessagePumpMojo. 224 // TODO(sky): use MessagePumpMojo.
230 scoped_ptr<base::MessageLoop> message_loop; 225 scoped_ptr<base::MessageLoop> message_loop;
231 #if defined(OS_LINUX) 226 #if defined(OS_LINUX)
232 base::AtExitManager exit_manager; 227 base::AtExitManager exit_manager;
233 #endif 228 #endif
234 if (!IsChild()) 229 if (!IsChild())
235 message_loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI)); 230 message_loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI));
236 MashRunner mash_runner; 231 MashRunner mash_runner;
237 mash_runner.Run(); 232 mash_runner.Run();
238 return 0; 233 return 0;
239 } 234 }
OLDNEW
« no previous file with comments | « chrome/app/mash/chrome_mash_manifest.json ('k') | components/filesystem/apptest_manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698