Index: chrome/browser/chrome_browser_main.cc |
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc |
index b7986bf8dd6c73b6f1d8a930eefc1d729e86d0b4..c64965cff39e812b7a4a778c6f50fdfe3610e2a7 100644 |
--- a/chrome/browser/chrome_browser_main.cc |
+++ b/chrome/browser/chrome_browser_main.cc |
@@ -859,8 +859,8 @@ void ChromeBrowserMainParts::PostMainMessageLoopStart() { |
chrome_extra_parts_[i]->PostMainMessageLoopStart(); |
} |
-int ChromeBrowserMainParts::PreCreateThreads() { |
- TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreads"); |
+int ChromeBrowserMainParts::PreCreateThreadsBegin() { |
+ TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreadsBegin"); |
result_code_ = PreCreateThreadsImpl(); |
if (result_code_ == content::RESULT_CODE_NORMAL_EXIT) { |
@@ -870,7 +870,7 @@ int ChromeBrowserMainParts::PreCreateThreads() { |
DCHECK(browser_creator_.get()); |
#endif // !defined(OS_ANDROID) |
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
- chrome_extra_parts_[i]->PreCreateThreads(); |
+ chrome_extra_parts_[i]->PreCreateThreadsBegin(); |
} |
return result_code_; |
@@ -1116,6 +1116,25 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { |
return content::RESULT_CODE_NORMAL_EXIT; |
} |
+void ChromeBrowserMainParts::PreCreateThreadsEnd() { |
+ // It is important to call gl_string_manager()->Initialize() before starting |
+ // the gpu process. Internally it properly setup the black listed features. |
+ // Which it is used to decide whether to start or not the gpu process from |
+ // BrowserMainLoop::BrowserThreadsStarted. |
+ |
+ // Retrieve cached GL strings from local state and use them for GPU |
+ // blacklist decisions. |
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
+ |
+ if (!command_line->HasSwitch("do-init-after-starting-gpu-process")) { |
+ if (g_browser_process->gl_string_manager()) |
+ g_browser_process->gl_string_manager()->Initialize(); |
+ |
+ // Create an instance of GpuModeManager to watch gpu mode pref change. |
+ g_browser_process->gpu_mode_manager(); |
+ } |
+} |
+ |
void ChromeBrowserMainParts::PreMainMessageLoopRun() { |
TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRun"); |
TRACK_SCOPED_REGION( |
@@ -1481,13 +1500,16 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { |
// (requires supporting early exit). |
PostProfileInit(); |
- // Retrieve cached GL strings from local state and use them for GPU |
- // blacklist decisions. |
- if (g_browser_process->gl_string_manager()) |
- g_browser_process->gl_string_manager()->Initialize(); |
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
+ |
+ if (command_line->HasSwitch("do-init-after-starting-gpu-process")) { |
+ VLOG(1) << "do init after starting gpu process"; |
+ if (g_browser_process->gl_string_manager()) |
+ g_browser_process->gl_string_manager()->Initialize(); |
- // Create an instance of GpuModeManager to watch gpu mode pref change. |
- g_browser_process->gpu_mode_manager(); |
+ // Create an instance of GpuModeManager to watch gpu mode pref change. |
+ g_browser_process->gpu_mode_manager(); |
+ } |
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) |
// Show the First Run UI if this is the first time Chrome has been run on |