OLD | NEW |
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 "shell/context.h" | 5 #include "shell/context.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 mojo::embedder::Init( | 54 mojo::embedder::Init( |
55 make_scoped_ptr(new mojo::embedder::SimplePlatformSupport())); | 55 make_scoped_ptr(new mojo::embedder::SimplePlatformSupport())); |
56 } | 56 } |
57 | 57 |
58 ~Setup() {} | 58 ~Setup() {} |
59 | 59 |
60 private: | 60 private: |
61 DISALLOW_COPY_AND_ASSIGN(Setup); | 61 DISALLOW_COPY_AND_ASSIGN(Setup); |
62 }; | 62 }; |
63 | 63 |
| 64 ApplicationManager::Options MakeApplicationManagerOptions() { |
| 65 ApplicationManager::Options options; |
| 66 options.disable_cache = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 67 switches::kDisableCache); |
| 68 options.predictable_app_filenames = |
| 69 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 70 switches::kPredictableAppFilenames); |
| 71 return options; |
| 72 } |
| 73 |
64 bool ConfigureURLMappings(const base::CommandLine& command_line, | 74 bool ConfigureURLMappings(const base::CommandLine& command_line, |
65 Context* context) { | 75 Context* context) { |
66 URLResolver* resolver = context->url_resolver(); | 76 URLResolver* resolver = context->url_resolver(); |
67 | 77 |
68 // Configure the resolution of unknown mojo: URLs. | 78 // Configure the resolution of unknown mojo: URLs. |
69 GURL base_url; | 79 GURL base_url; |
70 if (command_line.HasSwitch(switches::kOrigin)) | 80 if (command_line.HasSwitch(switches::kOrigin)) |
71 base_url = GURL(command_line.GetSwitchValueASCII(switches::kOrigin)); | 81 base_url = GURL(command_line.GetSwitchValueASCII(switches::kOrigin)); |
72 else | 82 else |
73 // Use the shell's file root if the base was not specified. | 83 // Use the shell's file root if the base was not specified. |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 204 |
195 private: | 205 private: |
196 Tracer* tracer_; | 206 Tracer* tracer_; |
197 mojo::StrongBinding<mojo::ServiceProvider> binding_; | 207 mojo::StrongBinding<mojo::ServiceProvider> binding_; |
198 | 208 |
199 DISALLOW_COPY_AND_ASSIGN(TracingServiceProvider); | 209 DISALLOW_COPY_AND_ASSIGN(TracingServiceProvider); |
200 }; | 210 }; |
201 | 211 |
202 } // namespace | 212 } // namespace |
203 | 213 |
204 Context::Context(Tracer* tracer) : tracer_(tracer), application_manager_(this) { | 214 Context::Context(Tracer* tracer) |
| 215 : tracer_(tracer), |
| 216 application_manager_(MakeApplicationManagerOptions(), this) { |
205 DCHECK(!base::MessageLoop::current()); | 217 DCHECK(!base::MessageLoop::current()); |
206 | 218 |
207 // By default assume that the local apps reside alongside the shell. | 219 // By default assume that the local apps reside alongside the shell. |
208 // TODO(ncbray): really, this should be passed in rather than defaulting. | 220 // TODO(ncbray): really, this should be passed in rather than defaulting. |
209 // This default makes sense for desktop but not Android. | 221 // This default makes sense for desktop but not Android. |
210 base::FilePath shell_dir; | 222 base::FilePath shell_dir; |
211 PathService::Get(base::DIR_MODULE, &shell_dir); | 223 PathService::Get(base::DIR_MODULE, &shell_dir); |
212 SetShellFileRoot(shell_dir); | 224 SetShellFileRoot(shell_dir); |
213 | 225 |
214 base::FilePath cwd; | 226 base::FilePath cwd; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 mojo::embedder::ProcessType::NONE, task_runners_->shell_runner(), this, | 294 mojo::embedder::ProcessType::NONE, task_runners_->shell_runner(), this, |
283 task_runners_->io_runner(), mojo::embedder::ScopedPlatformHandle()); | 295 task_runners_->io_runner(), mojo::embedder::ScopedPlatformHandle()); |
284 | 296 |
285 scoped_ptr<NativeRunnerFactory> runner_factory; | 297 scoped_ptr<NativeRunnerFactory> runner_factory; |
286 if (command_line.HasSwitch(switches::kEnableMultiprocess)) | 298 if (command_line.HasSwitch(switches::kEnableMultiprocess)) |
287 runner_factory.reset(new OutOfProcessNativeRunnerFactory(this)); | 299 runner_factory.reset(new OutOfProcessNativeRunnerFactory(this)); |
288 else | 300 else |
289 runner_factory.reset(new InProcessNativeRunnerFactory(this)); | 301 runner_factory.reset(new InProcessNativeRunnerFactory(this)); |
290 application_manager_.set_blocking_pool(task_runners_->blocking_pool()); | 302 application_manager_.set_blocking_pool(task_runners_->blocking_pool()); |
291 application_manager_.set_native_runner_factory(runner_factory.Pass()); | 303 application_manager_.set_native_runner_factory(runner_factory.Pass()); |
292 application_manager_.set_disable_cache( | |
293 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
294 switches::kDisableCache)); | |
295 | 304 |
296 InitContentHandlers(&application_manager_, command_line); | 305 InitContentHandlers(&application_manager_, command_line); |
297 InitNativeOptions(&application_manager_, command_line); | 306 InitNativeOptions(&application_manager_, command_line); |
298 | 307 |
299 ServiceProviderPtr tracing_services; | 308 ServiceProviderPtr tracing_services; |
300 ServiceProviderPtr tracing_exposed_services; | 309 ServiceProviderPtr tracing_exposed_services; |
301 new TracingServiceProvider(tracer_, GetProxy(&tracing_exposed_services)); | 310 new TracingServiceProvider(tracer_, GetProxy(&tracing_exposed_services)); |
302 application_manager_.ConnectToApplication( | 311 application_manager_.ConnectToApplication( |
303 GURL("mojo:tracing"), GURL(""), GetProxy(&tracing_services), | 312 GURL("mojo:tracing"), GURL(""), GetProxy(&tracing_services), |
304 tracing_exposed_services.Pass(), base::Closure()); | 313 tracing_exposed_services.Pass(), base::Closure()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 app_urls_.erase(url); | 362 app_urls_.erase(url); |
354 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) { | 363 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) { |
355 DCHECK_EQ(base::MessageLoop::current()->task_runner(), | 364 DCHECK_EQ(base::MessageLoop::current()->task_runner(), |
356 task_runners_->shell_runner()); | 365 task_runners_->shell_runner()); |
357 base::MessageLoop::current()->Quit(); | 366 base::MessageLoop::current()->Quit(); |
358 } | 367 } |
359 } | 368 } |
360 } | 369 } |
361 | 370 |
362 } // namespace shell | 371 } // namespace shell |
OLD | NEW |