| 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 #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 <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1289 SimpleEntryStat(base::Time::Now(), last_modified_, data_size_)); | 1289 SimpleEntryStat(base::Time::Now(), last_modified_, data_size_)); |
| 1290 RecordReadResult(cache_type_, READ_RESULT_SUCCESS); | 1290 RecordReadResult(cache_type_, READ_RESULT_SUCCESS); |
| 1291 return buf_len; | 1291 return buf_len; |
| 1292 } | 1292 } |
| 1293 | 1293 |
| 1294 int SimpleEntryImpl::SetStream0Data(net::IOBuffer* buf, | 1294 int SimpleEntryImpl::SetStream0Data(net::IOBuffer* buf, |
| 1295 int offset, | 1295 int offset, |
| 1296 int buf_len, | 1296 int buf_len, |
| 1297 bool truncate) { | 1297 bool truncate) { |
| 1298 // Currently, stream 0 is only used for HTTP headers, and always writes them | 1298 // Currently, stream 0 is only used for HTTP headers, and always writes them |
| 1299 // with a single, truncating write. Detect these writes and record the size | 1299 // with a single, truncating write. Detect these writes and record the size |
| 1300 // changes of the headers. Also, support writes to stream 0 that have | 1300 // changes of the headers. Also, support writes to stream 0 that have |
| 1301 // different access patterns, as required by the API contract. | 1301 // different access patterns, as required by the API contract. |
| 1302 // All other clients of the Simple Cache are encouraged to use stream 1. | 1302 // All other clients of the Simple Cache are encouraged to use stream 1. |
| 1303 have_written_[0] = true; | 1303 have_written_[0] = true; |
| 1304 int data_size = GetDataSize(0); | 1304 int data_size = GetDataSize(0); |
| 1305 if (offset == 0 && truncate) { | 1305 if (offset == 0 && truncate) { |
| 1306 RecordHeaderSizeChange(cache_type_, data_size, buf_len); | 1306 RecordHeaderSizeChange(cache_type_, data_size, buf_len); |
| 1307 stream_0_data_->SetCapacity(buf_len); | 1307 stream_0_data_->SetCapacity(buf_len); |
| 1308 memcpy(stream_0_data_->data(), buf->data(), buf_len); | 1308 memcpy(stream_0_data_->data(), buf->data(), buf_len); |
| 1309 data_size_[0] = buf_len; | 1309 data_size_[0] = buf_len; |
| 1310 } else { | 1310 } else { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1347 } | 1347 } |
| 1348 crc32s_end_offset_[stream_index] = offset + length; | 1348 crc32s_end_offset_[stream_index] = offset + length; |
| 1349 } else if (offset < crc32s_end_offset_[stream_index]) { | 1349 } else if (offset < crc32s_end_offset_[stream_index]) { |
| 1350 // If a range for which the crc32 was already computed is rewritten, the | 1350 // If a range for which the crc32 was already computed is rewritten, the |
| 1351 // computation of the crc32 need to start from 0 again. | 1351 // computation of the crc32 need to start from 0 again. |
| 1352 crc32s_end_offset_[stream_index] = 0; | 1352 crc32s_end_offset_[stream_index] = 0; |
| 1353 } | 1353 } |
| 1354 } | 1354 } |
| 1355 | 1355 |
| 1356 } // namespace disk_cache | 1356 } // namespace disk_cache |
| OLD | NEW |