| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 // ShaderDiskCache is the interface to the on disk cache for | 27 // ShaderDiskCache is the interface to the on disk cache for |
| 28 // GL shaders. | 28 // GL shaders. |
| 29 // | 29 // |
| 30 // While this class is both RefCounted and SupportsWeakPtr | 30 // While this class is both RefCounted and SupportsWeakPtr |
| 31 // when using this class you should work with the RefCounting. | 31 // when using this class you should work with the RefCounting. |
| 32 // The WeakPtr is needed interally. | 32 // The WeakPtr is needed interally. |
| 33 class CONTENT_EXPORT ShaderDiskCache | 33 class CONTENT_EXPORT ShaderDiskCache |
| 34 : public base::RefCounted<ShaderDiskCache>, | 34 : public base::RefCounted<ShaderDiskCache>, |
| 35 public base::SupportsWeakPtr<ShaderDiskCache> { | 35 public base::SupportsWeakPtr<ShaderDiskCache> { |
| 36 public: | 36 public: |
| 37 using ShaderLoadedCallback = |
| 38 base::Callback<void(const std::string&, const std::string&)>; |
| 37 void Init(); | 39 void Init(); |
| 38 | 40 |
| 39 void set_host_id(int host_id) { host_id_ = host_id; } | 41 void set_shader_loaded_callback(const ShaderLoadedCallback& callback) { |
| 42 shader_loaded_callback_ = callback; |
| 43 } |
| 40 | 44 |
| 41 // Store the |shader| into the cache under |key|. | 45 // Store the |shader| into the cache under |key|. |
| 42 void Cache(const std::string& key, const std::string& shader); | 46 void Cache(const std::string& key, const std::string& shader); |
| 43 | 47 |
| 44 // Clear a range of entries. This supports unbounded deletes in either | 48 // 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|. | 49 // 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 | 50 // The return value is a net error code. If this method returns |
| 47 // ERR_IO_PENDING, the |completion_callback| will be invoked when the | 51 // ERR_IO_PENDING, the |completion_callback| will be invoked when the |
| 48 // operation completes. | 52 // operation completes. |
| 49 int Clear( | 53 int Clear( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 77 ~ShaderDiskCache(); | 81 ~ShaderDiskCache(); |
| 78 | 82 |
| 79 void CacheCreatedCallback(int rv); | 83 void CacheCreatedCallback(int rv); |
| 80 | 84 |
| 81 disk_cache::Backend* backend() { return backend_.get(); } | 85 disk_cache::Backend* backend() { return backend_.get(); } |
| 82 | 86 |
| 83 void EntryComplete(void* entry); | 87 void EntryComplete(void* entry); |
| 84 void ReadComplete(); | 88 void ReadComplete(); |
| 85 | 89 |
| 86 bool cache_available_; | 90 bool cache_available_; |
| 87 int host_id_; | |
| 88 base::FilePath cache_path_; | 91 base::FilePath cache_path_; |
| 89 bool is_initialized_; | 92 bool is_initialized_; |
| 90 net::CompletionCallback available_callback_; | 93 net::CompletionCallback available_callback_; |
| 91 net::CompletionCallback cache_complete_callback_; | 94 net::CompletionCallback cache_complete_callback_; |
| 95 ShaderLoadedCallback shader_loaded_callback_; |
| 92 | 96 |
| 93 std::unique_ptr<disk_cache::Backend> backend_; | 97 std::unique_ptr<disk_cache::Backend> backend_; |
| 94 | 98 |
| 95 scoped_refptr<ShaderDiskReadHelper> helper_; | 99 scoped_refptr<ShaderDiskReadHelper> helper_; |
| 96 std::map<void*, scoped_refptr<ShaderDiskCacheEntry> > entry_map_; | 100 std::map<void*, scoped_refptr<ShaderDiskCacheEntry> > entry_map_; |
| 97 | 101 |
| 98 DISALLOW_COPY_AND_ASSIGN(ShaderDiskCache); | 102 DISALLOW_COPY_AND_ASSIGN(ShaderDiskCache); |
| 99 }; | 103 }; |
| 100 | 104 |
| 101 // ShaderCacheFactory maintains a cache of ShaderDiskCache objects | 105 // ShaderCacheFactory maintains a cache of ShaderDiskCache objects |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 typedef std::map<base::FilePath, ShaderClearQueue> ShaderClearMap; | 152 typedef std::map<base::FilePath, ShaderClearQueue> ShaderClearMap; |
| 149 ShaderClearMap shader_clear_map_; | 153 ShaderClearMap shader_clear_map_; |
| 150 | 154 |
| 151 DISALLOW_COPY_AND_ASSIGN(ShaderCacheFactory); | 155 DISALLOW_COPY_AND_ASSIGN(ShaderCacheFactory); |
| 152 }; | 156 }; |
| 153 | 157 |
| 154 } // namespace content | 158 } // namespace content |
| 155 | 159 |
| 156 #endif // CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_H_ | 160 #endif // CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_H_ |
| 157 | 161 |
| OLD | NEW |