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

Unified Diff: content/browser/browser_main_loop.cc

Issue 879703003: Make in-process gpu init thread safe (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/browser_main_loop.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/browser_main_loop.cc
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc
index 64e3446bcce54b75ed116e3820d246929c916dcc..51f59e37b4d9d7d1a9b38816e5deef8d6e84faf4 100644
--- a/content/browser/browser_main_loop.cc
+++ b/content/browser/browser_main_loop.cc
@@ -394,8 +394,7 @@ void BrowserMainLoop::EarlyInitialization() {
#endif
#if defined(USE_X11)
- if (parsed_command_line_.HasSwitch(switches::kSingleProcess) ||
- parsed_command_line_.HasSwitch(switches::kInProcessGPU)) {
+ if (UsingInProcessGpu()) {
if (!gfx::InitializeThreadedX11()) {
LOG(ERROR) << "Failed to put Xlib into threaded mode.";
}
@@ -617,6 +616,11 @@ int BrowserMainLoop::PreCreateThreads() {
if (parsed_command_line_.HasSwitch(switches::kSingleProcess))
RenderProcessHost::SetRunRendererInProcess(true);
#endif
+
+ if (UsingInProcessGpu()) {
+ InitializeGpuDataManager();
+ }
+
return result_code_;
}
@@ -1024,20 +1028,9 @@ int BrowserMainLoop::BrowserThreadsStarted() {
#if !defined(OS_IOS)
HistogramSynchronizer::GetInstance();
- bool initialize_gpu_data_manager = true;
-#if defined(OS_ANDROID)
- // On Android, GLSurface::InitializeOneOff() must be called before initalizing
boliu 2015/01/26 23:56:09 Pasting your comment over. On 2015/01/26 19:51:45
- // the GpuDataManagerImpl as it uses the GL bindings. crbug.com/326295
- if (!gfx::GLSurface::InitializeOneOff()) {
- LOG(ERROR) << "GLSurface::InitializeOneOff failed";
- initialize_gpu_data_manager = false;
+ if (!UsingInProcessGpu()) {
+ InitializeGpuDataManager();
}
-#endif
-
- // Initialize the GpuDataManager before we set up the MessageLoops because
- // otherwise we'll trigger the assertion about doing IO on the UI thread.
- if (initialize_gpu_data_manager)
- GpuDataManagerImpl::GetInstance()->Initialize();
bool always_uses_gpu = true;
bool established_gpu_channel = false;
@@ -1118,8 +1111,7 @@ int BrowserMainLoop::BrowserThreadsStarted() {
if (GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(NULL) &&
!established_gpu_channel &&
always_uses_gpu &&
- !parsed_command_line_.HasSwitch(switches::kSingleProcess) &&
- !parsed_command_line_.HasSwitch(switches::kInProcessGPU)) {
+ !UsingInProcessGpu()) {
TRACE_EVENT_INSTANT0("gpu", "Post task to launch GPU process",
TRACE_EVENT_SCOPE_THREAD);
BrowserThread::PostTask(
@@ -1144,6 +1136,28 @@ int BrowserMainLoop::BrowserThreadsStarted() {
return result_code_;
}
+bool BrowserMainLoop::UsingInProcessGpu() const {
+ return parsed_command_line_.HasSwitch(switches::kSingleProcess) ||
+ parsed_command_line_.HasSwitch(switches::kInProcessGPU);
+}
+
+void BrowserMainLoop::InitializeGpuDataManager() {
+ bool initialize_gpu_data_manager = true;
+#if defined(OS_ANDROID)
+ // On Android, GLSurface::InitializeOneOff() must be called before initalizing
+ // the GpuDataManagerImpl as it uses the GL bindings. crbug.com/326295
+ if (!gfx::GLSurface::InitializeOneOff()) {
+ LOG(ERROR) << "GLSurface::InitializeOneOff failed";
+ initialize_gpu_data_manager = false;
+ }
+#endif
+
+ // Initialize the GpuDataManager before we set up the MessageLoops because
+ // otherwise we'll trigger the assertion about doing IO on the UI thread.
+ if (initialize_gpu_data_manager)
+ GpuDataManagerImpl::GetInstance()->Initialize();
+}
+
bool BrowserMainLoop::InitializeToolkit() {
TRACE_EVENT0("startup", "BrowserMainLoop::InitializeToolkit");
// TODO(evan): this function is rather subtle, due to the variety
« no previous file with comments | « content/browser/browser_main_loop.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698