| 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_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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 int32_t data_size_[kSimpleEntryStreamCount]; | 72 int32_t data_size_[kSimpleEntryStreamCount]; |
| 73 int32_t sparse_data_size_; | 73 int32_t sparse_data_size_; |
| 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 scoped_refptr<net::GrowableIOBuffer> stream_1_prefetch_data; |
| 82 SimpleEntryStat entry_stat; | 83 SimpleEntryStat entry_stat; |
| 83 uint32_t stream_0_crc32; | 84 uint32_t stream_0_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: |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 282 // Returns a net error, i.e. net::OK on success. | 283 // Returns a net error, i.e. net::OK on success. |
| 283 int InitializeForOpen(SimpleEntryStat* out_entry_stat, | 284 int InitializeForOpen( |
| 284 scoped_refptr<net::GrowableIOBuffer>* stream_0_data, | 285 SimpleEntryStat* out_entry_stat, |
| 285 uint32_t* out_stream_0_crc32); | 286 scoped_refptr<net::GrowableIOBuffer>* stream_0_data, |
| 287 uint32_t* out_stream_0_crc32, |
| 288 scoped_refptr<net::GrowableIOBuffer>* stream_1_prefetch_data); |
| 286 | 289 |
| 287 // Writes the header and key to a newly-created stream file. |index| is the | 290 // 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 | 291 // index of the stream. Returns true on success; returns false and sets |
| 289 // |*out_result| on failure. | 292 // |*out_result| on failure. |
| 290 bool InitializeCreatedFile(int index, CreateEntryResult* out_result); | 293 bool InitializeCreatedFile(int index, CreateEntryResult* out_result); |
| 291 | 294 |
| 292 // Returns a net error, including net::OK on success and net::FILE_EXISTS | 295 // Returns a net error, including net::OK on success and net::FILE_EXISTS |
| 293 // when the entry already exists. | 296 // when the entry already exists. |
| 294 int InitializeForCreate(SimpleEntryStat* out_entry_stat); | 297 int InitializeForCreate(SimpleEntryStat* out_entry_stat); |
| 295 | 298 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 int64_t sparse_tail_offset_; | 392 int64_t sparse_tail_offset_; |
| 390 | 393 |
| 391 // True if the entry was created, or false if it was opened. Used to log | 394 // True if the entry was created, or false if it was opened. Used to log |
| 392 // SimpleCache.*.EntryCreatedWithStream2Omitted only for created entries. | 395 // SimpleCache.*.EntryCreatedWithStream2Omitted only for created entries. |
| 393 bool files_created_; | 396 bool files_created_; |
| 394 }; | 397 }; |
| 395 | 398 |
| 396 } // namespace disk_cache | 399 } // namespace disk_cache |
| 397 | 400 |
| 398 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_ | 401 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_ |
| OLD | NEW |