| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 | 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/platform_file.h" | |
| 16 #include "base/time.h" | 15 #include "base/time.h" |
| 17 #include "net/base/cache_type.h" | 16 #include "net/base/cache_type.h" |
| 18 #include "net/base/completion_callback.h" | 17 #include "net/base/completion_callback.h" |
| 19 | 18 |
| 20 namespace net { | 19 namespace net { |
| 21 class IOBuffer; | 20 class IOBuffer; |
| 22 } | 21 } |
| 23 | 22 |
| 24 namespace disk_cache { | 23 namespace disk_cache { |
| 25 | 24 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // Note that the callback will be invoked in any case, even after Close has | 147 // Note that the callback will be invoked in any case, even after Close has |
| 149 // been called; in other words, the caller may close this entry without | 148 // been called; in other words, the caller may close this entry without |
| 150 // having to wait for all the callbacks, and still rely on the cleanup | 149 // having to wait for all the callbacks, and still rely on the cleanup |
| 151 // performed from the callback code. | 150 // performed from the callback code. |
| 152 // If truncate is true, this call will truncate the stored data at the end of | 151 // If truncate is true, this call will truncate the stored data at the end of |
| 153 // what we are writing here. | 152 // what we are writing here. |
| 154 virtual int WriteData(int index, int offset, net::IOBuffer* buf, int buf_len, | 153 virtual int WriteData(int index, int offset, net::IOBuffer* buf, int buf_len, |
| 155 net::CompletionCallback* completion_callback, | 154 net::CompletionCallback* completion_callback, |
| 156 bool truncate) = 0; | 155 bool truncate) = 0; |
| 157 | 156 |
| 158 // Prepares a target stream as an external file, returns a corresponding | |
| 159 // base::PlatformFile if successful, returns base::kInvalidPlatformFileValue | |
| 160 // if fails. If this call returns a valid base::PlatformFile value (i.e. | |
| 161 // not base::kInvalidPlatformFileValue), there is no guarantee that the file | |
| 162 // is truncated. Implementor can always return base::kInvalidPlatformFileValue | |
| 163 // if external file is not available in that particular implementation. | |
| 164 // The caller should close the file handle returned by this method or there | |
| 165 // will be a leak. | |
| 166 // With a stream prepared as an external file, the stream would always be | |
| 167 // kept in an external file since creation, even if the stream has 0 bytes. | |
| 168 // So we need to be cautious about using this option for preparing a stream or | |
| 169 // we will end up having a lot of empty cache files. Calling this method also | |
| 170 // means that all data written to the stream will always be written to file | |
| 171 // directly *without* buffering. | |
| 172 virtual base::PlatformFile UseExternalFile(int index) = 0; | |
| 173 | |
| 174 // Returns an asynchronous read file handle for the cache stream referenced by | |
| 175 // |index|. Values other than base::kInvalidPlatformFileValue are successful | |
| 176 // and the file handle should be managed by the caller, i.e. the caller should | |
| 177 // close the handle after use or there will be a leak. | |
| 178 virtual base::PlatformFile GetPlatformFile(int index) = 0; | |
| 179 | |
| 180 protected: | 157 protected: |
| 181 virtual ~Entry() {} | 158 virtual ~Entry() {} |
| 182 }; | 159 }; |
| 183 | 160 |
| 184 } // namespace disk_cache | 161 } // namespace disk_cache |
| 185 | 162 |
| 186 #endif // NET_DISK_CACHE_DISK_CACHE_H_ | 163 #endif // NET_DISK_CACHE_DISK_CACHE_H_ |
| OLD | NEW |