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

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

Issue 2957133002: Implement in-memory byte hints in SimpleCache (Closed)
Patch Set: Adjust to the interface's naming change. Created 3 years, 3 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) 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_backend_impl.h" 5 #include "net/disk_cache/simple/simple_backend_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstdlib> 8 #include <cstdlib>
9 #include <functional> 9 #include <functional>
10 #include <limits> 10 #include <limits>
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 587
588 size_t size = base::trace_event::EstimateMemoryUsage(index_) + 588 size_t size = base::trace_event::EstimateMemoryUsage(index_) +
589 base::trace_event::EstimateMemoryUsage(active_entries_); 589 base::trace_event::EstimateMemoryUsage(active_entries_);
590 // TODO(xunjieli): crbug.com/669108. Track |entries_pending_doom_| once 590 // TODO(xunjieli): crbug.com/669108. Track |entries_pending_doom_| once
591 // base::Closure is suppported in memory_usage_estimator.h. 591 // base::Closure is suppported in memory_usage_estimator.h.
592 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 592 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
593 base::trace_event::MemoryAllocatorDump::kUnitsBytes, size); 593 base::trace_event::MemoryAllocatorDump::kUnitsBytes, size);
594 return size; 594 return size;
595 } 595 }
596 596
597 uint8_t SimpleBackendImpl::GetEntryInMemoryData(const std::string& key) {
598 const uint64_t entry_hash = simple_util::GetEntryHashKey(key);
599 return index_->GetEntryInMemoryData(entry_hash);
600 }
601
602 void SimpleBackendImpl::SetEntryInMemoryData(const std::string& key,
603 uint8_t data) {
604 const uint64_t entry_hash = simple_util::GetEntryHashKey(key);
605 index_->SetEntryInMemoryData(entry_hash, data);
606 }
607
597 void SimpleBackendImpl::InitializeIndex(const CompletionCallback& callback, 608 void SimpleBackendImpl::InitializeIndex(const CompletionCallback& callback,
598 const DiskStatResult& result) { 609 const DiskStatResult& result) {
599 if (result.net_error == net::OK) { 610 if (result.net_error == net::OK) {
600 index_->SetMaxSize(result.max_size); 611 index_->SetMaxSize(result.max_size);
601 index_->Initialize(result.cache_dir_mtime); 612 index_->Initialize(result.cache_dir_mtime);
602 } 613 }
603 callback.Run(result.net_error); 614 callback.Run(result.net_error);
604 } 615 }
605 616
606 void SimpleBackendImpl::IndexReadyForDoom(Time initial_time, 617 void SimpleBackendImpl::IndexReadyForDoom(Time initial_time,
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 } 802 }
792 803
793 // static 804 // static
794 void SimpleBackendImpl::FlushWorkerPoolForTesting() { 805 void SimpleBackendImpl::FlushWorkerPoolForTesting() {
795 // We only need to do this if we there is an active task runner. 806 // We only need to do this if we there is an active task runner.
796 if (base::ThreadTaskRunnerHandle::IsSet()) 807 if (base::ThreadTaskRunnerHandle::IsSet())
797 g_sequenced_worker_pool.Get().FlushForTesting(); 808 g_sequenced_worker_pool.Get().FlushForTesting();
798 } 809 }
799 810
800 } // namespace disk_cache 811 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_backend_impl.h ('k') | net/disk_cache/simple/simple_backend_version.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698