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

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

Issue 1545233002: Convert Pass()→std::move() in //net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 | « net/disk_cache/simple/simple_backend_impl.cc ('k') | net/disk_cache/simple/simple_index.cc » ('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 <vector> 11 #include <vector>
11 12
12 #include "base/bind.h" 13 #include "base/bind.h"
13 #include "base/bind_helpers.h" 14 #include "base/bind_helpers.h"
14 #include "base/callback.h" 15 #include "base/callback.h"
15 #include "base/location.h" 16 #include "base/location.h"
16 #include "base/logging.h" 17 #include "base/logging.h"
17 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
18 #include "base/task_runner.h" 19 #include "base/task_runner.h"
19 #include "base/task_runner_util.h" 20 #include "base/task_runner_util.h"
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 offset + *result == GetDataSize(stream_index)) { 1225 offset + *result == GetDataSize(stream_index)) {
1225 crc_check_state_[stream_index] = CRC_CHECK_NOT_DONE; 1226 crc_check_state_[stream_index] = CRC_CHECK_NOT_DONE;
1226 } 1227 }
1227 } 1228 }
1228 if (net_log_.IsCapturing()) { 1229 if (net_log_.IsCapturing()) {
1229 net_log_.AddEvent( 1230 net_log_.AddEvent(
1230 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END, 1231 net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END,
1231 CreateNetLogReadWriteCompleteCallback(*result)); 1232 CreateNetLogReadWriteCompleteCallback(*result));
1232 } 1233 }
1233 1234
1234 EntryOperationComplete(completion_callback, *entry_stat, result.Pass()); 1235 EntryOperationComplete(completion_callback, *entry_stat, std::move(result));
1235 } 1236 }
1236 1237
1237 void SimpleEntryImpl::WriteOperationComplete( 1238 void SimpleEntryImpl::WriteOperationComplete(
1238 int stream_index, 1239 int stream_index,
1239 const CompletionCallback& completion_callback, 1240 const CompletionCallback& completion_callback,
1240 scoped_ptr<SimpleEntryStat> entry_stat, 1241 scoped_ptr<SimpleEntryStat> entry_stat,
1241 scoped_ptr<int> result) { 1242 scoped_ptr<int> result) {
1242 if (*result >= 0) 1243 if (*result >= 0)
1243 RecordWriteResult(cache_type_, WRITE_RESULT_SUCCESS); 1244 RecordWriteResult(cache_type_, WRITE_RESULT_SUCCESS);
1244 else 1245 else
1245 RecordWriteResult(cache_type_, WRITE_RESULT_SYNC_WRITE_FAILURE); 1246 RecordWriteResult(cache_type_, WRITE_RESULT_SYNC_WRITE_FAILURE);
1246 if (net_log_.IsCapturing()) { 1247 if (net_log_.IsCapturing()) {
1247 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_END, 1248 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_END,
1248 CreateNetLogReadWriteCompleteCallback(*result)); 1249 CreateNetLogReadWriteCompleteCallback(*result));
1249 } 1250 }
1250 1251
1251 if (*result < 0) { 1252 if (*result < 0) {
1252 crc32s_end_offset_[stream_index] = 0; 1253 crc32s_end_offset_[stream_index] = 0;
1253 } 1254 }
1254 1255
1255 EntryOperationComplete(completion_callback, *entry_stat, result.Pass()); 1256 EntryOperationComplete(completion_callback, *entry_stat, std::move(result));
1256 } 1257 }
1257 1258
1258 void SimpleEntryImpl::ReadSparseOperationComplete( 1259 void SimpleEntryImpl::ReadSparseOperationComplete(
1259 const CompletionCallback& completion_callback, 1260 const CompletionCallback& completion_callback,
1260 scoped_ptr<base::Time> last_used, 1261 scoped_ptr<base::Time> last_used,
1261 scoped_ptr<int> result) { 1262 scoped_ptr<int> result) {
1262 DCHECK(io_thread_checker_.CalledOnValidThread()); 1263 DCHECK(io_thread_checker_.CalledOnValidThread());
1263 DCHECK(synchronous_entry_); 1264 DCHECK(synchronous_entry_);
1264 DCHECK(result); 1265 DCHECK(result);
1265 1266
1266 SimpleEntryStat entry_stat(*last_used, last_modified_, data_size_, 1267 SimpleEntryStat entry_stat(*last_used, last_modified_, data_size_,
1267 sparse_data_size_); 1268 sparse_data_size_);
1268 EntryOperationComplete(completion_callback, entry_stat, result.Pass()); 1269 EntryOperationComplete(completion_callback, entry_stat, std::move(result));
1269 } 1270 }
1270 1271
1271 void SimpleEntryImpl::WriteSparseOperationComplete( 1272 void SimpleEntryImpl::WriteSparseOperationComplete(
1272 const CompletionCallback& completion_callback, 1273 const CompletionCallback& completion_callback,
1273 scoped_ptr<SimpleEntryStat> entry_stat, 1274 scoped_ptr<SimpleEntryStat> entry_stat,
1274 scoped_ptr<int> result) { 1275 scoped_ptr<int> result) {
1275 DCHECK(io_thread_checker_.CalledOnValidThread()); 1276 DCHECK(io_thread_checker_.CalledOnValidThread());
1276 DCHECK(synchronous_entry_); 1277 DCHECK(synchronous_entry_);
1277 DCHECK(result); 1278 DCHECK(result);
1278 1279
1279 EntryOperationComplete(completion_callback, *entry_stat, result.Pass()); 1280 EntryOperationComplete(completion_callback, *entry_stat, std::move(result));
1280 } 1281 }
1281 1282
1282 void SimpleEntryImpl::GetAvailableRangeOperationComplete( 1283 void SimpleEntryImpl::GetAvailableRangeOperationComplete(
1283 const CompletionCallback& completion_callback, 1284 const CompletionCallback& completion_callback,
1284 scoped_ptr<int> result) { 1285 scoped_ptr<int> result) {
1285 DCHECK(io_thread_checker_.CalledOnValidThread()); 1286 DCHECK(io_thread_checker_.CalledOnValidThread());
1286 DCHECK(synchronous_entry_); 1287 DCHECK(synchronous_entry_);
1287 DCHECK(result); 1288 DCHECK(result);
1288 1289
1289 SimpleEntryStat entry_stat(last_used_, last_modified_, data_size_, 1290 SimpleEntryStat entry_stat(last_used_, last_modified_, data_size_,
1290 sparse_data_size_); 1291 sparse_data_size_);
1291 EntryOperationComplete(completion_callback, entry_stat, result.Pass()); 1292 EntryOperationComplete(completion_callback, entry_stat, std::move(result));
1292 } 1293 }
1293 1294
1294 void SimpleEntryImpl::DoomOperationComplete( 1295 void SimpleEntryImpl::DoomOperationComplete(
1295 const CompletionCallback& callback, 1296 const CompletionCallback& callback,
1296 State state_to_restore, 1297 State state_to_restore,
1297 int result) { 1298 int result) {
1298 state_ = state_to_restore; 1299 state_ = state_to_restore;
1299 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_DOOM_END); 1300 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_DOOM_END);
1300 if (!callback.is_null()) 1301 if (!callback.is_null())
1301 callback.Run(result); 1302 callback.Run(result);
(...skipping 27 matching lines...) Expand all
1329 } else { 1330 } else {
1330 RecordReadResult(cache_type_, READ_RESULT_SYNC_CHECKSUM_FAILURE); 1331 RecordReadResult(cache_type_, READ_RESULT_SYNC_CHECKSUM_FAILURE);
1331 } 1332 }
1332 if (net_log_.IsCapturing()) { 1333 if (net_log_.IsCapturing()) {
1333 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END, 1334 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END,
1334 CreateNetLogReadWriteCompleteCallback(*result)); 1335 CreateNetLogReadWriteCompleteCallback(*result));
1335 } 1336 }
1336 1337
1337 SimpleEntryStat entry_stat(last_used_, last_modified_, data_size_, 1338 SimpleEntryStat entry_stat(last_used_, last_modified_, data_size_,
1338 sparse_data_size_); 1339 sparse_data_size_);
1339 EntryOperationComplete(completion_callback, entry_stat, result.Pass()); 1340 EntryOperationComplete(completion_callback, entry_stat, std::move(result));
1340 } 1341 }
1341 1342
1342 void SimpleEntryImpl::CloseOperationComplete() { 1343 void SimpleEntryImpl::CloseOperationComplete() {
1343 DCHECK(!synchronous_entry_); 1344 DCHECK(!synchronous_entry_);
1344 DCHECK_EQ(0, open_count_); 1345 DCHECK_EQ(0, open_count_);
1345 DCHECK(STATE_IO_PENDING == state_ || STATE_FAILURE == state_ || 1346 DCHECK(STATE_IO_PENDING == state_ || STATE_FAILURE == state_ ||
1346 STATE_UNINITIALIZED == state_); 1347 STATE_UNINITIALIZED == state_);
1347 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_CLOSE_END); 1348 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_CLOSE_END);
1348 AdjustOpenEntryCountBy(cache_type_, -1); 1349 AdjustOpenEntryCountBy(cache_type_, -1);
1349 MakeUninitialized(); 1350 MakeUninitialized();
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 } 1520 }
1520 crc32s_end_offset_[stream_index] = offset + length; 1521 crc32s_end_offset_[stream_index] = offset + length;
1521 } else if (offset < crc32s_end_offset_[stream_index]) { 1522 } else if (offset < crc32s_end_offset_[stream_index]) {
1522 // If a range for which the crc32 was already computed is rewritten, the 1523 // If a range for which the crc32 was already computed is rewritten, the
1523 // computation of the crc32 need to start from 0 again. 1524 // computation of the crc32 need to start from 0 again.
1524 crc32s_end_offset_[stream_index] = 0; 1525 crc32s_end_offset_[stream_index] = 0;
1525 } 1526 }
1526 } 1527 }
1527 1528
1528 } // namespace disk_cache 1529 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_backend_impl.cc ('k') | net/disk_cache/simple/simple_index.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698