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/macros.h" | 7 #include "base/macros.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 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 } | 525 } |
526 | 526 |
527 void ShaderDiskCache::Init() { | 527 void ShaderDiskCache::Init() { |
528 if (is_initialized_) { | 528 if (is_initialized_) { |
529 NOTREACHED(); // can't initialize disk cache twice. | 529 NOTREACHED(); // can't initialize disk cache twice. |
530 return; | 530 return; |
531 } | 531 } |
532 is_initialized_ = true; | 532 is_initialized_ = true; |
533 | 533 |
534 int rv = disk_cache::CreateCacheBackend( | 534 int rv = disk_cache::CreateCacheBackend( |
535 net::SHADER_CACHE, | 535 net::SHADER_CACHE, net::CACHE_BACKEND_DEFAULT, |
536 net::CACHE_BACKEND_DEFAULT, | |
537 cache_path_.Append(kGpuCachePath), | 536 cache_path_.Append(kGpuCachePath), |
538 gpu::kDefaultMaxProgramCacheMemoryBytes, | 537 gpu::kDefaultMaxProgramCacheMemoryBytes, true, |
539 true, | 538 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE).get(), NULL, |
540 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE).get(), | 539 &backend_, base::Bind(&ShaderDiskCache::CacheCreatedCallback, this)); |
541 NULL, | |
542 &backend_, | |
543 base::Bind(&ShaderDiskCache::CacheCreatedCallback, this)); | |
544 | 540 |
545 if (rv == net::OK) | 541 if (rv == net::OK) |
546 cache_available_ = true; | 542 cache_available_ = true; |
547 } | 543 } |
548 | 544 |
549 void ShaderDiskCache::Cache(const std::string& key, const std::string& shader) { | 545 void ShaderDiskCache::Cache(const std::string& key, const std::string& shader) { |
550 if (!cache_available_) | 546 if (!cache_available_) |
551 return; | 547 return; |
552 | 548 |
553 scoped_refptr<ShaderDiskCacheEntry> shim = | 549 scoped_refptr<ShaderDiskCacheEntry> shim = |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 const net::CompletionCallback& callback) { | 613 const net::CompletionCallback& callback) { |
618 if (entry_map_.empty()) { | 614 if (entry_map_.empty()) { |
619 return net::OK; | 615 return net::OK; |
620 } | 616 } |
621 cache_complete_callback_ = callback; | 617 cache_complete_callback_ = callback; |
622 return net::ERR_IO_PENDING; | 618 return net::ERR_IO_PENDING; |
623 } | 619 } |
624 | 620 |
625 } // namespace content | 621 } // namespace content |
626 | 622 |
OLD | NEW |