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_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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 | 569 |
570 size_t size = base::trace_event::EstimateMemoryUsage(index_) + | 570 size_t size = base::trace_event::EstimateMemoryUsage(index_) + |
571 base::trace_event::EstimateMemoryUsage(active_entries_); | 571 base::trace_event::EstimateMemoryUsage(active_entries_); |
572 // TODO(xunjieli): crbug.com/669108. Track |entries_pending_doom_| once | 572 // TODO(xunjieli): crbug.com/669108. Track |entries_pending_doom_| once |
573 // base::Closure is suppported in memory_usage_estimator.h. | 573 // base::Closure is suppported in memory_usage_estimator.h. |
574 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 574 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
575 base::trace_event::MemoryAllocatorDump::kUnitsBytes, size); | 575 base::trace_event::MemoryAllocatorDump::kUnitsBytes, size); |
576 return size; | 576 return size; |
577 } | 577 } |
578 | 578 |
| 579 uint8_t SimpleBackendImpl::GetMemoryEntryData(const std::string& key) { |
| 580 const uint64_t entry_hash = simple_util::GetEntryHashKey(key); |
| 581 return index_->GetMemoryEntryData(entry_hash); |
| 582 } |
| 583 |
| 584 void SimpleBackendImpl::SetMemoryEntryData(const std::string& key, |
| 585 uint8_t data) { |
| 586 const uint64_t entry_hash = simple_util::GetEntryHashKey(key); |
| 587 index_->SetMemoryEntryData(entry_hash, data); |
| 588 } |
| 589 |
579 void SimpleBackendImpl::InitializeIndex(const CompletionCallback& callback, | 590 void SimpleBackendImpl::InitializeIndex(const CompletionCallback& callback, |
580 const DiskStatResult& result) { | 591 const DiskStatResult& result) { |
581 if (result.net_error == net::OK) { | 592 if (result.net_error == net::OK) { |
582 index_->SetMaxSize(result.max_size); | 593 index_->SetMaxSize(result.max_size); |
583 index_->Initialize(result.cache_dir_mtime); | 594 index_->Initialize(result.cache_dir_mtime); |
584 } | 595 } |
585 callback.Run(result.net_error); | 596 callback.Run(result.net_error); |
586 } | 597 } |
587 | 598 |
588 void SimpleBackendImpl::IndexReadyForDoom(Time initial_time, | 599 void SimpleBackendImpl::IndexReadyForDoom(Time initial_time, |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 } | 782 } |
772 | 783 |
773 // static | 784 // static |
774 void SimpleBackendImpl::FlushWorkerPoolForTesting() { | 785 void SimpleBackendImpl::FlushWorkerPoolForTesting() { |
775 // We only need to do this if we there is an active task runner. | 786 // We only need to do this if we there is an active task runner. |
776 if (base::ThreadTaskRunnerHandle::IsSet()) | 787 if (base::ThreadTaskRunnerHandle::IsSet()) |
777 g_sequenced_worker_pool.Get().FlushForTesting(); | 788 g_sequenced_worker_pool.Get().FlushForTesting(); |
778 } | 789 } |
779 | 790 |
780 } // namespace disk_cache | 791 } // namespace disk_cache |
OLD | NEW |