Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: net/http/http_cache.cc

Issue 164507: Merge 22701 - Http Cache: Deactivate entries without having the key of the... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/http_cache.h ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Modified: svn:mergeinfo
Merged /trunk/src/net/http/http_cache.cc:r22701
OLDNEW
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 1713 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 ActiveEntry* entry = new ActiveEntry(disk_entry); 1724 ActiveEntry* entry = new ActiveEntry(disk_entry);
1725 active_entries_[key] = entry; 1725 active_entries_[key] = entry;
1726 return entry; 1726 return entry;
1727 } 1727 }
1728 1728
1729 #if defined(OS_WIN) 1729 #if defined(OS_WIN)
1730 #pragma optimize("", off) 1730 #pragma optimize("", off)
1731 #endif 1731 #endif
1732 // Avoid optimizing local_entry out of the code. 1732 // Avoid optimizing local_entry out of the code.
1733 void HttpCache::DeactivateEntry(ActiveEntry* entry) { 1733 void HttpCache::DeactivateEntry(ActiveEntry* entry) {
1734 std::string key = entry->disk_entry->GetKey();
1735 if (key.empty())
1736 return SlowDeactivateEntry(entry);
1737
1734 // TODO(rvargas): remove this code and go back to DCHECKS once we find out 1738 // TODO(rvargas): remove this code and go back to DCHECKS once we find out
1735 // why are we crashing. I'm just trying to gather more info for bug 3931. 1739 // why are we crashing. I'm just trying to gather more info for bug 3931.
1736 ActiveEntry local_entry = *entry; 1740 ActiveEntry local_entry = *entry;
1737 size_t readers_size = local_entry.readers.size(); 1741 size_t readers_size = local_entry.readers.size();
1738 size_t pending_size = local_entry.pending_queue.size(); 1742 size_t pending_size = local_entry.pending_queue.size();
1739 1743
1740 ActiveEntriesMap::iterator it = 1744 ActiveEntriesMap::iterator it = active_entries_.find(key);
1741 active_entries_.find(entry->disk_entry->GetKey());
1742 if (it == active_entries_.end() || it->second != entry || 1745 if (it == active_entries_.end() || it->second != entry ||
1743 local_entry.will_process_pending_queue || local_entry.doomed || 1746 local_entry.will_process_pending_queue || local_entry.doomed ||
1744 local_entry.writer || readers_size || pending_size || deleted_) { 1747 local_entry.writer || readers_size || pending_size || deleted_) {
1745 bool local_mem_flag = in_memory_cache_; 1748 bool local_mem_flag = in_memory_cache_;
1746 ActiveEntriesSet::iterator it2 = doomed_entries_.find(entry); 1749 ActiveEntriesSet::iterator it2 = doomed_entries_.find(entry);
1747 CHECK(it2 == doomed_entries_.end()); 1750 CHECK(it2 == doomed_entries_.end());
1748 CHECK(!deleted_); 1751 CHECK(!deleted_);
1749 CHECK(local_mem_flag); 1752 CHECK(local_mem_flag);
1750 CHECK(false); 1753 CHECK(false);
1751 } 1754 }
1752 1755
1753 active_entries_.erase(it); 1756 active_entries_.erase(it);
1754 delete entry; 1757 delete entry;
1755 1758
1756 // Avoid closing the disk_entry again on the destructor. 1759 // Avoid closing the disk_entry again on the destructor.
1757 local_entry.disk_entry = NULL; 1760 local_entry.disk_entry = NULL;
1758 } 1761 }
1759 #if defined(OS_WIN) 1762 #if defined(OS_WIN)
1760 #pragma optimize("", on) 1763 #pragma optimize("", on)
1761 #endif 1764 #endif
1762 1765
1766 // We don't know this entry's key so we have to find it without it.
1767 void HttpCache::SlowDeactivateEntry(ActiveEntry* entry) {
1768 for (ActiveEntriesMap::iterator it = active_entries_.begin();
1769 it != active_entries_.end(); ++it) {
1770 if (it->second == entry) {
1771 active_entries_.erase(it);
1772 delete entry;
1773 break;
1774 }
1775 }
1776 }
1777
1763 int HttpCache::AddTransactionToEntry(ActiveEntry* entry, Transaction* trans) { 1778 int HttpCache::AddTransactionToEntry(ActiveEntry* entry, Transaction* trans) {
1764 DCHECK(entry); 1779 DCHECK(entry);
1765 1780
1766 // We implement a basic reader/writer lock for the disk cache entry. If 1781 // We implement a basic reader/writer lock for the disk cache entry. If
1767 // there is already a writer, then everyone has to wait for the writer to 1782 // there is already a writer, then everyone has to wait for the writer to
1768 // finish before they can access the cache entry. There can be multiple 1783 // finish before they can access the cache entry. There can be multiple
1769 // readers. 1784 // readers.
1770 // 1785 //
1771 // NOTE: If the transaction can only write, then the entry should not be in 1786 // NOTE: If the transaction can only write, then the entry should not be in
1772 // use (since any existing entry should have already been doomed). 1787 // use (since any existing entry should have already been doomed).
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1936 static_cast<net::HttpNetworkLayer*>(network_layer_.get()); 1951 static_cast<net::HttpNetworkLayer*>(network_layer_.get());
1937 HttpNetworkSession* session = network->GetSession(); 1952 HttpNetworkSession* session = network->GetSession();
1938 if (session) { 1953 if (session) {
1939 session->connection_pool()->CloseIdleSockets(); 1954 session->connection_pool()->CloseIdleSockets();
1940 } 1955 }
1941 } 1956 }
1942 1957
1943 //----------------------------------------------------------------------------- 1958 //-----------------------------------------------------------------------------
1944 1959
1945 } // namespace net 1960 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_cache.h ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698