| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1590 #pragma optimize("", off) | 1590 #pragma optimize("", off) |
| 1591 #endif | 1591 #endif |
| 1592 // Avoid optimizing local_entry out of the code. | 1592 // Avoid optimizing local_entry out of the code. |
| 1593 void HttpCache::DeactivateEntry(ActiveEntry* entry) { | 1593 void HttpCache::DeactivateEntry(ActiveEntry* entry) { |
| 1594 // TODO(rvargas): remove this code and go back to DCHECKS once we find out | 1594 // TODO(rvargas): remove this code and go back to DCHECKS once we find out |
| 1595 // why are we crashing. I'm just trying to gather more info for bug 3931. | 1595 // why are we crashing. I'm just trying to gather more info for bug 3931. |
| 1596 ActiveEntry local_entry = *entry; | 1596 ActiveEntry local_entry = *entry; |
| 1597 size_t readers_size = local_entry.readers.size(); | 1597 size_t readers_size = local_entry.readers.size(); |
| 1598 size_t pending_size = local_entry.pending_queue.size(); | 1598 size_t pending_size = local_entry.pending_queue.size(); |
| 1599 | 1599 |
| 1600 ActiveEntriesMap::iterator it = | 1600 std::string key = entry->disk_entry->GetKey(); |
| 1601 active_entries_.find(entry->disk_entry->GetKey()); | 1601 ActiveEntriesMap::iterator it = active_entries_.find(key); |
| 1602 if (it == active_entries_.end() || it->second != entry || | 1602 if (it == active_entries_.end() || it->second != entry || |
| 1603 local_entry.will_process_pending_queue || local_entry.doomed || | 1603 local_entry.will_process_pending_queue || local_entry.doomed || |
| 1604 local_entry.writer || readers_size || pending_size || deleted_) { | 1604 local_entry.writer || readers_size || pending_size || deleted_) { |
| 1605 bool local_mem_flag = in_memory_cache_; | 1605 bool local_mem_flag = in_memory_cache_; |
| 1606 ActiveEntriesSet::iterator it2 = doomed_entries_.find(entry); | 1606 ActiveEntriesSet::iterator it2 = doomed_entries_.find(entry); |
| 1607 char local_key[64]; |
| 1608 int key_length = key.size(); |
| 1609 base::strlcpy(local_key, key.c_str(), sizeof(local_key)); |
| 1607 CHECK(it2 == doomed_entries_.end()); | 1610 CHECK(it2 == doomed_entries_.end()); |
| 1608 CHECK(!deleted_); | 1611 CHECK(!deleted_); |
| 1609 CHECK(local_mem_flag); | 1612 CHECK(local_mem_flag); |
| 1613 CHECK(key_length); |
| 1610 CHECK(false); | 1614 CHECK(false); |
| 1611 } | 1615 } |
| 1612 | 1616 |
| 1613 active_entries_.erase(it); | 1617 active_entries_.erase(it); |
| 1614 delete entry; | 1618 delete entry; |
| 1615 | 1619 |
| 1616 // Avoid closing the disk_entry again on the destructor. | 1620 // Avoid closing the disk_entry again on the destructor. |
| 1617 local_entry.disk_entry = NULL; | 1621 local_entry.disk_entry = NULL; |
| 1618 } | 1622 } |
| 1619 #if defined(OS_WIN) | 1623 #if defined(OS_WIN) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1670 return; | 1674 return; |
| 1671 | 1675 |
| 1672 if (entry->writer) { | 1676 if (entry->writer) { |
| 1673 // TODO(rvargas): convert this to a DCHECK. | 1677 // TODO(rvargas): convert this to a DCHECK. |
| 1674 CHECK(trans == entry->writer); | 1678 CHECK(trans == entry->writer); |
| 1675 // Get a local copy of the transaction, in preparation for a crash inside | 1679 // Get a local copy of the transaction, in preparation for a crash inside |
| 1676 // DeactivateEntry. | 1680 // DeactivateEntry. |
| 1677 char local_transaction[sizeof(*trans)]; | 1681 char local_transaction[sizeof(*trans)]; |
| 1678 memcpy(local_transaction, trans, sizeof(*trans)); | 1682 memcpy(local_transaction, trans, sizeof(*trans)); |
| 1679 | 1683 |
| 1684 char local_key[64]; |
| 1685 base::strlcpy(local_key, trans->key().c_str(), sizeof(local_key)); |
| 1686 |
| 1680 // Assume that this is not a successful write. | 1687 // Assume that this is not a successful write. |
| 1681 DoneWritingToEntry(entry, false); | 1688 DoneWritingToEntry(entry, false); |
| 1682 } else { | 1689 } else { |
| 1683 DoneReadingFromEntry(entry, trans); | 1690 DoneReadingFromEntry(entry, trans); |
| 1684 } | 1691 } |
| 1685 } | 1692 } |
| 1686 #if defined(OS_WIN) | 1693 #if defined(OS_WIN) |
| 1687 #pragma warning(default:4748) | 1694 #pragma warning(default:4748) |
| 1688 #pragma optimize("", on) | 1695 #pragma optimize("", on) |
| 1689 #endif | 1696 #endif |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1796 static_cast<net::HttpNetworkLayer*>(network_layer_.get()); | 1803 static_cast<net::HttpNetworkLayer*>(network_layer_.get()); |
| 1797 HttpNetworkSession* session = network->GetSession(); | 1804 HttpNetworkSession* session = network->GetSession(); |
| 1798 if (session) { | 1805 if (session) { |
| 1799 session->connection_pool()->CloseIdleSockets(); | 1806 session->connection_pool()->CloseIdleSockets(); |
| 1800 } | 1807 } |
| 1801 } | 1808 } |
| 1802 | 1809 |
| 1803 //----------------------------------------------------------------------------- | 1810 //----------------------------------------------------------------------------- |
| 1804 | 1811 |
| 1805 } // namespace net | 1812 } // namespace net |
| OLD | NEW |