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 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 SimpleBackendImpl::~SimpleBackendImpl() { | 177 SimpleBackendImpl::~SimpleBackendImpl() { |
178 index_->WriteToDisk(); | 178 index_->WriteToDisk(); |
179 } | 179 } |
180 | 180 |
181 int SimpleBackendImpl::Init(const CompletionCallback& completion_callback) { | 181 int SimpleBackendImpl::Init(const CompletionCallback& completion_callback) { |
182 MaybeCreateSequencedWorkerPool(); | 182 MaybeCreateSequencedWorkerPool(); |
183 | 183 |
184 worker_pool_ = g_sequenced_worker_pool->GetTaskRunnerWithShutdownBehavior( | 184 worker_pool_ = g_sequenced_worker_pool->GetTaskRunnerWithShutdownBehavior( |
185 SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 185 SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
186 | 186 |
187 index_.reset(new SimpleIndex(MessageLoopProxy::current(), path_, | 187 index_.reset( |
188 make_scoped_ptr(new SimpleIndexFile( | 188 new SimpleIndex(MessageLoopProxy::current().get(), |
189 cache_thread_.get(), worker_pool_.get(), | 189 path_, |
190 path_)))); | 190 make_scoped_ptr(new SimpleIndexFile( |
| 191 cache_thread_.get(), worker_pool_.get(), path_)))); |
191 index_->ExecuteWhenReady(base::Bind(&RecordIndexLoad, | 192 index_->ExecuteWhenReady(base::Bind(&RecordIndexLoad, |
192 base::TimeTicks::Now())); | 193 base::TimeTicks::Now())); |
193 | 194 |
194 InitializeIndexCallback initialize_index_callback = | 195 InitializeIndexCallback initialize_index_callback = |
195 base::Bind(&SimpleBackendImpl::InitializeIndex, | 196 base::Bind(&SimpleBackendImpl::InitializeIndex, |
196 base::Unretained(this), | 197 base::Unretained(this), |
197 completion_callback); | 198 completion_callback); |
198 cache_thread_->PostTask( | 199 cache_thread_->PostTask( |
199 FROM_HERE, | 200 FROM_HERE, |
200 base::Bind(&SimpleBackendImpl::ProvideDirectorySuggestBetterCacheSize, | 201 base::Bind(&SimpleBackendImpl::ProvideDirectorySuggestBetterCacheSize, |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 // currently active entry. | 382 // currently active entry. |
382 if (key != it->second->key()) { | 383 if (key != it->second->key()) { |
383 it->second->Doom(); | 384 it->second->Doom(); |
384 DCHECK_EQ(0U, active_entries_.count(entry_hash)); | 385 DCHECK_EQ(0U, active_entries_.count(entry_hash)); |
385 return CreateOrFindActiveEntry(key); | 386 return CreateOrFindActiveEntry(key); |
386 } | 387 } |
387 return make_scoped_refptr(it->second.get()); | 388 return make_scoped_refptr(it->second.get()); |
388 } | 389 } |
389 | 390 |
390 } // namespace disk_cache | 391 } // namespace disk_cache |
OLD | NEW |