Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: net/disk_cache/simple/simple_entry_impl.h

Issue 2874833005: SimpleCache: read small files all at once. (Closed)
Patch Set: Rename + comment a method. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 // the entry in |entry_stat|. Updates the metadata in the entry and in the 305 // the entry in |entry_stat|. Updates the metadata in the entry and in the
306 // index to make them available on next IO operations. 306 // index to make them available on next IO operations.
307 void UpdateDataFromEntryStat(const SimpleEntryStat& entry_stat); 307 void UpdateDataFromEntryStat(const SimpleEntryStat& entry_stat);
308 308
309 int64_t GetDiskUsage() const; 309 int64_t GetDiskUsage() const;
310 310
311 // Used to report histograms. 311 // Used to report histograms.
312 void RecordReadIsParallelizable(const SimpleEntryOperation& operation) const; 312 void RecordReadIsParallelizable(const SimpleEntryOperation& operation) const;
313 void RecordWriteDependencyType(const SimpleEntryOperation& operation) const; 313 void RecordWriteDependencyType(const SimpleEntryOperation& operation) const;
314 314
315 // Reads from the stream 0 data kept in memory. 315 // Completes a read from the stream data kept in memory, logging metrics
316 int ReadStream0Data(net::IOBuffer* buf, int offset, int buf_len); 316 // and updating metadata as appropriate. If |callback| is non-null, it will
317 // be posted to with the return code.
318 void ReadInMemoryStreamData(net::GrowableIOBuffer* in_buf,
319 int offset,
320 int buf_len,
321 net::IOBuffer* out_buf,
322 const CompletionCallback& callback);
317 323
318 // Copies data from |buf| to the internal in-memory buffer for stream 0. If 324 // Copies data from |buf| to the internal in-memory buffer for stream 0. If
319 // |truncate| is set to true, the target buffer will be truncated at |offset| 325 // |truncate| is set to true, the target buffer will be truncated at |offset|
320 // + |buf_len| before being written. 326 // + |buf_len| before being written.
321 int SetStream0Data(net::IOBuffer* buf, 327 int SetStream0Data(net::IOBuffer* buf,
322 int offset, int buf_len, 328 int offset, int buf_len,
323 bool truncate); 329 bool truncate);
324 330
325 // Updates |crc32s_| and |crc32s_end_offset_| for a write of the data in 331 // Updates |crc32s_| and |crc32s_end_offset_| for a write of the data in
326 // |buffer| on |stream_index|, starting at |offset| and of length |length|. 332 // |buffer| on |stream_index|, starting at |offset| and of length |length|.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 // Unlike other streams, stream 0 data is read from the disk when the entry is 402 // Unlike other streams, stream 0 data is read from the disk when the entry is
397 // opened, and then kept in memory. All read/write operations on stream 0 403 // opened, and then kept in memory. All read/write operations on stream 0
398 // affect the |stream_0_data_| buffer. When the entry is closed, 404 // affect the |stream_0_data_| buffer. When the entry is closed,
399 // |stream_0_data_| is written to the disk. 405 // |stream_0_data_| is written to the disk.
400 // Stream 0 is kept in memory because it is stored in the same file as stream 406 // Stream 0 is kept in memory because it is stored in the same file as stream
401 // 1 on disk, to reduce the number of file descriptors and save disk space. 407 // 1 on disk, to reduce the number of file descriptors and save disk space.
402 // This strategy allows stream 1 to change size easily. Since stream 0 is only 408 // This strategy allows stream 1 to change size easily. Since stream 0 is only
403 // used to write HTTP headers, the memory consumption of keeping it in memory 409 // used to write HTTP headers, the memory consumption of keeping it in memory
404 // is acceptable. 410 // is acceptable.
405 scoped_refptr<net::GrowableIOBuffer> stream_0_data_; 411 scoped_refptr<net::GrowableIOBuffer> stream_0_data_;
412
413 // Sometimes stream 1 data is prefetched when stream 0 is first read, to make
414 // the first read call on stream 1 synchronous. If a write to the stream
415 // occurs on the entry the prefetch buffer is discarded. It may also be
416 // null if it wasn't prefetched in the first place.
417 scoped_refptr<net::GrowableIOBuffer> stream_1_prefetch_data_;
406 }; 418 };
407 419
408 } // namespace disk_cache 420 } // namespace disk_cache
409 421
410 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ 422 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698