OLD | NEW |
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_host.h" | 5 #include "content/browser/dom_storage/dom_storage_host.h" |
6 | 6 |
7 #include "content/browser/dom_storage/dom_storage_area.h" | 7 #include "content/browser/dom_storage/dom_storage_area.h" |
8 #include "content/browser/dom_storage/dom_storage_context_impl.h" | 8 #include "content/browser/dom_storage/dom_storage_context_impl.h" |
9 #include "content/browser/dom_storage/dom_storage_namespace.h" | 9 #include "content/browser/dom_storage/dom_storage_namespace.h" |
10 #include "content/common/dom_storage/dom_storage_types.h" | 10 #include "content/common/dom_storage/dom_storage_types.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 bool DOMStorageHost::ExtractAreaValues( | 49 bool DOMStorageHost::ExtractAreaValues( |
50 int connection_id, DOMStorageValuesMap* map) { | 50 int connection_id, DOMStorageValuesMap* map) { |
51 map->clear(); | 51 map->clear(); |
52 DOMStorageArea* area = GetOpenArea(connection_id); | 52 DOMStorageArea* area = GetOpenArea(connection_id); |
53 if (!area) | 53 if (!area) |
54 return false; | 54 return false; |
55 if (!area->IsLoadedInMemory()) { | 55 if (!area->IsLoadedInMemory()) { |
56 DOMStorageNamespace* ns = GetNamespace(connection_id); | 56 DOMStorageNamespace* ns = GetNamespace(connection_id); |
57 DCHECK(ns); | 57 DCHECK(ns); |
58 if (ns->CountInMemoryAreas() > kMaxInMemoryStorageAreas) { | 58 ns->PurgeMemory(DOMStorageNamespace::PURGE_UNSPECIFIED); |
59 ns->PurgeMemory(DOMStorageNamespace::PURGE_UNOPENED); | |
60 if (ns->CountInMemoryAreas() > kMaxInMemoryStorageAreas) | |
61 ns->PurgeMemory(DOMStorageNamespace::PURGE_AGGRESSIVE); | |
62 } | |
63 } | 59 } |
64 area->ExtractValues(map); | 60 area->ExtractValues(map); |
65 return true; | 61 return true; |
66 } | 62 } |
67 | 63 |
68 unsigned DOMStorageHost::GetAreaLength(int connection_id) { | 64 unsigned DOMStorageHost::GetAreaLength(int connection_id) { |
69 DOMStorageArea* area = GetOpenArea(connection_id); | 65 DOMStorageArea* area = GetOpenArea(connection_id); |
70 if (!area) | 66 if (!area) |
71 return 0; | 67 return 0; |
72 return area->Length(); | 68 return area->Length(); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 147 } |
152 | 148 |
153 // NamespaceAndArea | 149 // NamespaceAndArea |
154 | 150 |
155 DOMStorageHost::NamespaceAndArea::NamespaceAndArea() {} | 151 DOMStorageHost::NamespaceAndArea::NamespaceAndArea() {} |
156 DOMStorageHost::NamespaceAndArea::NamespaceAndArea( | 152 DOMStorageHost::NamespaceAndArea::NamespaceAndArea( |
157 const NamespaceAndArea& other) = default; | 153 const NamespaceAndArea& other) = default; |
158 DOMStorageHost::NamespaceAndArea::~NamespaceAndArea() {} | 154 DOMStorageHost::NamespaceAndArea::~NamespaceAndArea() {} |
159 | 155 |
160 } // namespace content | 156 } // namespace content |
OLD | NEW |