OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/http/mock_http_cache.h" | 5 #include "net/http/mock_http_cache.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 callback_list.clear(); | 363 callback_list.clear(); |
364 } | 364 } |
365 } | 365 } |
366 | 366 |
367 // Statics. | 367 // Statics. |
368 bool MockDiskEntry::ignore_callbacks_ = false; | 368 bool MockDiskEntry::ignore_callbacks_ = false; |
369 | 369 |
370 //----------------------------------------------------------------------------- | 370 //----------------------------------------------------------------------------- |
371 | 371 |
372 MockDiskCache::MockDiskCache() | 372 MockDiskCache::MockDiskCache() |
373 : open_count_(0), create_count_(0), fail_requests_(false), | 373 : open_count_(0), |
374 soft_failures_(false), double_create_check_(true), | 374 create_count_(0), |
375 fail_sparse_requests_(false) { | 375 doomed_count_(0), |
376 } | 376 fail_requests_(false), |
| 377 soft_failures_(false), |
| 378 double_create_check_(true), |
| 379 fail_sparse_requests_(false) {} |
377 | 380 |
378 MockDiskCache::~MockDiskCache() { | 381 MockDiskCache::~MockDiskCache() { |
379 ReleaseAll(); | 382 ReleaseAll(); |
380 } | 383 } |
381 | 384 |
382 CacheType MockDiskCache::GetCacheType() const { | 385 CacheType MockDiskCache::GetCacheType() const { |
383 return DISK_CACHE; | 386 return DISK_CACHE; |
384 } | 387 } |
385 | 388 |
386 int32_t MockDiskCache::GetEntryCount() const { | 389 int32_t MockDiskCache::GetEntryCount() const { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 return ERR_IO_PENDING; | 464 return ERR_IO_PENDING; |
462 } | 465 } |
463 | 466 |
464 int MockDiskCache::DoomEntry(const std::string& key, | 467 int MockDiskCache::DoomEntry(const std::string& key, |
465 const CompletionCallback& callback) { | 468 const CompletionCallback& callback) { |
466 DCHECK(!callback.is_null()); | 469 DCHECK(!callback.is_null()); |
467 EntryMap::iterator it = entries_.find(key); | 470 EntryMap::iterator it = entries_.find(key); |
468 if (it != entries_.end()) { | 471 if (it != entries_.end()) { |
469 it->second->Release(); | 472 it->second->Release(); |
470 entries_.erase(it); | 473 entries_.erase(it); |
| 474 doomed_count_++; |
471 } | 475 } |
472 | 476 |
473 if (GetTestModeForEntry(key) & TEST_MODE_SYNC_CACHE_START) | 477 if (GetTestModeForEntry(key) & TEST_MODE_SYNC_CACHE_START) |
474 return OK; | 478 return OK; |
475 | 479 |
476 CallbackLater(callback, OK); | 480 CallbackLater(callback, OK); |
477 return ERR_IO_PENDING; | 481 return ERR_IO_PENDING; |
478 } | 482 } |
479 | 483 |
480 int MockDiskCache::DoomAllEntries(const CompletionCallback& callback) { | 484 int MockDiskCache::DoomAllEntries(const CompletionCallback& callback) { |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 if (!callback_.is_null()) { | 746 if (!callback_.is_null()) { |
743 if (!fail_) | 747 if (!fail_) |
744 backend_->reset(new MockDiskCache()); | 748 backend_->reset(new MockDiskCache()); |
745 CompletionCallback cb = callback_; | 749 CompletionCallback cb = callback_; |
746 callback_.Reset(); | 750 callback_.Reset(); |
747 cb.Run(Result()); // This object can be deleted here. | 751 cb.Run(Result()); // This object can be deleted here. |
748 } | 752 } |
749 } | 753 } |
750 | 754 |
751 } // namespace net | 755 } // namespace net |
OLD | NEW |