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/http_cache.h" | 5 #include "net/http/http_cache.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 | 10 |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 if (rv != ERR_IO_PENDING) { | 715 if (rv != ERR_IO_PENDING) { |
716 item->ClearTransaction(); | 716 item->ClearTransaction(); |
717 pending_op->callback.Run(rv); | 717 pending_op->callback.Run(rv); |
718 } | 718 } |
719 | 719 |
720 return rv; | 720 return rv; |
721 } | 721 } |
722 | 722 |
723 int HttpCache::CreateEntry(const std::string& key, ActiveEntry** entry, | 723 int HttpCache::CreateEntry(const std::string& key, ActiveEntry** entry, |
724 Transaction* trans) { | 724 Transaction* trans) { |
725 DCHECK(!FindActiveEntry(key)); | 725 if (FindActiveEntry(key)) { |
| 726 return ERR_CACHE_RACE; |
| 727 } |
726 | 728 |
727 WorkItem* item = new WorkItem(WI_CREATE_ENTRY, trans, entry); | 729 WorkItem* item = new WorkItem(WI_CREATE_ENTRY, trans, entry); |
728 PendingOp* pending_op = GetPendingOp(key); | 730 PendingOp* pending_op = GetPendingOp(key); |
729 if (pending_op->writer) { | 731 if (pending_op->writer) { |
730 pending_op->pending_queue.push_back(item); | 732 pending_op->pending_queue.push_back(item); |
731 return ERR_IO_PENDING; | 733 return ERR_IO_PENDING; |
732 } | 734 } |
733 | 735 |
734 DCHECK(pending_op->pending_queue.empty()); | 736 DCHECK(pending_op->pending_queue.empty()); |
735 | 737 |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 building_backend_ = false; | 1129 building_backend_ = false; |
1128 DeletePendingOp(pending_op); | 1130 DeletePendingOp(pending_op); |
1129 } | 1131 } |
1130 | 1132 |
1131 // The cache may be gone when we return from the callback. | 1133 // The cache may be gone when we return from the callback. |
1132 if (!item->DoCallback(result, backend)) | 1134 if (!item->DoCallback(result, backend)) |
1133 item->NotifyTransaction(result, NULL); | 1135 item->NotifyTransaction(result, NULL); |
1134 } | 1136 } |
1135 | 1137 |
1136 } // namespace net | 1138 } // namespace net |
OLD | NEW |