Chromium Code Reviews| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 // Ignore mutations to |key| until OnRemoveItemComplete. | 143 // Ignore mutations to |key| until OnRemoveItemComplete. |
| 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. We still need to make sure the |
| 154 // LevelDBWrapper is actually ready and connected to a database to ensure | |
| 155 // changes will get written to the database if the browser quits soon. | |
| 156 if (!map_) { | |
| 157 base::TimeTicks before = base::TimeTicks::Now(); | |
| 158 leveldb_->Sync(); | |
|
michaeln
2017/01/25 02:28:38
that's unfortunate?
would an async call to storag
Marijn Kruisselbrink
2017/01/25 22:00:07
Yes, it is. I don't really see a way around it tho
michaeln
2017/01/25 23:53:28
I see, the problem is not the renderer-to-browser
| |
| 159 base::TimeDelta time_to_prime = base::TimeTicks::Now() - before; | |
| 160 UMA_HISTOGRAM_TIMES("LocalStorage.MojoTimeToPrimeClear", time_to_prime); | |
| 161 } | |
| 154 | 162 |
| 155 Reset(); | 163 Reset(); |
| 156 map_ = new DOMStorageMap(kPerStorageAreaQuota); | 164 map_ = new DOMStorageMap(kPerStorageAreaQuota); |
| 157 ignore_all_mutations_ = true; | 165 ignore_all_mutations_ = true; |
| 158 leveldb_->DeleteAll(PackSource(page_url, storage_area_id), | 166 leveldb_->DeleteAll(PackSource(page_url, storage_area_id), |
| 159 base::Bind(&LocalStorageCachedArea::OnClearComplete, | 167 base::Bind(&LocalStorageCachedArea::OnClearComplete, |
| 160 weak_factory_.GetWeakPtr())); | 168 weak_factory_.GetWeakPtr())); |
| 161 } | 169 } |
| 162 | 170 |
| 163 void LocalStorageCachedArea::AreaCreated(LocalStorageArea* area) { | 171 void LocalStorageCachedArea::AreaCreated(LocalStorageArea* area) { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 } | 373 } |
| 366 | 374 |
| 367 void LocalStorageCachedArea::Reset() { | 375 void LocalStorageCachedArea::Reset() { |
| 368 map_ = NULL; | 376 map_ = NULL; |
| 369 ignore_key_mutations_.clear(); | 377 ignore_key_mutations_.clear(); |
| 370 ignore_all_mutations_ = false; | 378 ignore_all_mutations_ = false; |
| 371 weak_factory_.InvalidateWeakPtrs(); | 379 weak_factory_.InvalidateWeakPtrs(); |
| 372 } | 380 } |
| 373 | 381 |
| 374 } // namespace content | 382 } // namespace content |
| OLD | NEW |