| 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 index_.reset(new SimpleIndex( | 253 index_.reset(new SimpleIndex( |
| 254 base::ThreadTaskRunnerHandle::Get(), | 254 base::ThreadTaskRunnerHandle::Get(), |
| 255 this, | 255 this, |
| 256 cache_type_, | 256 cache_type_, |
| 257 make_scoped_ptr(new SimpleIndexFile( | 257 make_scoped_ptr(new SimpleIndexFile( |
| 258 cache_thread_, worker_pool_.get(), cache_type_, path_)))); | 258 cache_thread_, worker_pool_.get(), cache_type_, path_)))); |
| 259 index_->ExecuteWhenReady( | 259 index_->ExecuteWhenReady( |
| 260 base::Bind(&RecordIndexLoad, cache_type_, base::TimeTicks::Now())); | 260 base::Bind(&RecordIndexLoad, cache_type_, base::TimeTicks::Now())); |
| 261 | 261 |
| 262 PostTaskAndReplyWithResult( | 262 PostTaskAndReplyWithResult( |
| 263 cache_thread_, | 263 cache_thread_.get(), |
| 264 FROM_HERE, | 264 FROM_HERE, |
| 265 base::Bind( | 265 base::Bind( |
| 266 &SimpleBackendImpl::InitCacheStructureOnDisk, path_, orig_max_size_), | 266 &SimpleBackendImpl::InitCacheStructureOnDisk, path_, orig_max_size_), |
| 267 base::Bind(&SimpleBackendImpl::InitializeIndex, | 267 base::Bind(&SimpleBackendImpl::InitializeIndex, |
| 268 AsWeakPtr(), | 268 AsWeakPtr(), |
| 269 completion_callback)); | 269 completion_callback)); |
| 270 return net::ERR_IO_PENDING; | 270 return net::ERR_IO_PENDING; |
| 271 } | 271 } |
| 272 | 272 |
| 273 bool SimpleBackendImpl::SetMaxSize(int max_bytes) { | 273 bool SimpleBackendImpl::SetMaxSize(int max_bytes) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 end = mass_doom_entry_hashes->end(); | 346 end = mass_doom_entry_hashes->end(); |
| 347 it != end; ++it) { | 347 it != end; ++it) { |
| 348 index_->Remove(*it); | 348 index_->Remove(*it); |
| 349 OnDoomStart(*it); | 349 OnDoomStart(*it); |
| 350 } | 350 } |
| 351 | 351 |
| 352 // Taking this pointer here avoids undefined behaviour from calling | 352 // Taking this pointer here avoids undefined behaviour from calling |
| 353 // base::Passed before mass_doom_entry_hashes.get(). | 353 // base::Passed before mass_doom_entry_hashes.get(). |
| 354 std::vector<uint64>* mass_doom_entry_hashes_ptr = | 354 std::vector<uint64>* mass_doom_entry_hashes_ptr = |
| 355 mass_doom_entry_hashes.get(); | 355 mass_doom_entry_hashes.get(); |
| 356 PostTaskAndReplyWithResult( | 356 PostTaskAndReplyWithResult(worker_pool_.get(), |
| 357 worker_pool_, FROM_HERE, | 357 FROM_HERE, |
| 358 base::Bind(&SimpleSynchronousEntry::DoomEntrySet, | 358 base::Bind(&SimpleSynchronousEntry::DoomEntrySet, |
| 359 mass_doom_entry_hashes_ptr, path_), | 359 mass_doom_entry_hashes_ptr, |
| 360 base::Bind(&SimpleBackendImpl::DoomEntriesComplete, | 360 path_), |
| 361 AsWeakPtr(), base::Passed(&mass_doom_entry_hashes), | 361 base::Bind(&SimpleBackendImpl::DoomEntriesComplete, |
| 362 barrier_callback)); | 362 AsWeakPtr(), |
| 363 base::Passed(&mass_doom_entry_hashes), |
| 364 barrier_callback)); |
| 363 } | 365 } |
| 364 | 366 |
| 365 net::CacheType SimpleBackendImpl::GetCacheType() const { | 367 net::CacheType SimpleBackendImpl::GetCacheType() const { |
| 366 return net::DISK_CACHE; | 368 return net::DISK_CACHE; |
| 367 } | 369 } |
| 368 | 370 |
| 369 int32 SimpleBackendImpl::GetEntryCount() const { | 371 int32 SimpleBackendImpl::GetEntryCount() const { |
| 370 // TODO(pasko): Use directory file count when index is not ready. | 372 // TODO(pasko): Use directory file count when index is not ready. |
| 371 return index_->GetEntryCount(); | 373 return index_->GetEntryCount(); |
| 372 } | 374 } |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 this)); | 728 this)); |
| 727 callback.Run(result); | 729 callback.Run(result); |
| 728 } | 730 } |
| 729 | 731 |
| 730 void SimpleBackendImpl::FlushWorkerPoolForTesting() { | 732 void SimpleBackendImpl::FlushWorkerPoolForTesting() { |
| 731 if (g_sequenced_worker_pool) | 733 if (g_sequenced_worker_pool) |
| 732 g_sequenced_worker_pool->FlushForTesting(); | 734 g_sequenced_worker_pool->FlushForTesting(); |
| 733 } | 735 } |
| 734 | 736 |
| 735 } // namespace disk_cache | 737 } // namespace disk_cache |
| OLD | NEW |