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 #ifndef NET_DISK_CACHE_ENTRY_IMPL_H_ | 5 #ifndef NET_DISK_CACHE_ENTRY_IMPL_H_ |
6 #define NET_DISK_CACHE_ENTRY_IMPL_H_ | 6 #define NET_DISK_CACHE_ENTRY_IMPL_H_ |
7 | 7 |
8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
9 #include "net/disk_cache/disk_cache.h" | 9 #include "net/disk_cache/disk_cache.h" |
10 #include "net/disk_cache/storage_block.h" | 10 #include "net/disk_cache/storage_block.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 virtual int ReadSparseData(int64 offset, net::IOBuffer* buf, int buf_len, | 46 virtual int ReadSparseData(int64 offset, net::IOBuffer* buf, int buf_len, |
47 net::CompletionCallback* completion_callback); | 47 net::CompletionCallback* completion_callback); |
48 virtual int WriteSparseData(int64 offset, net::IOBuffer* buf, int buf_len, | 48 virtual int WriteSparseData(int64 offset, net::IOBuffer* buf, int buf_len, |
49 net::CompletionCallback* completion_callback); | 49 net::CompletionCallback* completion_callback); |
50 virtual int GetAvailableRange(int64 offset, int len, int64* start, | 50 virtual int GetAvailableRange(int64 offset, int len, int64* start, |
51 CompletionCallback* callback); | 51 CompletionCallback* callback); |
52 virtual bool CouldBeSparse() const; | 52 virtual bool CouldBeSparse() const; |
53 virtual void CancelSparseIO(); | 53 virtual void CancelSparseIO(); |
54 virtual int ReadyForSparseIO(net::CompletionCallback* completion_callback); | 54 virtual int ReadyForSparseIO(net::CompletionCallback* completion_callback); |
55 | 55 |
| 56 // Background implementation of the Entry interface. |
| 57 void DoomImpl(); |
| 58 int ReadDataImpl(int index, int offset, net::IOBuffer* buf, int buf_len, |
| 59 CompletionCallback* callback); |
| 60 int WriteDataImpl(int index, int offset, net::IOBuffer* buf, int buf_len, |
| 61 CompletionCallback* callback, bool truncate); |
| 62 int ReadSparseDataImpl(int64 offset, net::IOBuffer* buf, int buf_len, |
| 63 CompletionCallback* callback); |
| 64 int WriteSparseDataImpl(int64 offset, net::IOBuffer* buf, int buf_len, |
| 65 CompletionCallback* callback); |
| 66 int GetAvailableRangeImpl(int64 offset, int len, int64* start); |
| 67 void CancelSparseIOImpl(); |
| 68 int ReadyForSparseIOImpl(CompletionCallback* callback); |
| 69 |
56 inline CacheEntryBlock* entry() { | 70 inline CacheEntryBlock* entry() { |
57 return &entry_; | 71 return &entry_; |
58 } | 72 } |
59 | 73 |
60 inline CacheRankingsBlock* rankings() { | 74 inline CacheRankingsBlock* rankings() { |
61 return &node_; | 75 return &node_; |
62 } | 76 } |
63 | 77 |
64 uint32 GetHash(); | 78 uint32 GetHash(); |
65 | 79 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 193 |
180 // Logs this entry to the internal trace buffer. | 194 // Logs this entry to the internal trace buffer. |
181 void Log(const char* msg); | 195 void Log(const char* msg); |
182 | 196 |
183 CacheEntryBlock entry_; // Key related information for this entry. | 197 CacheEntryBlock entry_; // Key related information for this entry. |
184 CacheRankingsBlock node_; // Rankings related information for this entry. | 198 CacheRankingsBlock node_; // Rankings related information for this entry. |
185 BackendImpl* backend_; // Back pointer to the cache. | 199 BackendImpl* backend_; // Back pointer to the cache. |
186 scoped_array<char> user_buffers_[kNumStreams]; // Store user data. | 200 scoped_array<char> user_buffers_[kNumStreams]; // Store user data. |
187 // Files to store external user data and key. | 201 // Files to store external user data and key. |
188 scoped_refptr<File> files_[kNumStreams + 1]; | 202 scoped_refptr<File> files_[kNumStreams + 1]; |
189 // Copy of the file used to store the key. We don't own this object. | 203 mutable std::string key_; // Copy of the key. |
190 mutable File* key_file_; | |
191 int unreported_size_[kNumStreams]; // Bytes not reported yet to the backend. | 204 int unreported_size_[kNumStreams]; // Bytes not reported yet to the backend. |
192 bool doomed_; // True if this entry was removed from the cache. | 205 bool doomed_; // True if this entry was removed from the cache. |
193 scoped_ptr<SparseControl> sparse_; // Support for sparse entries. | 206 scoped_ptr<SparseControl> sparse_; // Support for sparse entries. |
194 | 207 |
195 DISALLOW_COPY_AND_ASSIGN(EntryImpl); | 208 DISALLOW_COPY_AND_ASSIGN(EntryImpl); |
196 }; | 209 }; |
197 | 210 |
198 } // namespace disk_cache | 211 } // namespace disk_cache |
199 | 212 |
200 #endif // NET_DISK_CACHE_ENTRY_IMPL_H_ | 213 #endif // NET_DISK_CACHE_ENTRY_IMPL_H_ |
OLD | NEW |