| 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" | |
| 11 #include "url/gurl.h" | 10 #include "url/gurl.h" |
| 12 | 11 |
| 13 namespace content { | 12 namespace content { |
| 14 | 13 |
| 15 DOMStorageHost::DOMStorageHost(DOMStorageContextImpl* context) | 14 DOMStorageHost::DOMStorageHost(DOMStorageContextImpl* context) |
| 16 : context_(context) { | 15 : context_(context) { |
| 17 } | 16 } |
| 18 | 17 |
| 19 DOMStorageHost::~DOMStorageHost() { | 18 DOMStorageHost::~DOMStorageHost() { |
| 20 AreaMap::const_iterator it = connections_.begin(); | 19 AreaMap::const_iterator it = connections_.begin(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 48 | 47 |
| 49 bool DOMStorageHost::ExtractAreaValues( | 48 bool DOMStorageHost::ExtractAreaValues( |
| 50 int connection_id, DOMStorageValuesMap* map) { | 49 int connection_id, DOMStorageValuesMap* map) { |
| 51 map->clear(); | 50 map->clear(); |
| 52 DOMStorageArea* area = GetOpenArea(connection_id); | 51 DOMStorageArea* area = GetOpenArea(connection_id); |
| 53 if (!area) | 52 if (!area) |
| 54 return false; | 53 return false; |
| 55 if (!area->IsLoadedInMemory()) { | 54 if (!area->IsLoadedInMemory()) { |
| 56 DOMStorageNamespace* ns = GetNamespace(connection_id); | 55 DOMStorageNamespace* ns = GetNamespace(connection_id); |
| 57 DCHECK(ns); | 56 DCHECK(ns); |
| 58 if (ns->CountInMemoryAreas() > kMaxInMemoryStorageAreas) { | 57 context_->PurgeMemory(DOMStorageContextImpl::PURGE_IF_NEEDED); |
| 59 ns->PurgeMemory(DOMStorageNamespace::PURGE_UNOPENED); | |
| 60 if (ns->CountInMemoryAreas() > kMaxInMemoryStorageAreas) | |
| 61 ns->PurgeMemory(DOMStorageNamespace::PURGE_AGGRESSIVE); | |
| 62 } | |
| 63 } | 58 } |
| 64 area->ExtractValues(map); | 59 area->ExtractValues(map); |
| 65 return true; | 60 return true; |
| 66 } | 61 } |
| 67 | 62 |
| 68 unsigned DOMStorageHost::GetAreaLength(int connection_id) { | 63 unsigned DOMStorageHost::GetAreaLength(int connection_id) { |
| 69 DOMStorageArea* area = GetOpenArea(connection_id); | 64 DOMStorageArea* area = GetOpenArea(connection_id); |
| 70 if (!area) | 65 if (!area) |
| 71 return 0; | 66 return 0; |
| 72 return area->Length(); | 67 return area->Length(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } | 146 } |
| 152 | 147 |
| 153 // NamespaceAndArea | 148 // NamespaceAndArea |
| 154 | 149 |
| 155 DOMStorageHost::NamespaceAndArea::NamespaceAndArea() {} | 150 DOMStorageHost::NamespaceAndArea::NamespaceAndArea() {} |
| 156 DOMStorageHost::NamespaceAndArea::NamespaceAndArea( | 151 DOMStorageHost::NamespaceAndArea::NamespaceAndArea( |
| 157 const NamespaceAndArea& other) = default; | 152 const NamespaceAndArea& other) = default; |
| 158 DOMStorageHost::NamespaceAndArea::~NamespaceAndArea() {} | 153 DOMStorageHost::NamespaceAndArea::~NamespaceAndArea() {} |
| 159 | 154 |
| 160 } // namespace content | 155 } // namespace content |
| OLD | NEW |