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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 // The |synchronous_entry_| is the worker thread object that performs IO on | 362 // The |synchronous_entry_| is the worker thread object that performs IO on |
363 // entries. It's owned by this SimpleEntryImpl whenever |executing_operation_| | 363 // entries. It's owned by this SimpleEntryImpl whenever |executing_operation_| |
364 // is false (i.e. when an operation is not pending on the worker pool). When | 364 // is false (i.e. when an operation is not pending on the worker pool). When |
365 // an operation is being executed no one owns the synchronous entry. Therefore | 365 // an operation is being executed no one owns the synchronous entry. Therefore |
366 // SimpleEntryImpl should not be deleted while an operation is running as that | 366 // SimpleEntryImpl should not be deleted while an operation is running as that |
367 // would leak the SimpleSynchronousEntry. | 367 // would leak the SimpleSynchronousEntry. |
368 SimpleSynchronousEntry* synchronous_entry_; | 368 SimpleSynchronousEntry* synchronous_entry_; |
369 | 369 |
370 std::queue<SimpleEntryOperation> pending_operations_; | 370 std::queue<SimpleEntryOperation> pending_operations_; |
371 | 371 |
372 net::BoundNetLog net_log_; | 372 net::NetLogWithSource net_log_; |
373 | 373 |
374 std::unique_ptr<SimpleEntryOperation> executing_operation_; | 374 std::unique_ptr<SimpleEntryOperation> executing_operation_; |
375 | 375 |
376 // Unlike other streams, stream 0 data is read from the disk when the entry is | 376 // Unlike other streams, stream 0 data is read from the disk when the entry is |
377 // opened, and then kept in memory. All read/write operations on stream 0 | 377 // opened, and then kept in memory. All read/write operations on stream 0 |
378 // affect the |stream_0_data_| buffer. When the entry is closed, | 378 // affect the |stream_0_data_| buffer. When the entry is closed, |
379 // |stream_0_data_| is written to the disk. | 379 // |stream_0_data_| is written to the disk. |
380 // Stream 0 is kept in memory because it is stored in the same file as stream | 380 // Stream 0 is kept in memory because it is stored in the same file as stream |
381 // 1 on disk, to reduce the number of file descriptors and save disk space. | 381 // 1 on disk, to reduce the number of file descriptors and save disk space. |
382 // This strategy allows stream 1 to change size easily. Since stream 0 is only | 382 // This strategy allows stream 1 to change size easily. Since stream 0 is only |
383 // used to write HTTP headers, the memory consumption of keeping it in memory | 383 // used to write HTTP headers, the memory consumption of keeping it in memory |
384 // is acceptable. | 384 // is acceptable. |
385 scoped_refptr<net::GrowableIOBuffer> stream_0_data_; | 385 scoped_refptr<net::GrowableIOBuffer> stream_0_data_; |
386 }; | 386 }; |
387 | 387 |
388 } // namespace disk_cache | 388 } // namespace disk_cache |
389 | 389 |
390 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ | 390 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ |
OLD | NEW |