Chromium Code Reviews| Index: content/browser/gpu/shader_disk_cache.h |
| diff --git a/content/browser/gpu/shader_disk_cache.h b/content/browser/gpu/shader_disk_cache.h |
| index 3ca54200546ac1d38b1d85b9a4f154df075fe8d1..187fd58b236dc797b42d2588a61bd4a84207260d 100644 |
| --- a/content/browser/gpu/shader_disk_cache.h |
| +++ b/content/browser/gpu/shader_disk_cache.h |
| @@ -6,17 +6,20 @@ |
| #define CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_H_ |
| #include <map> |
| +#include <queue> |
| #include <string> |
| #include "base/files/file_path.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/memory/singleton.h" |
| +#include "content/common/content_export.h" |
| #include "net/disk_cache/disk_cache.h" |
| namespace content { |
| class ShaderDiskCacheEntry; |
| class ShaderDiskReadHelper; |
| +class ShaderClearHelper; |
| // ShaderDiskCache is the interface to the on disk cache for |
| // GL shaders. |
| @@ -24,7 +27,7 @@ class ShaderDiskReadHelper; |
| // While this class is both RefCounted and SupportsWeakPtr |
| // when using this class you should work with the RefCounting. |
| // The WeakPtr is needed interally. |
| -class ShaderDiskCache |
| +class CONTENT_EXPORT ShaderDiskCache |
| : public base::RefCounted<ShaderDiskCache>, |
| public base::SupportsWeakPtr<ShaderDiskCache> { |
| public: |
| @@ -37,6 +40,21 @@ class ShaderDiskCache |
| void Cache(const std::string& key, const std::string& shader); |
| + int Clear( |
|
jam
2013/04/02 17:34:50
nit: here and below, add comments for (at least) p
dsinclair
2013/04/03 18:59:23
Done.
|
| + const base::Time begin_time, |
| + const base::Time end_time, |
| + const net::CompletionCallback& completion_callback); |
| + |
| + // Sets a callback for when the cache is available. If the cache is |
| + // already available the callback will not be called and net::OK is returned. |
| + // If the callback is set net::ERR_IO_PENDING is returned and the callback |
| + // will be executed when the cache is available. |
| + int SetAvailableCallback(const net::CompletionCallback& callback); |
| + |
| + int32 Size(); |
| + |
| + int SetCacheCompleteCallback(const net::CompletionCallback& callback); |
| + |
| private: |
| friend class base::RefCounted<ShaderDiskCache>; |
| friend class ShaderDiskCacheEntry; |
| @@ -58,6 +76,8 @@ class ShaderDiskCache |
| int host_id_; |
| base::FilePath cache_path_; |
| bool is_initialized_; |
| + net::CompletionCallback available_callback_; |
| + net::CompletionCallback cache_complete_callback_; |
| disk_cache::Backend* backend_; |
| @@ -69,10 +89,15 @@ class ShaderDiskCache |
| // ShaderCacheFactory maintains a cache of ShaderDiskCache objects |
| // so we only create one per profile directory. |
| -class ShaderCacheFactory { |
| +class CONTENT_EXPORT ShaderCacheFactory { |
| public: |
| static ShaderCacheFactory* GetInstance(); |
| + void ClearByPath(const base::FilePath& path, |
| + const base::Time& begin_time, |
| + const base::Time& end_time, |
| + const base::Closure& callback); |
| + |
| scoped_refptr<ShaderDiskCache> Get(int32 client_id); |
| void SetCacheInfo(int32 client_id, const base::FilePath& path); |
| @@ -83,9 +108,13 @@ class ShaderCacheFactory { |
| private: |
| friend struct DefaultSingletonTraits<ShaderCacheFactory>; |
| + friend class ShaderClearHelper; |
| ShaderCacheFactory(); |
| - ~ShaderCacheFactory(); |
| + virtual ~ShaderCacheFactory(); |
|
jam
2013/04/02 17:34:50
nit: not needed anymore?
dsinclair
2013/04/03 18:59:23
error: [chromium-style] Complex class/struct needs
jam
2013/04/04 14:53:31
I meant the virtual
dsinclair
2013/04/04 16:04:00
Oh, sorry. Done.
|
| + |
| + scoped_refptr<ShaderDiskCache> GetByPath(const base::FilePath& path); |
| + void CacheCleared(const base::FilePath& path); |
| typedef std::map<base::FilePath, ShaderDiskCache*> ShaderCacheMap; |
| ShaderCacheMap shader_cache_map_; |
| @@ -93,6 +122,10 @@ class ShaderCacheFactory { |
| typedef std::map<int32, base::FilePath> ClientIdToPathMap; |
| ClientIdToPathMap client_id_to_path_map_; |
| + typedef std::queue<scoped_refptr<ShaderClearHelper> > ShaderClearQueue; |
| + typedef std::map<base::FilePath, ShaderClearQueue> ShaderClearMap; |
| + ShaderClearMap shader_clear_map_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(ShaderCacheFactory); |
| }; |