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

Side by Side Diff: content/browser/gpu/browser_gpu_channel_host_factory.cc

Issue 860293004: Instrumenting GPU initialization for jank (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing Created 5 years, 10 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
« no previous file with comments | « no previous file | content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc » ('j') | 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/gpu/browser_gpu_channel_host_factory.h" 5 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/profiler/scoped_tracker.h"
10 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
11 #include "base/threading/thread_restrictions.h" 12 #include "base/threading/thread_restrictions.h"
12 #include "base/trace_event/trace_event.h" 13 #include "base/trace_event/trace_event.h"
13 #include "base/tracked_objects.h"
14 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" 14 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
15 #include "content/browser/gpu/gpu_data_manager_impl.h" 15 #include "content/browser/gpu/gpu_data_manager_impl.h"
16 #include "content/browser/gpu/gpu_process_host.h" 16 #include "content/browser/gpu/gpu_process_host.h"
17 #include "content/browser/gpu/gpu_surface_tracker.h" 17 #include "content/browser/gpu/gpu_surface_tracker.h"
18 #include "content/common/child_process_host_impl.h" 18 #include "content/common/child_process_host_impl.h"
19 #include "content/common/gpu/gpu_memory_buffer_factory.h" 19 #include "content/common/gpu/gpu_memory_buffer_factory.h"
20 #include "content/common/gpu/gpu_messages.h" 20 #include "content/common/gpu/gpu_messages.h"
21 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/gpu_data_manager.h" 22 #include "content/public/browser/gpu_data_manager.h"
23 #include "content/public/common/content_client.h" 23 #include "content/public/common/content_client.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 BrowserGpuChannelHostFactory* factory = 187 BrowserGpuChannelHostFactory* factory =
188 BrowserGpuChannelHostFactory::instance(); 188 BrowserGpuChannelHostFactory::instance();
189 factory->GpuChannelEstablished(); 189 factory->GpuChannelEstablished();
190 finished_ = true; 190 finished_ = true;
191 } 191 }
192 } 192 }
193 193
194 void BrowserGpuChannelHostFactory::EstablishRequest::Wait() { 194 void BrowserGpuChannelHostFactory::EstablishRequest::Wait() {
195 DCHECK(main_loop_->BelongsToCurrentThread()); 195 DCHECK(main_loop_->BelongsToCurrentThread());
196 { 196 {
197 // Since the current task synchronously waits for establishing a GPU 197 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is fixed.
198 // channel, it shouldn't be tallied because its execution time has nothing 198 tracked_objects::ScopedTracker tracking_profile(
199 // to do with its efficiency. Using task stopwatch to exclude the waiting 199 FROM_HERE_WITH_EXPLICIT_FUNCTION(
200 // time from the current task run time. 200 "125248 BrowserGpuChannelHostFactory::EstablishRequest::Wait"));
201 tracked_objects::TaskStopwatch stopwatch;
202 stopwatch.Start();
203 201
204 // We're blocking the UI thread, which is generally undesirable. 202 // We're blocking the UI thread, which is generally undesirable.
205 // In this case we need to wait for this before we can show any UI 203 // In this case we need to wait for this before we can show any UI
206 // /anyway/, so it won't cause additional jank. 204 // /anyway/, so it won't cause additional jank.
207 // TODO(piman): Make this asynchronous (http://crbug.com/125248). 205 // TODO(piman): Make this asynchronous (http://crbug.com/125248).
208 TRACE_EVENT0("browser", 206 TRACE_EVENT0("browser",
209 "BrowserGpuChannelHostFactory::EstablishGpuChannelSync"); 207 "BrowserGpuChannelHostFactory::EstablishGpuChannelSync");
210 base::ThreadRestrictions::ScopedAllowWait allow_wait; 208 base::ThreadRestrictions::ScopedAllowWait allow_wait;
211 event_.Wait(); 209 event_.Wait();
212
213 stopwatch.Stop();
214 } 210 }
215 FinishOnMain(); 211 FinishOnMain();
216 } 212 }
217 213
218 void BrowserGpuChannelHostFactory::EstablishRequest::Cancel() { 214 void BrowserGpuChannelHostFactory::EstablishRequest::Cancel() {
219 DCHECK(main_loop_->BelongsToCurrentThread()); 215 DCHECK(main_loop_->BelongsToCurrentThread());
220 finished_ = true; 216 finished_ = true;
221 } 217 }
222 218
223 bool BrowserGpuChannelHostFactory::CanUseForTesting() { 219 bool BrowserGpuChannelHostFactory::CanUseForTesting() {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 int32 surface_id, 320 int32 surface_id,
325 const GPUCreateCommandBufferConfig& init_params, 321 const GPUCreateCommandBufferConfig& init_params,
326 int32 route_id) { 322 int32 route_id) {
327 CreateRequest request(route_id); 323 CreateRequest request(route_id);
328 GetIOLoopProxy()->PostTask(FROM_HERE, base::Bind( 324 GetIOLoopProxy()->PostTask(FROM_HERE, base::Bind(
329 &BrowserGpuChannelHostFactory::CreateViewCommandBufferOnIO, 325 &BrowserGpuChannelHostFactory::CreateViewCommandBufferOnIO,
330 base::Unretained(this), 326 base::Unretained(this),
331 &request, 327 &request,
332 surface_id, 328 surface_id,
333 init_params)); 329 init_params));
330 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is fixed.
331 tracked_objects::ScopedTracker tracking_profile(
332 FROM_HERE_WITH_EXPLICIT_FUNCTION(
333 "125248 BrowserGpuChannelHostFactory::CreateViewCommandBuffer"));
334
334 // We're blocking the UI thread, which is generally undesirable. 335 // We're blocking the UI thread, which is generally undesirable.
335 // In this case we need to wait for this before we can show any UI /anyway/, 336 // In this case we need to wait for this before we can show any UI /anyway/,
336 // so it won't cause additional jank. 337 // so it won't cause additional jank.
337 // TODO(piman): Make this asynchronous (http://crbug.com/125248). 338 // TODO(piman): Make this asynchronous (http://crbug.com/125248).
338 TRACE_EVENT0("browser", 339 TRACE_EVENT0("browser",
339 "BrowserGpuChannelHostFactory::CreateViewCommandBuffer"); 340 "BrowserGpuChannelHostFactory::CreateViewCommandBuffer");
340 base::ThreadRestrictions::ScopedAllowWait allow_wait; 341 base::ThreadRestrictions::ScopedAllowWait allow_wait;
341 request.event.Wait(); 342 request.event.Wait();
342 return request.result; 343 return request.result;
343 } 344 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 539 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
539 540
540 CreateGpuMemoryBufferCallbackMap::iterator iter = 541 CreateGpuMemoryBufferCallbackMap::iterator iter =
541 create_gpu_memory_buffer_requests_.find(request_id); 542 create_gpu_memory_buffer_requests_.find(request_id);
542 DCHECK(iter != create_gpu_memory_buffer_requests_.end()); 543 DCHECK(iter != create_gpu_memory_buffer_requests_.end());
543 iter->second.Run(handle); 544 iter->second.Run(handle);
544 create_gpu_memory_buffer_requests_.erase(iter); 545 create_gpu_memory_buffer_requests_.erase(iter);
545 } 546 }
546 547
547 } // namespace content 548 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698