Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/threading/thread_checker.h" | 7 #include "base/threading/thread_checker.h" |
| 8 #include "content/browser/gpu/gpu_process_host.h" | 8 #include "content/browser/gpu/gpu_process_host.h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 566 return net::OK; | 566 return net::OK; |
| 567 available_callback_ = callback; | 567 available_callback_ = callback; |
| 568 return net::ERR_IO_PENDING; | 568 return net::ERR_IO_PENDING; |
| 569 } | 569 } |
| 570 | 570 |
| 571 void ShaderDiskCache::CacheCreatedCallback(int rv) { | 571 void ShaderDiskCache::CacheCreatedCallback(int rv) { |
| 572 if (rv != net::OK) { | 572 if (rv != net::OK) { |
| 573 LOG(ERROR) << "Shader Cache Creation failed: " << rv; | 573 LOG(ERROR) << "Shader Cache Creation failed: " << rv; |
| 574 return; | 574 return; |
| 575 } | 575 } |
| 576 cache_available_ = true; | |
| 577 | |
| 578 helper_ = new ShaderDiskReadHelper(AsWeakPtr(), host_id_); | 576 helper_ = new ShaderDiskReadHelper(AsWeakPtr(), host_id_); |
| 579 helper_->LoadCache(); | 577 helper_->LoadCache(); |
| 580 | |
| 581 if (!available_callback_.is_null()) { | |
| 582 available_callback_.Run(net::OK); | |
| 583 available_callback_.Reset(); | |
| 584 } | |
| 585 } | 578 } |
| 586 | 579 |
| 587 void ShaderDiskCache::EntryComplete(void* entry) { | 580 void ShaderDiskCache::EntryComplete(void* entry) { |
| 588 entry_map_.erase(entry); | 581 entry_map_.erase(entry); |
| 589 | 582 |
| 590 if (entry_map_.empty() && !cache_complete_callback_.is_null()) | 583 if (entry_map_.empty() && !cache_complete_callback_.is_null()) |
| 591 cache_complete_callback_.Run(net::OK); | 584 cache_complete_callback_.Run(net::OK); |
| 592 } | 585 } |
| 593 | 586 |
| 594 void ShaderDiskCache::ReadComplete() { | 587 void ShaderDiskCache::ReadComplete() { |
| 595 helper_ = NULL; | 588 helper_ = NULL; |
| 589 | |
| 590 /* The cache is considered available after we have finished reading any | |
|
apatrick_chromium
2013/04/08 18:03:05
nit: use // style comment rather than /* */
dsinclair
2013/04/09 22:52:02
Done.
| |
| 591 * of the old cache values off disk. This prevents a potential race where we | |
| 592 * are reading from disk and execute a cache clear at the same time. */ | |
| 593 cache_available_ = true; | |
| 594 if (!available_callback_.is_null()) { | |
| 595 available_callback_.Run(net::OK); | |
| 596 available_callback_.Reset(); | |
| 597 } | |
| 596 } | 598 } |
| 597 | 599 |
| 598 int ShaderDiskCache::SetCacheCompleteCallback( | 600 int ShaderDiskCache::SetCacheCompleteCallback( |
| 599 const net::CompletionCallback& callback) { | 601 const net::CompletionCallback& callback) { |
| 600 if (entry_map_.empty()) { | 602 if (entry_map_.empty()) { |
| 601 return net::OK; | 603 return net::OK; |
| 602 } | 604 } |
| 603 cache_complete_callback_ = callback; | 605 cache_complete_callback_ = callback; |
| 604 return net::ERR_IO_PENDING; | 606 return net::ERR_IO_PENDING; |
| 605 } | 607 } |
| 606 | 608 |
| 607 } // namespace content | 609 } // namespace content |
| 608 | 610 |
| OLD | NEW |