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 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 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, |
154 net::CompletionCallback* completion_callback, | 154 net::CompletionCallback* completion_callback, |
155 bool truncate) = 0; | 155 bool truncate) = 0; |
156 | 156 |
157 // Prepares a target stream as an external file, returns a corresponding | 157 // Prepares a target stream as an external file, returns a corresponding |
158 // base::PlatformFile if successful, returns base::kInvalidPlatformFileValue | 158 // base::PlatformFile if successful, returns base::kInvalidPlatformFileValue |
159 // if fails. If this call returns a valid base::PlatformFile value (i.e. | 159 // if fails. If this call returns a valid base::PlatformFile value (i.e. |
160 // not base::kInvalidPlatformFileValue), there is no guarantee that the file | 160 // not base::kInvalidPlatformFileValue), there is no guarantee that the file |
161 // is truncated. Implementor can always return base::kInvalidPlatformFileValue | 161 // is truncated. Implementor can always return base::kInvalidPlatformFileValue |
162 // if external file is not available in that particular implementation. | 162 // if external file is not available in that particular implementation. |
163 // Caller should never close the file handle returned by this method, since | 163 // The caller should close the file handle returned by this method or there |
164 // the handle should be managed by the implementor of this class. Caller | 164 // will be a leak. |
165 // should never save the handle for future use. | |
166 // With a stream prepared as an external file, the stream would always be | 165 // 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. | 166 // 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 | 167 // 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 | 168 // 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 | 169 // means that all data written to the stream will always be written to file |
171 // directly *without* buffering. | 170 // directly *without* buffering. |
172 virtual base::PlatformFile UseExternalFile(int index) = 0; | 171 virtual base::PlatformFile UseExternalFile(int index) = 0; |
173 | 172 |
174 // Returns a read file handle for the cache stream referenced by |index|. | 173 // Returns an asynchronous read file handle for the cache stream referenced by |
175 // Caller should never close the handle returned by this method and should | 174 // |index|. Values other than base::kInvalidPlatformFileValue are successful |
176 // not save it for future use. The lifetime of the base::PlatformFile handle | 175 // and the file handle should be managed by the caller, i.e. caller should |
177 // is managed by the implementor of this class. | 176 // close the handle after use or there will be a leak. |
178 virtual base::PlatformFile GetPlatformFile(int index) = 0; | 177 virtual base::PlatformFile GetPlatformFile(int index) = 0; |
179 | 178 |
180 protected: | 179 protected: |
181 virtual ~Entry() {} | 180 virtual ~Entry() {} |
182 }; | 181 }; |
183 | 182 |
184 } // namespace disk_cache | 183 } // namespace disk_cache |
185 | 184 |
186 #endif // NET_DISK_CACHE_DISK_CACHE_H_ | 185 #endif // NET_DISK_CACHE_DISK_CACHE_H_ |
OLD | NEW |