Chromium Code Reviews| 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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 463 base::Bind(&SimpleBackendImpl::IndexReadyForDoom, AsWeakPtr(), | 463 base::Bind(&SimpleBackendImpl::IndexReadyForDoom, AsWeakPtr(), |
| 464 initial_time, end_time, callback)); | 464 initial_time, end_time, callback)); |
| 465 } | 465 } |
| 466 | 466 |
| 467 int SimpleBackendImpl::DoomEntriesSince( | 467 int SimpleBackendImpl::DoomEntriesSince( |
| 468 const Time initial_time, | 468 const Time initial_time, |
| 469 const CompletionCallback& callback) { | 469 const CompletionCallback& callback) { |
| 470 return DoomEntriesBetween(initial_time, Time(), callback); | 470 return DoomEntriesBetween(initial_time, Time(), callback); |
| 471 } | 471 } |
| 472 | 472 |
| 473 void SimpleBackendImpl::IndexReadyForCalculation( | |
| 474 const CompletionCallback& callback, | |
| 475 int result) { | |
| 476 if (result == net::OK) | |
| 477 result = static_cast<int>(index_->GetCacheSize()); | |
|
msramek
2015/10/09 09:32:24
cache_size_, and thus also GetCacheSize(), are uin
pasko
2015/10/09 15:52:03
We do not want to introduce more constraints in th
msramek
2015/10/13 09:45:06
Ah ok, good to know. Still, I'd like to keep the s
| |
| 478 callback.Run(result); | |
| 479 } | |
| 480 | |
| 473 int SimpleBackendImpl::CalculateSizeOfAllEntries( | 481 int SimpleBackendImpl::CalculateSizeOfAllEntries( |
| 474 const CompletionCallback& callback) { | 482 const CompletionCallback& callback) { |
| 475 // TODO(msramek): Implement. | 483 return index_->ExecuteWhenReady( |
| 476 return net::ERR_NOT_IMPLEMENTED; | 484 base::Bind(&SimpleBackendImpl::IndexReadyForCalculation, |
| 485 AsWeakPtr(), | |
| 486 callback)); | |
| 477 } | 487 } |
| 478 | 488 |
| 479 class SimpleBackendImpl::SimpleIterator final : public Iterator { | 489 class SimpleBackendImpl::SimpleIterator final : public Iterator { |
| 480 public: | 490 public: |
| 481 explicit SimpleIterator(base::WeakPtr<SimpleBackendImpl> backend) | 491 explicit SimpleIterator(base::WeakPtr<SimpleBackendImpl> backend) |
| 482 : backend_(backend), | 492 : backend_(backend), |
| 483 weak_factory_(this) { | 493 weak_factory_(this) { |
| 484 } | 494 } |
| 485 | 495 |
| 486 // From Backend::Iterator: | 496 // From Backend::Iterator: |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 739 } | 749 } |
| 740 | 750 |
| 741 // static | 751 // static |
| 742 void SimpleBackendImpl::FlushWorkerPoolForTesting() { | 752 void SimpleBackendImpl::FlushWorkerPoolForTesting() { |
| 743 // We only need to do this if we there is an active task runner. | 753 // We only need to do this if we there is an active task runner. |
| 744 if (base::ThreadTaskRunnerHandle::IsSet()) | 754 if (base::ThreadTaskRunnerHandle::IsSet()) |
| 745 g_sequenced_worker_pool.Get().FlushForTesting(); | 755 g_sequenced_worker_pool.Get().FlushForTesting(); |
| 746 } | 756 } |
| 747 | 757 |
| 748 } // namespace disk_cache | 758 } // namespace disk_cache |
| OLD | NEW |