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

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

Issue 773463004: Further instrumentations to locate the jank source (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gavinp@ comments Created 6 years 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 | net/http/disk_cache_based_quic_server_info.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/shader_disk_cache.h" 5 #include "content/browser/gpu/shader_disk_cache.h"
6 6
7 #include "base/profiler/scoped_tracker.h" 7 #include "base/profiler/scoped_tracker.h"
8 #include "base/threading/thread_checker.h" 8 #include "base/threading/thread_checker.h"
9 #include "content/browser/gpu/gpu_process_host.h" 9 #include "content/browser/gpu/gpu_process_host.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 break; 289 break;
290 default: 290 default:
291 NOTREACHED(); // Invalid state for read helper 291 NOTREACHED(); // Invalid state for read helper
292 rv = net::ERR_FAILED; 292 rv = net::ERR_FAILED;
293 break; 293 break;
294 } 294 }
295 } while (rv != net::ERR_IO_PENDING); 295 } while (rv != net::ERR_IO_PENDING);
296 } 296 }
297 297
298 int ShaderDiskReadHelper::OpenNextEntry() { 298 int ShaderDiskReadHelper::OpenNextEntry() {
299 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
300 tracked_objects::ScopedTracker tracking_profile(
301 FROM_HERE_WITH_EXPLICIT_FUNCTION(
302 "422516 ShaderDiskReadHelper::OpenNextEntry"));
303
299 DCHECK(CalledOnValidThread()); 304 DCHECK(CalledOnValidThread());
300 // Called through OnOpComplete, so we know |cache_| is valid. 305 // Called through OnOpComplete, so we know |cache_| is valid.
301 op_type_ = OPEN_NEXT_COMPLETE; 306 op_type_ = OPEN_NEXT_COMPLETE;
302 if (!iter_) 307 if (!iter_)
303 iter_ = cache_->backend()->CreateIterator(); 308 iter_ = cache_->backend()->CreateIterator();
304 return iter_->OpenNextEntry( 309 return iter_->OpenNextEntry(
305 &entry_, base::Bind(&ShaderDiskReadHelper::OnOpComplete, this)); 310 &entry_, base::Bind(&ShaderDiskReadHelper::OnOpComplete, this));
306 } 311 }
307 312
308 int ShaderDiskReadHelper::OpenNextEntryComplete(int rv) { 313 int ShaderDiskReadHelper::OpenNextEntryComplete(int rv) {
314 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
315 tracked_objects::ScopedTracker tracking_profile(
316 FROM_HERE_WITH_EXPLICIT_FUNCTION(
317 "422516 ShaderDiskReadHelper::OpenNextEntryComplete"));
318
309 DCHECK(CalledOnValidThread()); 319 DCHECK(CalledOnValidThread());
310 // Called through OnOpComplete, so we know |cache_| is valid. 320 // Called through OnOpComplete, so we know |cache_| is valid.
311 if (rv == net::ERR_FAILED) { 321 if (rv == net::ERR_FAILED) {
312 iter_.reset(); 322 iter_.reset();
313 op_type_ = ITERATION_FINISHED; 323 op_type_ = ITERATION_FINISHED;
314 return net::OK; 324 return net::OK;
315 } 325 }
316 326
317 if (rv < 0) 327 if (rv < 0)
318 return rv; 328 return rv;
319 329
320 op_type_ = READ_COMPLETE; 330 op_type_ = READ_COMPLETE;
321 buf_ = new net::IOBufferWithSize(entry_->GetDataSize(1)); 331 buf_ = new net::IOBufferWithSize(entry_->GetDataSize(1));
322 return entry_->ReadData( 332 return entry_->ReadData(
323 1, 333 1,
324 0, 334 0,
325 buf_.get(), 335 buf_.get(),
326 buf_->size(), 336 buf_->size(),
327 base::Bind(&ShaderDiskReadHelper::OnOpComplete, this)); 337 base::Bind(&ShaderDiskReadHelper::OnOpComplete, this));
328 } 338 }
329 339
330 int ShaderDiskReadHelper::ReadComplete(int rv) { 340 int ShaderDiskReadHelper::ReadComplete(int rv) {
341 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
342 tracked_objects::ScopedTracker tracking_profile(
343 FROM_HERE_WITH_EXPLICIT_FUNCTION(
344 "422516 ShaderDiskReadHelper::ReadComplete"));
345
331 DCHECK(CalledOnValidThread()); 346 DCHECK(CalledOnValidThread());
332 // Called through OnOpComplete, so we know |cache_| is valid. 347 // Called through OnOpComplete, so we know |cache_| is valid.
333 if (rv && rv == buf_->size()) { 348 if (rv && rv == buf_->size()) {
334 GpuProcessHost* host = GpuProcessHost::FromID(host_id_); 349 GpuProcessHost* host = GpuProcessHost::FromID(host_id_);
335 if (host) 350 if (host)
336 host->LoadedShader(entry_->GetKey(), std::string(buf_->data(), 351 host->LoadedShader(entry_->GetKey(), std::string(buf_->data(),
337 buf_->size())); 352 buf_->size()));
338 } 353 }
339 354
340 buf_ = NULL; 355 buf_ = NULL;
341 entry_->Close(); 356 entry_->Close();
342 entry_ = NULL; 357 entry_ = NULL;
343 358
344 op_type_ = OPEN_NEXT; 359 op_type_ = OPEN_NEXT;
345 return net::OK; 360 return net::OK;
346 } 361 }
347 362
348 int ShaderDiskReadHelper::IterationComplete(int rv) { 363 int ShaderDiskReadHelper::IterationComplete(int rv) {
364 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
365 tracked_objects::ScopedTracker tracking_profile(
366 FROM_HERE_WITH_EXPLICIT_FUNCTION(
367 "422516 ShaderDiskReadHelper::IterationComplete"));
368
349 DCHECK(CalledOnValidThread()); 369 DCHECK(CalledOnValidThread());
350 // Called through OnOpComplete, so we know |cache_| is valid. 370 // Called through OnOpComplete, so we know |cache_| is valid.
351 iter_.reset(); 371 iter_.reset();
352 op_type_ = TERMINATE; 372 op_type_ = TERMINATE;
353 return net::OK; 373 return net::OK;
354 } 374 }
355 375
356 ShaderDiskReadHelper::~ShaderDiskReadHelper() { 376 ShaderDiskReadHelper::~ShaderDiskReadHelper() {
357 if (entry_) { 377 if (entry_) {
358 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 378 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 const net::CompletionCallback& callback) { 642 const net::CompletionCallback& callback) {
623 if (entry_map_.empty()) { 643 if (entry_map_.empty()) {
624 return net::OK; 644 return net::OK;
625 } 645 }
626 cache_complete_callback_ = callback; 646 cache_complete_callback_ = callback;
627 return net::ERR_IO_PENDING; 647 return net::ERR_IO_PENDING;
628 } 648 }
629 649
630 } // namespace content 650 } // namespace content
631 651
OLDNEW
« no previous file with comments | « no previous file | net/http/disk_cache_based_quic_server_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698