| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/time.h" | 15 #include "base/time.h" |
| 16 #include "net/base/cache_type.h" | 16 #include "net/base/cache_type.h" |
| 17 #include "net/base/completion_callback.h" | 17 #include "net/base/completion_callback.h" |
| 18 #include "net/base/net_export.h" | 18 #include "net/base/net_export.h" |
| 19 | 19 |
| 20 namespace base { |
| 20 class FilePath; | 21 class FilePath; |
| 21 | |
| 22 namespace base { | |
| 23 class MessageLoopProxy; | 22 class MessageLoopProxy; |
| 24 } | 23 } |
| 25 | 24 |
| 26 namespace net { | 25 namespace net { |
| 27 class IOBuffer; | 26 class IOBuffer; |
| 28 class NetLog; | 27 class NetLog; |
| 29 } | 28 } |
| 30 | 29 |
| 31 namespace disk_cache { | 30 namespace disk_cache { |
| 32 | 31 |
| 33 class Entry; | 32 class Entry; |
| 34 class Backend; | 33 class Backend; |
| 35 | 34 |
| 36 // Returns an instance of a Backend of the given |type|. |path| points to a | 35 // 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 | 36 // 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 | 37 // 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. | 38 // 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 | 39 // 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 | 40 // 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 | 41 // 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 | 42 // 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 | 43 // 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 | 44 // 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 | 45 // 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 | 46 // 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. | 47 // 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 | 48 // The pointer to receive the |backend| must remain valid until the operation |
| 50 // completes (the callback is notified). | 49 // completes (the callback is notified). |
| 51 NET_EXPORT int CreateCacheBackend(net::CacheType type, const FilePath& path, | 50 NET_EXPORT int CreateCacheBackend(net::CacheType type, |
| 51 const base::FilePath& path, |
| 52 int max_bytes, bool force, | 52 int max_bytes, bool force, |
| 53 base::MessageLoopProxy* thread, | 53 base::MessageLoopProxy* thread, |
| 54 net::NetLog* net_log, Backend** backend, | 54 net::NetLog* net_log, Backend** backend, |
| 55 const net::CompletionCallback& callback); | 55 const net::CompletionCallback& callback); |
| 56 | 56 |
| 57 // The root interface for a disk cache instance. | 57 // The root interface for a disk cache instance. |
| 58 class NET_EXPORT Backend { | 58 class NET_EXPORT Backend { |
| 59 public: | 59 public: |
| 60 typedef net::CompletionCallback CompletionCallback; | 60 typedef net::CompletionCallback CompletionCallback; |
| 61 | 61 |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 // Note: This method is deprecated. | 302 // Note: This method is deprecated. |
| 303 virtual int ReadyForSparseIO(const CompletionCallback& callback) = 0; | 303 virtual int ReadyForSparseIO(const CompletionCallback& callback) = 0; |
| 304 | 304 |
| 305 protected: | 305 protected: |
| 306 virtual ~Entry() {} | 306 virtual ~Entry() {} |
| 307 }; | 307 }; |
| 308 | 308 |
| 309 } // namespace disk_cache | 309 } // namespace disk_cache |
| 310 | 310 |
| 311 #endif // NET_DISK_CACHE_DISK_CACHE_H_ | 311 #endif // NET_DISK_CACHE_DISK_CACHE_H_ |
| OLD | NEW |