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

Side by Side Diff: content/browser/dom_storage/dom_storage_namespace.cc

Issue 2717843002: Purge session storage caches on memory pressure (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "content/browser/dom_storage/dom_storage_namespace.h" 5 #include "content/browser/dom_storage/dom_storage_namespace.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/browser/dom_storage/dom_storage_area.h" 10 #include "content/browser/dom_storage/dom_storage_area.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 111 }
112 } 112 }
113 113
114 void DOMStorageNamespace::DeleteSessionStorageOrigin(const GURL& origin) { 114 void DOMStorageNamespace::DeleteSessionStorageOrigin(const GURL& origin) {
115 DOMStorageArea* area = OpenStorageArea(origin); 115 DOMStorageArea* area = OpenStorageArea(origin);
116 area->FastClear(); 116 area->FastClear();
117 CloseStorageArea(area); 117 CloseStorageArea(area);
118 } 118 }
119 119
120 void DOMStorageNamespace::PurgeMemory(bool aggressively) { 120 void DOMStorageNamespace::PurgeMemory(bool aggressively) {
121 if (directory_.empty()) 121 if (namespace_id_ == kLocalStorageNamespaceId && directory_.empty())
122 return; // We can't purge w/o backing on disk. 122 return; // We can't purge local storage w/o backing on disk.
123 123
124 AreaMap::iterator it = areas_.begin(); 124 AreaMap::iterator it = areas_.begin();
125 while (it != areas_.end()) { 125 while (it != areas_.end()) {
126 const AreaHolder& holder = it->second; 126 const AreaHolder& holder = it->second;
127 127
128 // We can't purge if there are changes pending. 128 // We can't purge if there are changes pending.
129 if (holder.area_->HasUncommittedChanges()) { 129 if (holder.area_->HasUncommittedChanges()) {
130 if (holder.open_count_ == 0) { 130 if (holder.open_count_ == 0) {
131 // Schedule an immediate commit so the next time we're asked to purge, 131 // Schedule an immediate commit so the next time we're asked to purge,
132 // we can drop it from memory. 132 // we can drop it from memory.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 DOMStorageArea* area, int count) 214 DOMStorageArea* area, int count)
215 : area_(area), open_count_(count) { 215 : area_(area), open_count_(count) {
216 } 216 }
217 217
218 DOMStorageNamespace::AreaHolder::AreaHolder(const AreaHolder& other) = default; 218 DOMStorageNamespace::AreaHolder::AreaHolder(const AreaHolder& other) = default;
219 219
220 DOMStorageNamespace::AreaHolder::~AreaHolder() { 220 DOMStorageNamespace::AreaHolder::~AreaHolder() {
221 } 221 }
222 222
223 } // namespace content 223 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698