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_cached_area.h" | 5 #include "webkit/dom_storage/dom_storage_cached_area.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "webkit/dom_storage/dom_storage_map.h" | 10 #include "webkit/dom_storage/dom_storage_map.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 // to be ignored. | 147 // to be ignored. |
148 | 148 |
149 // Ignore all mutations until OnLoadComplete time. | 149 // Ignore all mutations until OnLoadComplete time. |
150 ignore_all_mutations_ = true; | 150 ignore_all_mutations_ = true; |
151 ValuesMap values; | 151 ValuesMap values; |
152 base::TimeTicks before = base::TimeTicks::Now(); | 152 base::TimeTicks before = base::TimeTicks::Now(); |
153 proxy_->LoadArea( | 153 proxy_->LoadArea( |
154 connection_id, &values, | 154 connection_id, &values, |
155 base::Bind(&DomStorageCachedArea::OnLoadComplete, | 155 base::Bind(&DomStorageCachedArea::OnLoadComplete, |
156 weak_factory_.GetWeakPtr())); | 156 weak_factory_.GetWeakPtr())); |
157 base::TimeDelta time_to_prime = base::TimeTicks::Now() - before; | |
158 // Keeping this histogram named the same (without the ForRenderer suffix) | |
159 // to maintain histogram continuity. | |
157 UMA_HISTOGRAM_TIMES("LocalStorage.TimeToPrimeLocalStorage", | 160 UMA_HISTOGRAM_TIMES("LocalStorage.TimeToPrimeLocalStorage", |
158 base::TimeTicks::Now() - before); | 161 time_to_prime); |
159 map_ = new DomStorageMap(dom_storage::kPerAreaQuota); | 162 map_ = new DomStorageMap(dom_storage::kPerAreaQuota); |
160 map_->SwapValues(&values); | 163 map_->SwapValues(&values); |
164 | |
165 size_t local_storage_size_kb = MemoryBytesUsedByCache() / 1024; | |
michaeln
2013/02/12 01:49:55
could use map_->bytes_used() here
willchan no longer on Chromium
2013/02/12 01:53:41
Done.
| |
166 // Track localStorage size, from 0-6MB. Note that the maximum size should be | |
167 // 5MB, but we add some slop since we want to make sure the max size is always | |
168 // above what we see in practice, since histograms can't change. | |
169 UMA_HISTOGRAM_CUSTOM_COUNTS("LocalStorage.RendererLocalStorageSizeInKB", | |
170 local_storage_size_kb, | |
171 0, 6 * 1024, 50); | |
172 if (local_storage_size_kb < 100) { | |
173 UMA_HISTOGRAM_TIMES( | |
174 "LocalStorage.RendererTimeToPrimeLocalStorageUnder100KB", | |
175 time_to_prime); | |
176 } else if (local_storage_size_kb < 1000) { | |
177 UMA_HISTOGRAM_TIMES( | |
178 "LocalStorage.RendererTimeToPrimeLocalStorage100KBTo1MB", | |
179 time_to_prime); | |
180 } else { | |
181 UMA_HISTOGRAM_TIMES( | |
182 "LocalStorage.RendererTimeToPrimeLocalStorage1MBTo5MB", | |
183 time_to_prime); | |
184 } | |
161 } | 185 } |
162 | 186 |
163 void DomStorageCachedArea::Reset() { | 187 void DomStorageCachedArea::Reset() { |
164 map_ = NULL; | 188 map_ = NULL; |
165 weak_factory_.InvalidateWeakPtrs(); | 189 weak_factory_.InvalidateWeakPtrs(); |
166 ignore_key_mutations_.clear(); | 190 ignore_key_mutations_.clear(); |
167 ignore_all_mutations_ = false; | 191 ignore_all_mutations_ = false; |
168 } | 192 } |
169 | 193 |
170 void DomStorageCachedArea::OnLoadComplete(bool success) { | 194 void DomStorageCachedArea::OnLoadComplete(bool success) { |
(...skipping 23 matching lines...) Expand all Loading... | |
194 ignore_key_mutations_.erase(found); | 218 ignore_key_mutations_.erase(found); |
195 } | 219 } |
196 | 220 |
197 void DomStorageCachedArea::OnClearComplete(bool success) { | 221 void DomStorageCachedArea::OnClearComplete(bool success) { |
198 DCHECK(success); | 222 DCHECK(success); |
199 DCHECK(ignore_all_mutations_); | 223 DCHECK(ignore_all_mutations_); |
200 ignore_all_mutations_ = false; | 224 ignore_all_mutations_ = false; |
201 } | 225 } |
202 | 226 |
203 } // namespace dom_storage | 227 } // namespace dom_storage |
OLD | NEW |