| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/disk_cache/simple/simple_backend_impl.h" | 5 #include "net/disk_cache/simple/simple_backend_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstdlib> | 8 #include <cstdlib> |
| 9 #include <functional> | 9 #include <functional> |
| 10 | 10 |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 base::Bind(&SimpleBackendImpl::OnEntryOpenedFromHash, | 558 base::Bind(&SimpleBackendImpl::OnEntryOpenedFromHash, |
| 559 AsWeakPtr(), entry_hash, entry, simple_entry, callback); | 559 AsWeakPtr(), entry_hash, entry, simple_entry, callback); |
| 560 return simple_entry->OpenEntry(entry, backend_callback); | 560 return simple_entry->OpenEntry(entry, backend_callback); |
| 561 } | 561 } |
| 562 | 562 |
| 563 int SimpleBackendImpl::DoomEntryFromHash(uint64 entry_hash, | 563 int SimpleBackendImpl::DoomEntryFromHash(uint64 entry_hash, |
| 564 const CompletionCallback& callback) { | 564 const CompletionCallback& callback) { |
| 565 Entry** entry = new Entry*(); | 565 Entry** entry = new Entry*(); |
| 566 scoped_ptr<Entry*> scoped_entry(entry); | 566 scoped_ptr<Entry*> scoped_entry(entry); |
| 567 | 567 |
| 568 base::hash_map<uint64, std::vector<Closure> >::iterator it = | 568 base::hash_map<uint64, std::vector<Closure> >::iterator pending_it = |
| 569 entries_pending_doom_.find(entry_hash); | 569 entries_pending_doom_.find(entry_hash); |
| 570 if (it != entries_pending_doom_.end()) { | 570 if (pending_it != entries_pending_doom_.end()) { |
| 571 Callback<int(const net::CompletionCallback&)> operation = | 571 Callback<int(const net::CompletionCallback&)> operation = |
| 572 base::Bind(&SimpleBackendImpl::DoomEntryFromHash, | 572 base::Bind(&SimpleBackendImpl::DoomEntryFromHash, |
| 573 base::Unretained(this), entry_hash); | 573 base::Unretained(this), entry_hash); |
| 574 it->second.push_back(base::Bind(&RunOperationAndCallback, | 574 pending_it->second.push_back(base::Bind(&RunOperationAndCallback, |
| 575 operation, callback)); | 575 operation, callback)); |
| 576 return net::ERR_IO_PENDING; | 576 return net::ERR_IO_PENDING; |
| 577 } | 577 } |
| 578 | 578 |
| 579 EntryMap::iterator active_it = active_entries_.find(entry_hash); | 579 EntryMap::iterator active_it = active_entries_.find(entry_hash); |
| 580 if (active_it != active_entries_.end()) | 580 if (active_it != active_entries_.end()) |
| 581 return active_it->second->DoomEntry(callback); | 581 return active_it->second->DoomEntry(callback); |
| 582 | 582 |
| 583 // There's no pending dooms, nor any open entry. We can make a trivial | 583 // There's no pending dooms, nor any open entry. We can make a trivial |
| 584 // call to DoomEntries() to delete this entry. | 584 // call to DoomEntries() to delete this entry. |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 this)); | 702 this)); |
| 703 callback.Run(result); | 703 callback.Run(result); |
| 704 } | 704 } |
| 705 | 705 |
| 706 void SimpleBackendImpl::FlushWorkerPoolForTesting() { | 706 void SimpleBackendImpl::FlushWorkerPoolForTesting() { |
| 707 if (g_sequenced_worker_pool) | 707 if (g_sequenced_worker_pool) |
| 708 g_sequenced_worker_pool->FlushForTesting(); | 708 g_sequenced_worker_pool->FlushForTesting(); |
| 709 } | 709 } |
| 710 | 710 |
| 711 } // namespace disk_cache | 711 } // namespace disk_cache |
| OLD | NEW |