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

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

Issue 2842193002: A crude cut at incorporating stream 1 footer read into stream 0 read.
Patch Set: Rebase. Still needs design re-thought Created 3 years, 7 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.h » ('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 #include "net/disk_cache/simple/simple_entry_impl.h" 5 #include "net/disk_cache/simple/simple_entry_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 #include <limits> 9 #include <limits>
10 #include <utility> 10 #include <utility>
(...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 bool truncate) { 1477 bool truncate) {
1478 // Currently, stream 0 is only used for HTTP headers, and always writes them 1478 // Currently, stream 0 is only used for HTTP headers, and always writes them
1479 // with a single, truncating write. Detect these writes and record the size 1479 // with a single, truncating write. Detect these writes and record the size
1480 // changes of the headers. Also, support writes to stream 0 that have 1480 // changes of the headers. Also, support writes to stream 0 that have
1481 // different access patterns, as required by the API contract. 1481 // different access patterns, as required by the API contract.
1482 // All other clients of the Simple Cache are encouraged to use stream 1. 1482 // All other clients of the Simple Cache are encouraged to use stream 1.
1483 have_written_[0] = true; 1483 have_written_[0] = true;
1484 int data_size = GetDataSize(0); 1484 int data_size = GetDataSize(0);
1485 if (offset == 0 && truncate) { 1485 if (offset == 0 && truncate) {
1486 RecordHeaderSizeChange(cache_type_, data_size, buf_len); 1486 RecordHeaderSizeChange(cache_type_, data_size, buf_len);
1487 // Undo some of the offset weirdness from SimpleSynchronousEntry
1488 stream_0_data_->set_offset(0);
1487 stream_0_data_->SetCapacity(buf_len); 1489 stream_0_data_->SetCapacity(buf_len);
1488 memcpy(stream_0_data_->data(), buf->data(), buf_len); 1490 memcpy(stream_0_data_->data(), buf->data(), buf_len);
1489 data_size_[0] = buf_len; 1491 data_size_[0] = buf_len;
1490 } else { 1492 } else {
1491 RecordUnexpectedStream0Write(cache_type_); 1493 RecordUnexpectedStream0Write(cache_type_);
1492 const int buffer_size = 1494 const int buffer_size =
1493 truncate ? offset + buf_len : std::max(offset + buf_len, data_size); 1495 truncate ? offset + buf_len : std::max(offset + buf_len, data_size);
1494 stream_0_data_->SetCapacity(buffer_size); 1496 stream_0_data_->SetCapacity(buffer_size + stream_0_data_->offset());
1495 // If |stream_0_data_| was extended, the extension until offset needs to be 1497 // If |stream_0_data_| was extended, the extension until offset needs to be
1496 // zero-filled. 1498 // zero-filled.
1497 const int fill_size = offset <= data_size ? 0 : offset - data_size; 1499 const int fill_size = offset <= data_size ? 0 : offset - data_size;
1498 if (fill_size > 0) 1500 if (fill_size > 0)
1499 memset(stream_0_data_->data() + data_size, 0, fill_size); 1501 memset(stream_0_data_->data() + data_size, 0, fill_size);
1500 if (buf) 1502 if (buf)
1501 memcpy(stream_0_data_->data() + offset, buf->data(), buf_len); 1503 memcpy(stream_0_data_->data() + offset, buf->data(), buf_len);
1502 data_size_[0] = buffer_size; 1504 data_size_[0] = buffer_size;
1503 } 1505 }
1504 base::Time modification_time = base::Time::Now(); 1506 base::Time modification_time = base::Time::Now();
(...skipping 23 matching lines...) Expand all
1528 } 1530 }
1529 crc32s_end_offset_[stream_index] = offset + length; 1531 crc32s_end_offset_[stream_index] = offset + length;
1530 } else if (offset < crc32s_end_offset_[stream_index]) { 1532 } else if (offset < crc32s_end_offset_[stream_index]) {
1531 // If a range for which the crc32 was already computed is rewritten, the 1533 // If a range for which the crc32 was already computed is rewritten, the
1532 // computation of the crc32 need to start from 0 again. 1534 // computation of the crc32 need to start from 0 again.
1533 crc32s_end_offset_[stream_index] = 0; 1535 crc32s_end_offset_[stream_index] = 0;
1534 } 1536 }
1535 } 1537 }
1536 1538
1537 } // namespace disk_cache 1539 } // namespace disk_cache
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_synchronous_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698