| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/renderer/dom_storage/local_storage_cached_area.h" | 5 #include "content/renderer/dom_storage/local_storage_cached_area.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 ignore_key_mutations_[key]++; | 144 ignore_key_mutations_[key]++; |
| 145 leveldb_->Delete(String16ToUint8Vector(key), | 145 leveldb_->Delete(String16ToUint8Vector(key), |
| 146 PackSource(page_url, storage_area_id), | 146 PackSource(page_url, storage_area_id), |
| 147 base::Bind(&LocalStorageCachedArea::OnRemoveItemComplete, | 147 base::Bind(&LocalStorageCachedArea::OnRemoveItemComplete, |
| 148 weak_factory_.GetWeakPtr(), key)); | 148 weak_factory_.GetWeakPtr(), key)); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void LocalStorageCachedArea::Clear(const GURL& page_url, | 151 void LocalStorageCachedArea::Clear(const GURL& page_url, |
| 152 const std::string& storage_area_id) { | 152 const std::string& storage_area_id) { |
| 153 // No need to prime the cache in this case. | 153 // No need to prime the cache in this case. |
| 154 | |
| 155 Reset(); | 154 Reset(); |
| 156 map_ = new DOMStorageMap(kPerStorageAreaQuota); | 155 map_ = new DOMStorageMap(kPerStorageAreaQuota); |
| 157 ignore_all_mutations_ = true; | 156 ignore_all_mutations_ = true; |
| 158 leveldb_->DeleteAll(PackSource(page_url, storage_area_id), | 157 leveldb_->DeleteAll(PackSource(page_url, storage_area_id), |
| 159 base::Bind(&LocalStorageCachedArea::OnClearComplete, | 158 base::Bind(&LocalStorageCachedArea::OnClearComplete, |
| 160 weak_factory_.GetWeakPtr())); | 159 weak_factory_.GetWeakPtr())); |
| 161 } | 160 } |
| 162 | 161 |
| 163 void LocalStorageCachedArea::AreaCreated(LocalStorageArea* area) { | 162 void LocalStorageCachedArea::AreaCreated(LocalStorageArea* area) { |
| 164 areas_[area->id()] = area; | 163 areas_[area->id()] = area; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 } | 364 } |
| 366 | 365 |
| 367 void LocalStorageCachedArea::Reset() { | 366 void LocalStorageCachedArea::Reset() { |
| 368 map_ = NULL; | 367 map_ = NULL; |
| 369 ignore_key_mutations_.clear(); | 368 ignore_key_mutations_.clear(); |
| 370 ignore_all_mutations_ = false; | 369 ignore_all_mutations_ = false; |
| 371 weak_factory_.InvalidateWeakPtrs(); | 370 weak_factory_.InvalidateWeakPtrs(); |
| 372 } | 371 } |
| 373 | 372 |
| 374 } // namespace content | 373 } // namespace content |
| OLD | NEW |