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

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

Issue 2131493002: ShellConnection -> ServiceContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@st
Patch Set: . Created 4 years, 5 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/mash_runner.h ('k') | chrome/test/base/mash_browser_tests_main.cc » ('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/window_manager_application.h" 7 #include "ash/mus/window_manager_application.h"
8 #include "ash/sysui/sysui_application.h" 8 #include "ash/sysui/sysui_application.h"
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/debug/debugger.h" 12 #include "base/debug/debugger.h"
13 #include "base/i18n/icu_util.h" 13 #include "base/i18n/icu_util.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/process/launch.h" 17 #include "base/process/launch.h"
18 #include "content/public/common/content_switches.h" 18 #include "content/public/common/content_switches.h"
19 #include "mash/app_driver/app_driver.h" 19 #include "mash/app_driver/app_driver.h"
20 #include "mash/quick_launch/quick_launch_application.h" 20 #include "mash/quick_launch/quick_launch_application.h"
21 #include "mash/session/session.h" 21 #include "mash/session/session.h"
22 #include "mash/task_viewer/task_viewer.h" 22 #include "mash/task_viewer/task_viewer.h"
23 #include "mojo/public/cpp/bindings/binding_set.h" 23 #include "mojo/public/cpp/bindings/binding_set.h"
24 #include "services/shell/background/background_shell.h" 24 #include "services/shell/background/background_shell.h"
25 #include "services/shell/native_runner_delegate.h" 25 #include "services/shell/native_runner_delegate.h"
26 #include "services/shell/public/cpp/connector.h" 26 #include "services/shell/public/cpp/connector.h"
27 #include "services/shell/public/cpp/identity.h" 27 #include "services/shell/public/cpp/identity.h"
28 #include "services/shell/public/cpp/service.h" 28 #include "services/shell/public/cpp/service.h"
29 #include "services/shell/public/cpp/shell_connection.h" 29 #include "services/shell/public/cpp/service_context.h"
30 #include "services/shell/public/interfaces/service_factory.mojom.h" 30 #include "services/shell/public/interfaces/service_factory.mojom.h"
31 #include "services/shell/runner/common/switches.h" 31 #include "services/shell/runner/common/switches.h"
32 #include "services/shell/runner/host/child_process_base.h" 32 #include "services/shell/runner/host/child_process_base.h"
33 #include "services/ui/service.h" 33 #include "services/ui/service.h"
34 34
35 #if defined(OS_LINUX) 35 #if defined(OS_LINUX)
36 #include "components/font_service/font_service_app.h" 36 #include "components/font_service/font_service_app.h"
37 #endif 37 #endif
38 38
39 using shell::mojom::ServiceFactory; 39 using shell::mojom::ServiceFactory;
(...skipping 26 matching lines...) Expand all
66 // ServiceFactory: 66 // ServiceFactory:
67 void CreateService(shell::mojom::ServiceRequest request, 67 void CreateService(shell::mojom::ServiceRequest request,
68 const mojo::String& mojo_name) override { 68 const mojo::String& mojo_name) override {
69 if (service_) { 69 if (service_) {
70 LOG(ERROR) << "request to create additional service " << mojo_name; 70 LOG(ERROR) << "request to create additional service " << mojo_name;
71 return; 71 return;
72 } 72 }
73 service_ = CreateService(mojo_name); 73 service_ = CreateService(mojo_name);
74 if (service_) { 74 if (service_) {
75 shell_connection_.reset( 75 shell_connection_.reset(
76 new shell::ShellConnection(service_.get(), std::move(request))); 76 new shell::ServiceContext(service_.get(), std::move(request)));
77 return; 77 return;
78 } 78 }
79 LOG(ERROR) << "unknown name " << mojo_name; 79 LOG(ERROR) << "unknown name " << mojo_name;
80 NOTREACHED(); 80 NOTREACHED();
81 } 81 }
82 82
83 private: 83 private:
84 // TODO(sky): move this into mash. 84 // TODO(sky): move this into mash.
85 std::unique_ptr<shell::Service> CreateService( 85 std::unique_ptr<shell::Service> CreateService(
86 const std::string& name) { 86 const std::string& name) {
(...skipping 14 matching lines...) Expand all
101 return base::WrapUnique(new font_service::FontServiceApp); 101 return base::WrapUnique(new font_service::FontServiceApp);
102 #endif 102 #endif
103 if (name == "mojo:app_driver") { 103 if (name == "mojo:app_driver") {
104 return base::WrapUnique(new mash::app_driver::AppDriver()); 104 return base::WrapUnique(new mash::app_driver::AppDriver());
105 } 105 }
106 return nullptr; 106 return nullptr;
107 } 107 }
108 108
109 mojo::BindingSet<ServiceFactory> service_factory_bindings_; 109 mojo::BindingSet<ServiceFactory> service_factory_bindings_;
110 std::unique_ptr<shell::Service> service_; 110 std::unique_ptr<shell::Service> service_;
111 std::unique_ptr<shell::ShellConnection> shell_connection_; 111 std::unique_ptr<shell::ServiceContext> shell_connection_;
112 112
113 DISALLOW_COPY_AND_ASSIGN(DefaultService); 113 DISALLOW_COPY_AND_ASSIGN(DefaultService);
114 }; 114 };
115 115
116 bool IsChild() { 116 bool IsChild() {
117 return base::CommandLine::ForCurrentProcess()->HasSwitch( 117 return base::CommandLine::ForCurrentProcess()->HasSwitch(
118 switches::kProcessType) && 118 switches::kProcessType) &&
119 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 119 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
120 switches::kProcessType) == kMashChild; 120 switches::kProcessType) == kMashChild;
121 } 121 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // TODO(sky): refactor backgroundshell so can supply own context, we 180 // TODO(sky): refactor backgroundshell so can supply own context, we
181 // shouldn't we using context as it has a lot of stuff we don't really want 181 // shouldn't we using context as it has a lot of stuff we don't really want
182 // in chrome. 182 // in chrome.
183 NativeRunnerDelegateImpl native_runner_delegate; 183 NativeRunnerDelegateImpl native_runner_delegate;
184 shell::BackgroundShell background_shell; 184 shell::BackgroundShell background_shell;
185 std::unique_ptr<shell::BackgroundShell::InitParams> init_params( 185 std::unique_ptr<shell::BackgroundShell::InitParams> init_params(
186 new shell::BackgroundShell::InitParams); 186 new shell::BackgroundShell::InitParams);
187 init_params->native_runner_delegate = &native_runner_delegate; 187 init_params->native_runner_delegate = &native_runner_delegate;
188 background_shell.Init(std::move(init_params)); 188 background_shell.Init(std::move(init_params));
189 service_.reset(new DefaultService); 189 service_.reset(new DefaultService);
190 shell_connection_.reset(new shell::ShellConnection( 190 shell_connection_.reset(new shell::ServiceContext(
191 service_.get(), 191 service_.get(),
192 background_shell.CreateServiceRequest("exe:chrome_mash"))); 192 background_shell.CreateServiceRequest("exe:chrome_mash")));
193 shell_connection_->connector()->Connect("mojo:mash_session"); 193 shell_connection_->connector()->Connect("mojo:mash_session");
194 base::MessageLoop::current()->Run(); 194 base::MessageLoop::current()->Run();
195 } 195 }
196 196
197 void MashRunner::RunChild() { 197 void MashRunner::RunChild() {
198 base::i18n::InitializeICU(); 198 base::i18n::InitializeICU();
199 shell::ChildProcessMainWithCallback( 199 shell::ChildProcessMainWithCallback(
200 base::Bind(&MashRunner::StartChildApp, base::Unretained(this))); 200 base::Bind(&MashRunner::StartChildApp, base::Unretained(this)));
201 } 201 }
202 202
203 void MashRunner::StartChildApp( 203 void MashRunner::StartChildApp(
204 shell::mojom::ServiceRequest service_request) { 204 shell::mojom::ServiceRequest service_request) {
205 // TODO(sky): use MessagePumpMojo. 205 // TODO(sky): use MessagePumpMojo.
206 base::MessageLoop message_loop(base::MessageLoop::TYPE_UI); 206 base::MessageLoop message_loop(base::MessageLoop::TYPE_UI);
207 service_.reset(new DefaultService); 207 service_.reset(new DefaultService);
208 shell_connection_.reset(new shell::ShellConnection( 208 shell_connection_.reset(new shell::ServiceContext(
209 service_.get(), std::move(service_request))); 209 service_.get(), std::move(service_request)));
210 message_loop.Run(); 210 message_loop.Run();
211 } 211 }
212 212
213 int MashMain() { 213 int MashMain() {
214 #if defined(OS_WIN) 214 #if defined(OS_WIN)
215 base::RouteStdioToConsole(false); 215 base::RouteStdioToConsole(false);
216 #endif 216 #endif
217 // TODO(sky): wire this up correctly. 217 // TODO(sky): wire this up correctly.
218 logging::LoggingSettings settings; 218 logging::LoggingSettings settings;
219 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; 219 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
220 logging::InitLogging(settings); 220 logging::InitLogging(settings);
221 // To view log output with IDs and timestamps use "adb logcat -v threadtime". 221 // To view log output with IDs and timestamps use "adb logcat -v threadtime".
222 logging::SetLogItems(true, // Process ID 222 logging::SetLogItems(true, // Process ID
223 true, // Thread ID 223 true, // Thread ID
224 true, // Timestamp 224 true, // Timestamp
225 true); // Tick count 225 true); // Tick count
226 226
227 // TODO(sky): use MessagePumpMojo. 227 // TODO(sky): use MessagePumpMojo.
228 std::unique_ptr<base::MessageLoop> message_loop; 228 std::unique_ptr<base::MessageLoop> message_loop;
229 #if defined(OS_LINUX) 229 #if defined(OS_LINUX)
230 base::AtExitManager exit_manager; 230 base::AtExitManager exit_manager;
231 #endif 231 #endif
232 if (!IsChild()) 232 if (!IsChild())
233 message_loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI)); 233 message_loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI));
234 MashRunner mash_runner; 234 MashRunner mash_runner;
235 mash_runner.Run(); 235 mash_runner.Run();
236 return 0; 236 return 0;
237 } 237 }
OLDNEW
« no previous file with comments | « chrome/app/mash/mash_runner.h ('k') | chrome/test/base/mash_browser_tests_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698