Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_namespace.h" | 5 #include "webkit/dom_storage/dom_storage_namespace.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 area->DeleteOrigin(); | 110 area->DeleteOrigin(); |
| 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::PurgeUnopenedAreas() { | |
| 121 if (directory_.empty()) | |
| 122 return; // We can't purge w/o backing on disk. | |
| 123 AreaMap::iterator it = areas_.begin(); | |
| 124 while (it != areas_.end()) { | |
|
michaeln
2013/04/05 23:39:23
There's a block of code in PurgeMemory that i thin
kinuko
2013/04/10 07:04:14
Sounds good, I consolidated the two methods.
| |
| 125 if (it->second.open_count_ == 0) { | |
| 126 it->second.area_->Shutdown(); | |
| 127 areas_.erase(it++); | |
| 128 continue; | |
| 129 } | |
| 130 ++it; | |
| 131 } | |
| 132 } | |
| 133 | |
| 120 void DomStorageNamespace::PurgeMemory() { | 134 void DomStorageNamespace::PurgeMemory() { |
| 121 if (directory_.empty()) | 135 if (directory_.empty()) |
| 122 return; // We can't purge w/o backing on disk. | 136 return; // We can't purge w/o backing on disk. |
| 123 AreaMap::iterator it = areas_.begin(); | 137 AreaMap::iterator it = areas_.begin(); |
| 124 while (it != areas_.end()) { | 138 while (it != areas_.end()) { |
| 125 // Leave it alone if changes are pending | 139 // Leave it alone if changes are pending |
| 126 if (it->second.area_->HasUncommittedChanges()) { | 140 if (it->second.area_->HasUncommittedChanges()) { |
| 127 ++it; | 141 ++it; |
| 128 continue; | 142 continue; |
| 129 } | 143 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 | 179 |
| 166 DomStorageNamespace::AreaHolder::AreaHolder( | 180 DomStorageNamespace::AreaHolder::AreaHolder( |
| 167 DomStorageArea* area, int count) | 181 DomStorageArea* area, int count) |
| 168 : area_(area), open_count_(count) { | 182 : area_(area), open_count_(count) { |
| 169 } | 183 } |
| 170 | 184 |
| 171 DomStorageNamespace::AreaHolder::~AreaHolder() { | 185 DomStorageNamespace::AreaHolder::~AreaHolder() { |
| 172 } | 186 } |
| 173 | 187 |
| 174 } // namespace dom_storage | 188 } // namespace dom_storage |
| OLD | NEW |