OLD | NEW |
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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/disk-cache | 6 // http://dev.chromium.org/developers/design-documents/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/cache_type.h" | 17 #include "net/base/cache_type.h" |
18 #include "net/base/completion_callback.h" | 18 #include "net/base/completion_callback.h" |
19 | 19 |
20 class FilePath; | 20 class FilePath; |
21 | 21 |
22 namespace base { | 22 namespace base { |
23 class MessageLoopProxy; | 23 class MessageLoopProxy; |
24 } | 24 } |
25 | 25 |
26 namespace net { | 26 namespace net { |
| 27 class BoundNetLog; |
27 class IOBuffer; | 28 class IOBuffer; |
| 29 class NetLog; |
28 } | 30 } |
29 | 31 |
30 namespace disk_cache { | 32 namespace disk_cache { |
31 | 33 |
32 class Entry; | 34 class Entry; |
33 class Backend; | 35 class Backend; |
34 typedef net::CompletionCallback CompletionCallback; | 36 typedef net::CompletionCallback CompletionCallback; |
35 | 37 |
36 // Returns an instance of a Backend of the given |type|. |path| points to a | 38 // Returns an instance of a Backend of the given |type|. |path| points to a |
37 // folder where the cached data will be stored (if appropriate). This cache | 39 // folder where the cached data will be stored (if appropriate). This cache |
38 // instance must be the only object that will be reading or writing files to | 40 // instance must be the only object that will be reading or writing files to |
39 // that folder. The returned object should be deleted when not needed anymore. | 41 // that folder. The returned object should be deleted when not needed anymore. |
40 // If |force| is true, and there is a problem with the cache initialization, the | 42 // If |force| is true, and there is a problem with the cache initialization, the |
41 // 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 |
42 // 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 |
43 // 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 |
44 // 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 |
45 // 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 |
46 // 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 |
47 // 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 |
48 // 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. |
49 // 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 |
50 // completes (the callback is notified). | 52 // completes (the callback is notified). |
51 int CreateCacheBackend(net::CacheType type, const FilePath& path, int max_bytes, | 53 int CreateCacheBackend(net::CacheType type, const FilePath& path, int max_bytes, |
52 bool force, base::MessageLoopProxy* thread, | 54 bool force, base::MessageLoopProxy* thread, |
53 Backend** backend, CompletionCallback* callback); | 55 net::NetLog* net_log, Backend** backend, |
| 56 CompletionCallback* callback); |
54 | 57 |
55 // The root interface for a disk cache instance. | 58 // The root interface for a disk cache instance. |
56 class Backend { | 59 class Backend { |
57 public: | 60 public: |
58 // If the backend is destroyed when there are operations in progress (any | 61 // If the backend is destroyed when there are operations in progress (any |
59 // callback that has not been invoked yet), this method cancels said | 62 // callback that has not been invoked yet), this method cancels said |
60 // operations so the callbacks are not invoked, possibly leaving the work | 63 // operations so the callbacks are not invoked, possibly leaving the work |
61 // half way (for instance, dooming just a few entries). Note that pending IO | 64 // half way (for instance, dooming just a few entries). Note that pending IO |
62 // for a given Entry (as opposed to the Backend) will still generate a | 65 // for a given Entry (as opposed to the Backend) will still generate a |
63 // callback from within this method. | 66 // callback from within this method. |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 // Note: This method is deprecated. | 290 // Note: This method is deprecated. |
288 virtual int ReadyForSparseIO(CompletionCallback* completion_callback) = 0; | 291 virtual int ReadyForSparseIO(CompletionCallback* completion_callback) = 0; |
289 | 292 |
290 protected: | 293 protected: |
291 virtual ~Entry() {} | 294 virtual ~Entry() {} |
292 }; | 295 }; |
293 | 296 |
294 } // namespace disk_cache | 297 } // namespace disk_cache |
295 | 298 |
296 #endif // NET_DISK_CACHE_DISK_CACHE_H_ | 299 #endif // NET_DISK_CACHE_DISK_CACHE_H_ |
OLD | NEW |