Chromium Code Reviews| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 971 if (entry->HasNoActiveTransactions() && | 971 if (entry->HasNoActiveTransactions() && |
| 972 !entry->will_process_queued_transactions) { | 972 !entry->will_process_queued_transactions) { |
| 973 entry->disk_entry->Doom(); | 973 entry->disk_entry->Doom(); |
| 974 RemoveAllQueuedTransactions(entry, &list); | 974 RemoveAllQueuedTransactions(entry, &list); |
| 975 DestroyEntry(entry); | 975 DestroyEntry(entry); |
| 976 } else { | 976 } else { |
| 977 DoomActiveEntry(entry->disk_entry->GetKey()); | 977 DoomActiveEntry(entry->disk_entry->GetKey()); |
| 978 RemoveAllQueuedTransactions(entry, &list); | 978 RemoveAllQueuedTransactions(entry, &list); |
| 979 } | 979 } |
| 980 // ERR_CACHE_RACE causes the transaction to restart the whole process. | 980 // ERR_CACHE_RACE causes the transaction to restart the whole process. |
| 981 for (auto* transaction : list) | 981 for (auto* transaction : list) { |
| 982 transaction->io_callback().Run(net::ERR_CACHE_RACE); | 982 // Post task here to avoid a race in case we are here because of the |
| 983 // transaction that is dooming this entry and creating a new one because of | |
| 984 // validation not matching. | |
| 985 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
| 986 FROM_HERE, base::Bind(transaction->io_callback(), net::ERR_CACHE_RACE)); | |
|
Randy Smith (Not in Mondays)
2017/04/27 17:47:12
Random thought, not for this CL: If we do this eve
| |
| 987 } | |
| 983 } | 988 } |
| 984 | 989 |
| 985 void HttpCache::ProcessQueuedTransactions(ActiveEntry* entry) { | 990 void HttpCache::ProcessQueuedTransactions(ActiveEntry* entry) { |
| 986 // Multiple readers may finish with an entry at once, so we want to batch up | 991 // Multiple readers may finish with an entry at once, so we want to batch up |
| 987 // calls to OnProcessQueuedTransactions. This flag also tells us that we | 992 // calls to OnProcessQueuedTransactions. This flag also tells us that we |
| 988 // should not delete the entry before OnProcessQueuedTransactions runs. | 993 // should not delete the entry before OnProcessQueuedTransactions runs. |
| 989 if (entry->will_process_queued_transactions) | 994 if (entry->will_process_queued_transactions) |
| 990 return; | 995 return; |
| 991 | 996 |
| 992 entry->will_process_queued_transactions = true; | 997 entry->will_process_queued_transactions = true; |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1332 building_backend_ = false; | 1337 building_backend_ = false; |
| 1333 DeletePendingOp(pending_op); | 1338 DeletePendingOp(pending_op); |
| 1334 } | 1339 } |
| 1335 | 1340 |
| 1336 // The cache may be gone when we return from the callback. | 1341 // The cache may be gone when we return from the callback. |
| 1337 if (!item->DoCallback(result, disk_cache_.get())) | 1342 if (!item->DoCallback(result, disk_cache_.get())) |
| 1338 item->NotifyTransaction(result, NULL); | 1343 item->NotifyTransaction(result, NULL); |
| 1339 } | 1344 } |
| 1340 | 1345 |
| 1341 } // namespace net | 1346 } // namespace net |
| OLD | NEW |