| 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 return data_size_[stream_index]; | 340 return data_size_[stream_index]; |
| 341 } | 341 } |
| 342 | 342 |
| 343 int SimpleEntryImpl::ReadData(int stream_index, | 343 int SimpleEntryImpl::ReadData(int stream_index, |
| 344 int offset, | 344 int offset, |
| 345 net::IOBuffer* buf, | 345 net::IOBuffer* buf, |
| 346 int buf_len, | 346 int buf_len, |
| 347 const CompletionCallback& callback) { | 347 const CompletionCallback& callback) { |
| 348 DCHECK(io_thread_checker_.CalledOnValidThread()); | 348 DCHECK(io_thread_checker_.CalledOnValidThread()); |
| 349 | 349 |
| 350 if (net_log_.IsLogging()) { | 350 if (net_log_.GetCaptureMode().enabled()) { |
| 351 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_CALL, | 351 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_CALL, |
| 352 CreateNetLogReadWriteDataCallback(stream_index, offset, buf_len, | 352 CreateNetLogReadWriteDataCallback(stream_index, offset, buf_len, |
| 353 false)); | 353 false)); |
| 354 } | 354 } |
| 355 | 355 |
| 356 if (stream_index < 0 || stream_index >= kSimpleEntryStreamCount || | 356 if (stream_index < 0 || stream_index >= kSimpleEntryStreamCount || |
| 357 buf_len < 0) { | 357 buf_len < 0) { |
| 358 if (net_log_.IsLogging()) { | 358 if (net_log_.GetCaptureMode().enabled()) { |
| 359 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END, | 359 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END, |
| 360 CreateNetLogReadWriteCompleteCallback(net::ERR_INVALID_ARGUMENT)); | 360 CreateNetLogReadWriteCompleteCallback(net::ERR_INVALID_ARGUMENT)); |
| 361 } | 361 } |
| 362 | 362 |
| 363 RecordReadResult(cache_type_, READ_RESULT_INVALID_ARGUMENT); | 363 RecordReadResult(cache_type_, READ_RESULT_INVALID_ARGUMENT); |
| 364 return net::ERR_INVALID_ARGUMENT; | 364 return net::ERR_INVALID_ARGUMENT; |
| 365 } | 365 } |
| 366 if (pending_operations_.empty() && (offset >= GetDataSize(stream_index) || | 366 if (pending_operations_.empty() && (offset >= GetDataSize(stream_index) || |
| 367 offset < 0 || !buf_len)) { | 367 offset < 0 || !buf_len)) { |
| 368 if (net_log_.IsLogging()) { | 368 if (net_log_.GetCaptureMode().enabled()) { |
| 369 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END, | 369 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END, |
| 370 CreateNetLogReadWriteCompleteCallback(0)); | 370 CreateNetLogReadWriteCompleteCallback(0)); |
| 371 } | 371 } |
| 372 | 372 |
| 373 RecordReadResult(cache_type_, READ_RESULT_NONBLOCK_EMPTY_RETURN); | 373 RecordReadResult(cache_type_, READ_RESULT_NONBLOCK_EMPTY_RETURN); |
| 374 return 0; | 374 return 0; |
| 375 } | 375 } |
| 376 | 376 |
| 377 // TODO(clamy): return immediatly when reading from stream 0. | 377 // TODO(clamy): return immediatly when reading from stream 0. |
| 378 | 378 |
| 379 // TODO(felipeg): Optimization: Add support for truly parallel read | 379 // TODO(felipeg): Optimization: Add support for truly parallel read |
| 380 // operations. | 380 // operations. |
| 381 bool alone_in_queue = | 381 bool alone_in_queue = |
| 382 pending_operations_.size() == 0 && state_ == STATE_READY; | 382 pending_operations_.size() == 0 && state_ == STATE_READY; |
| 383 pending_operations_.push(SimpleEntryOperation::ReadOperation( | 383 pending_operations_.push(SimpleEntryOperation::ReadOperation( |
| 384 this, stream_index, offset, buf_len, buf, callback, alone_in_queue)); | 384 this, stream_index, offset, buf_len, buf, callback, alone_in_queue)); |
| 385 RunNextOperationIfNeeded(); | 385 RunNextOperationIfNeeded(); |
| 386 return net::ERR_IO_PENDING; | 386 return net::ERR_IO_PENDING; |
| 387 } | 387 } |
| 388 | 388 |
| 389 int SimpleEntryImpl::WriteData(int stream_index, | 389 int SimpleEntryImpl::WriteData(int stream_index, |
| 390 int offset, | 390 int offset, |
| 391 net::IOBuffer* buf, | 391 net::IOBuffer* buf, |
| 392 int buf_len, | 392 int buf_len, |
| 393 const CompletionCallback& callback, | 393 const CompletionCallback& callback, |
| 394 bool truncate) { | 394 bool truncate) { |
| 395 DCHECK(io_thread_checker_.CalledOnValidThread()); | 395 DCHECK(io_thread_checker_.CalledOnValidThread()); |
| 396 | 396 |
| 397 if (net_log_.IsLogging()) { | 397 if (net_log_.GetCaptureMode().enabled()) { |
| 398 net_log_.AddEvent( | 398 net_log_.AddEvent( |
| 399 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_CALL, | 399 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_CALL, |
| 400 CreateNetLogReadWriteDataCallback(stream_index, offset, buf_len, | 400 CreateNetLogReadWriteDataCallback(stream_index, offset, buf_len, |
| 401 truncate)); | 401 truncate)); |
| 402 } | 402 } |
| 403 | 403 |
| 404 if (stream_index < 0 || stream_index >= kSimpleEntryStreamCount || | 404 if (stream_index < 0 || stream_index >= kSimpleEntryStreamCount || |
| 405 offset < 0 || buf_len < 0) { | 405 offset < 0 || buf_len < 0) { |
| 406 if (net_log_.IsLogging()) { | 406 if (net_log_.GetCaptureMode().enabled()) { |
| 407 net_log_.AddEvent( | 407 net_log_.AddEvent( |
| 408 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_END, | 408 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_END, |
| 409 CreateNetLogReadWriteCompleteCallback(net::ERR_INVALID_ARGUMENT)); | 409 CreateNetLogReadWriteCompleteCallback(net::ERR_INVALID_ARGUMENT)); |
| 410 } | 410 } |
| 411 RecordWriteResult(cache_type_, WRITE_RESULT_INVALID_ARGUMENT); | 411 RecordWriteResult(cache_type_, WRITE_RESULT_INVALID_ARGUMENT); |
| 412 return net::ERR_INVALID_ARGUMENT; | 412 return net::ERR_INVALID_ARGUMENT; |
| 413 } | 413 } |
| 414 if (backend_.get() && offset + buf_len > backend_->GetMaxFileSize()) { | 414 if (backend_.get() && offset + buf_len > backend_->GetMaxFileSize()) { |
| 415 if (net_log_.IsLogging()) { | 415 if (net_log_.GetCaptureMode().enabled()) { |
| 416 net_log_.AddEvent( | 416 net_log_.AddEvent( |
| 417 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_END, | 417 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_END, |
| 418 CreateNetLogReadWriteCompleteCallback(net::ERR_FAILED)); | 418 CreateNetLogReadWriteCompleteCallback(net::ERR_FAILED)); |
| 419 } | 419 } |
| 420 RecordWriteResult(cache_type_, WRITE_RESULT_OVER_MAX_SIZE); | 420 RecordWriteResult(cache_type_, WRITE_RESULT_OVER_MAX_SIZE); |
| 421 return net::ERR_FAILED; | 421 return net::ERR_FAILED; |
| 422 } | 422 } |
| 423 ScopedOperationRunner operation_runner(this); | 423 ScopedOperationRunner operation_runner(this); |
| 424 | 424 |
| 425 // Stream 0 data is kept in memory, so can be written immediatly if there are | 425 // Stream 0 data is kept in memory, so can be written immediatly if there are |
| (...skipping 21 matching lines...) Expand all Loading... |
| 447 } else { | 447 } else { |
| 448 // TODO(gavinp,pasko): For performance, don't use a copy of an IOBuffer | 448 // TODO(gavinp,pasko): For performance, don't use a copy of an IOBuffer |
| 449 // here to avoid paying the price of the RefCountedThreadSafe atomic | 449 // here to avoid paying the price of the RefCountedThreadSafe atomic |
| 450 // operations. | 450 // operations. |
| 451 if (buf) { | 451 if (buf) { |
| 452 op_buf = new IOBuffer(buf_len); | 452 op_buf = new IOBuffer(buf_len); |
| 453 memcpy(op_buf->data(), buf->data(), buf_len); | 453 memcpy(op_buf->data(), buf->data(), buf_len); |
| 454 } | 454 } |
| 455 op_callback = CompletionCallback(); | 455 op_callback = CompletionCallback(); |
| 456 ret_value = buf_len; | 456 ret_value = buf_len; |
| 457 if (net_log_.IsLogging()) { | 457 if (net_log_.GetCaptureMode().enabled()) { |
| 458 net_log_.AddEvent( | 458 net_log_.AddEvent( |
| 459 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_OPTIMISTIC, | 459 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_OPTIMISTIC, |
| 460 CreateNetLogReadWriteCompleteCallback(buf_len)); | 460 CreateNetLogReadWriteCompleteCallback(buf_len)); |
| 461 } | 461 } |
| 462 } | 462 } |
| 463 | 463 |
| 464 pending_operations_.push(SimpleEntryOperation::WriteOperation(this, | 464 pending_operations_.push(SimpleEntryOperation::WriteOperation(this, |
| 465 stream_index, | 465 stream_index, |
| 466 offset, | 466 offset, |
| 467 buf_len, | 467 buf_len, |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 } | 802 } |
| 803 | 803 |
| 804 void SimpleEntryImpl::ReadDataInternal(int stream_index, | 804 void SimpleEntryImpl::ReadDataInternal(int stream_index, |
| 805 int offset, | 805 int offset, |
| 806 net::IOBuffer* buf, | 806 net::IOBuffer* buf, |
| 807 int buf_len, | 807 int buf_len, |
| 808 const CompletionCallback& callback) { | 808 const CompletionCallback& callback) { |
| 809 DCHECK(io_thread_checker_.CalledOnValidThread()); | 809 DCHECK(io_thread_checker_.CalledOnValidThread()); |
| 810 ScopedOperationRunner operation_runner(this); | 810 ScopedOperationRunner operation_runner(this); |
| 811 | 811 |
| 812 if (net_log_.IsLogging()) { | 812 if (net_log_.GetCaptureMode().enabled()) { |
| 813 net_log_.AddEvent( | 813 net_log_.AddEvent( |
| 814 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_BEGIN, | 814 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_BEGIN, |
| 815 CreateNetLogReadWriteDataCallback(stream_index, offset, buf_len, | 815 CreateNetLogReadWriteDataCallback(stream_index, offset, buf_len, |
| 816 false)); | 816 false)); |
| 817 } | 817 } |
| 818 | 818 |
| 819 if (state_ == STATE_FAILURE || state_ == STATE_UNINITIALIZED) { | 819 if (state_ == STATE_FAILURE || state_ == STATE_UNINITIALIZED) { |
| 820 if (!callback.is_null()) { | 820 if (!callback.is_null()) { |
| 821 RecordReadResult(cache_type_, READ_RESULT_BAD_STATE); | 821 RecordReadResult(cache_type_, READ_RESULT_BAD_STATE); |
| 822 // Note that the API states that client-provided callbacks for entry-level | 822 // Note that the API states that client-provided callbacks for entry-level |
| 823 // (i.e. non-backend) operations (e.g. read, write) are invoked even if | 823 // (i.e. non-backend) operations (e.g. read, write) are invoked even if |
| 824 // the backend was already destroyed. | 824 // the backend was already destroyed. |
| 825 base::ThreadTaskRunnerHandle::Get()->PostTask( | 825 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 826 FROM_HERE, base::Bind(callback, net::ERR_FAILED)); | 826 FROM_HERE, base::Bind(callback, net::ERR_FAILED)); |
| 827 } | 827 } |
| 828 if (net_log_.IsLogging()) { | 828 if (net_log_.GetCaptureMode().enabled()) { |
| 829 net_log_.AddEvent( | 829 net_log_.AddEvent( |
| 830 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END, | 830 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END, |
| 831 CreateNetLogReadWriteCompleteCallback(net::ERR_FAILED)); | 831 CreateNetLogReadWriteCompleteCallback(net::ERR_FAILED)); |
| 832 } | 832 } |
| 833 return; | 833 return; |
| 834 } | 834 } |
| 835 DCHECK_EQ(STATE_READY, state_); | 835 DCHECK_EQ(STATE_READY, state_); |
| 836 if (offset >= GetDataSize(stream_index) || offset < 0 || !buf_len) { | 836 if (offset >= GetDataSize(stream_index) || offset < 0 || !buf_len) { |
| 837 RecordReadResult(cache_type_, READ_RESULT_FAST_EMPTY_RETURN); | 837 RecordReadResult(cache_type_, READ_RESULT_FAST_EMPTY_RETURN); |
| 838 // If there is nothing to read, we bail out before setting state_ to | 838 // If there is nothing to read, we bail out before setting state_ to |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 | 885 |
| 886 void SimpleEntryImpl::WriteDataInternal(int stream_index, | 886 void SimpleEntryImpl::WriteDataInternal(int stream_index, |
| 887 int offset, | 887 int offset, |
| 888 net::IOBuffer* buf, | 888 net::IOBuffer* buf, |
| 889 int buf_len, | 889 int buf_len, |
| 890 const CompletionCallback& callback, | 890 const CompletionCallback& callback, |
| 891 bool truncate) { | 891 bool truncate) { |
| 892 DCHECK(io_thread_checker_.CalledOnValidThread()); | 892 DCHECK(io_thread_checker_.CalledOnValidThread()); |
| 893 ScopedOperationRunner operation_runner(this); | 893 ScopedOperationRunner operation_runner(this); |
| 894 | 894 |
| 895 if (net_log_.IsLogging()) { | 895 if (net_log_.GetCaptureMode().enabled()) { |
| 896 net_log_.AddEvent( | 896 net_log_.AddEvent( |
| 897 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_BEGIN, | 897 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_BEGIN, |
| 898 CreateNetLogReadWriteDataCallback(stream_index, offset, buf_len, | 898 CreateNetLogReadWriteDataCallback(stream_index, offset, buf_len, |
| 899 truncate)); | 899 truncate)); |
| 900 } | 900 } |
| 901 | 901 |
| 902 if (state_ == STATE_FAILURE || state_ == STATE_UNINITIALIZED) { | 902 if (state_ == STATE_FAILURE || state_ == STATE_UNINITIALIZED) { |
| 903 RecordWriteResult(cache_type_, WRITE_RESULT_BAD_STATE); | 903 RecordWriteResult(cache_type_, WRITE_RESULT_BAD_STATE); |
| 904 if (net_log_.IsLogging()) { | 904 if (net_log_.GetCaptureMode().enabled()) { |
| 905 net_log_.AddEvent( | 905 net_log_.AddEvent( |
| 906 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_END, | 906 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_END, |
| 907 CreateNetLogReadWriteCompleteCallback(net::ERR_FAILED)); | 907 CreateNetLogReadWriteCompleteCallback(net::ERR_FAILED)); |
| 908 } | 908 } |
| 909 if (!callback.is_null()) { | 909 if (!callback.is_null()) { |
| 910 base::ThreadTaskRunnerHandle::Get()->PostTask( | 910 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 911 FROM_HERE, base::Bind(callback, net::ERR_FAILED)); | 911 FROM_HERE, base::Bind(callback, net::ERR_FAILED)); |
| 912 } | 912 } |
| 913 // |this| may be destroyed after return here. | 913 // |this| may be destroyed after return here. |
| 914 return; | 914 return; |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1223 | 1223 |
| 1224 if (*result < 0) { | 1224 if (*result < 0) { |
| 1225 RecordReadResult(cache_type_, READ_RESULT_SYNC_READ_FAILURE); | 1225 RecordReadResult(cache_type_, READ_RESULT_SYNC_READ_FAILURE); |
| 1226 } else { | 1226 } else { |
| 1227 RecordReadResult(cache_type_, READ_RESULT_SUCCESS); | 1227 RecordReadResult(cache_type_, READ_RESULT_SUCCESS); |
| 1228 if (crc_check_state_[stream_index] == CRC_CHECK_NEVER_READ_TO_END && | 1228 if (crc_check_state_[stream_index] == CRC_CHECK_NEVER_READ_TO_END && |
| 1229 offset + *result == GetDataSize(stream_index)) { | 1229 offset + *result == GetDataSize(stream_index)) { |
| 1230 crc_check_state_[stream_index] = CRC_CHECK_NOT_DONE; | 1230 crc_check_state_[stream_index] = CRC_CHECK_NOT_DONE; |
| 1231 } | 1231 } |
| 1232 } | 1232 } |
| 1233 if (net_log_.IsLogging()) { | 1233 if (net_log_.GetCaptureMode().enabled()) { |
| 1234 net_log_.AddEvent( | 1234 net_log_.AddEvent( |
| 1235 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END, | 1235 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END, |
| 1236 CreateNetLogReadWriteCompleteCallback(*result)); | 1236 CreateNetLogReadWriteCompleteCallback(*result)); |
| 1237 } | 1237 } |
| 1238 | 1238 |
| 1239 EntryOperationComplete(completion_callback, *entry_stat, result.Pass()); | 1239 EntryOperationComplete(completion_callback, *entry_stat, result.Pass()); |
| 1240 } | 1240 } |
| 1241 | 1241 |
| 1242 void SimpleEntryImpl::WriteOperationComplete( | 1242 void SimpleEntryImpl::WriteOperationComplete( |
| 1243 int stream_index, | 1243 int stream_index, |
| 1244 const CompletionCallback& completion_callback, | 1244 const CompletionCallback& completion_callback, |
| 1245 scoped_ptr<SimpleEntryStat> entry_stat, | 1245 scoped_ptr<SimpleEntryStat> entry_stat, |
| 1246 scoped_ptr<int> result) { | 1246 scoped_ptr<int> result) { |
| 1247 if (*result >= 0) | 1247 if (*result >= 0) |
| 1248 RecordWriteResult(cache_type_, WRITE_RESULT_SUCCESS); | 1248 RecordWriteResult(cache_type_, WRITE_RESULT_SUCCESS); |
| 1249 else | 1249 else |
| 1250 RecordWriteResult(cache_type_, WRITE_RESULT_SYNC_WRITE_FAILURE); | 1250 RecordWriteResult(cache_type_, WRITE_RESULT_SYNC_WRITE_FAILURE); |
| 1251 if (net_log_.IsLogging()) { | 1251 if (net_log_.GetCaptureMode().enabled()) { |
| 1252 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_END, | 1252 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_END, |
| 1253 CreateNetLogReadWriteCompleteCallback(*result)); | 1253 CreateNetLogReadWriteCompleteCallback(*result)); |
| 1254 } | 1254 } |
| 1255 | 1255 |
| 1256 if (*result < 0) { | 1256 if (*result < 0) { |
| 1257 crc32s_end_offset_[stream_index] = 0; | 1257 crc32s_end_offset_[stream_index] = 0; |
| 1258 } | 1258 } |
| 1259 | 1259 |
| 1260 EntryOperationComplete(completion_callback, *entry_stat, result.Pass()); | 1260 EntryOperationComplete(completion_callback, *entry_stat, result.Pass()); |
| 1261 } | 1261 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1312 void SimpleEntryImpl::ChecksumOperationComplete( | 1312 void SimpleEntryImpl::ChecksumOperationComplete( |
| 1313 int orig_result, | 1313 int orig_result, |
| 1314 int stream_index, | 1314 int stream_index, |
| 1315 const CompletionCallback& completion_callback, | 1315 const CompletionCallback& completion_callback, |
| 1316 scoped_ptr<int> result) { | 1316 scoped_ptr<int> result) { |
| 1317 DCHECK(io_thread_checker_.CalledOnValidThread()); | 1317 DCHECK(io_thread_checker_.CalledOnValidThread()); |
| 1318 DCHECK(synchronous_entry_); | 1318 DCHECK(synchronous_entry_); |
| 1319 DCHECK_EQ(STATE_IO_PENDING, state_); | 1319 DCHECK_EQ(STATE_IO_PENDING, state_); |
| 1320 DCHECK(result); | 1320 DCHECK(result); |
| 1321 | 1321 |
| 1322 if (net_log_.IsLogging()) { | 1322 if (net_log_.GetCaptureMode().enabled()) { |
| 1323 net_log_.AddEventWithNetErrorCode( | 1323 net_log_.AddEventWithNetErrorCode( |
| 1324 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_CHECKSUM_END, | 1324 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_CHECKSUM_END, |
| 1325 *result); | 1325 *result); |
| 1326 } | 1326 } |
| 1327 | 1327 |
| 1328 if (*result == net::OK) { | 1328 if (*result == net::OK) { |
| 1329 *result = orig_result; | 1329 *result = orig_result; |
| 1330 if (orig_result >= 0) | 1330 if (orig_result >= 0) |
| 1331 RecordReadResult(cache_type_, READ_RESULT_SUCCESS); | 1331 RecordReadResult(cache_type_, READ_RESULT_SUCCESS); |
| 1332 else | 1332 else |
| 1333 RecordReadResult(cache_type_, READ_RESULT_SYNC_READ_FAILURE); | 1333 RecordReadResult(cache_type_, READ_RESULT_SYNC_READ_FAILURE); |
| 1334 } else { | 1334 } else { |
| 1335 RecordReadResult(cache_type_, READ_RESULT_SYNC_CHECKSUM_FAILURE); | 1335 RecordReadResult(cache_type_, READ_RESULT_SYNC_CHECKSUM_FAILURE); |
| 1336 } | 1336 } |
| 1337 if (net_log_.IsLogging()) { | 1337 if (net_log_.GetCaptureMode().enabled()) { |
| 1338 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END, | 1338 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END, |
| 1339 CreateNetLogReadWriteCompleteCallback(*result)); | 1339 CreateNetLogReadWriteCompleteCallback(*result)); |
| 1340 } | 1340 } |
| 1341 | 1341 |
| 1342 SimpleEntryStat entry_stat(last_used_, last_modified_, data_size_, | 1342 SimpleEntryStat entry_stat(last_used_, last_modified_, data_size_, |
| 1343 sparse_data_size_); | 1343 sparse_data_size_); |
| 1344 EntryOperationComplete(completion_callback, entry_stat, result.Pass()); | 1344 EntryOperationComplete(completion_callback, entry_stat, result.Pass()); |
| 1345 } | 1345 } |
| 1346 | 1346 |
| 1347 void SimpleEntryImpl::CloseOperationComplete() { | 1347 void SimpleEntryImpl::CloseOperationComplete() { |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1524 } | 1524 } |
| 1525 crc32s_end_offset_[stream_index] = offset + length; | 1525 crc32s_end_offset_[stream_index] = offset + length; |
| 1526 } else if (offset < crc32s_end_offset_[stream_index]) { | 1526 } else if (offset < crc32s_end_offset_[stream_index]) { |
| 1527 // If a range for which the crc32 was already computed is rewritten, the | 1527 // If a range for which the crc32 was already computed is rewritten, the |
| 1528 // computation of the crc32 need to start from 0 again. | 1528 // computation of the crc32 need to start from 0 again. |
| 1529 crc32s_end_offset_[stream_index] = 0; | 1529 crc32s_end_offset_[stream_index] = 0; |
| 1530 } | 1530 } |
| 1531 } | 1531 } |
| 1532 | 1532 |
| 1533 } // namespace disk_cache | 1533 } // namespace disk_cache |
| OLD | NEW |