Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Side by Side Diff: webkit/dom_storage/dom_storage_cached_area.cc

Issue 12209085: Add histograms to track localStorage size and load time by size. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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;
157 UMA_HISTOGRAM_TIMES("LocalStorage.TimeToPrimeLocalStorage", 158 UMA_HISTOGRAM_TIMES("LocalStorage.TimeToPrimeLocalStorage",
158 base::TimeTicks::Now() - before); 159 time_to_prime);
159 map_ = new DomStorageMap(dom_storage::kPerAreaQuota); 160 map_ = new DomStorageMap(dom_storage::kPerAreaQuota);
160 map_->SwapValues(&values); 161 map_->SwapValues(&values);
162
163 size_t local_storage_size_kb = MemoryBytesUsedByCache() / 1024;
164 // Track localStorage size, from 0-6MB. Note that the maximum size should be
165 // 5MB, but we add some slop since we want to make sure the max size is always
166 // above what we see in practice, since histograms can't change.
michaeln 2013/02/12 00:38:15 lgtm modulo the paranoia about 'too large' ... bu
willchan no longer on Chromium 2013/02/12 00:42:22 Is there a way to instrument this in a way so I ca
michaeln 2013/02/12 01:17:12 Not from this class|method, we can't distinguish h
167 UMA_HISTOGRAM_CUSTOM_COUNTS("LocalStorage.LocalStorageSizeInKB",
168 local_storage_size_kb,
169 0, 6 * 1024, 50);
michaeln 2013/02/12 00:38:15 What happens if we give this macro a value that's
willchan no longer on Chromium 2013/02/12 00:42:22 It doesn't crash, we just lose granularity. What's
michaeln 2013/02/12 01:17:12 sgtm!
170 if (local_storage_size_kb < 100) {
171 UMA_HISTOGRAM_TIMES("LocalStorage.TimeToPrimeLocalStorageUnder100KB",
172 time_to_prime);
173 } else if (local_storage_size_kb < 1000) {
174 UMA_HISTOGRAM_TIMES("LocalStorage.TimeToPrimeLocalStorageUnder1MB",
175 time_to_prime);
176 } else {
177 UMA_HISTOGRAM_TIMES("LocalStorage.TimeToPrimeLocalStorageUnder5MB",
jar (doing other things) 2013/02/11 19:27:51 Based on the above logic, the histograms are reall
willchan no longer on Chromium 2013/02/12 00:42:22 Good point. I'll rename once I settle the above st
178 time_to_prime);
179 }
161 } 180 }
162 181
163 void DomStorageCachedArea::Reset() { 182 void DomStorageCachedArea::Reset() {
164 map_ = NULL; 183 map_ = NULL;
165 weak_factory_.InvalidateWeakPtrs(); 184 weak_factory_.InvalidateWeakPtrs();
166 ignore_key_mutations_.clear(); 185 ignore_key_mutations_.clear();
167 ignore_all_mutations_ = false; 186 ignore_all_mutations_ = false;
168 } 187 }
169 188
170 void DomStorageCachedArea::OnLoadComplete(bool success) { 189 void DomStorageCachedArea::OnLoadComplete(bool success) {
(...skipping 23 matching lines...) Expand all
194 ignore_key_mutations_.erase(found); 213 ignore_key_mutations_.erase(found);
195 } 214 }
196 215
197 void DomStorageCachedArea::OnClearComplete(bool success) { 216 void DomStorageCachedArea::OnClearComplete(bool success) {
198 DCHECK(success); 217 DCHECK(success);
199 DCHECK(ignore_all_mutations_); 218 DCHECK(ignore_all_mutations_);
200 ignore_all_mutations_ = false; 219 ignore_all_mutations_ = false;
201 } 220 }
202 221
203 } // namespace dom_storage 222 } // namespace dom_storage
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698