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

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

Issue 1000373002: favor DCHECK_CURRENTLY_ON for better logs in content/browser/[f-p]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 5 years, 9 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
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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 const base::Closure& callback) 392 const base::Closure& callback)
393 : cache_(cache), 393 : cache_(cache),
394 op_type_(VERIFY_CACHE_SETUP), 394 op_type_(VERIFY_CACHE_SETUP),
395 path_(path), 395 path_(path),
396 delete_begin_(delete_begin), 396 delete_begin_(delete_begin),
397 delete_end_(delete_end), 397 delete_end_(delete_end),
398 callback_(callback) { 398 callback_(callback) {
399 } 399 }
400 400
401 ShaderClearHelper::~ShaderClearHelper() { 401 ShaderClearHelper::~ShaderClearHelper() {
402 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 402 DCHECK_CURRENTLY_ON(BrowserThread::IO);
403 } 403 }
404 404
405 void ShaderClearHelper::Clear() { 405 void ShaderClearHelper::Clear() {
406 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 406 DCHECK_CURRENTLY_ON(BrowserThread::IO);
407 DoClearShaderCache(net::OK); 407 DoClearShaderCache(net::OK);
408 } 408 }
409 409
410 void ShaderClearHelper::DoClearShaderCache(int rv) { 410 void ShaderClearHelper::DoClearShaderCache(int rv) {
411 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 411 DCHECK_CURRENTLY_ON(BrowserThread::IO);
412 412
413 // Hold a ref to ourselves so when we do the CacheCleared call we don't get 413 // Hold a ref to ourselves so when we do the CacheCleared call we don't get
414 // auto-deleted when our ref count drops to zero. 414 // auto-deleted when our ref count drops to zero.
415 scoped_refptr<ShaderClearHelper> helper = this; 415 scoped_refptr<ShaderClearHelper> helper = this;
416 416
417 while (rv != net::ERR_IO_PENDING) { 417 while (rv != net::ERR_IO_PENDING) {
418 switch (op_type_) { 418 switch (op_type_) {
419 case VERIFY_CACHE_SETUP: 419 case VERIFY_CACHE_SETUP:
420 rv = cache_->SetAvailableCallback( 420 rv = cache_->SetAvailableCallback(
421 base::Bind(&ShaderClearHelper::DoClearShaderCache, AsWeakPtr())); 421 base::Bind(&ShaderClearHelper::DoClearShaderCache, AsWeakPtr()));
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 } 486 }
487 487
488 void ShaderCacheFactory::RemoveFromCache(const base::FilePath& key) { 488 void ShaderCacheFactory::RemoveFromCache(const base::FilePath& key) {
489 shader_cache_map_.erase(key); 489 shader_cache_map_.erase(key);
490 } 490 }
491 491
492 void ShaderCacheFactory::ClearByPath(const base::FilePath& path, 492 void ShaderCacheFactory::ClearByPath(const base::FilePath& path,
493 const base::Time& delete_begin, 493 const base::Time& delete_begin,
494 const base::Time& delete_end, 494 const base::Time& delete_end,
495 const base::Closure& callback) { 495 const base::Closure& callback) {
496 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 496 DCHECK_CURRENTLY_ON(BrowserThread::IO);
497 DCHECK(!callback.is_null()); 497 DCHECK(!callback.is_null());
498 498
499 scoped_refptr<ShaderClearHelper> helper = new ShaderClearHelper( 499 scoped_refptr<ShaderClearHelper> helper = new ShaderClearHelper(
500 GetByPath(path), path, delete_begin, delete_end, callback); 500 GetByPath(path), path, delete_begin, delete_end, callback);
501 501
502 // We could receive requests to clear the same path with different 502 // We could receive requests to clear the same path with different
503 // begin/end times. So, we keep a list of requests. If we haven't seen this 503 // begin/end times. So, we keep a list of requests. If we haven't seen this
504 // path before we kick off the clear and add it to the list. If we have see it 504 // path before we kick off the clear and add it to the list. If we have see it
505 // already, then we already have a clear running. We add this clear to the 505 // already, then we already have a clear running. We add this clear to the
506 // list and wait for any previous clears to finish. 506 // list and wait for any previous clears to finish.
507 ShaderClearMap::iterator iter = shader_clear_map_.find(path); 507 ShaderClearMap::iterator iter = shader_clear_map_.find(path);
508 if (iter != shader_clear_map_.end()) { 508 if (iter != shader_clear_map_.end()) {
509 iter->second.push(helper); 509 iter->second.push(helper);
510 return; 510 return;
511 } 511 }
512 512
513 shader_clear_map_.insert( 513 shader_clear_map_.insert(
514 std::pair<base::FilePath, ShaderClearQueue>(path, ShaderClearQueue())); 514 std::pair<base::FilePath, ShaderClearQueue>(path, ShaderClearQueue()));
515 shader_clear_map_[path].push(helper); 515 shader_clear_map_[path].push(helper);
516 helper->Clear(); 516 helper->Clear();
517 } 517 }
518 518
519 void ShaderCacheFactory::CacheCleared(const base::FilePath& path) { 519 void ShaderCacheFactory::CacheCleared(const base::FilePath& path) {
520 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 520 DCHECK_CURRENTLY_ON(BrowserThread::IO);
521 521
522 ShaderClearMap::iterator iter = shader_clear_map_.find(path); 522 ShaderClearMap::iterator iter = shader_clear_map_.find(path);
523 if (iter == shader_clear_map_.end()) { 523 if (iter == shader_clear_map_.end()) {
524 LOG(ERROR) << "Completed clear but missing clear helper."; 524 LOG(ERROR) << "Completed clear but missing clear helper.";
525 return; 525 return;
526 } 526 }
527 527
528 iter->second.pop(); 528 iter->second.pop();
529 529
530 // If there are remaining items in the list we trigger the Clear on the 530 // If there are remaining items in the list we trigger the Clear on the
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 const net::CompletionCallback& callback) { 642 const net::CompletionCallback& callback) {
643 if (entry_map_.empty()) { 643 if (entry_map_.empty()) {
644 return net::OK; 644 return net::OK;
645 } 645 }
646 cache_complete_callback_ = callback; 646 cache_complete_callback_ = callback;
647 return net::ERR_IO_PENDING; 647 return net::ERR_IO_PENDING;
648 } 648 }
649 649
650 } // namespace content 650 } // namespace content
651 651
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_process_host_ui_shim.cc ('k') | content/browser/histogram_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698