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

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

Issue 1230113012: [net] Better StopCaching() handling for HttpCache::Transaction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
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/http_cache.h" 5 #include "net/http/http_cache.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 832
833 // We do this before calling EntryAvailable to force any further calls to 833 // We do this before calling EntryAvailable to force any further calls to
834 // AddTransactionToEntry to add their transaction to the pending queue, which 834 // AddTransactionToEntry to add their transaction to the pending queue, which
835 // ensures FIFO ordering. 835 // ensures FIFO ordering.
836 if (!entry->writer && !entry->pending_queue.empty()) 836 if (!entry->writer && !entry->pending_queue.empty())
837 ProcessPendingQueue(entry); 837 ProcessPendingQueue(entry);
838 838
839 return OK; 839 return OK;
840 } 840 }
841 841
842 void HttpCache::DoneWithEntry(ActiveEntry* entry, Transaction* trans,
843 bool cancel) {
844 // If we already posted a task to move on to the next transaction and this was
845 // the writer, there is nothing to cancel.
846 if (entry->will_process_pending_queue && entry->readers.empty())
rvargas (doing something else) 2015/08/19 23:46:37 I worry about removing this method. This logic sh
847 return;
848
849 if (entry->writer) {
850 DCHECK(trans == entry->writer);
851
852 // Assume there was a failure.
853 bool success = false;
854 if (cancel) {
855 DCHECK(entry->disk_entry);
856 // This is a successful operation in the sense that we want to keep the
857 // entry.
858 success = trans->AddTruncatedFlag();
859 // The previous operation may have deleted the entry.
860 if (!trans->entry())
861 return;
862 }
863 DoneWritingToEntry(entry, success);
864 } else {
865 DoneReadingFromEntry(entry, trans);
866 }
867 }
868
869 void HttpCache::DoneWritingToEntry(ActiveEntry* entry, bool success) { 842 void HttpCache::DoneWritingToEntry(ActiveEntry* entry, bool success) {
870 DCHECK(entry->readers.empty()); 843 DCHECK(entry->readers.empty());
871 844
872 entry->writer = NULL; 845 entry->writer = NULL;
873 846
874 if (success) { 847 if (success) {
875 ProcessPendingQueue(entry); 848 ProcessPendingQueue(entry);
876 } else { 849 } else {
877 DCHECK(!entry->will_process_pending_queue); 850 DCHECK(!entry->will_process_pending_queue);
878 851
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 building_backend_ = false; 1154 building_backend_ = false;
1182 DeletePendingOp(pending_op); 1155 DeletePendingOp(pending_op);
1183 } 1156 }
1184 1157
1185 // The cache may be gone when we return from the callback. 1158 // The cache may be gone when we return from the callback.
1186 if (!item->DoCallback(result, disk_cache_.get())) 1159 if (!item->DoCallback(result, disk_cache_.get()))
1187 item->NotifyTransaction(result, NULL); 1160 item->NotifyTransaction(result, NULL);
1188 } 1161 }
1189 1162
1190 } // namespace net 1163 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698