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

Side by Side Diff: base/prefs/json_pref_store.cc

Issue 149073003: Add a Settings.FilterOnLoadTime histogram to observe time spent on this critical path in the wild. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removal date Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | 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 "base/prefs/json_pref_store.h" 5 #include "base/prefs/json_pref_store.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/json/json_file_value_serializer.h" 12 #include "base/json/json_file_value_serializer.h"
13 #include "base/json/json_string_value_serializer.h" 13 #include "base/json/json_string_value_serializer.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/message_loop/message_loop_proxy.h" 15 #include "base/message_loop/message_loop_proxy.h"
16 #include "base/metrics/histogram.h"
16 #include "base/prefs/pref_filter.h" 17 #include "base/prefs/pref_filter.h"
17 #include "base/sequenced_task_runner.h" 18 #include "base/sequenced_task_runner.h"
18 #include "base/threading/sequenced_worker_pool.h" 19 #include "base/threading/sequenced_worker_pool.h"
20 #include "base/time/time.h"
19 #include "base/values.h" 21 #include "base/values.h"
20 22
21 namespace { 23 namespace {
22 24
23 // Some extensions we'll tack on to copies of the Preferences files. 25 // Some extensions we'll tack on to copies of the Preferences files.
24 const base::FilePath::CharType* kBadExtension = FILE_PATH_LITERAL("bad"); 26 const base::FilePath::CharType* kBadExtension = FILE_PATH_LITERAL("bad");
25 27
26 // Differentiates file loading between origin thread and passed 28 // Differentiates file loading between origin thread and passed
27 // (aka file) thread. 29 // (aka file) thread.
28 class FileThreadDeserializer 30 class FileThreadDeserializer
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 // If the file just doesn't exist, maybe this is first run. In any case 309 // If the file just doesn't exist, maybe this is first run. In any case
308 // there's no harm in writing out default prefs in this case. 310 // there's no harm in writing out default prefs in this case.
309 break; 311 break;
310 case PREF_READ_ERROR_JSON_PARSE: 312 case PREF_READ_ERROR_JSON_PARSE:
311 case PREF_READ_ERROR_JSON_REPEAT: 313 case PREF_READ_ERROR_JSON_REPEAT:
312 break; 314 break;
313 default: 315 default:
314 NOTREACHED() << "Unknown error: " << error; 316 NOTREACHED() << "Unknown error: " << error;
315 } 317 }
316 318
317 if (pref_filter_) 319 if (pref_filter_) {
320 // TODO(gab): Remove this histogram by Feb 21 2014; after sufficient timing
321 // data has been gathered from the wild to be confident this doesn't
322 // significantly affect startup.
323 base::TimeTicks checkpoint = base::TimeTicks::Now();
318 pref_filter_->FilterOnLoad(prefs_.get()); 324 pref_filter_->FilterOnLoad(prefs_.get());
325 UMA_HISTOGRAM_TIMES("Settings.FilterOnLoadTime",
326 base::TimeTicks::Now() - checkpoint);
327 }
319 328
320 if (error_delegate_.get() && error != PREF_READ_ERROR_NONE) 329 if (error_delegate_.get() && error != PREF_READ_ERROR_NONE)
321 error_delegate_->OnError(error); 330 error_delegate_->OnError(error);
322 331
323 FOR_EACH_OBSERVER(PrefStore::Observer, 332 FOR_EACH_OBSERVER(PrefStore::Observer,
324 observers_, 333 observers_,
325 OnInitializationCompleted(true)); 334 OnInitializationCompleted(true));
326 } 335 }
327 336
328 JsonPrefStore::~JsonPrefStore() { 337 JsonPrefStore::~JsonPrefStore() {
329 CommitPendingWrite(); 338 CommitPendingWrite();
330 } 339 }
331 340
332 bool JsonPrefStore::SerializeData(std::string* output) { 341 bool JsonPrefStore::SerializeData(std::string* output) {
333 if (pref_filter_) 342 if (pref_filter_) {
343 // TODO(gab): Remove this histogram by Feb 21 2014; after sufficient timing
344 // data has been gathered from the wild to be confident this doesn't
345 // significantly affect performance on the UI thread.
346 base::TimeTicks checkpoint = base::TimeTicks::Now();
334 pref_filter_->FilterSerializeData(prefs_.get()); 347 pref_filter_->FilterSerializeData(prefs_.get());
348 UMA_HISTOGRAM_TIMES("Settings.FilterSerializeDataTime",
349 base::TimeTicks::Now() - checkpoint);
350 }
335 351
336 JSONStringValueSerializer serializer(output); 352 JSONStringValueSerializer serializer(output);
337 serializer.set_pretty_print(true); 353 serializer.set_pretty_print(true);
338 return serializer.Serialize(*prefs_); 354 return serializer.Serialize(*prefs_);
339 } 355 }
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698