Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Unified Diff: content/browser/gpu/shader_disk_cache_impl.h

Issue 12500009: Add the ability to clear the shader disk cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 52%
rename from content/browser/gpu/shader_disk_cache.h
rename to content/browser/gpu/shader_disk_cache_impl.h
index 3ca54200546ac1d38b1d85b9a4f154df075fe8d1..363fffd8657ee18db7679572b65892611decebbc 100644
--- a/content/browser/gpu/shader_disk_cache.h
+++ b/content/browser/gpu/shader_disk_cache_impl.h
@@ -2,8 +2,8 @@
// 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 <string>
@@ -11,6 +11,7 @@
#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 {
@@ -30,21 +31,30 @@ class ShaderDiskCache
public:
void Init();
- void set_host_id(int host_id) { host_id_ = host_id; }
jonathan.backer 2013/03/20 18:39:05 Why not inline?
dsinclair 2013/03/21 17:46:59 Will put back. Was removed because the compiler di
- void set_max_cache_size(size_t max_cache_size) {
- max_cache_size_ = max_cache_size;
- }
+ void set_host_id(int host_id);
+ void set_max_cache_size(size_t max_cache_size);
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 availble 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);
jonathan.backer 2013/03/20 18:39:05 s/availble/available
dsinclair 2013/03/21 17:46:59 Done.
+
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();
+ virtual ~ShaderDiskCache();
jonathan.backer 2013/03/20 18:39:05 Why is this now virtual?
dsinclair 2013/03/21 17:46:59 Done. Did have an interface which is now removed.
void CacheCreatedCallback(int rv);
@@ -58,6 +68,7 @@ class ShaderDiskCache
int host_id_;
base::FilePath cache_path_;
bool is_initialized_;
+ net::CompletionCallback available_callback_;
disk_cache::Backend* backend_;
@@ -67,12 +78,18 @@ 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> GetByPath(const base::FilePath& path);
jonathan.backer 2013/03/20 18:39:05 private?
dsinclair 2013/03/21 17:46:59 Done.
scoped_refptr<ShaderDiskCache> Get(int32 client_id);
void SetCacheInfo(int32 client_id, const base::FilePath& path);
@@ -82,10 +99,19 @@ class ShaderCacheFactory {
void RemoveFromCache(const base::FilePath& path);
private:
- friend struct DefaultSingletonTraits<ShaderCacheFactory>;
+ friend struct DefaultSingletonTraits<ShaderCacheFactoryImpl>;
+ friend content::ShaderCacheFactory;
- ShaderCacheFactory();
- ~ShaderCacheFactory();
+ enum OpType {
+ TERMINATE,
+ CREATE_CACHE,
+ DELETE_CACHE
+ };
+
+ ShaderCacheFactoryImpl();
+ virtual ~ShaderCacheFactoryImpl();
+
+ void DoClearShaderCache(int rv);
typedef std::map<base::FilePath, ShaderDiskCache*> ShaderCacheMap;
ShaderCacheMap shader_cache_map_;
@@ -93,10 +119,18 @@ class ShaderCacheFactory {
typedef std::map<int32, base::FilePath> ClientIdToPathMap;
ClientIdToPathMap client_id_to_path_map_;
- DISALLOW_COPY_AND_ASSIGN(ShaderCacheFactory);
+ // Used fo the cache Clear call.
jonathan.backer 2013/03/20 18:39:05 s/fo/for
dsinclair 2013/03/21 17:46:59 Done.
+ OpType op_type_;
+ base::FilePath clear_path_;
+ base::Time delete_begin_;
+ base::Time delete_end_;
+ base::Closure clear_callback_;
+ scoped_refptr<ShaderDiskCache> clear_shader_cache_;
jonathan.backer 2013/03/20 18:39:05 What happens if you clear multiple times in rapid
dsinclair 2013/03/21 17:46:59 Done.
+
+ DISALLOW_COPY_AND_ASSIGN(ShaderCacheFactoryImpl);
};
} // namespace content
-#endif // CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_H_
+#endif // CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698