| 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 #ifndef CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_H_ | 5 #ifndef CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_H_ |
| 6 #define CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_H_ | 6 #define CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 // While this class is both RefCounted and SupportsWeakPtr | 27 // While this class is both RefCounted and SupportsWeakPtr |
| 28 // when using this class you should work with the RefCounting. | 28 // when using this class you should work with the RefCounting. |
| 29 // The WeakPtr is needed interally. | 29 // The WeakPtr is needed interally. |
| 30 class CONTENT_EXPORT ShaderDiskCache | 30 class CONTENT_EXPORT ShaderDiskCache |
| 31 : public base::RefCounted<ShaderDiskCache>, | 31 : public base::RefCounted<ShaderDiskCache>, |
| 32 public base::SupportsWeakPtr<ShaderDiskCache> { | 32 public base::SupportsWeakPtr<ShaderDiskCache> { |
| 33 public: | 33 public: |
| 34 void Init(); | 34 void Init(); |
| 35 | 35 |
| 36 void set_host_id(int host_id) { host_id_ = host_id; } | 36 void set_host_id(int host_id) { host_id_ = host_id; } |
| 37 void set_max_cache_size(size_t max_cache_size) { | |
| 38 max_cache_size_ = max_cache_size; | |
| 39 } | |
| 40 | 37 |
| 41 // Store the |shader| into the cache under |key|. | 38 // Store the |shader| into the cache under |key|. |
| 42 void Cache(const std::string& key, const std::string& shader); | 39 void Cache(const std::string& key, const std::string& shader); |
| 43 | 40 |
| 44 // Clear a range of entries. This supports unbounded deletes in either | 41 // Clear a range of entries. This supports unbounded deletes in either |
| 45 // direction by using null Time values for either |begin_time| or |end_time|. | 42 // direction by using null Time values for either |begin_time| or |end_time|. |
| 46 // The return value is a net error code. If this method returns | 43 // The return value is a net error code. If this method returns |
| 47 // ERR_IO_PENDING, the |completion_callback| will be invoked when the | 44 // ERR_IO_PENDING, the |completion_callback| will be invoked when the |
| 48 // operation completes. | 45 // operation completes. |
| 49 int Clear( | 46 int Clear( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 77 ~ShaderDiskCache(); | 74 ~ShaderDiskCache(); |
| 78 | 75 |
| 79 void CacheCreatedCallback(int rv); | 76 void CacheCreatedCallback(int rv); |
| 80 | 77 |
| 81 disk_cache::Backend* backend() { return backend_; } | 78 disk_cache::Backend* backend() { return backend_; } |
| 82 | 79 |
| 83 void EntryComplete(void* entry); | 80 void EntryComplete(void* entry); |
| 84 void ReadComplete(); | 81 void ReadComplete(); |
| 85 | 82 |
| 86 bool cache_available_; | 83 bool cache_available_; |
| 87 size_t max_cache_size_; | |
| 88 int host_id_; | 84 int host_id_; |
| 89 base::FilePath cache_path_; | 85 base::FilePath cache_path_; |
| 90 bool is_initialized_; | 86 bool is_initialized_; |
| 91 net::CompletionCallback available_callback_; | 87 net::CompletionCallback available_callback_; |
| 92 net::CompletionCallback cache_complete_callback_; | 88 net::CompletionCallback cache_complete_callback_; |
| 93 | 89 |
| 94 disk_cache::Backend* backend_; | 90 disk_cache::Backend* backend_; |
| 95 | 91 |
| 96 scoped_refptr<ShaderDiskReadHelper> helper_; | 92 scoped_refptr<ShaderDiskReadHelper> helper_; |
| 97 std::map<void*, scoped_refptr<ShaderDiskCacheEntry> > entry_map_; | 93 std::map<void*, scoped_refptr<ShaderDiskCacheEntry> > entry_map_; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 typedef std::map<base::FilePath, ShaderClearQueue> ShaderClearMap; | 145 typedef std::map<base::FilePath, ShaderClearQueue> ShaderClearMap; |
| 150 ShaderClearMap shader_clear_map_; | 146 ShaderClearMap shader_clear_map_; |
| 151 | 147 |
| 152 DISALLOW_COPY_AND_ASSIGN(ShaderCacheFactory); | 148 DISALLOW_COPY_AND_ASSIGN(ShaderCacheFactory); |
| 153 }; | 149 }; |
| 154 | 150 |
| 155 } // namespace content | 151 } // namespace content |
| 156 | 152 |
| 157 #endif // CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_H_ | 153 #endif // CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_H_ |
| 158 | 154 |
| OLD | NEW |