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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 // will_process_pending_queue flag. | 335 // will_process_pending_queue flag. |
336 while (!active_entries_.empty()) { | 336 while (!active_entries_.empty()) { |
337 ActiveEntry* entry = active_entries_.begin()->second; | 337 ActiveEntry* entry = active_entries_.begin()->second; |
338 entry->will_process_pending_queue = false; | 338 entry->will_process_pending_queue = false; |
339 entry->pending_queue.clear(); | 339 entry->pending_queue.clear(); |
340 entry->readers.clear(); | 340 entry->readers.clear(); |
341 entry->writer = NULL; | 341 entry->writer = NULL; |
342 DeactivateEntry(entry); | 342 DeactivateEntry(entry); |
343 } | 343 } |
344 | 344 |
345 STLDeleteElements(&doomed_entries_); | 345 base::STLDeleteElements(&doomed_entries_); |
346 | 346 |
347 // Before deleting pending_ops_, we have to make sure that the disk cache is | 347 // Before deleting pending_ops_, we have to make sure that the disk cache is |
348 // done with said operations, or it will attempt to use deleted data. | 348 // done with said operations, or it will attempt to use deleted data. |
349 disk_cache_.reset(); | 349 disk_cache_.reset(); |
350 | 350 |
351 PendingOpsMap::iterator pending_it = pending_ops_.begin(); | 351 PendingOpsMap::iterator pending_it = pending_ops_.begin(); |
352 for (; pending_it != pending_ops_.end(); ++pending_it) { | 352 for (; pending_it != pending_ops_.end(); ++pending_it) { |
353 // We are not notifying the transactions about the cache going away, even | 353 // We are not notifying the transactions about the cache going away, even |
354 // though they are waiting for a callback that will never fire. | 354 // though they are waiting for a callback that will never fire. |
355 PendingOp* pending_op = pending_it->second; | 355 PendingOp* pending_op = pending_it->second; |
356 delete pending_op->writer; | 356 delete pending_op->writer; |
357 bool delete_pending_op = true; | 357 bool delete_pending_op = true; |
358 if (building_backend_) { | 358 if (building_backend_) { |
359 // If we don't have a backend, when its construction finishes it will | 359 // If we don't have a backend, when its construction finishes it will |
360 // deliver the callbacks. | 360 // deliver the callbacks. |
361 if (!pending_op->callback.is_null()) { | 361 if (!pending_op->callback.is_null()) { |
362 // If not null, the callback will delete the pending operation later. | 362 // If not null, the callback will delete the pending operation later. |
363 delete_pending_op = false; | 363 delete_pending_op = false; |
364 } | 364 } |
365 } else { | 365 } else { |
366 pending_op->callback.Reset(); | 366 pending_op->callback.Reset(); |
367 } | 367 } |
368 | 368 |
369 STLDeleteElements(&pending_op->pending_queue); | 369 base::STLDeleteElements(&pending_op->pending_queue); |
370 if (delete_pending_op) | 370 if (delete_pending_op) |
371 delete pending_op; | 371 delete pending_op; |
372 } | 372 } |
373 } | 373 } |
374 | 374 |
375 int HttpCache::GetBackend(disk_cache::Backend** backend, | 375 int HttpCache::GetBackend(disk_cache::Backend** backend, |
376 const CompletionCallback& callback) { | 376 const CompletionCallback& callback) { |
377 DCHECK(!callback.is_null()); | 377 DCHECK(!callback.is_null()); |
378 | 378 |
379 if (disk_cache_.get()) { | 379 if (disk_cache_.get()) { |
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 building_backend_ = false; | 1154 building_backend_ = false; |
1155 DeletePendingOp(pending_op); | 1155 DeletePendingOp(pending_op); |
1156 } | 1156 } |
1157 | 1157 |
1158 // The cache may be gone when we return from the callback. | 1158 // The cache may be gone when we return from the callback. |
1159 if (!item->DoCallback(result, disk_cache_.get())) | 1159 if (!item->DoCallback(result, disk_cache_.get())) |
1160 item->NotifyTransaction(result, NULL); | 1160 item->NotifyTransaction(result, NULL); |
1161 } | 1161 } |
1162 | 1162 |
1163 } // namespace net | 1163 } // namespace net |
OLD | NEW |