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

Side by Side Diff: mojo/shell/context.cc

Issue 522443003: Accept inbound connections on unix domain socket (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bug407782
Patch Set: Deleted extra curly brace, which was closing a namespace too early Created 6 years, 2 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 | « mojo/shell/context.h ('k') | mojo/shell/external_application_listener.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/context.h" 5 #include "mojo/shell/context.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h"
9 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/files/file_path.h"
10 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
11 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
13 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
14 #include "build/build_config.h" 16 #include "build/build_config.h"
15 #include "gpu/command_buffer/service/mailbox_manager.h" 17 #include "gpu/command_buffer/service/mailbox_manager.h"
16 #include "mojo/application_manager/application_loader.h" 18 #include "mojo/application_manager/application_loader.h"
17 #include "mojo/application_manager/application_manager.h" 19 #include "mojo/application_manager/application_manager.h"
18 #include "mojo/application_manager/background_shell_application_loader.h" 20 #include "mojo/application_manager/background_shell_application_loader.h"
19 #include "mojo/embedder/embedder.h" 21 #include "mojo/embedder/embedder.h"
20 #include "mojo/embedder/simple_platform_support.h" 22 #include "mojo/embedder/simple_platform_support.h"
21 #include "mojo/public/cpp/application/application_connection.h" 23 #include "mojo/public/cpp/application/application_connection.h"
22 #include "mojo/public/cpp/application/application_delegate.h" 24 #include "mojo/public/cpp/application/application_delegate.h"
23 #include "mojo/public/cpp/application/application_impl.h" 25 #include "mojo/public/cpp/application/application_impl.h"
24 #include "mojo/shell/dynamic_application_loader.h" 26 #include "mojo/shell/dynamic_application_loader.h"
27 #include "mojo/shell/external_application_listener.h"
25 #include "mojo/shell/in_process_dynamic_service_runner.h" 28 #include "mojo/shell/in_process_dynamic_service_runner.h"
26 #include "mojo/shell/out_of_process_dynamic_service_runner.h" 29 #include "mojo/shell/out_of_process_dynamic_service_runner.h"
27 #include "mojo/shell/switches.h" 30 #include "mojo/shell/switches.h"
28 #include "mojo/shell/ui_application_loader_android.h" 31 #include "mojo/shell/ui_application_loader_android.h"
29 #include "mojo/spy/spy.h" 32 #include "mojo/spy/spy.h"
30 33
31 #if defined(OS_LINUX) 34 #if defined(OS_LINUX)
32 #include "mojo/shell/dbus_application_loader_linux.h" 35 #include "mojo/shell/dbus_application_loader_linux.h"
33 #endif // defined(OS_LINUX) 36 #endif // defined(OS_LINUX)
34 37
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 void Context::Init() { 174 void Context::Init() {
172 application_manager_.set_delegate(this); 175 application_manager_.set_delegate(this);
173 setup.Get(); 176 setup.Get();
174 task_runners_.reset( 177 task_runners_.reset(
175 new TaskRunners(base::MessageLoop::current()->message_loop_proxy())); 178 new TaskRunners(base::MessageLoop::current()->message_loop_proxy()));
176 179
177 for (size_t i = 0; i < arraysize(kLocalMojoURLs); ++i) 180 for (size_t i = 0; i < arraysize(kLocalMojoURLs); ++i)
178 mojo_url_resolver_.AddLocalFileMapping(GURL(kLocalMojoURLs[i])); 181 mojo_url_resolver_.AddLocalFileMapping(GURL(kLocalMojoURLs[i]));
179 182
180 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 183 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
184
185 if (command_line->HasSwitch(switches::kEnableExternalApplications)) {
186 listener_ = ExternalApplicationListener::Create(
187 task_runners_->shell_runner(), task_runners_->io_runner());
188 listener_->ListenInBackground(
189 ExternalApplicationListener::ConstructDefaultSocketPath(),
190 base::Bind(&ApplicationManager::RegisterExternalApplication,
191 base::Unretained(&application_manager_)));
192 }
181 scoped_ptr<DynamicServiceRunnerFactory> runner_factory; 193 scoped_ptr<DynamicServiceRunnerFactory> runner_factory;
182 if (command_line->HasSwitch(switches::kEnableMultiprocess)) 194 if (command_line->HasSwitch(switches::kEnableMultiprocess))
183 runner_factory.reset(new OutOfProcessDynamicServiceRunnerFactory()); 195 runner_factory.reset(new OutOfProcessDynamicServiceRunnerFactory());
184 else 196 else
185 runner_factory.reset(new InProcessDynamicServiceRunnerFactory()); 197 runner_factory.reset(new InProcessDynamicServiceRunnerFactory());
186 198
187 DynamicApplicationLoader* dynamic_application_loader = 199 DynamicApplicationLoader* dynamic_application_loader =
188 new DynamicApplicationLoader(this, runner_factory.Pass()); 200 new DynamicApplicationLoader(this, runner_factory.Pass());
189 InitContentHandlers(dynamic_application_loader, command_line); 201 InitContentHandlers(dynamic_application_loader, command_line);
190 application_manager_.set_default_loader( 202 application_manager_.set_default_loader(
(...skipping 27 matching lines...) Expand all
218 { 230 {
219 scoped_ptr<BackgroundShellApplicationLoader> loader( 231 scoped_ptr<BackgroundShellApplicationLoader> loader(
220 new BackgroundShellApplicationLoader( 232 new BackgroundShellApplicationLoader(
221 scoped_ptr<ApplicationLoader>(new NetworkApplicationLoader()), 233 scoped_ptr<ApplicationLoader>(new NetworkApplicationLoader()),
222 "network_service", 234 "network_service",
223 base::MessageLoop::TYPE_IO)); 235 base::MessageLoop::TYPE_IO));
224 application_manager_.SetLoaderForURL(loader.PassAs<ApplicationLoader>(), 236 application_manager_.SetLoaderForURL(loader.PassAs<ApplicationLoader>(),
225 GURL("mojo:mojo_network_service")); 237 GURL("mojo:mojo_network_service"));
226 } 238 }
227 #endif 239 #endif
240
241 if (listener_)
242 listener_->WaitForListening();
228 } 243 }
229 244
230 void Context::OnApplicationError(const GURL& gurl) { 245 void Context::OnApplicationError(const GURL& gurl) {
231 if (app_urls_.find(gurl) != app_urls_.end()) { 246 if (app_urls_.find(gurl) != app_urls_.end()) {
232 app_urls_.erase(gurl); 247 app_urls_.erase(gurl);
233 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) 248 if (app_urls_.empty() && base::MessageLoop::current()->is_running())
234 base::MessageLoop::current()->Quit(); 249 base::MessageLoop::current()->Quit();
235 } 250 }
236 } 251 }
237 252
238 void Context::Run(const GURL& url) { 253 void Context::Run(const GURL& url) {
239 EmptyServiceProvider* sp = new EmptyServiceProvider; 254 EmptyServiceProvider* sp = new EmptyServiceProvider;
240 ServiceProviderPtr spp; 255 ServiceProviderPtr spp;
241 BindToProxy(sp, &spp); 256 BindToProxy(sp, &spp);
242 257
243 app_urls_.insert(url); 258 app_urls_.insert(url);
244 application_manager_.ConnectToApplication(url, GURL(), spp.Pass()); 259 application_manager_.ConnectToApplication(url, GURL(), spp.Pass());
245 } 260 }
246 261
247 ScopedMessagePipeHandle Context::ConnectToServiceByName( 262 ScopedMessagePipeHandle Context::ConnectToServiceByName(
248 const GURL& application_url, 263 const GURL& application_url,
249 const std::string& service_name) { 264 const std::string& service_name) {
250 app_urls_.insert(application_url); 265 app_urls_.insert(application_url);
251 return application_manager_.ConnectToServiceByName( 266 return application_manager_.ConnectToServiceByName(
252 application_url, service_name).Pass(); 267 application_url, service_name).Pass();
253 } 268 }
254 269
255 } // namespace shell 270 } // namespace shell
256 } // namespace mojo 271 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/context.h ('k') | mojo/shell/external_application_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698