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 | 10 |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 248 |
249 SimpleBackendImpl::~SimpleBackendImpl() { | 249 SimpleBackendImpl::~SimpleBackendImpl() { |
250 index_->WriteToDisk(SimpleIndex::INDEX_WRITE_REASON_SHUTDOWN); | 250 index_->WriteToDisk(SimpleIndex::INDEX_WRITE_REASON_SHUTDOWN); |
251 } | 251 } |
252 | 252 |
253 int SimpleBackendImpl::Init(const CompletionCallback& completion_callback) { | 253 int SimpleBackendImpl::Init(const CompletionCallback& completion_callback) { |
254 worker_pool_ = g_sequenced_worker_pool.Get().GetTaskRunner(); | 254 worker_pool_ = g_sequenced_worker_pool.Get().GetTaskRunner(); |
255 | 255 |
256 index_.reset(new SimpleIndex( | 256 index_.reset(new SimpleIndex( |
257 base::ThreadTaskRunnerHandle::Get(), this, cache_type_, | 257 base::ThreadTaskRunnerHandle::Get(), this, cache_type_, |
258 base::WrapUnique(new SimpleIndexFile(cache_thread_, worker_pool_.get(), | 258 base::MakeUnique<SimpleIndexFile>(cache_thread_, worker_pool_.get(), |
259 cache_type_, path_)))); | 259 cache_type_, path_))); |
260 index_->ExecuteWhenReady( | 260 index_->ExecuteWhenReady( |
261 base::Bind(&RecordIndexLoad, cache_type_, base::TimeTicks::Now())); | 261 base::Bind(&RecordIndexLoad, cache_type_, base::TimeTicks::Now())); |
262 | 262 |
263 PostTaskAndReplyWithResult( | 263 PostTaskAndReplyWithResult( |
264 cache_thread_.get(), | 264 cache_thread_.get(), |
265 FROM_HERE, | 265 FROM_HERE, |
266 base::Bind( | 266 base::Bind( |
267 &SimpleBackendImpl::InitCacheStructureOnDisk, path_, orig_max_size_), | 267 &SimpleBackendImpl::InitCacheStructureOnDisk, path_, orig_max_size_), |
268 base::Bind(&SimpleBackendImpl::InitializeIndex, | 268 base::Bind(&SimpleBackendImpl::InitializeIndex, |
269 AsWeakPtr(), | 269 AsWeakPtr(), |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 } | 718 } |
719 | 719 |
720 // static | 720 // static |
721 void SimpleBackendImpl::FlushWorkerPoolForTesting() { | 721 void SimpleBackendImpl::FlushWorkerPoolForTesting() { |
722 // We only need to do this if we there is an active task runner. | 722 // We only need to do this if we there is an active task runner. |
723 if (base::ThreadTaskRunnerHandle::IsSet()) | 723 if (base::ThreadTaskRunnerHandle::IsSet()) |
724 g_sequenced_worker_pool.Get().FlushForTesting(); | 724 g_sequenced_worker_pool.Get().FlushForTesting(); |
725 } | 725 } |
726 | 726 |
727 } // namespace disk_cache | 727 } // namespace disk_cache |
OLD | NEW |