OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "net/base/net_log.h" | 10 #include "net/base/net_log.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 kReadAsync1, | 34 kReadAsync1, |
35 kWriteAsync1 | 35 kWriteAsync1 |
36 }; | 36 }; |
37 | 37 |
38 EntryImpl(BackendImpl* backend, Addr address, bool read_only); | 38 EntryImpl(BackendImpl* backend, Addr address, bool read_only); |
39 | 39 |
40 // Background implementation of the Entry interface. | 40 // Background implementation of the Entry interface. |
41 void DoomImpl(); | 41 void DoomImpl(); |
42 int ReadDataImpl(int index, int offset, net::IOBuffer* buf, int buf_len, | 42 int ReadDataImpl(int index, int offset, net::IOBuffer* buf, int buf_len, |
43 OldCompletionCallback* callback); | 43 OldCompletionCallback* callback); |
44 int ReadDataImpl(int index, int offset, net::IOBuffer* buf, int buf_len, | |
45 const net::CompletionCallback& callback); | |
46 int WriteDataImpl(int index, int offset, net::IOBuffer* buf, int buf_len, | 44 int WriteDataImpl(int index, int offset, net::IOBuffer* buf, int buf_len, |
47 OldCompletionCallback* callback, bool truncate); | 45 OldCompletionCallback* callback, bool truncate); |
48 int WriteDataImpl(int index, int offset, net::IOBuffer* buf, int buf_len, | |
49 const net::CompletionCallback& callback, bool truncate); | |
50 int ReadSparseDataImpl(int64 offset, net::IOBuffer* buf, int buf_len, | 46 int ReadSparseDataImpl(int64 offset, net::IOBuffer* buf, int buf_len, |
51 OldCompletionCallback* callback); | 47 OldCompletionCallback* callback); |
52 int WriteSparseDataImpl(int64 offset, net::IOBuffer* buf, int buf_len, | 48 int WriteSparseDataImpl(int64 offset, net::IOBuffer* buf, int buf_len, |
53 OldCompletionCallback* callback); | 49 OldCompletionCallback* callback); |
54 int GetAvailableRangeImpl(int64 offset, int len, int64* start); | 50 int GetAvailableRangeImpl(int64 offset, int len, int64* start); |
55 void CancelSparseIOImpl(); | 51 void CancelSparseIOImpl(); |
56 int ReadyForSparseIOImpl(OldCompletionCallback* callback); | 52 int ReadyForSparseIOImpl(OldCompletionCallback* callback); |
57 | 53 |
58 inline CacheEntryBlock* entry() { | 54 inline CacheEntryBlock* entry() { |
59 return &entry_; | 55 return &entry_; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // Entry interface. | 142 // Entry interface. |
147 virtual void Doom() OVERRIDE; | 143 virtual void Doom() OVERRIDE; |
148 virtual void Close() OVERRIDE; | 144 virtual void Close() OVERRIDE; |
149 virtual std::string GetKey() const OVERRIDE; | 145 virtual std::string GetKey() const OVERRIDE; |
150 virtual base::Time GetLastUsed() const OVERRIDE; | 146 virtual base::Time GetLastUsed() const OVERRIDE; |
151 virtual base::Time GetLastModified() const OVERRIDE; | 147 virtual base::Time GetLastModified() const OVERRIDE; |
152 virtual int32 GetDataSize(int index) const OVERRIDE; | 148 virtual int32 GetDataSize(int index) const OVERRIDE; |
153 virtual int ReadData( | 149 virtual int ReadData( |
154 int index, int offset, net::IOBuffer* buf, int buf_len, | 150 int index, int offset, net::IOBuffer* buf, int buf_len, |
155 net::OldCompletionCallback* completion_callback) OVERRIDE; | 151 net::OldCompletionCallback* completion_callback) OVERRIDE; |
156 virtual int ReadData( | |
157 int index, int offset, net::IOBuffer* buf, int buf_len, | |
158 const net::CompletionCallback& completion_callback) OVERRIDE; | |
159 virtual int WriteData(int index, int offset, net::IOBuffer* buf, int buf_len, | 152 virtual int WriteData(int index, int offset, net::IOBuffer* buf, int buf_len, |
160 net::OldCompletionCallback* completion_callback, | 153 net::OldCompletionCallback* completion_callback, |
161 bool truncate) OVERRIDE; | 154 bool truncate) OVERRIDE; |
162 virtual int WriteData(int index, int offset, net::IOBuffer* buf, int buf_len, | |
163 const net::CompletionCallback& completion_callback, | |
164 bool truncate) OVERRIDE; | |
165 virtual int ReadSparseData( | 155 virtual int ReadSparseData( |
166 int64 offset, net::IOBuffer* buf, int buf_len, | 156 int64 offset, net::IOBuffer* buf, int buf_len, |
167 net::OldCompletionCallback* completion_callback) OVERRIDE; | 157 net::OldCompletionCallback* completion_callback) OVERRIDE; |
168 virtual int WriteSparseData( | 158 virtual int WriteSparseData( |
169 int64 offset, net::IOBuffer* buf, int buf_len, | 159 int64 offset, net::IOBuffer* buf, int buf_len, |
170 net::OldCompletionCallback* completion_callback) OVERRIDE; | 160 net::OldCompletionCallback* completion_callback) OVERRIDE; |
171 virtual int GetAvailableRange(int64 offset, int len, int64* start, | 161 virtual int GetAvailableRange(int64 offset, int len, int64* start, |
172 OldCompletionCallback* callback) OVERRIDE; | 162 OldCompletionCallback* callback) OVERRIDE; |
173 virtual bool CouldBeSparse() const OVERRIDE; | 163 virtual bool CouldBeSparse() const OVERRIDE; |
174 virtual void CancelSparseIO() OVERRIDE; | 164 virtual void CancelSparseIO() OVERRIDE; |
175 virtual int ReadyForSparseIO( | 165 virtual int ReadyForSparseIO( |
176 net::OldCompletionCallback* completion_callback) OVERRIDE; | 166 net::OldCompletionCallback* completion_callback) OVERRIDE; |
177 | 167 |
178 private: | 168 private: |
179 enum { | 169 enum { |
180 kNumStreams = 3 | 170 kNumStreams = 3 |
181 }; | 171 }; |
182 class UserBuffer; | 172 class UserBuffer; |
183 | 173 |
184 virtual ~EntryImpl(); | 174 virtual ~EntryImpl(); |
185 | 175 |
186 // Do all the work for ReadDataImpl and WriteDataImpl. Implemented as | 176 // Do all the work for ReadDataImpl and WriteDataImpl. Implemented as |
187 // separate functions to make logging of results simpler. | 177 // separate functions to make logging of results simpler. |
188 int InternalReadData(int index, int offset, net::IOBuffer* buf, | 178 int InternalReadData(int index, int offset, net::IOBuffer* buf, |
189 int buf_len, OldCompletionCallback* callback); | 179 int buf_len, OldCompletionCallback* callback); |
190 int InternalReadData(int index, int offset, net::IOBuffer* buf, | |
191 int buf_len, const net::CompletionCallback& callback); | |
192 int InternalWriteData(int index, int offset, net::IOBuffer* buf, int buf_len, | 180 int InternalWriteData(int index, int offset, net::IOBuffer* buf, int buf_len, |
193 OldCompletionCallback* callback, bool truncate); | 181 OldCompletionCallback* callback, bool truncate); |
194 int InternalWriteData(int index, int offset, net::IOBuffer* buf, int buf_len, | |
195 const net::CompletionCallback& callback, bool truncate); | |
196 | 182 |
197 // Initializes the storage for an internal or external data block. | 183 // Initializes the storage for an internal or external data block. |
198 bool CreateDataBlock(int index, int size); | 184 bool CreateDataBlock(int index, int size); |
199 | 185 |
200 // Initializes the storage for an internal or external generic block. | 186 // Initializes the storage for an internal or external generic block. |
201 bool CreateBlock(int size, Addr* address); | 187 bool CreateBlock(int size, Addr* address); |
202 | 188 |
203 // Deletes the data pointed by address, maybe backed by files_[index]. | 189 // Deletes the data pointed by address, maybe backed by files_[index]. |
204 // Note that most likely the caller should delete (and store) the reference to | 190 // Note that most likely the caller should delete (and store) the reference to |
205 // |address| *before* calling this method because we don't want to have an | 191 // |address| *before* calling this method because we don't want to have an |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 scoped_ptr<SparseControl> sparse_; // Support for sparse entries. | 265 scoped_ptr<SparseControl> sparse_; // Support for sparse entries. |
280 | 266 |
281 net::BoundNetLog net_log_; | 267 net::BoundNetLog net_log_; |
282 | 268 |
283 DISALLOW_COPY_AND_ASSIGN(EntryImpl); | 269 DISALLOW_COPY_AND_ASSIGN(EntryImpl); |
284 }; | 270 }; |
285 | 271 |
286 } // namespace disk_cache | 272 } // namespace disk_cache |
287 | 273 |
288 #endif // NET_DISK_CACHE_ENTRY_IMPL_H_ | 274 #endif // NET_DISK_CACHE_ENTRY_IMPL_H_ |
OLD | NEW |