OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/browser_main_loop.h" | 5 #include "content/browser/browser_main_loop.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
15 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
16 #include "content/browser/browser_thread_impl.h" | 16 #include "content/browser/browser_thread_impl.h" |
17 #include "content/browser/download/download_file_manager.h" | 17 #include "content/browser/download/download_file_manager.h" |
18 #include "content/browser/download/save_file_manager.h" | 18 #include "content/browser/download/save_file_manager.h" |
19 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 19 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 20 #include "content/browser/gpu/gpu_process_host.h" |
20 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 21 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
21 #include "content/browser/in_process_webkit/webkit_thread.h" | 22 #include "content/browser/in_process_webkit/webkit_thread.h" |
22 #include "content/browser/plugin_service_impl.h" | 23 #include "content/browser/plugin_service_impl.h" |
23 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 24 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
24 #include "content/browser/trace_controller.h" | 25 #include "content/browser/trace_controller.h" |
25 #include "content/common/hi_res_timer_manager.h" | 26 #include "content/common/hi_res_timer_manager.h" |
26 #include "content/common/sandbox_policy.h" | 27 #include "content/common/sandbox_policy.h" |
27 #include "content/public/browser/browser_main_parts.h" | 28 #include "content/public/browser/browser_main_parts.h" |
28 #include "content/public/browser/browser_shutdown.h" | 29 #include "content/public/browser/browser_shutdown.h" |
29 #include "content/public/browser/content_browser_client.h" | 30 #include "content/public/browser/content_browser_client.h" |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 #endif | 423 #endif |
423 | 424 |
424 BrowserThreadsStarted(); | 425 BrowserThreadsStarted(); |
425 | 426 |
426 if (parts_.get()) | 427 if (parts_.get()) |
427 parts_->PreMainMessageLoopRun(); | 428 parts_->PreMainMessageLoopRun(); |
428 | 429 |
429 // If the UI thread blocks, the whole UI is unresponsive. | 430 // If the UI thread blocks, the whole UI is unresponsive. |
430 // Do not allow disk IO from the UI thread. | 431 // Do not allow disk IO from the UI thread. |
431 base::ThreadRestrictions::SetIOAllowed(false); | 432 base::ThreadRestrictions::SetIOAllowed(false); |
| 433 |
| 434 BrowserThread::PostDelayedTask( |
| 435 BrowserThread::IO, FROM_HERE, base::Bind( |
| 436 base::IgnoreResult(&GpuProcessHost::GetForClient), |
| 437 1, // Arbitrary non-0 (to cause sandboxing) client_id. |
| 438 content::CAUSE_FOR_GPU_LAUNCH_BROWSER_STARTUP), |
| 439 // Arbitrary delay to avoid allow browser init precious CPU cycles. |
| 440 base::TimeDelta::FromSeconds(5)); |
432 } | 441 } |
433 | 442 |
434 void BrowserMainLoop::RunMainMessageLoopParts() { | 443 void BrowserMainLoop::RunMainMessageLoopParts() { |
435 TRACE_EVENT_BEGIN_ETW("BrowserMain:MESSAGE_LOOP", 0, ""); | 444 TRACE_EVENT_BEGIN_ETW("BrowserMain:MESSAGE_LOOP", 0, ""); |
436 | 445 |
437 bool ran_main_loop = false; | 446 bool ran_main_loop = false; |
438 if (parts_.get()) | 447 if (parts_.get()) |
439 ran_main_loop = parts_->MainMessageLoopRun(&result_code_); | 448 ran_main_loop = parts_->MainMessageLoopRun(&result_code_); |
440 | 449 |
441 if (!ran_main_loop) | 450 if (!ran_main_loop) |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); | 637 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); |
629 | 638 |
630 #if defined(OS_MACOSX) | 639 #if defined(OS_MACOSX) |
631 MessageLoopForUI::current()->Run(); | 640 MessageLoopForUI::current()->Run(); |
632 #else | 641 #else |
633 MessageLoopForUI::current()->RunWithDispatcher(NULL); | 642 MessageLoopForUI::current()->RunWithDispatcher(NULL); |
634 #endif | 643 #endif |
635 } | 644 } |
636 | 645 |
637 } // namespace content | 646 } // namespace content |
OLD | NEW |