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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) { |
| 274 if (max_bytes < 0) |
| 275 return false; |
274 orig_max_size_ = max_bytes; | 276 orig_max_size_ = max_bytes; |
275 return index_->SetMaxSize(max_bytes); | 277 index_->SetMaxSize(max_bytes); |
| 278 return true; |
276 } | 279 } |
277 | 280 |
278 int SimpleBackendImpl::GetMaxFileSize() const { | 281 int SimpleBackendImpl::GetMaxFileSize() const { |
279 return index_->max_size() / kMaxFileRatio; | 282 return static_cast<int>(index_->max_size() / kMaxFileRatio); |
280 } | 283 } |
281 | 284 |
282 void SimpleBackendImpl::OnDoomStart(uint64 entry_hash) { | 285 void SimpleBackendImpl::OnDoomStart(uint64 entry_hash) { |
283 DCHECK_EQ(0u, entries_pending_doom_.count(entry_hash)); | 286 DCHECK_EQ(0u, entries_pending_doom_.count(entry_hash)); |
284 entries_pending_doom_.insert( | 287 entries_pending_doom_.insert( |
285 std::make_pair(entry_hash, std::vector<Closure>())); | 288 std::make_pair(entry_hash, std::vector<Closure>())); |
286 } | 289 } |
287 | 290 |
288 void SimpleBackendImpl::OnDoomComplete(uint64 entry_hash) { | 291 void SimpleBackendImpl::OnDoomComplete(uint64 entry_hash) { |
289 DCHECK_EQ(1u, entries_pending_doom_.count(entry_hash)); | 292 DCHECK_EQ(1u, entries_pending_doom_.count(entry_hash)); |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 this)); | 732 this)); |
730 callback.Run(result); | 733 callback.Run(result); |
731 } | 734 } |
732 | 735 |
733 void SimpleBackendImpl::FlushWorkerPoolForTesting() { | 736 void SimpleBackendImpl::FlushWorkerPoolForTesting() { |
734 if (g_sequenced_worker_pool) | 737 if (g_sequenced_worker_pool) |
735 g_sequenced_worker_pool->FlushForTesting(); | 738 g_sequenced_worker_pool->FlushForTesting(); |
736 } | 739 } |
737 | 740 |
738 } // namespace disk_cache | 741 } // namespace disk_cache |
OLD | NEW |