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 | |
70 inline CacheEntryBlock* entry() { | 56 inline CacheEntryBlock* entry() { |
71 return &entry_; | 57 return &entry_; |
72 } | 58 } |
73 | 59 |
74 inline CacheRankingsBlock* rankings() { | 60 inline CacheRankingsBlock* rankings() { |
75 return &node_; | 61 return &node_; |
76 } | 62 } |
77 | 63 |
78 uint32 GetHash(); | 64 uint32 GetHash(); |
79 | 65 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 179 |
194 // Logs this entry to the internal trace buffer. | 180 // Logs this entry to the internal trace buffer. |
195 void Log(const char* msg); | 181 void Log(const char* msg); |
196 | 182 |
197 CacheEntryBlock entry_; // Key related information for this entry. | 183 CacheEntryBlock entry_; // Key related information for this entry. |
198 CacheRankingsBlock node_; // Rankings related information for this entry. | 184 CacheRankingsBlock node_; // Rankings related information for this entry. |
199 BackendImpl* backend_; // Back pointer to the cache. | 185 BackendImpl* backend_; // Back pointer to the cache. |
200 scoped_array<char> user_buffers_[kNumStreams]; // Store user data. | 186 scoped_array<char> user_buffers_[kNumStreams]; // Store user data. |
201 // Files to store external user data and key. | 187 // Files to store external user data and key. |
202 scoped_refptr<File> files_[kNumStreams + 1]; | 188 scoped_refptr<File> files_[kNumStreams + 1]; |
203 mutable std::string key_; // Copy of the key. | 189 // Copy of the file used to store the key. We don't own this object. |
| 190 mutable File* key_file_; |
204 int unreported_size_[kNumStreams]; // Bytes not reported yet to the backend. | 191 int unreported_size_[kNumStreams]; // Bytes not reported yet to the backend. |
205 bool doomed_; // True if this entry was removed from the cache. | 192 bool doomed_; // True if this entry was removed from the cache. |
206 scoped_ptr<SparseControl> sparse_; // Support for sparse entries. | 193 scoped_ptr<SparseControl> sparse_; // Support for sparse entries. |
207 | 194 |
208 DISALLOW_COPY_AND_ASSIGN(EntryImpl); | 195 DISALLOW_COPY_AND_ASSIGN(EntryImpl); |
209 }; | 196 }; |
210 | 197 |
211 } // namespace disk_cache | 198 } // namespace disk_cache |
212 | 199 |
213 #endif // NET_DISK_CACHE_ENTRY_IMPL_H_ | 200 #endif // NET_DISK_CACHE_ENTRY_IMPL_H_ |
OLD | NEW |