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

Side by Side Diff: net/disk_cache/blockfile/backend_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, 11 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/backend_unittest.cc ('k') | net/disk_cache/blockfile/file_posix.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/blockfile/backend_impl.h" 5 #include "net/disk_cache/blockfile/backend_impl.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
11 #include "base/files/file.h" 12 #include "base/files/file.h"
12 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
13 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
14 #include "base/hash.h" 15 #include "base/hash.h"
15 #include "base/location.h" 16 #include "base/location.h"
16 #include "base/metrics/field_trial.h" 17 #include "base/metrics/field_trial.h"
17 #include "base/metrics/histogram.h" 18 #include "base/metrics/histogram.h"
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 node = next; 396 node = next;
396 next = OpenNextEntryImpl(iterator.get()); 397 next = OpenNextEntryImpl(iterator.get());
397 398
398 if (node->GetLastUsed() >= initial_time && 399 if (node->GetLastUsed() >= initial_time &&
399 node->GetLastUsed() < end_time) { 400 node->GetLastUsed() < end_time) {
400 node->DoomImpl(); 401 node->DoomImpl();
401 } else if (node->GetLastUsed() < initial_time) { 402 } else if (node->GetLastUsed() < initial_time) {
402 if (next) 403 if (next)
403 next->Release(); 404 next->Release();
404 next = NULL; 405 next = NULL;
405 SyncEndEnumeration(iterator.Pass()); 406 SyncEndEnumeration(std::move(iterator));
406 } 407 }
407 408
408 node->Release(); 409 node->Release();
409 } 410 }
410 411
411 return net::OK; 412 return net::OK;
412 } 413 }
413 414
414 int BackendImpl::SyncCalculateSizeOfAllEntries() { 415 int BackendImpl::SyncCalculateSizeOfAllEntries() {
415 DCHECK_NE(net::APP_CACHE, cache_type_); 416 DCHECK_NE(net::APP_CACHE, cache_type_);
(...skipping 12 matching lines...) Expand all
428 429
429 stats_.OnEvent(Stats::DOOM_RECENT); 430 stats_.OnEvent(Stats::DOOM_RECENT);
430 for (;;) { 431 for (;;) {
431 scoped_ptr<Rankings::Iterator> iterator(new Rankings::Iterator()); 432 scoped_ptr<Rankings::Iterator> iterator(new Rankings::Iterator());
432 EntryImpl* entry = OpenNextEntryImpl(iterator.get()); 433 EntryImpl* entry = OpenNextEntryImpl(iterator.get());
433 if (!entry) 434 if (!entry)
434 return net::OK; 435 return net::OK;
435 436
436 if (initial_time > entry->GetLastUsed()) { 437 if (initial_time > entry->GetLastUsed()) {
437 entry->Release(); 438 entry->Release();
438 SyncEndEnumeration(iterator.Pass()); 439 SyncEndEnumeration(std::move(iterator));
439 return net::OK; 440 return net::OK;
440 } 441 }
441 442
442 entry->DoomImpl(); 443 entry->DoomImpl();
443 entry->Release(); 444 entry->Release();
444 SyncEndEnumeration(iterator.Pass()); // The doom invalidated the iterator. 445 SyncEndEnumeration(
446 std::move(iterator)); // The doom invalidated the iterator.
445 } 447 }
446 } 448 }
447 449
448 int BackendImpl::SyncOpenNextEntry(Rankings::Iterator* iterator, 450 int BackendImpl::SyncOpenNextEntry(Rankings::Iterator* iterator,
449 Entry** next_entry) { 451 Entry** next_entry) {
450 *next_entry = OpenNextEntryImpl(iterator); 452 *next_entry = OpenNextEntryImpl(iterator);
451 return (*next_entry) ? net::OK : net::ERR_FAILED; 453 return (*next_entry) ? net::OK : net::ERR_FAILED;
452 } 454 }
453 455
454 void BackendImpl::SyncEndEnumeration(scoped_ptr<Rankings::Iterator> iterator) { 456 void BackendImpl::SyncEndEnumeration(scoped_ptr<Rankings::Iterator> iterator) {
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
1274 1276
1275 class BackendImpl::IteratorImpl : public Backend::Iterator { 1277 class BackendImpl::IteratorImpl : public Backend::Iterator {
1276 public: 1278 public:
1277 explicit IteratorImpl(base::WeakPtr<InFlightBackendIO> background_queue) 1279 explicit IteratorImpl(base::WeakPtr<InFlightBackendIO> background_queue)
1278 : background_queue_(background_queue), 1280 : background_queue_(background_queue),
1279 iterator_(new Rankings::Iterator()) { 1281 iterator_(new Rankings::Iterator()) {
1280 } 1282 }
1281 1283
1282 ~IteratorImpl() override { 1284 ~IteratorImpl() override {
1283 if (background_queue_) 1285 if (background_queue_)
1284 background_queue_->EndEnumeration(iterator_.Pass()); 1286 background_queue_->EndEnumeration(std::move(iterator_));
1285 } 1287 }
1286 1288
1287 int OpenNextEntry(Entry** next_entry, 1289 int OpenNextEntry(Entry** next_entry,
1288 const net::CompletionCallback& callback) override { 1290 const net::CompletionCallback& callback) override {
1289 if (!background_queue_) 1291 if (!background_queue_)
1290 return net::ERR_FAILED; 1292 return net::ERR_FAILED;
1291 background_queue_->OpenNextEntry(iterator_.get(), next_entry, callback); 1293 background_queue_->OpenNextEntry(iterator_.get(), next_entry, callback);
1292 return net::ERR_IO_PENDING; 1294 return net::ERR_IO_PENDING;
1293 } 1295 }
1294 1296
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 1366
1365 int flags = base::File::FLAG_READ | base::File::FLAG_WRITE | 1367 int flags = base::File::FLAG_READ | base::File::FLAG_WRITE |
1366 base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_EXCLUSIVE_WRITE; 1368 base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_EXCLUSIVE_WRITE;
1367 base::File base_file(index_name, flags); 1369 base::File base_file(index_name, flags);
1368 if (!base_file.IsValid()) 1370 if (!base_file.IsValid())
1369 return false; 1371 return false;
1370 1372
1371 bool ret = true; 1373 bool ret = true;
1372 *file_created = base_file.created(); 1374 *file_created = base_file.created();
1373 1375
1374 scoped_refptr<disk_cache::File> file(new disk_cache::File(base_file.Pass())); 1376 scoped_refptr<disk_cache::File> file(
1377 new disk_cache::File(std::move(base_file)));
1375 if (*file_created) 1378 if (*file_created)
1376 ret = CreateBackingStore(file.get()); 1379 ret = CreateBackingStore(file.get());
1377 1380
1378 file = NULL; 1381 file = NULL;
1379 if (!ret) 1382 if (!ret)
1380 return false; 1383 return false;
1381 1384
1382 index_ = new MappedFile(); 1385 index_ = new MappedFile();
1383 data_ = static_cast<Index*>(index_->Init(index_name, 0)); 1386 data_ = static_cast<Index*>(index_->Init(index_name, 0));
1384 if (!data_) { 1387 if (!data_) {
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
2111 if (total_memory > kMaxBuffersSize || total_memory <= 0) 2114 if (total_memory > kMaxBuffersSize || total_memory <= 0)
2112 total_memory = kMaxBuffersSize; 2115 total_memory = kMaxBuffersSize;
2113 2116
2114 done = true; 2117 done = true;
2115 } 2118 }
2116 2119
2117 return static_cast<int>(total_memory); 2120 return static_cast<int>(total_memory);
2118 } 2121 }
2119 2122
2120 } // namespace disk_cache 2123 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/backend_unittest.cc ('k') | net/disk_cache/blockfile/file_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698