| 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 IOBuffer; | 27 class IOBuffer; |
| 28 class NetLog; |
| 28 } | 29 } |
| 29 | 30 |
| 30 namespace disk_cache { | 31 namespace disk_cache { |
| 31 | 32 |
| 32 class Entry; | 33 class Entry; |
| 33 class Backend; | 34 class Backend; |
| 34 typedef net::CompletionCallback CompletionCallback; | 35 typedef net::CompletionCallback CompletionCallback; |
| 35 | 36 |
| 36 // Returns an instance of a Backend of the given |type|. |path| points to a | 37 // 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 | 38 // 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 | 39 // 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. | 40 // 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 | 41 // 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 | 42 // 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 | 43 // 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 | 44 // 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 | 45 // 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 | 46 // 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 | 47 // 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 | 48 // 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. | 49 // 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 | 50 // The pointer to receive the |backend| must remain valid until the operation |
| 50 // completes (the callback is notified). | 51 // completes (the callback is notified). |
| 51 int CreateCacheBackend(net::CacheType type, const FilePath& path, int max_bytes, | 52 int CreateCacheBackend(net::CacheType type, const FilePath& path, int max_bytes, |
| 52 bool force, base::MessageLoopProxy* thread, | 53 bool force, base::MessageLoopProxy* thread, |
| 53 Backend** backend, CompletionCallback* callback); | 54 net::NetLog* net_log, Backend** backend, |
| 55 CompletionCallback* callback); |
| 54 | 56 |
| 55 // The root interface for a disk cache instance. | 57 // The root interface for a disk cache instance. |
| 56 class Backend { | 58 class Backend { |
| 57 public: | 59 public: |
| 58 // If the backend is destroyed when there are operations in progress (any | 60 // If the backend is destroyed when there are operations in progress (any |
| 59 // callback that has not been invoked yet), this method cancels said | 61 // callback that has not been invoked yet), this method cancels said |
| 60 // operations so the callbacks are not invoked, possibly leaving the work | 62 // 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 | 63 // 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 | 64 // for a given Entry (as opposed to the Backend) will still generate a |
| 63 // callback from within this method. | 65 // callback from within this method. |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 // Note: This method is deprecated. | 289 // Note: This method is deprecated. |
| 288 virtual int ReadyForSparseIO(CompletionCallback* completion_callback) = 0; | 290 virtual int ReadyForSparseIO(CompletionCallback* completion_callback) = 0; |
| 289 | 291 |
| 290 protected: | 292 protected: |
| 291 virtual ~Entry() {} | 293 virtual ~Entry() {} |
| 292 }; | 294 }; |
| 293 | 295 |
| 294 } // namespace disk_cache | 296 } // namespace disk_cache |
| 295 | 297 |
| 296 #endif // NET_DISK_CACHE_DISK_CACHE_H_ | 298 #endif // NET_DISK_CACHE_DISK_CACHE_H_ |
| OLD | NEW |