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 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1072 Closure reply = base::Bind( | 1072 Closure reply = base::Bind( |
1073 &SimpleEntryImpl::GetAvailableRangeOperationComplete, | 1073 &SimpleEntryImpl::GetAvailableRangeOperationComplete, |
1074 this, | 1074 this, |
1075 callback, | 1075 callback, |
1076 base::Passed(&result)); | 1076 base::Passed(&result)); |
1077 worker_pool_->PostTaskAndReply(FROM_HERE, task, reply); | 1077 worker_pool_->PostTaskAndReply(FROM_HERE, task, reply); |
1078 } | 1078 } |
1079 | 1079 |
1080 void SimpleEntryImpl::DoomEntryInternal(const CompletionCallback& callback) { | 1080 void SimpleEntryImpl::DoomEntryInternal(const CompletionCallback& callback) { |
1081 PostTaskAndReplyWithResult( | 1081 PostTaskAndReplyWithResult( |
1082 worker_pool_, FROM_HERE, | 1082 worker_pool_.get(), |
| 1083 FROM_HERE, |
1083 base::Bind(&SimpleSynchronousEntry::DoomEntry, path_, entry_hash_), | 1084 base::Bind(&SimpleSynchronousEntry::DoomEntry, path_, entry_hash_), |
1084 base::Bind(&SimpleEntryImpl::DoomOperationComplete, this, callback, | 1085 base::Bind( |
1085 state_)); | 1086 &SimpleEntryImpl::DoomOperationComplete, this, callback, state_)); |
1086 state_ = STATE_IO_PENDING; | 1087 state_ = STATE_IO_PENDING; |
1087 } | 1088 } |
1088 | 1089 |
1089 void SimpleEntryImpl::CreationOperationComplete( | 1090 void SimpleEntryImpl::CreationOperationComplete( |
1090 const CompletionCallback& completion_callback, | 1091 const CompletionCallback& completion_callback, |
1091 const base::TimeTicks& start_time, | 1092 const base::TimeTicks& start_time, |
1092 scoped_ptr<SimpleEntryCreationResults> in_results, | 1093 scoped_ptr<SimpleEntryCreationResults> in_results, |
1093 Entry** out_entry, | 1094 Entry** out_entry, |
1094 net::NetLog::EventType end_event_type) { | 1095 net::NetLog::EventType end_event_type) { |
1095 DCHECK(io_thread_checker_.CalledOnValidThread()); | 1096 DCHECK(io_thread_checker_.CalledOnValidThread()); |
(...skipping 12 matching lines...) Expand all Loading... |
1108 MakeUninitialized(); | 1109 MakeUninitialized(); |
1109 return; | 1110 return; |
1110 } | 1111 } |
1111 // If out_entry is NULL, it means we already called ReturnEntryToCaller from | 1112 // If out_entry is NULL, it means we already called ReturnEntryToCaller from |
1112 // the optimistic Create case. | 1113 // the optimistic Create case. |
1113 if (out_entry) | 1114 if (out_entry) |
1114 ReturnEntryToCaller(out_entry); | 1115 ReturnEntryToCaller(out_entry); |
1115 | 1116 |
1116 state_ = STATE_READY; | 1117 state_ = STATE_READY; |
1117 synchronous_entry_ = in_results->sync_entry; | 1118 synchronous_entry_ = in_results->sync_entry; |
1118 if (in_results->stream_0_data) { | 1119 if (in_results->stream_0_data.get()) { |
1119 stream_0_data_ = in_results->stream_0_data; | 1120 stream_0_data_ = in_results->stream_0_data; |
1120 // The crc was read in SimpleSynchronousEntry. | 1121 // The crc was read in SimpleSynchronousEntry. |
1121 crc_check_state_[0] = CRC_CHECK_DONE; | 1122 crc_check_state_[0] = CRC_CHECK_DONE; |
1122 crc32s_[0] = in_results->stream_0_crc32; | 1123 crc32s_[0] = in_results->stream_0_crc32; |
1123 crc32s_end_offset_[0] = in_results->entry_stat.data_size(0); | 1124 crc32s_end_offset_[0] = in_results->entry_stat.data_size(0); |
1124 } | 1125 } |
1125 if (key_.empty()) { | 1126 if (key_.empty()) { |
1126 SetKey(synchronous_entry_->key()); | 1127 SetKey(synchronous_entry_->key()); |
1127 } else { | 1128 } else { |
1128 // This should only be triggered when creating an entry. The key check in | 1129 // This should only be triggered when creating an entry. The key check in |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1523 } | 1524 } |
1524 crc32s_end_offset_[stream_index] = offset + length; | 1525 crc32s_end_offset_[stream_index] = offset + length; |
1525 } else if (offset < crc32s_end_offset_[stream_index]) { | 1526 } else if (offset < crc32s_end_offset_[stream_index]) { |
1526 // 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 |
1527 // computation of the crc32 need to start from 0 again. | 1528 // computation of the crc32 need to start from 0 again. |
1528 crc32s_end_offset_[stream_index] = 0; | 1529 crc32s_end_offset_[stream_index] = 0; |
1529 } | 1530 } |
1530 } | 1531 } |
1531 | 1532 |
1532 } // namespace disk_cache | 1533 } // namespace disk_cache |
OLD | NEW |