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

Side by Side Diff: webkit/dom_storage/dom_storage_host.cc

Issue 12398008: Purge in-memory localStorage areas if the # of areas exceeds the limit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment fix Created 7 years, 8 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 | « webkit/dom_storage/dom_storage_host.h ('k') | webkit/dom_storage/dom_storage_namespace.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "webkit/dom_storage/dom_storage_host.h" 5 #include "webkit/dom_storage/dom_storage_host.h"
6 6
7 #include "googleurl/src/gurl.h" 7 #include "googleurl/src/gurl.h"
8 #include "webkit/dom_storage/dom_storage_area.h" 8 #include "webkit/dom_storage/dom_storage_area.h"
9 #include "webkit/dom_storage/dom_storage_context.h" 9 #include "webkit/dom_storage/dom_storage_context.h"
10 #include "webkit/dom_storage/dom_storage_namespace.h" 10 #include "webkit/dom_storage/dom_storage_namespace.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 bool DomStorageHost::ExtractAreaValues( 54 bool DomStorageHost::ExtractAreaValues(
55 int connection_id, ValuesMap* map) { 55 int connection_id, ValuesMap* map) {
56 map->clear(); 56 map->clear();
57 DomStorageArea* area = GetOpenArea(connection_id); 57 DomStorageArea* area = GetOpenArea(connection_id);
58 if (!area) { 58 if (!area) {
59 // TODO(michaeln): Fix crbug/134003 and return false here. 59 // TODO(michaeln): Fix crbug/134003 and return false here.
60 // Until then return true to avoid crashing the renderer 60 // Until then return true to avoid crashing the renderer
61 // for sending a bad message. 61 // for sending a bad message.
62 return true; 62 return true;
63 } 63 }
64 if (!area->IsLoadedInMemory()) {
65 DomStorageNamespace* ns = GetNamespace(connection_id);
66 DCHECK(ns);
67 if (ns->CountInMemoryAreas() > kMaxInMemoryAreas) {
68 ns->PurgeMemory(DomStorageNamespace::PURGE_UNOPENED);
69 if (ns->CountInMemoryAreas() > kMaxInMemoryAreas)
70 ns->PurgeMemory(DomStorageNamespace::PURGE_AGGRESSIVE);
71 }
72 }
64 area->ExtractValues(map); 73 area->ExtractValues(map);
65 return true; 74 return true;
66 } 75 }
67 76
68 unsigned DomStorageHost::GetAreaLength(int connection_id) { 77 unsigned DomStorageHost::GetAreaLength(int connection_id) {
69 DomStorageArea* area = GetOpenArea(connection_id); 78 DomStorageArea* area = GetOpenArea(connection_id);
70 if (!area) 79 if (!area)
71 return 0; 80 return 0;
72 return area->Length(); 81 return area->Length();
73 } 82 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 return false; 148 return false;
140 } 149 }
141 150
142 DomStorageArea* DomStorageHost::GetOpenArea(int connection_id) { 151 DomStorageArea* DomStorageHost::GetOpenArea(int connection_id) {
143 AreaMap::iterator found = connections_.find(connection_id); 152 AreaMap::iterator found = connections_.find(connection_id);
144 if (found == connections_.end()) 153 if (found == connections_.end())
145 return NULL; 154 return NULL;
146 return found->second.area_; 155 return found->second.area_;
147 } 156 }
148 157
158 DomStorageNamespace* DomStorageHost::GetNamespace(int connection_id) {
159 AreaMap::iterator found = connections_.find(connection_id);
160 if (found == connections_.end())
161 return NULL;
162 return found->second.namespace_;
163 }
164
149 // NamespaceAndArea 165 // NamespaceAndArea
150 166
151 DomStorageHost::NamespaceAndArea::NamespaceAndArea() {} 167 DomStorageHost::NamespaceAndArea::NamespaceAndArea() {}
152 DomStorageHost::NamespaceAndArea::~NamespaceAndArea() {} 168 DomStorageHost::NamespaceAndArea::~NamespaceAndArea() {}
153 169
154 } // namespace dom_storage 170 } // namespace dom_storage
OLDNEW
« no previous file with comments | « webkit/dom_storage/dom_storage_host.h ('k') | webkit/dom_storage/dom_storage_namespace.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698