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

Side by Side Diff: content/browser/browser_main_loop.cc

Issue 11469022: Start GPU process earlier (when force-compositing mode is enabled) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: combine reverted patch Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 14 matching lines...) Expand all
25 #include "content/browser/histogram_synchronizer.h" 25 #include "content/browser/histogram_synchronizer.h"
26 #include "content/browser/in_process_webkit/webkit_thread.h" 26 #include "content/browser/in_process_webkit/webkit_thread.h"
27 #include "content/browser/loader/resource_dispatcher_host_impl.h" 27 #include "content/browser/loader/resource_dispatcher_host_impl.h"
28 #include "content/browser/net/browser_online_state_observer.h" 28 #include "content/browser/net/browser_online_state_observer.h"
29 #include "content/browser/plugin_service_impl.h" 29 #include "content/browser/plugin_service_impl.h"
30 #include "content/browser/renderer_host/media/media_stream_manager.h" 30 #include "content/browser/renderer_host/media/media_stream_manager.h"
31 #include "content/browser/speech/speech_recognition_manager_impl.h" 31 #include "content/browser/speech/speech_recognition_manager_impl.h"
32 #include "content/browser/trace_controller_impl.h" 32 #include "content/browser/trace_controller_impl.h"
33 #include "content/public/browser/browser_main_parts.h" 33 #include "content/public/browser/browser_main_parts.h"
34 #include "content/public/browser/browser_shutdown.h" 34 #include "content/public/browser/browser_shutdown.h"
35 #include "content/public/browser/compositor_util.h"
35 #include "content/public/browser/content_browser_client.h" 36 #include "content/public/browser/content_browser_client.h"
36 #include "content/public/browser/render_process_host.h" 37 #include "content/public/browser/render_process_host.h"
37 #include "content/public/common/content_switches.h" 38 #include "content/public/common/content_switches.h"
38 #include "content/public/common/main_function_params.h" 39 #include "content/public/common/main_function_params.h"
39 #include "content/public/common/result_codes.h" 40 #include "content/public/common/result_codes.h"
40 #include "crypto/nss_util.h" 41 #include "crypto/nss_util.h"
41 #include "media/audio/audio_manager.h" 42 #include "media/audio/audio_manager.h"
42 #include "net/base/network_change_notifier.h" 43 #include "net/base/network_change_notifier.h"
43 #include "net/base/ssl_config_service.h" 44 #include "net/base/ssl_config_service.h"
44 #include "net/socket/client_socket_factory.h" 45 #include "net/socket/client_socket_factory.h"
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 } else { 459 } else {
459 NOTREACHED(); 460 NOTREACHED();
460 } 461 }
461 } 462 }
462 463
463 BrowserThreadsStarted(); 464 BrowserThreadsStarted();
464 465
465 if (parts_.get()) 466 if (parts_.get())
466 parts_->PreMainMessageLoopRun(); 467 parts_->PreMainMessageLoopRun();
467 468
468 #if !defined(OS_IOS)
469 // When running the GPU thread in-process, avoid optimistically starting it
470 // since creating the GPU thread races against creation of the one-and-only
471 // ChildProcess instance which is created by the renderer thread.
472 if (GpuDataManagerImpl::GetInstance()->GpuAccessAllowed() &&
473 !parsed_command_line_.HasSwitch(switches::kDisableGpuProcessPrelaunch) &&
474 !parsed_command_line_.HasSwitch(switches::kSingleProcess) &&
475 !parsed_command_line_.HasSwitch(switches::kInProcessGPU)) {
476 TRACE_EVENT_INSTANT0("gpu", "Post task to launch GPU process");
477 BrowserThread::PostTask(
478 BrowserThread::IO, FROM_HERE, base::Bind(
479 base::IgnoreResult(&GpuProcessHost::Get),
480 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED,
481 CAUSE_FOR_GPU_LAUNCH_BROWSER_STARTUP));
482 }
483 #endif // !defined(OS_IOS)
484
485 // If the UI thread blocks, the whole UI is unresponsive. 469 // If the UI thread blocks, the whole UI is unresponsive.
486 // Do not allow disk IO from the UI thread. 470 // Do not allow disk IO from the UI thread.
487 base::ThreadRestrictions::SetIOAllowed(false); 471 base::ThreadRestrictions::SetIOAllowed(false);
488 base::ThreadRestrictions::DisallowWaiting(); 472 base::ThreadRestrictions::DisallowWaiting();
489 } 473 }
490 474
491 void BrowserMainLoop::RunMainMessageLoopParts() { 475 void BrowserMainLoop::RunMainMessageLoopParts() {
492 TRACE_EVENT_BEGIN_ETW("BrowserMain:MESSAGE_LOOP", 0, ""); 476 TRACE_EVENT_BEGIN_ETW("BrowserMain:MESSAGE_LOOP", 0, "");
493 477
494 bool ran_main_loop = false; 478 bool ran_main_loop = false;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 // clipboard: 672 // clipboard:
689 std::vector<base::PlatformThreadId> allowed_clipboard_threads; 673 std::vector<base::PlatformThreadId> allowed_clipboard_threads;
690 // The current thread is the UI thread. 674 // The current thread is the UI thread.
691 allowed_clipboard_threads.push_back(base::PlatformThread::CurrentId()); 675 allowed_clipboard_threads.push_back(base::PlatformThread::CurrentId());
692 #if defined(OS_WIN) 676 #if defined(OS_WIN)
693 // On Windows, clipboards are also used on the File or IO threads. 677 // On Windows, clipboards are also used on the File or IO threads.
694 allowed_clipboard_threads.push_back(file_thread_->thread_id()); 678 allowed_clipboard_threads.push_back(file_thread_->thread_id());
695 allowed_clipboard_threads.push_back(io_thread_->thread_id()); 679 allowed_clipboard_threads.push_back(io_thread_->thread_id());
696 #endif 680 #endif
697 ui::Clipboard::SetAllowedThreads(allowed_clipboard_threads); 681 ui::Clipboard::SetAllowedThreads(allowed_clipboard_threads);
682
683 // When running the GPU thread in-process, avoid optimistically starting it
684 // since creating the GPU thread races against creation of the one-and-only
685 // ChildProcess instance which is created by the renderer thread.
686 if (GpuDataManagerImpl::GetInstance()->GpuAccessAllowed() &&
687 content::IsForceCompositingModeEnabled() &&
688 !parsed_command_line_.HasSwitch(switches::kDisableGpuProcessPrelaunch) &&
689 !parsed_command_line_.HasSwitch(switches::kSingleProcess) &&
690 !parsed_command_line_.HasSwitch(switches::kInProcessGPU)) {
691 TRACE_EVENT_INSTANT0("gpu", "Post task to launch GPU process");
692 BrowserThread::PostTask(
693 BrowserThread::IO, FROM_HERE, base::Bind(
694 base::IgnoreResult(&GpuProcessHost::Get),
695 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED,
696 CAUSE_FOR_GPU_LAUNCH_BROWSER_STARTUP));
697 }
698 #endif // !defined(OS_IOS) 698 #endif // !defined(OS_IOS)
699 } 699 }
700 700
701 void BrowserMainLoop::InitializeToolkit() { 701 void BrowserMainLoop::InitializeToolkit() {
702 // TODO(evan): this function is rather subtle, due to the variety 702 // TODO(evan): this function is rather subtle, due to the variety
703 // of intersecting ifdefs we have. To keep it easy to follow, there 703 // of intersecting ifdefs we have. To keep it easy to follow, there
704 // are no #else branches on any #ifs. 704 // are no #else branches on any #ifs.
705 // TODO(stevenjb): Move platform specific code into platform specific Parts 705 // TODO(stevenjb): Move platform specific code into platform specific Parts
706 // (Need to add InitializeToolkit stage to BrowserParts). 706 // (Need to add InitializeToolkit stage to BrowserParts).
707 #if defined(OS_LINUX) || defined(OS_OPENBSD) 707 #if defined(OS_LINUX) || defined(OS_OPENBSD)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); 746 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type());
747 if (parameters_.ui_task) 747 if (parameters_.ui_task)
748 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); 748 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task);
749 749
750 base::RunLoop run_loop; 750 base::RunLoop run_loop;
751 run_loop.Run(); 751 run_loop.Run();
752 #endif 752 #endif
753 } 753 }
754 754
755 } // namespace content 755 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698