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

Side by Side Diff: content/gpu/gpu_main.cc

Issue 10386185: Add trace events to measure GPU process startup timing and time to first present. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
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 <stdlib.h> 5 #include <stdlib.h>
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #endif 9 #endif
10 10
11 #include "base/debug/trace_event.h"
11 #include "base/environment.h" 12 #include "base/environment.h"
12 #include "base/message_loop.h" 13 #include "base/message_loop.h"
13 #include "base/rand_util.h" 14 #include "base/rand_util.h"
14 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
15 #include "base/threading/platform_thread.h" 16 #include "base/threading/platform_thread.h"
16 #include "base/win/scoped_com_initializer.h" 17 #include "base/win/scoped_com_initializer.h"
17 #include "build/build_config.h" 18 #include "build/build_config.h"
18 #include "content/common/gpu/gpu_config.h" 19 #include "content/common/gpu/gpu_config.h"
19 #include "content/gpu/gpu_child_thread.h" 20 #include "content/gpu/gpu_child_thread.h"
20 #include "content/gpu/gpu_info_collector.h" 21 #include "content/gpu/gpu_info_collector.h"
(...skipping 13 matching lines...) Expand all
34 #if defined(USE_X11) 35 #if defined(USE_X11)
35 #include "ui/base/x/x11_util.h" 36 #include "ui/base/x/x11_util.h"
36 #endif 37 #endif
37 38
38 #if defined(OS_LINUX) 39 #if defined(OS_LINUX)
39 #include "content/public/common/sandbox_init.h" 40 #include "content/public/common/sandbox_init.h"
40 #endif 41 #endif
41 42
42 // Main function for starting the Gpu process. 43 // Main function for starting the Gpu process.
43 int GpuMain(const content::MainFunctionParams& parameters) { 44 int GpuMain(const content::MainFunctionParams& parameters) {
45 TRACE_EVENT0("gpu", "GpuMain");
46
44 base::Time start_time = base::Time::Now(); 47 base::Time start_time = base::Time::Now();
45 48
46 const CommandLine& command_line = parameters.command_line; 49 const CommandLine& command_line = parameters.command_line;
47 if (command_line.HasSwitch(switches::kGpuStartupDialog)) { 50 if (command_line.HasSwitch(switches::kGpuStartupDialog)) {
48 ChildProcess::WaitForDebugger("Gpu"); 51 ChildProcess::WaitForDebugger("Gpu");
49 } 52 }
50 53
51 if (!command_line.HasSwitch(switches::kSingleProcess)) { 54 if (!command_line.HasSwitch(switches::kSingleProcess)) {
52 #if defined(OS_WIN) 55 #if defined(OS_WIN)
53 // Prevent Windows from displaying a modal dialog on failures like not being 56 // Prevent Windows from displaying a modal dialog on failures like not being
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 #endif 96 #endif
94 97
95 // Set the GPU info even if it failed. 98 // Set the GPU info even if it failed.
96 content::GetContentClient()->SetGpuInfo(gpu_info); 99 content::GetContentClient()->SetGpuInfo(gpu_info);
97 } else { 100 } else {
98 LOG(INFO) << "gfx::GLSurface::InitializeOneOff failed"; 101 LOG(INFO) << "gfx::GLSurface::InitializeOneOff failed";
99 gpu_info.gpu_accessible = false; 102 gpu_info.gpu_accessible = false;
100 dead_on_arrival = true; 103 dead_on_arrival = true;
101 } 104 }
102 105
103 // Warm up the random subsystem, which needs to be done pre-sandbox on all 106 {
104 // platforms. 107 TRACE_EVENT0("gpu", "Warm up rand");
105 (void) base::RandUint64(); 108 // Warm up the random subsystem, which needs to be done pre-sandbox on all
106 109 // platforms.
107 // Warm up the crypto subsystem, which needs to done pre-sandbox on all 110 (void) base::RandUint64();
108 // platforms. 111 }
109 crypto::HMAC hmac(crypto::HMAC::SHA256); 112 {
110 unsigned char key = '\0'; 113 TRACE_EVENT0("gpu", "Warm up HMAC");
111 bool ret = hmac.Init(&key, sizeof(key)); 114 // Warm up the crypto subsystem, which needs to done pre-sandbox on all
112 (void) ret; 115 // platforms.
116 crypto::HMAC hmac(crypto::HMAC::SHA256);
117 unsigned char key = '\0';
118 bool ret = hmac.Init(&key, sizeof(key));
119 (void) ret;
120 }
113 121
114 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 122 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
115 content::InitializeSandbox(); 123 {
124 TRACE_EVENT0("gpu", "Initialize sandbox");
125 content::InitializeSandbox();
126 }
116 #endif 127 #endif
117 128
118 base::win::ScopedCOMInitializer com_initializer; 129 {
130 TRACE_EVENT0("gpu", "Initialize COM");
131 base::win::ScopedCOMInitializer com_initializer;
132 }
119 133
120 #if defined(OS_WIN) 134 #if defined(OS_WIN)
121 // Preload this DLL because the sandbox prevents it from loading. 135 {
122 LoadLibrary(L"setupapi.dll"); 136 TRACE_EVENT0("gpu", "Preload setupapi.dll");
137 // Preload this DLL because the sandbox prevents it from loading.
138 LoadLibrary(L"setupapi.dll");
139 }
123 140
124 sandbox::TargetServices* target_services = 141 {
125 parameters.sandbox_info->target_services; 142 TRACE_EVENT0("gpu", "Initialize DXVA");
126 // Initialize H/W video decoding stuff which fails in the sandbox. 143 // Initialize H/W video decoding stuff which fails in the sandbox.
127 DXVAVideoDecodeAccelerator::PreSandboxInitialization(); 144 DXVAVideoDecodeAccelerator::PreSandboxInitialization();
128 // For windows, if the target_services interface is not zero, the process 145 }
129 // is sandboxed and we must call LowerToken() before rendering untrusted 146
130 // content. 147 {
131 if (target_services) 148 TRACE_EVENT0("gpu", "Lower token");
132 target_services->LowerToken(); 149 // For windows, if the target_services interface is not zero, the process
150 // is sandboxed and we must call LowerToken() before rendering untrusted
151 // content.
152 sandbox::TargetServices* target_services =
153 parameters.sandbox_info->target_services;
154 if (target_services)
155 target_services->LowerToken();
156 }
133 #endif 157 #endif
134 158
135 MessageLoop::Type message_loop_type = MessageLoop::TYPE_UI; 159 MessageLoop::Type message_loop_type = MessageLoop::TYPE_UI;
136 #if defined(OS_WIN) 160 #if defined(OS_WIN)
137 // Unless we're running on desktop GL, we don't need a UI message 161 // Unless we're running on desktop GL, we don't need a UI message
138 // loop, so avoid its use to work around apparent problems with some 162 // loop, so avoid its use to work around apparent problems with some
139 // third-party software. 163 // third-party software.
140 message_loop_type = MessageLoop::TYPE_IO; 164 message_loop_type = MessageLoop::TYPE_IO;
141 if (command_line.HasSwitch(switches::kUseGL) && 165 if (command_line.HasSwitch(switches::kUseGL) &&
142 command_line.GetSwitchValueASCII(switches::kUseGL) == 166 command_line.GetSwitchValueASCII(switches::kUseGL) ==
143 gfx::kGLImplementationDesktopName) { 167 gfx::kGLImplementationDesktopName) {
144 message_loop_type = MessageLoop::TYPE_UI; 168 message_loop_type = MessageLoop::TYPE_UI;
145 } 169 }
146 #elif defined(OS_LINUX) 170 #elif defined(OS_LINUX)
147 message_loop_type = MessageLoop::TYPE_DEFAULT; 171 message_loop_type = MessageLoop::TYPE_DEFAULT;
148 #endif 172 #endif
149 173
150 MessageLoop main_message_loop(message_loop_type); 174 MessageLoop main_message_loop(message_loop_type);
151 base::PlatformThread::SetName("CrGpuMain"); 175 base::PlatformThread::SetName("CrGpuMain");
152 176
153 GpuProcess gpu_process; 177 GpuProcess gpu_process;
154 178
155 GpuChildThread* child_thread = new GpuChildThread(dead_on_arrival, gpu_info); 179 GpuChildThread* child_thread = new GpuChildThread(dead_on_arrival, gpu_info);
156 180
157 child_thread->Init(start_time); 181 child_thread->Init(start_time);
158 182
159 gpu_process.set_main_thread(child_thread); 183 gpu_process.set_main_thread(child_thread);
160 184
161 main_message_loop.Run(); 185 {
186 TRACE_EVENT0("gpu", "Run Message Loop");
187 main_message_loop.Run();
188 }
162 189
163 child_thread->StopWatchdog(); 190 child_thread->StopWatchdog();
164 191
165 return 0; 192 return 0;
166 } 193 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698