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

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

Issue 2090263004: **WIP** Simple Cache: reduce seeks on stream 0 read. Base URL: https://chromium.googlesource.com/chromium/src.git@simply-oom
Patch Set: rebase better Created 3 years, 4 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
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_synchronous_entry.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_SYNCHRONOUS_ENTRY_H_ 5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_
6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_ 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 }; 74 };
75 75
76 struct SimpleEntryCreationResults { 76 struct SimpleEntryCreationResults {
77 explicit SimpleEntryCreationResults(SimpleEntryStat entry_stat); 77 explicit SimpleEntryCreationResults(SimpleEntryStat entry_stat);
78 ~SimpleEntryCreationResults(); 78 ~SimpleEntryCreationResults();
79 79
80 SimpleSynchronousEntry* sync_entry; 80 SimpleSynchronousEntry* sync_entry;
81 scoped_refptr<net::GrowableIOBuffer> stream_0_data; 81 scoped_refptr<net::GrowableIOBuffer> stream_0_data;
82 SimpleEntryStat entry_stat; 82 SimpleEntryStat entry_stat;
83 uint32_t stream_0_crc32; 83 uint32_t stream_0_crc32;
84 uint32_t stream_1_crc32;
84 int result; 85 int result;
85 }; 86 };
86 87
87 // Worker thread interface to the very simple cache. This interface is not 88 // Worker thread interface to the very simple cache. This interface is not
88 // thread safe, and callers must ensure that it is only ever accessed from 89 // thread safe, and callers must ensure that it is only ever accessed from
89 // a single thread between synchronization points. 90 // a single thread between synchronization points.
90 class SimpleSynchronousEntry { 91 class SimpleSynchronousEntry {
91 public: 92 public:
92 struct CRCRecord { 93 struct CRCRecord {
93 CRCRecord(); 94 CRCRecord();
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 bool CreateFiles(SimpleEntryStat* out_entry_stat); 273 bool CreateFiles(SimpleEntryStat* out_entry_stat);
273 void CloseFile(int index); 274 void CloseFile(int index);
274 void CloseFiles(); 275 void CloseFiles();
275 276
276 // Read the header and key at the beginning of the file, and validate that 277 // Read the header and key at the beginning of the file, and validate that
277 // they are correct. If this entry was opened with a key, the key is checked 278 // they are correct. If this entry was opened with a key, the key is checked
278 // for a match. If not, then the |key_| member is set based on the value in 279 // for a match. If not, then the |key_| member is set based on the value in
279 // this header. Records histograms if any check is failed. 280 // this header. Records histograms if any check is failed.
280 bool CheckHeaderAndKey(int file_index); 281 bool CheckHeaderAndKey(int file_index);
281 282
283 // Read the
284 bool ReadStream0Data(SimpleEntryStat* out_entry_stat,
285 scoped_refptr<net::GrowableIOBuffer>* stream_0_data,
286 uint32_t* out_stream_0_crc32);
287
282 // Returns a net error, i.e. net::OK on success. 288 // Returns a net error, i.e. net::OK on success.
283 int InitializeForOpen(SimpleEntryStat* out_entry_stat, 289 int InitializeForOpen(SimpleEntryStat* out_entry_stat,
284 scoped_refptr<net::GrowableIOBuffer>* stream_0_data, 290 scoped_refptr<net::GrowableIOBuffer>* stream_0_data,
285 uint32_t* out_stream_0_crc32); 291 uint32_t* out_stream_0_crc32);
286 292
287 // Writes the header and key to a newly-created stream file. |index| is the 293 // Writes the header and key to a newly-created stream file. |index| is the
288 // index of the stream. Returns true on success; returns false and sets 294 // index of the stream. Returns true on success; returns false and sets
289 // |*out_result| on failure. 295 // |*out_result| on failure.
290 bool InitializeCreatedFile(int index, CreateEntryResult* out_result); 296 bool InitializeCreatedFile(int index, CreateEntryResult* out_result);
291 297
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 int64_t sparse_tail_offset_; 395 int64_t sparse_tail_offset_;
390 396
391 // True if the entry was created, or false if it was opened. Used to log 397 // True if the entry was created, or false if it was opened. Used to log
392 // SimpleCache.*.EntryCreatedWithStream2Omitted only for created entries. 398 // SimpleCache.*.EntryCreatedWithStream2Omitted only for created entries.
393 bool files_created_; 399 bool files_created_;
394 }; 400 };
395 401
396 } // namespace disk_cache 402 } // namespace disk_cache
397 403
398 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_ 404 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_synchronous_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698