Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: net/http/mock_http_cache.cc

Issue 2721933002: HttpCache::Transaction layer allowing parallel validation (Closed)
Patch Set: Josh's latest feedback addressed Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« net/http/http_cache_unittest.cc ('K') | « net/http/mock_http_cache.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 it->second->Release(); 525 it->second->Release();
526 entries_.clear(); 526 entries_.clear();
527 } 527 }
528 528
529 void MockDiskCache::CallbackLater(const CompletionCallback& callback, 529 void MockDiskCache::CallbackLater(const CompletionCallback& callback,
530 int result) { 530 int result) {
531 base::ThreadTaskRunnerHandle::Get()->PostTask( 531 base::ThreadTaskRunnerHandle::Get()->PostTask(
532 FROM_HERE, base::Bind(&CallbackForwader, callback, result)); 532 FROM_HERE, base::Bind(&CallbackForwader, callback, result));
533 } 533 }
534 534
535 bool MockDiskCache::IsDiskEntryDoomed(const std::string& key) {
536 auto it = entries_.find(key);
537 if (it == entries_.end())
538 return false;
539 return it->second->is_doomed();
540 }
541
535 //----------------------------------------------------------------------------- 542 //-----------------------------------------------------------------------------
536 543
537 int MockBackendFactory::CreateBackend( 544 int MockBackendFactory::CreateBackend(
538 NetLog* net_log, 545 NetLog* net_log,
539 std::unique_ptr<disk_cache::Backend>* backend, 546 std::unique_ptr<disk_cache::Backend>* backend,
540 const CompletionCallback& callback) { 547 const CompletionCallback& callback) {
541 backend->reset(new MockDiskCache()); 548 backend->reset(new MockDiskCache());
542 return OK; 549 return OK;
543 } 550 }
544 551
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 return test_mode; 645 return test_mode;
639 646
640 return g_test_mode; 647 return g_test_mode;
641 } 648 }
642 649
643 // Static. 650 // Static.
644 void MockHttpCache::SetTestMode(int test_mode) { 651 void MockHttpCache::SetTestMode(int test_mode) {
645 g_test_mode = test_mode; 652 g_test_mode = test_mode;
646 } 653 }
647 654
655 bool MockHttpCache::IsWriterPresent(const std::string& key) {
656 HttpCache::ActiveEntry* entry = http_cache_.FindActiveEntry(key);
657 if (entry)
658 return entry->writer;
659 return false;
660 }
661
662 bool MockHttpCache::IsHeadersTransactionPresent(const std::string& key) {
663 HttpCache::ActiveEntry* entry = http_cache_.FindActiveEntry(key);
664 if (entry)
665 return entry->headers_transaction;
666 return false;
667 }
668
669 int MockHttpCache::GetCountReaders(const std::string& key) {
670 HttpCache::ActiveEntry* entry = http_cache_.FindActiveEntry(key);
671 if (entry)
672 return entry->readers.size();
673 return false;
674 }
675
676 int MockHttpCache::GetCountAddToEntryQueue(const std::string& key) {
677 HttpCache::ActiveEntry* entry = http_cache_.FindActiveEntry(key);
678 if (entry)
679 return entry->add_to_entry_queue.size();
680 return false;
681 }
682
683 int MockHttpCache::GetCountDoneHeadersQueue(const std::string& key) {
684 HttpCache::ActiveEntry* entry = http_cache_.FindActiveEntry(key);
685 if (entry)
686 return entry->done_headers_queue.size();
687 return false;
688 }
689
648 //----------------------------------------------------------------------------- 690 //-----------------------------------------------------------------------------
649 691
650 int MockDiskCacheNoCB::CreateEntry(const std::string& key, 692 int MockDiskCacheNoCB::CreateEntry(const std::string& key,
651 disk_cache::Entry** entry, 693 disk_cache::Entry** entry,
652 const CompletionCallback& callback) { 694 const CompletionCallback& callback) {
653 return ERR_IO_PENDING; 695 return ERR_IO_PENDING;
654 } 696 }
655 697
656 //----------------------------------------------------------------------------- 698 //-----------------------------------------------------------------------------
657 699
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 if (!callback_.is_null()) { 736 if (!callback_.is_null()) {
695 if (!fail_) 737 if (!fail_)
696 backend_->reset(new MockDiskCache()); 738 backend_->reset(new MockDiskCache());
697 CompletionCallback cb = callback_; 739 CompletionCallback cb = callback_;
698 callback_.Reset(); 740 callback_.Reset();
699 cb.Run(Result()); // This object can be deleted here. 741 cb.Run(Result()); // This object can be deleted here.
700 } 742 }
701 } 743 }
702 744
703 } // namespace net 745 } // namespace net
OLDNEW
« net/http/http_cache_unittest.cc ('K') | « net/http/mock_http_cache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698