OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Defines the public interface of the disk cache. For more details see | 5 // Defines the public interface of the disk cache. For more details see |
6 // http://dev.chromium.org/developers/design-documents/network-stack/disk-cache | 6 // http://dev.chromium.org/developers/design-documents/network-stack/disk-cache |
7 | 7 |
8 #ifndef NET_DISK_CACHE_DISK_CACHE_H_ | 8 #ifndef NET_DISK_CACHE_DISK_CACHE_H_ |
9 #define NET_DISK_CACHE_DISK_CACHE_H_ | 9 #define NET_DISK_CACHE_DISK_CACHE_H_ |
10 #pragma once | 10 #pragma once |
11 | 11 |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
16 #include "base/time.h" | 16 #include "base/time.h" |
17 #include "net/base/net_api.h" | |
18 #include "net/base/cache_type.h" | 17 #include "net/base/cache_type.h" |
19 #include "net/base/completion_callback.h" | 18 #include "net/base/completion_callback.h" |
19 #include "net/base/net_export.h" | |
20 | 20 |
21 class FilePath; | 21 class FilePath; |
22 | 22 |
23 namespace base { | 23 namespace base { |
24 class MessageLoopProxy; | 24 class MessageLoopProxy; |
25 } | 25 } |
26 | 26 |
27 namespace net { | 27 namespace net { |
28 class IOBuffer; | 28 class IOBuffer; |
29 class NetLog; | 29 class NetLog; |
(...skipping 13 matching lines...) Expand all Loading... | |
43 // files will be deleted and a new set will be created. |max_bytes| is the | 43 // files will be deleted and a new set will be created. |max_bytes| is the |
44 // maximum size the cache can grow to. If zero is passed in as |max_bytes|, the | 44 // maximum size the cache can grow to. If zero is passed in as |max_bytes|, the |
45 // cache will determine the value to use. |thread| can be used to perform IO | 45 // cache will determine the value to use. |thread| can be used to perform IO |
46 // operations if a dedicated thread is required; a valid value is expected for | 46 // operations if a dedicated thread is required; a valid value is expected for |
47 // any backend that performs operations on a disk. The returned pointer can be | 47 // any backend that performs operations on a disk. The returned pointer can be |
48 // NULL if a fatal error is found. The actual return value of the function is a | 48 // NULL if a fatal error is found. The actual return value of the function is a |
49 // net error code. If this function returns ERR_IO_PENDING, the |callback| will | 49 // net error code. If this function returns ERR_IO_PENDING, the |callback| will |
50 // be invoked when a backend is available or a fatal error condition is reached. | 50 // be invoked when a backend is available or a fatal error condition is reached. |
51 // The pointer to receive the |backend| must remain valid until the operation | 51 // The pointer to receive the |backend| must remain valid until the operation |
52 // completes (the callback is notified). | 52 // completes (the callback is notified). |
53 NET_API int CreateCacheBackend(net::CacheType type, const FilePath& path, | 53 NET_EXPORT int CreateCacheBackend(net::CacheType type, const FilePath& path, |
54 int max_bytes, bool force, | 54 int max_bytes, bool force, |
55 base::MessageLoopProxy* thread, | 55 base::MessageLoopProxy* thread, |
56 net::NetLog* net_log, Backend** backend, | 56 net::NetLog* net_log, Backend** backend, |
57 CompletionCallback* callback); | 57 CompletionCallback* callback); |
58 | 58 |
59 // The root interface for a disk cache instance. | 59 // The root interface for a disk cache instance. |
60 class NET_API Backend { | 60 class NET_EXPORT Backend { |
61 public: | 61 public: |
62 // If the backend is destroyed when there are operations in progress (any | 62 // If the backend is destroyed when there are operations in progress (any |
63 // callback that has not been invoked yet), this method cancels said | 63 // callback that has not been invoked yet), this method cancels said |
64 // operations so the callbacks are not invoked, possibly leaving the work | 64 // operations so the callbacks are not invoked, possibly leaving the work |
65 // half way (for instance, dooming just a few entries). Note that pending IO | 65 // half way (for instance, dooming just a few entries). Note that pending IO |
66 // for a given Entry (as opposed to the Backend) will still generate a | 66 // for a given Entry (as opposed to the Backend) will still generate a |
67 // callback from within this method. | 67 // callback from within this method. |
68 virtual ~Backend() {} | 68 virtual ~Backend() {} |
69 | 69 |
70 // Returns the number of entries in the cache. | 70 // Returns the number of entries in the cache. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 // Return a list of cache statistics. | 137 // Return a list of cache statistics. |
138 virtual void GetStats( | 138 virtual void GetStats( |
139 std::vector<std::pair<std::string, std::string> >* stats) = 0; | 139 std::vector<std::pair<std::string, std::string> >* stats) = 0; |
140 | 140 |
141 // Called whenever an external cache in the system reuses the resource | 141 // Called whenever an external cache in the system reuses the resource |
142 // referred to by |key|. | 142 // referred to by |key|. |
143 virtual void OnExternalCacheHit(const std::string& key) = 0; | 143 virtual void OnExternalCacheHit(const std::string& key) = 0; |
144 }; | 144 }; |
145 | 145 |
146 // This interface represents an entry in the disk cache. | 146 // This interface represents an entry in the disk cache. |
147 class NET_TEST Entry { | 147 class NET_EXPORT_PRIVATE Entry { |
rvargas (doing something else)
2011/08/11 01:25:29
Could you make this a NET_EXPORT?. My mistake.
| |
148 public: | 148 public: |
149 // Marks this cache entry for deletion. | 149 // Marks this cache entry for deletion. |
150 virtual void Doom() = 0; | 150 virtual void Doom() = 0; |
151 | 151 |
152 // Releases this entry. Calling this method does not cancel pending IO | 152 // Releases this entry. Calling this method does not cancel pending IO |
153 // operations on this entry. Even after the last reference to this object has | 153 // operations on this entry. Even after the last reference to this object has |
154 // been released, pending completion callbacks may be invoked. | 154 // been released, pending completion callbacks may be invoked. |
155 virtual void Close() = 0; | 155 virtual void Close() = 0; |
156 | 156 |
157 // Returns the key associated with this cache entry. | 157 // Returns the key associated with this cache entry. |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 // Note: This method is deprecated. | 295 // Note: This method is deprecated. |
296 virtual int ReadyForSparseIO(CompletionCallback* completion_callback) = 0; | 296 virtual int ReadyForSparseIO(CompletionCallback* completion_callback) = 0; |
297 | 297 |
298 protected: | 298 protected: |
299 virtual ~Entry() {} | 299 virtual ~Entry() {} |
300 }; | 300 }; |
301 | 301 |
302 } // namespace disk_cache | 302 } // namespace disk_cache |
303 | 303 |
304 #endif // NET_DISK_CACHE_DISK_CACHE_H_ | 304 #endif // NET_DISK_CACHE_DISK_CACHE_H_ |
OLD | NEW |