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

Side by Side Diff: net/disk_cache/blockfile/backend_impl_v3.cc

Issue 1894733002: Change scoped_ptr to std::unique_ptr in //net/disk_cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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_v3.h" 5 #include "net/disk_cache/blockfile/backend_impl_v3.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 return net::ERR_FAILED; 678 return net::ERR_FAILED;
679 background_queue_->OpenNextEntry(&data_, next_entry, callback); 679 background_queue_->OpenNextEntry(&data_, next_entry, callback);
680 return net::ERR_IO_PENDING; 680 return net::ERR_IO_PENDING;
681 } 681 }
682 682
683 private: 683 private:
684 const base::WeakPtr<InFlightBackendIO> background_queue_; 684 const base::WeakPtr<InFlightBackendIO> background_queue_;
685 void* data_; 685 void* data_;
686 }; 686 };
687 687
688 scoped_ptr<Backend::Iterator> BackendImplV3::CreateIterator() { 688 std::unique_ptr<Backend::Iterator> BackendImplV3::CreateIterator() {
689 return scoped_ptr<Backend::Iterator>(new IteratorImpl(GetBackgroundQueue())); 689 return std::unique_ptr<Backend::Iterator>(
690 new IteratorImpl(GetBackgroundQueue()));
690 } 691 }
691 692
692 void BackendImplV3::GetStats(StatsItems* stats) { 693 void BackendImplV3::GetStats(StatsItems* stats) {
693 if (disabled_) 694 if (disabled_)
694 return; 695 return;
695 696
696 std::pair<std::string, std::string> item; 697 std::pair<std::string, std::string> item;
697 698
698 item.first = "Entries"; 699 item.first = "Entries";
699 item.second = base::IntToString(data_->header.num_entries); 700 item.second = base::IntToString(data_->header.num_entries);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 NOTREACHED(); 789 NOTREACHED();
789 return false; 790 return false;
790 } 791 }
791 792
792 // Load the required data. 793 // Load the required data.
793 size = address.num_blocks() * address.BlockSize(); 794 size = address.num_blocks() * address.BlockSize();
794 MappedFile* file = File(address); 795 MappedFile* file = File(address);
795 if (!file) 796 if (!file)
796 return false; 797 return false;
797 798
798 scoped_ptr<char[]> data(new char[size]); 799 std::unique_ptr<char[]> data(new char[size]);
799 size_t offset = address.start_block() * address.BlockSize() + 800 size_t offset = address.start_block() * address.BlockSize() +
800 kBlockHeaderSize; 801 kBlockHeaderSize;
801 if (!file->Read(data.get(), size, offset)) 802 if (!file->Read(data.get(), size, offset))
802 return false; 803 return false;
803 804
804 if (!stats_.Init(data.get(), size, address)) 805 if (!stats_.Init(data.get(), size, address))
805 return false; 806 return false;
806 if (cache_type_ == net::DISK_CACHE && ShouldReportAgain()) 807 if (cache_type_ == net::DISK_CACHE && ShouldReportAgain())
807 stats_.InitSizeHistogram(); 808 stats_.InitSizeHistogram();
808 return true; 809 return true;
809 } 810 }
810 811
811 void BackendImplV3::StoreStats() { 812 void BackendImplV3::StoreStats() {
812 int size = stats_.StorageSize(); 813 int size = stats_.StorageSize();
813 scoped_ptr<char[]> data(new char[size]); 814 std::unique_ptr<char[]> data(new char[size]);
814 Addr address; 815 Addr address;
815 size = stats_.SerializeStats(data.get(), size, &address); 816 size = stats_.SerializeStats(data.get(), size, &address);
816 DCHECK(size); 817 DCHECK(size);
817 if (!address.is_initialized()) 818 if (!address.is_initialized())
818 return; 819 return;
819 820
820 MappedFile* file = File(address); 821 MappedFile* file = File(address);
821 if (!file) 822 if (!file)
822 return; 823 return;
823 824
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 1383
1383 if (data_->header.num_entries < 0) { 1384 if (data_->header.num_entries < 0) {
1384 LOG(ERROR) << "Invalid number of entries"; 1385 LOG(ERROR) << "Invalid number of entries";
1385 return false; 1386 return false;
1386 } 1387 }
1387 1388
1388 if (!mask_) 1389 if (!mask_)
1389 mask_ = data_->header.table_len - 1; 1390 mask_ = data_->header.table_len - 1;
1390 1391
1391 // Load the table into memory with a single read. 1392 // Load the table into memory with a single read.
1392 scoped_ptr<char[]> buf(new char[current_size]); 1393 std::unique_ptr<char[]> buf(new char[current_size]);
1393 return index_->Read(buf.get(), current_size, 0); 1394 return index_->Read(buf.get(), current_size, 0);
1394 } 1395 }
1395 1396
1396 int BackendImplV3::CheckAllEntries() { 1397 int BackendImplV3::CheckAllEntries() {
1397 int num_dirty = 0; 1398 int num_dirty = 0;
1398 int num_entries = 0; 1399 int num_entries = 0;
1399 DCHECK(mask_ < std::numeric_limits<uint32_t>::max()); 1400 DCHECK(mask_ < std::numeric_limits<uint32_t>::max());
1400 for (unsigned int i = 0; i <= mask_; i++) { 1401 for (unsigned int i = 0; i <= mask_; i++) {
1401 Addr address(data_->table[i]); 1402 Addr address(data_->table[i]);
1402 if (!address.is_initialized()) 1403 if (!address.is_initialized())
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 } 1520 }
1520 1521
1521 class BackendImplV3::NotImplementedIterator : public Backend::Iterator { 1522 class BackendImplV3::NotImplementedIterator : public Backend::Iterator {
1522 public: 1523 public:
1523 int OpenNextEntry(disk_cache::Entry** next_entry, 1524 int OpenNextEntry(disk_cache::Entry** next_entry,
1524 const net::CompletionCallback& callback) override { 1525 const net::CompletionCallback& callback) override {
1525 return net::ERR_NOT_IMPLEMENTED; 1526 return net::ERR_NOT_IMPLEMENTED;
1526 } 1527 }
1527 }; 1528 };
1528 1529
1529 scoped_ptr<Backend::Iterator> BackendImplV3::CreateIterator() { 1530 std::unique_ptr<Backend::Iterator> BackendImplV3::CreateIterator() {
1530 return scoped_ptr<Iterator>(new NotImplementedIterator()); 1531 return std::unique_ptr<Iterator>(new NotImplementedIterator());
1531 } 1532 }
1532 1533
1533 void BackendImplV3::GetStats(StatsItems* stats) { 1534 void BackendImplV3::GetStats(StatsItems* stats) {
1534 NOTIMPLEMENTED(); 1535 NOTIMPLEMENTED();
1535 } 1536 }
1536 1537
1537 void BackendImplV3::OnExternalCacheHit(const std::string& key) { 1538 void BackendImplV3::OnExternalCacheHit(const std::string& key) {
1538 NOTIMPLEMENTED(); 1539 NOTIMPLEMENTED();
1539 } 1540 }
1540 1541
1541 void BackendImplV3::CleanupCache() { 1542 void BackendImplV3::CleanupCache() {
1542 } 1543 }
1543 1544
1544 } // namespace disk_cache 1545 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/blockfile/backend_impl_v3.h ('k') | net/disk_cache/blockfile/backend_worker_v3.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698