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

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

Issue 1109993002: Adds support for mojo apps to live in their own directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge to trunk and move filename_util to own dir Created 5 years, 8 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/runner/BUILD.gn ('k') | mojo/runner/filename_util.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/runner/context.h" 5 #include "mojo/runner/context.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
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/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/scoped_vector.h" 15 #include "base/memory/scoped_vector.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "base/strings/string_split.h" 18 #include "base/strings/string_split.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "base/trace_event/trace_event.h" 20 #include "base/trace_event/trace_event.h"
21 #include "build/build_config.h" 21 #include "build/build_config.h"
22 #include "mojo/common/trace_controller_impl.h" 22 #include "mojo/common/trace_controller_impl.h"
23 #include "mojo/common/tracing_impl.h" 23 #include "mojo/common/tracing_impl.h"
24 #include "mojo/edk/embedder/embedder.h" 24 #include "mojo/edk/embedder/embedder.h"
25 #include "mojo/edk/embedder/simple_platform_support.h" 25 #include "mojo/edk/embedder/simple_platform_support.h"
26 #include "mojo/public/cpp/application/application_connection.h" 26 #include "mojo/public/cpp/application/application_connection.h"
27 #include "mojo/public/cpp/application/application_delegate.h" 27 #include "mojo/public/cpp/application/application_delegate.h"
28 #include "mojo/public/cpp/application/application_impl.h" 28 #include "mojo/public/cpp/application/application_impl.h"
29 #include "mojo/runner/filename_util.h"
30 #include "mojo/runner/in_process_native_runner.h" 29 #include "mojo/runner/in_process_native_runner.h"
31 #include "mojo/runner/out_of_process_native_runner.h" 30 #include "mojo/runner/out_of_process_native_runner.h"
32 #include "mojo/runner/switches.h" 31 #include "mojo/runner/switches.h"
33 #include "mojo/services/tracing/tracing.mojom.h" 32 #include "mojo/services/tracing/tracing.mojom.h"
34 #include "mojo/shell/application_loader.h" 33 #include "mojo/shell/application_loader.h"
35 #include "mojo/shell/application_manager.h" 34 #include "mojo/shell/application_manager.h"
35 #include "mojo/util/filename_util.h"
36 #include "url/gurl.h" 36 #include "url/gurl.h"
37 37
38 namespace mojo { 38 namespace mojo {
39 namespace shell { 39 namespace shell {
40 namespace { 40 namespace {
41 41
42 // Used to ensure we only init once. 42 // Used to ensure we only init once.
43 class Setup { 43 class Setup {
44 public: 44 public:
45 Setup() { 45 Setup() {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 DCHECK(!base::MessageLoop::current()); 210 DCHECK(!base::MessageLoop::current());
211 } 211 }
212 212
213 // static 213 // static
214 void Context::EnsureEmbedderIsInitialized() { 214 void Context::EnsureEmbedderIsInitialized() {
215 static base::LazyInstance<Setup>::Leaky setup = LAZY_INSTANCE_INITIALIZER; 215 static base::LazyInstance<Setup>::Leaky setup = LAZY_INSTANCE_INITIALIZER;
216 setup.Get(); 216 setup.Get();
217 } 217 }
218 218
219 void Context::SetShellFileRoot(const base::FilePath& path) { 219 void Context::SetShellFileRoot(const base::FilePath& path) {
220 shell_file_root_ = AddTrailingSlashIfNeeded(FilePathToFileURL(path)); 220 shell_file_root_ =
221 util::AddTrailingSlashIfNeeded(util::FilePathToFileURL(path));
221 } 222 }
222 223
223 GURL Context::ResolveShellFileURL(const std::string& path) { 224 GURL Context::ResolveShellFileURL(const std::string& path) {
224 return shell_file_root_.Resolve(path); 225 return shell_file_root_.Resolve(path);
225 } 226 }
226 227
227 void Context::SetCommandLineCWD(const base::FilePath& path) { 228 void Context::SetCommandLineCWD(const base::FilePath& path) {
228 command_line_cwd_ = AddTrailingSlashIfNeeded(FilePathToFileURL(path)); 229 command_line_cwd_ =
230 util::AddTrailingSlashIfNeeded(util::FilePathToFileURL(path));
229 } 231 }
230 232
231 GURL Context::ResolveCommandLineURL(const std::string& path) { 233 GURL Context::ResolveCommandLineURL(const std::string& path) {
232 return command_line_cwd_.Resolve(path); 234 return command_line_cwd_.Resolve(path);
233 } 235 }
234 236
235 bool Context::Init() { 237 bool Context::Init() {
236 TRACE_EVENT0("mojo_shell", "Context::Init"); 238 TRACE_EVENT0("mojo_shell", "Context::Init");
237 const base::CommandLine& command_line = 239 const base::CommandLine& command_line =
238 *base::CommandLine::ForCurrentProcess(); 240 *base::CommandLine::ForCurrentProcess();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) { 317 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) {
316 DCHECK_EQ(base::MessageLoop::current()->task_runner(), 318 DCHECK_EQ(base::MessageLoop::current()->task_runner(),
317 task_runners_->shell_runner()); 319 task_runners_->shell_runner());
318 base::MessageLoop::current()->Quit(); 320 base::MessageLoop::current()->Quit();
319 } 321 }
320 } 322 }
321 } 323 }
322 324
323 } // namespace shell 325 } // namespace shell
324 } // namespace mojo 326 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/runner/BUILD.gn ('k') | mojo/runner/filename_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698