| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 257 |
| 258 GURL Context::ResolveCommandLineURL(const std::string& path) { | 258 GURL Context::ResolveCommandLineURL(const std::string& path) { |
| 259 return command_line_cwd_.Resolve(path); | 259 return command_line_cwd_.Resolve(path); |
| 260 } | 260 } |
| 261 | 261 |
| 262 bool Context::Init() { | 262 bool Context::Init() { |
| 263 base::FilePath shell_path = base::MakeAbsoluteFilePath( | 263 base::FilePath shell_path = base::MakeAbsoluteFilePath( |
| 264 base::CommandLine::ForCurrentProcess()->GetProgram()); | 264 base::CommandLine::ForCurrentProcess()->GetProgram()); |
| 265 base::FilePath shell_child_path = | 265 base::FilePath shell_child_path = |
| 266 shell_path.DirName().AppendASCII("mojo_shell_child"); | 266 shell_path.DirName().AppendASCII("mojo_shell_child"); |
| 267 return InitWithPaths(shell_child_path); | 267 return InitWithPaths(shell_child_path, nullptr); |
| 268 } | 268 } |
| 269 | 269 |
| 270 bool Context::InitWithPaths(const base::FilePath& shell_child_path) { | 270 bool Context::InitWithPaths( |
| 271 const base::FilePath& shell_child_path, |
| 272 mojo::URLResponseDiskCacheDelegate* url_response_disk_cache_delegate) { |
| 271 TRACE_EVENT0("mojo_shell", "Context::InitWithPaths"); | 273 TRACE_EVENT0("mojo_shell", "Context::InitWithPaths"); |
| 272 const base::CommandLine& command_line = | 274 const base::CommandLine& command_line = |
| 273 *base::CommandLine::ForCurrentProcess(); | 275 *base::CommandLine::ForCurrentProcess(); |
| 274 | 276 |
| 275 if (command_line.HasSwitch(switches::kWaitForDebugger)) | 277 if (command_line.HasSwitch(switches::kWaitForDebugger)) |
| 276 base::debug::WaitForDebugger(60, true); | 278 base::debug::WaitForDebugger(60, true); |
| 277 | 279 |
| 278 mojo_shell_child_path_ = shell_child_path; | 280 mojo_shell_child_path_ = shell_child_path; |
| 279 | 281 |
| 280 task_runners_.reset( | 282 task_runners_.reset( |
| 281 new TaskRunners(base::MessageLoop::current()->message_loop_proxy())); | 283 new TaskRunners(base::MessageLoop::current()->message_loop_proxy())); |
| 282 | 284 |
| 283 #if !defined(OS_MACOSX) | 285 #if !defined(OS_MACOSX) |
| 284 application_manager()->SetLoaderForURL( | 286 application_manager()->SetLoaderForURL( |
| 285 make_scoped_ptr(new BackgroundApplicationLoader( | 287 make_scoped_ptr(new BackgroundApplicationLoader( |
| 286 make_scoped_ptr( | 288 make_scoped_ptr( |
| 287 new URLResponseDiskCacheLoader(task_runners_->blocking_pool())), | 289 new URLResponseDiskCacheLoader(task_runners_->blocking_pool(), |
| 290 url_response_disk_cache_delegate)), |
| 288 "url_response_disk_cache", base::MessageLoop::TYPE_DEFAULT)), | 291 "url_response_disk_cache", base::MessageLoop::TYPE_DEFAULT)), |
| 289 GURL("mojo:url_response_disk_cache")); | 292 GURL("mojo:url_response_disk_cache")); |
| 290 #endif | 293 #endif |
| 291 | 294 |
| 292 EnsureEmbedderIsInitialized(); | 295 EnsureEmbedderIsInitialized(); |
| 293 | 296 |
| 294 // TODO(vtl): Probably these failures should be checked before |Init()|, and | 297 // TODO(vtl): Probably these failures should be checked before |Init()|, and |
| 295 // this function simply shouldn't fail. | 298 // this function simply shouldn't fail. |
| 296 if (!shell_file_root_.is_valid()) | 299 if (!shell_file_root_.is_valid()) |
| 297 return false; | 300 return false; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 app_urls_.erase(url); | 384 app_urls_.erase(url); |
| 382 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) { | 385 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) { |
| 383 DCHECK_EQ(base::MessageLoop::current()->task_runner(), | 386 DCHECK_EQ(base::MessageLoop::current()->task_runner(), |
| 384 task_runners_->shell_runner()); | 387 task_runners_->shell_runner()); |
| 385 base::MessageLoop::current()->Quit(); | 388 base::MessageLoop::current()->Quit(); |
| 386 } | 389 } |
| 387 } | 390 } |
| 388 } | 391 } |
| 389 | 392 |
| 390 } // namespace shell | 393 } // namespace shell |
| OLD | NEW |