Lines Matching refs:entry
96 HttpCache::ActiveEntry::ActiveEntry(disk_cache::Entry* entry)
97 : disk_entry(entry),
118 disk_cache::Entry* disk_entry;
139 WorkItem(WorkItemOperation operation, Transaction* trans, ActiveEntry** entry)
140 : operation_(operation), trans_(trans), entry_(entry), callback_(NULL),
149 void NotifyTransaction(int result, ActiveEntry* entry) {
150 DCHECK(!entry || entry->disk_entry);
152 *entry_ = entry;
218 // to a given entry.
376 ActiveEntry* entry = active_entries_.begin()->second;
377 entry->will_process_pending_queue = false;
378 entry->pending_queue.clear();
379 entry->readers.clear();
380 entry->writer = NULL;
381 DeactivateEntry(entry);
506 // entry, so we use an empty key for it.
584 // Need to abandon the ActiveEntry, but any transaction attached to the entry
585 // should not be impacted. Dooming an entry only means that it will no
587 // all consumers are finished with the entry).
593 ActiveEntry* entry = it->second;
598 doomed_entries_.insert(entry);
600 entry->disk_entry->Doom();
601 entry->doomed = true;
603 DCHECK(entry->writer || !entry->readers.empty());
631 void HttpCache::FinalizeDoomedEntry(ActiveEntry* entry) {
632 DCHECK(entry->doomed);
633 DCHECK(!entry->writer);
634 DCHECK(entry->readers.empty());
635 DCHECK(entry->pending_queue.empty());
637 ActiveEntriesSet::iterator it = doomed_entries_.find(entry);
641 delete entry;
650 disk_cache::Entry* disk_entry) {
652 ActiveEntry* entry = new ActiveEntry(disk_entry);
653 active_entries_[disk_entry->GetKey()] = entry;
654 return entry;
657 void HttpCache::DeactivateEntry(ActiveEntry* entry) {
658 DCHECK(!entry->will_process_pending_queue);
659 DCHECK(!entry->doomed);
660 DCHECK(!entry->writer);
661 DCHECK(entry->disk_entry);
662 DCHECK(entry->readers.empty());
663 DCHECK(entry->pending_queue.empty());
665 std::string key = entry->disk_entry->GetKey();
667 return SlowDeactivateEntry(entry);
671 DCHECK(it->second == entry);
674 delete entry;
677 // We don't know this entry's key so we have to find it without it.
678 void HttpCache::SlowDeactivateEntry(ActiveEntry* entry) {
681 if (it->second == entry) {
683 delete entry;
724 int HttpCache::OpenEntry(const std::string& key, ActiveEntry** entry,
728 *entry = active_entry;
732 WorkItem* item = new WorkItem(WI_OPEN_ENTRY, trans, entry);
754 int HttpCache::CreateEntry(const std::string& key, ActiveEntry** entry,
758 WorkItem* item = new WorkItem(WI_CREATE_ENTRY, trans, entry);
781 void HttpCache::DestroyEntry(ActiveEntry* entry) {
782 if (entry->doomed) {
783 FinalizeDoomedEntry(entry);
785 DeactivateEntry(entry);
789 int HttpCache::AddTransactionToEntry(ActiveEntry* entry, Transaction* trans) {
790 DCHECK(entry);
791 DCHECK(entry->disk_entry);
793 // We implement a basic reader/writer lock for the disk cache entry. If
795 // finish before they can access the cache entry. There can be multiple
798 // NOTE: If the transaction can only write, then the entry should not be in
799 // use (since any existing entry should have already been doomed).
801 if (entry->writer || entry->will_process_pending_queue) {
802 entry->pending_queue.push_back(trans);
807 // transaction needs exclusive access to the entry
808 if (entry->readers.empty()) {
809 entry->writer = trans;
811 entry->pending_queue.push_back(trans);
815 // transaction needs read access to the entry
816 entry->readers.push_back(trans);
822 if (!entry->writer && !entry->pending_queue.empty())
823 ProcessPendingQueue(entry);
828 void HttpCache::DoneWithEntry(ActiveEntry* entry, Transaction* trans,
832 if (entry->will_process_pending_queue && entry->readers.empty())
835 if (entry->writer) {
836 DCHECK(trans == entry->writer);
841 DCHECK(entry->disk_entry);
843 // entry.
846 DoneWritingToEntry(entry, success);
848 DoneReadingFromEntry(entry, trans);
852 void HttpCache::DoneWritingToEntry(ActiveEntry* entry, bool success) {
853 DCHECK(entry->readers.empty());
855 entry->writer = NULL;
858 ProcessPendingQueue(entry);
860 DCHECK(!entry->will_process_pending_queue);
862 // We failed to create this entry.
864 pending_queue.swap(entry->pending_queue);
866 entry->disk_entry->Doom();
867 DestroyEntry(entry);
870 // be added to a new entry.
879 void HttpCache::DoneReadingFromEntry(ActiveEntry* entry, Transaction* trans) {
880 DCHECK(!entry->writer);
883 std::find(entry->readers.begin(), entry->readers.end(), trans);
884 DCHECK(it != entry->readers.end());
886 entry->readers.erase(it);
888 ProcessPendingQueue(entry);
891 void HttpCache::ConvertWriterToReader(ActiveEntry* entry) {
892 DCHECK(entry->writer);
893 DCHECK(entry->writer->mode() == Transaction::READ_WRITE);
894 DCHECK(entry->readers.empty());
896 Transaction* trans = entry->writer;
898 entry->writer = NULL;
899 entry->readers.push_back(trans);
901 ProcessPendingQueue(entry);
909 // active_entries_, we should be creating the backend or the entry.
949 bool HttpCache::RemovePendingTransactionFromEntry(ActiveEntry* entry,
951 TransactionList& pending_queue = entry->pending_queue;
982 void HttpCache::ProcessPendingQueue(ActiveEntry* entry) {
983 // Multiple readers may finish with an entry at once, so we want to batch up
985 // not delete the entry before OnProcessPendingQueue runs.
986 if (entry->will_process_pending_queue)
988 entry->will_process_pending_queue = true;
993 entry));
996 void HttpCache::OnProcessPendingQueue(ActiveEntry* entry) {
997 entry->will_process_pending_queue = false;
998 DCHECK(!entry->writer);
1000 // If no one is interested in this entry, then we can de-activate it.
1001 if (entry->pending_queue.empty()) {
1002 if (entry->readers.empty())
1003 DestroyEntry(entry);
1008 Transaction* next = entry->pending_queue.front();
1009 if ((next->mode() & Transaction::WRITE) && !entry->readers.empty())
1012 entry->pending_queue.erase(entry->pending_queue.begin());
1014 int rv = AddTransactionToEntry(entry, next);
1030 ActiveEntry* entry = NULL;
1038 entry = ActivateEntry(pending_op->disk_entry);
1064 item->NotifyTransaction(result, entry);
1074 entry = FindActiveEntry(key);
1075 if (!entry)
1094 item->NotifyTransaction(result, entry);
1103 item->NotifyTransaction(result, entry);