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> |
| 9 |
8 #include <map> | 10 #include <map> |
9 #include <queue> | 11 #include <queue> |
10 #include <string> | 12 #include <string> |
11 | 13 |
12 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
14 #include "base/memory/singleton.h" | 17 #include "base/memory/singleton.h" |
15 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
16 #include "net/disk_cache/disk_cache.h" | 19 #include "net/disk_cache/disk_cache.h" |
17 | 20 |
18 namespace content { | 21 namespace content { |
19 | 22 |
20 class ShaderDiskCacheEntry; | 23 class ShaderDiskCacheEntry; |
21 class ShaderDiskReadHelper; | 24 class ShaderDiskReadHelper; |
22 class ShaderClearHelper; | 25 class ShaderClearHelper; |
(...skipping 25 matching lines...) Expand all Loading... |
48 const base::Time end_time, | 51 const base::Time end_time, |
49 const net::CompletionCallback& completion_callback); | 52 const net::CompletionCallback& completion_callback); |
50 | 53 |
51 // Sets a callback for when the cache is available. If the cache is | 54 // Sets a callback for when the cache is available. If the cache is |
52 // already available the callback will not be called and net::OK is returned. | 55 // already available the callback will not be called and net::OK is returned. |
53 // If the callback is set net::ERR_IO_PENDING is returned and the callback | 56 // If the callback is set net::ERR_IO_PENDING is returned and the callback |
54 // will be executed when the cache is available. | 57 // will be executed when the cache is available. |
55 int SetAvailableCallback(const net::CompletionCallback& callback); | 58 int SetAvailableCallback(const net::CompletionCallback& callback); |
56 | 59 |
57 // Returns the number of elements currently in the cache. | 60 // Returns the number of elements currently in the cache. |
58 int32 Size(); | 61 int32_t Size(); |
59 | 62 |
60 // Set a callback notification for when all current entries have been | 63 // Set a callback notification for when all current entries have been |
61 // written to the cache. | 64 // written to the cache. |
62 // The return value is a net error code. If this method returns | 65 // The return value is a net error code. If this method returns |
63 // ERR_IO_PENDING, the |callback| will be invoked when all entries have | 66 // ERR_IO_PENDING, the |callback| will be invoked when all entries have |
64 // been written to the cache. | 67 // been written to the cache. |
65 int SetCacheCompleteCallback(const net::CompletionCallback& callback); | 68 int SetCacheCompleteCallback(const net::CompletionCallback& callback); |
66 | 69 |
67 private: | 70 private: |
68 friend class base::RefCounted<ShaderDiskCache>; | 71 friend class base::RefCounted<ShaderDiskCache>; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // Clear the shader disk cache for the given |path|. This supports unbounded | 107 // Clear the shader disk cache for the given |path|. This supports unbounded |
105 // deletes in either direction by using null Time values for either | 108 // deletes in either direction by using null Time values for either |
106 // |begin_time| or |end_time|. The |callback| will be executed when the | 109 // |begin_time| or |end_time|. The |callback| will be executed when the |
107 // clear is complete. | 110 // clear is complete. |
108 void ClearByPath(const base::FilePath& path, | 111 void ClearByPath(const base::FilePath& path, |
109 const base::Time& begin_time, | 112 const base::Time& begin_time, |
110 const base::Time& end_time, | 113 const base::Time& end_time, |
111 const base::Closure& callback); | 114 const base::Closure& callback); |
112 | 115 |
113 // Retrieve the shader disk cache for the provided |client_id|. | 116 // Retrieve the shader disk cache for the provided |client_id|. |
114 scoped_refptr<ShaderDiskCache> Get(int32 client_id); | 117 scoped_refptr<ShaderDiskCache> Get(int32_t client_id); |
115 | 118 |
116 // Set the |path| to be used for the disk cache for |client_id|. | 119 // Set the |path| to be used for the disk cache for |client_id|. |
117 void SetCacheInfo(int32 client_id, const base::FilePath& path); | 120 void SetCacheInfo(int32_t client_id, const base::FilePath& path); |
118 | 121 |
119 // Remove the path mapping for |client_id|. | 122 // Remove the path mapping for |client_id|. |
120 void RemoveCacheInfo(int32 client_id); | 123 void RemoveCacheInfo(int32_t client_id); |
121 | 124 |
122 // Set the provided |cache| into the cache map for the given |path|. | 125 // Set the provided |cache| into the cache map for the given |path|. |
123 void AddToCache(const base::FilePath& path, ShaderDiskCache* cache); | 126 void AddToCache(const base::FilePath& path, ShaderDiskCache* cache); |
124 | 127 |
125 // Remove the provided |path| from our cache map. | 128 // Remove the provided |path| from our cache map. |
126 void RemoveFromCache(const base::FilePath& path); | 129 void RemoveFromCache(const base::FilePath& path); |
127 | 130 |
128 private: | 131 private: |
129 friend struct base::DefaultSingletonTraits<ShaderCacheFactory>; | 132 friend struct base::DefaultSingletonTraits<ShaderCacheFactory>; |
130 friend class ShaderClearHelper; | 133 friend class ShaderClearHelper; |
131 | 134 |
132 ShaderCacheFactory(); | 135 ShaderCacheFactory(); |
133 ~ShaderCacheFactory(); | 136 ~ShaderCacheFactory(); |
134 | 137 |
135 scoped_refptr<ShaderDiskCache> GetByPath(const base::FilePath& path); | 138 scoped_refptr<ShaderDiskCache> GetByPath(const base::FilePath& path); |
136 void CacheCleared(const base::FilePath& path); | 139 void CacheCleared(const base::FilePath& path); |
137 | 140 |
138 typedef std::map<base::FilePath, ShaderDiskCache*> ShaderCacheMap; | 141 typedef std::map<base::FilePath, ShaderDiskCache*> ShaderCacheMap; |
139 ShaderCacheMap shader_cache_map_; | 142 ShaderCacheMap shader_cache_map_; |
140 | 143 |
141 typedef std::map<int32, base::FilePath> ClientIdToPathMap; | 144 typedef std::map<int32_t, base::FilePath> ClientIdToPathMap; |
142 ClientIdToPathMap client_id_to_path_map_; | 145 ClientIdToPathMap client_id_to_path_map_; |
143 | 146 |
144 typedef std::queue<scoped_refptr<ShaderClearHelper> > ShaderClearQueue; | 147 typedef std::queue<scoped_refptr<ShaderClearHelper> > ShaderClearQueue; |
145 typedef std::map<base::FilePath, ShaderClearQueue> ShaderClearMap; | 148 typedef std::map<base::FilePath, ShaderClearQueue> ShaderClearMap; |
146 ShaderClearMap shader_clear_map_; | 149 ShaderClearMap shader_clear_map_; |
147 | 150 |
148 DISALLOW_COPY_AND_ASSIGN(ShaderCacheFactory); | 151 DISALLOW_COPY_AND_ASSIGN(ShaderCacheFactory); |
149 }; | 152 }; |
150 | 153 |
151 } // namespace content | 154 } // namespace content |
152 | 155 |
153 #endif // CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_H_ | 156 #endif // CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_H_ |
154 | 157 |
OLD | NEW |