| Index: content/browser/gpu/shader_disk_cache_impl.h
|
| diff --git a/content/browser/gpu/shader_disk_cache.h b/content/browser/gpu/shader_disk_cache_impl.h
|
| similarity index 57%
|
| rename from content/browser/gpu/shader_disk_cache.h
|
| rename to content/browser/gpu/shader_disk_cache_impl.h
|
| index 3ca54200546ac1d38b1d85b9a4f154df075fe8d1..9ec831674f9dc55045f2103405ce4fcf235893c1 100644
|
| --- a/content/browser/gpu/shader_disk_cache.h
|
| +++ b/content/browser/gpu/shader_disk_cache_impl.h
|
| @@ -2,21 +2,24 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_H_
|
| -#define CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_H_
|
| +#ifndef CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_IMPL_H_
|
| +#define CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_IMPL_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/public/browser/shader_disk_cache.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.
|
| @@ -37,11 +40,22 @@ class ShaderDiskCache
|
|
|
| void Cache(const std::string& key, const std::string& shader);
|
|
|
| + int Clear(
|
| + 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);
|
| +
|
| private:
|
| friend class base::RefCounted<ShaderDiskCache>;
|
| friend class ShaderDiskCacheEntry;
|
| friend class ShaderDiskReadHelper;
|
| - friend class ShaderCacheFactory;
|
| + friend class ShaderCacheFactoryImpl;
|
|
|
| explicit ShaderDiskCache(const base::FilePath& cache_path);
|
| ~ShaderDiskCache();
|
| @@ -58,6 +72,7 @@ class ShaderDiskCache
|
| int host_id_;
|
| base::FilePath cache_path_;
|
| bool is_initialized_;
|
| + net::CompletionCallback available_callback_;
|
|
|
| disk_cache::Backend* backend_;
|
|
|
| @@ -67,11 +82,16 @@ class ShaderDiskCache
|
| DISALLOW_COPY_AND_ASSIGN(ShaderDiskCache);
|
| };
|
|
|
| -// ShaderCacheFactory maintains a cache of ShaderDiskCache objects
|
| +// ShaderCacheFactory maintains a cache of ShaderDiskCacheImpl objects
|
| // so we only create one per profile directory.
|
| -class ShaderCacheFactory {
|
| +class ShaderCacheFactoryImpl : public content::ShaderCacheFactory {
|
| public:
|
| - static ShaderCacheFactory* GetInstance();
|
| + static ShaderCacheFactoryImpl* GetInstance();
|
| +
|
| + virtual void ClearByPath(const base::FilePath& path,
|
| + const base::Time& begin_time,
|
| + const base::Time& end_time,
|
| + const base::Closure& callback) OVERRIDE;
|
|
|
| scoped_refptr<ShaderDiskCache> Get(int32 client_id);
|
|
|
| @@ -82,10 +102,15 @@ class ShaderCacheFactory {
|
| void RemoveFromCache(const base::FilePath& path);
|
|
|
| private:
|
| - friend struct DefaultSingletonTraits<ShaderCacheFactory>;
|
| + friend struct DefaultSingletonTraits<ShaderCacheFactoryImpl>;
|
| + friend class ShaderCacheFactory;
|
| + friend class ShaderClearHelper;
|
| +
|
| + ShaderCacheFactoryImpl();
|
| + virtual ~ShaderCacheFactoryImpl();
|
|
|
| - ShaderCacheFactory();
|
| - ~ShaderCacheFactory();
|
| + 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,10 +118,14 @@ class ShaderCacheFactory {
|
| typedef std::map<int32, base::FilePath> ClientIdToPathMap;
|
| ClientIdToPathMap client_id_to_path_map_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(ShaderCacheFactory);
|
| + typedef std::queue<scoped_refptr<ShaderClearHelper> > ShaderClearQueue;
|
| + typedef std::map<base::FilePath, ShaderClearQueue> ShaderClearMap;
|
| + ShaderClearMap shader_clear_map_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ShaderCacheFactoryImpl);
|
| };
|
|
|
| } // namespace content
|
|
|
| -#endif // CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_H_
|
| +#endif // CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_IMPL_H_
|
|
|
|
|