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 |