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/hi_res_timer_manager.h" | 10 #include "base/hi_res_timer_manager.h" |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 } else { | 430 } else { |
431 NOTREACHED(); | 431 NOTREACHED(); |
432 } | 432 } |
433 } | 433 } |
434 | 434 |
435 BrowserThreadsStarted(); | 435 BrowserThreadsStarted(); |
436 | 436 |
437 if (parts_.get()) | 437 if (parts_.get()) |
438 parts_->PreMainMessageLoopRun(); | 438 parts_->PreMainMessageLoopRun(); |
439 | 439 |
| 440 // When running the GPU thread in-process, avoid optimistically starting it |
| 441 // since creating the GPU thread races against creation of the one-and-only |
| 442 // ChildProcess instance which is created by the renderer thread. |
| 443 GpuDataManager* gpu_data_manager = content::GpuDataManager::GetInstance(); |
| 444 if (gpu_data_manager->GpuAccessAllowed() && |
| 445 !parsed_command_line_.HasSwitch(switches::kDisableGpuProcessPrelaunch) && |
| 446 !parsed_command_line_.HasSwitch(switches::kSingleProcess) && |
| 447 !parsed_command_line_.HasSwitch(switches::kInProcessGPU)) { |
| 448 TRACE_EVENT_INSTANT0("gpu", "Post task to launch GPU process"); |
| 449 BrowserThread::PostTask( |
| 450 BrowserThread::IO, FROM_HERE, base::Bind( |
| 451 base::IgnoreResult(&GpuProcessHost::Get), |
| 452 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
| 453 content::CAUSE_FOR_GPU_LAUNCH_BROWSER_STARTUP)); |
| 454 } |
| 455 |
440 // If the UI thread blocks, the whole UI is unresponsive. | 456 // If the UI thread blocks, the whole UI is unresponsive. |
441 // Do not allow disk IO from the UI thread. | 457 // Do not allow disk IO from the UI thread. |
442 base::ThreadRestrictions::SetIOAllowed(false); | 458 base::ThreadRestrictions::SetIOAllowed(false); |
443 base::ThreadRestrictions::DisallowWaiting(); | 459 base::ThreadRestrictions::DisallowWaiting(); |
444 } | 460 } |
445 | 461 |
446 void BrowserMainLoop::RunMainMessageLoopParts() { | 462 void BrowserMainLoop::RunMainMessageLoopParts() { |
447 TRACE_EVENT_BEGIN_ETW("BrowserMain:MESSAGE_LOOP", 0, ""); | 463 TRACE_EVENT_BEGIN_ETW("BrowserMain:MESSAGE_LOOP", 0, ""); |
448 | 464 |
449 bool ran_main_loop = false; | 465 bool ran_main_loop = false; |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 | 617 |
602 // RDH needs the IO thread to be created. | 618 // RDH needs the IO thread to be created. |
603 resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl()); | 619 resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl()); |
604 | 620 |
605 #if defined(ENABLE_INPUT_SPEECH) | 621 #if defined(ENABLE_INPUT_SPEECH) |
606 speech_recognition_manager_.reset(new speech::SpeechRecognitionManagerImpl()); | 622 speech_recognition_manager_.reset(new speech::SpeechRecognitionManagerImpl()); |
607 #endif | 623 #endif |
608 | 624 |
609 // Start the GpuDataManager before we set up the MessageLoops because | 625 // Start the GpuDataManager before we set up the MessageLoops because |
610 // otherwise we'll trigger the assertion about doing IO on the UI thread. | 626 // otherwise we'll trigger the assertion about doing IO on the UI thread. |
611 GpuDataManager* gpu_data_manager = content::GpuDataManager::GetInstance(); | 627 content::GpuDataManager::GetInstance(); |
612 | |
613 // When running the GPU thread in-process, avoid optimistically starting it | |
614 // since creating the GPU thread races against creation of the one-and-only | |
615 // ChildProcess instance which is created by the renderer thread. | |
616 if (gpu_data_manager->GpuAccessAllowed() && | |
617 !parsed_command_line_.HasSwitch(switches::kDisableGpuProcessPrelaunch) && | |
618 !parsed_command_line_.HasSwitch(switches::kSingleProcess) && | |
619 !parsed_command_line_.HasSwitch(switches::kInProcessGPU)) { | |
620 TRACE_EVENT_INSTANT0("gpu", "Post task to launch GPU process"); | |
621 BrowserThread::PostTask( | |
622 BrowserThread::IO, FROM_HERE, base::Bind( | |
623 base::IgnoreResult(&GpuProcessHost::Get), | |
624 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | |
625 content::CAUSE_FOR_GPU_LAUNCH_BROWSER_STARTUP)); | |
626 } | |
627 } | 628 } |
628 | 629 |
629 void BrowserMainLoop::InitializeToolkit() { | 630 void BrowserMainLoop::InitializeToolkit() { |
630 // TODO(evan): this function is rather subtle, due to the variety | 631 // TODO(evan): this function is rather subtle, due to the variety |
631 // of intersecting ifdefs we have. To keep it easy to follow, there | 632 // of intersecting ifdefs we have. To keep it easy to follow, there |
632 // are no #else branches on any #ifs. | 633 // are no #else branches on any #ifs. |
633 // TODO(stevenjb): Move platform specific code into platform specific Parts | 634 // TODO(stevenjb): Move platform specific code into platform specific Parts |
634 // (Need to add InitializeToolkit stage to BrowserParts). | 635 // (Need to add InitializeToolkit stage to BrowserParts). |
635 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 636 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
636 // Glib type system initialization. Needed at least for gconf, | 637 // Glib type system initialization. Needed at least for gconf, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); | 675 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); |
675 if (parameters_.ui_task) | 676 if (parameters_.ui_task) |
676 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); | 677 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); |
677 | 678 |
678 base::RunLoop run_loop; | 679 base::RunLoop run_loop; |
679 run_loop.Run(); | 680 run_loop.Run(); |
680 #endif | 681 #endif |
681 } | 682 } |
682 | 683 |
683 } // namespace content | 684 } // namespace content |
OLD | NEW |