| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_SIMPLE_SIMPLE_ENTRY_IMPL_H_ | 5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ |
| 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ | 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 void OpenEntryInternal(bool have_index, | 188 void OpenEntryInternal(bool have_index, |
| 189 const CompletionCallback& callback, | 189 const CompletionCallback& callback, |
| 190 Entry** out_entry); | 190 Entry** out_entry); |
| 191 | 191 |
| 192 void CreateEntryInternal(bool have_index, | 192 void CreateEntryInternal(bool have_index, |
| 193 const CompletionCallback& callback, | 193 const CompletionCallback& callback, |
| 194 Entry** out_entry); | 194 Entry** out_entry); |
| 195 | 195 |
| 196 void CloseInternal(); | 196 void CloseInternal(); |
| 197 | 197 |
| 198 void ReadDataInternal(int index, | 198 int ReadDataInternal(bool sync_possible, |
| 199 int offset, | 199 int index, |
| 200 net::IOBuffer* buf, | 200 int offset, |
| 201 int buf_len, | 201 net::IOBuffer* buf, |
| 202 const CompletionCallback& callback); | 202 int buf_len, |
| 203 const CompletionCallback& callback); |
| 203 | 204 |
| 204 void WriteDataInternal(int index, | 205 void WriteDataInternal(int index, |
| 205 int offset, | 206 int offset, |
| 206 net::IOBuffer* buf, | 207 net::IOBuffer* buf, |
| 207 int buf_len, | 208 int buf_len, |
| 208 const CompletionCallback& callback, | 209 const CompletionCallback& callback, |
| 209 bool truncate); | 210 bool truncate); |
| 210 | 211 |
| 211 void ReadSparseDataInternal(int64_t sparse_offset, | 212 void ReadSparseDataInternal(int64_t sparse_offset, |
| 212 net::IOBuffer* buf, | 213 net::IOBuffer* buf, |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 // operations. | 299 // operations. |
| 299 void UpdateDataFromEntryStat(const SimpleEntryStat& entry_stat); | 300 void UpdateDataFromEntryStat(const SimpleEntryStat& entry_stat); |
| 300 | 301 |
| 301 int64_t GetDiskUsage() const; | 302 int64_t GetDiskUsage() const; |
| 302 | 303 |
| 303 // Used to report histograms. | 304 // Used to report histograms. |
| 304 void RecordReadIsParallelizable(const SimpleEntryOperation& operation) const; | 305 void RecordReadIsParallelizable(const SimpleEntryOperation& operation) const; |
| 305 void RecordWriteDependencyType(const SimpleEntryOperation& operation) const; | 306 void RecordWriteDependencyType(const SimpleEntryOperation& operation) const; |
| 306 | 307 |
| 307 // Completes a read from the stream data kept in memory, logging metrics | 308 // Completes a read from the stream data kept in memory, logging metrics |
| 308 // and updating metadata. If |callback| is non-null, it will be posted to the | 309 // and updating metadata. Returns the # of bytes read successfully. |
| 309 // current task runner with the return code. | 310 // This asumes the caller has already range-checked offset and buf_len |
| 310 void ReadFromBufferAndPostReply(net::GrowableIOBuffer* in_buf, | 311 // appropriately. |
| 311 int offset, | 312 int ReadFromBuffer(net::GrowableIOBuffer* in_buf, |
| 312 int buf_len, | 313 int offset, |
| 313 net::IOBuffer* out_buf, | 314 int buf_len, |
| 314 const CompletionCallback& callback); | 315 net::IOBuffer* out_buf); |
| 315 | 316 |
| 316 // Copies data from |buf| to the internal in-memory buffer for stream 0. If | 317 // Copies data from |buf| to the internal in-memory buffer for stream 0. If |
| 317 // |truncate| is set to true, the target buffer will be truncated at |offset| | 318 // |truncate| is set to true, the target buffer will be truncated at |offset| |
| 318 // + |buf_len| before being written. | 319 // + |buf_len| before being written. |
| 319 int SetStream0Data(net::IOBuffer* buf, | 320 int SetStream0Data(net::IOBuffer* buf, |
| 320 int offset, int buf_len, | 321 int offset, int buf_len, |
| 321 bool truncate); | 322 bool truncate); |
| 322 | 323 |
| 323 // Updates |crc32s_| and |crc32s_end_offset_| for a write of the data in | 324 // Updates |crc32s_| and |crc32s_end_offset_| for a write of the data in |
| 324 // |buffer| on |stream_index|, starting at |offset| and of length |length|. | 325 // |buffer| on |stream_index|, starting at |offset| and of length |length|. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 | 409 |
| 409 // Sometimes stream 1 data is prefetched when stream 0 is first read. | 410 // Sometimes stream 1 data is prefetched when stream 0 is first read. |
| 410 // If a write to the stream occurs on the entry the prefetch buffer is | 411 // If a write to the stream occurs on the entry the prefetch buffer is |
| 411 // discarded. It may also be null if it wasn't prefetched in the first place. | 412 // discarded. It may also be null if it wasn't prefetched in the first place. |
| 412 scoped_refptr<net::GrowableIOBuffer> stream_1_prefetch_data_; | 413 scoped_refptr<net::GrowableIOBuffer> stream_1_prefetch_data_; |
| 413 }; | 414 }; |
| 414 | 415 |
| 415 } // namespace disk_cache | 416 } // namespace disk_cache |
| 416 | 417 |
| 417 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ | 418 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ |
| OLD | NEW |