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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 | 601 |
602 // RDH needs the IO thread to be created. | 602 // RDH needs the IO thread to be created. |
603 resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl()); | 603 resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl()); |
604 | 604 |
605 #if defined(ENABLE_INPUT_SPEECH) | 605 #if defined(ENABLE_INPUT_SPEECH) |
606 speech_recognition_manager_.reset(new speech::SpeechRecognitionManagerImpl()); | 606 speech_recognition_manager_.reset(new speech::SpeechRecognitionManagerImpl()); |
607 #endif | 607 #endif |
608 | 608 |
609 // Start the GpuDataManager before we set up the MessageLoops because | 609 // Start the GpuDataManager before we set up the MessageLoops because |
610 // otherwise we'll trigger the assertion about doing IO on the UI thread. | 610 // otherwise we'll trigger the assertion about doing IO on the UI thread. |
611 content::GpuDataManager::GetInstance(); | 611 GpuDataManager* gpu_data_manager = 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 } |
612 } | 627 } |
613 | 628 |
614 void BrowserMainLoop::InitializeToolkit() { | 629 void BrowserMainLoop::InitializeToolkit() { |
615 // TODO(evan): this function is rather subtle, due to the variety | 630 // TODO(evan): this function is rather subtle, due to the variety |
616 // of intersecting ifdefs we have. To keep it easy to follow, there | 631 // of intersecting ifdefs we have. To keep it easy to follow, there |
617 // are no #else branches on any #ifs. | 632 // are no #else branches on any #ifs. |
618 // TODO(stevenjb): Move platform specific code into platform specific Parts | 633 // TODO(stevenjb): Move platform specific code into platform specific Parts |
619 // (Need to add InitializeToolkit stage to BrowserParts). | 634 // (Need to add InitializeToolkit stage to BrowserParts). |
620 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 635 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
621 // Glib type system initialization. Needed at least for gconf, | 636 // Glib type system initialization. Needed at least for gconf, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); | 674 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); |
660 if (parameters_.ui_task) | 675 if (parameters_.ui_task) |
661 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); | 676 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); |
662 | 677 |
663 base::RunLoop run_loop; | 678 base::RunLoop run_loop; |
664 run_loop.Run(); | 679 run_loop.Run(); |
665 #endif | 680 #endif |
666 } | 681 } |
667 | 682 |
668 } // namespace content | 683 } // namespace content |
OLD | NEW |