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

Side by Side Diff: chrome/browser/supervised_user/supervised_user_site_list.cc

Issue 928253002: Use SCOPED_UMA_HISTOGRAM_TIMER in SupervisedUserSiteList. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/supervised_user/supervised_user_site_list.h" 5 #include "chrome/browser/supervised_user/supervised_user_site_list.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/json/json_file_value_serializer.h" 8 #include "base/json/json_file_value_serializer.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram_macros.h"
11 #include "base/task_runner_util.h" 11 #include "base/task_runner_util.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/safe_json_parser.h" 13 #include "chrome/browser/safe_json_parser.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "url/gurl.h" 15 #include "url/gurl.h"
16 16
17 const int kSitelistFormatVersion = 1; 17 const int kSitelistFormatVersion = 1;
18 18
19 const char kHostnameHashesKey[] = "hostname_hashes"; 19 const char kHostnameHashesKey[] = "hostname_hashes";
20 const char kNameKey[] = "name"; 20 const char kNameKey[] = "name";
21 const char kSitesKey[] = "sites"; 21 const char kSitesKey[] = "sites";
22 const char kSitelistFormatVersionKey[] = "version"; 22 const char kSitelistFormatVersionKey[] = "version";
23 const char kUrlKey[] = "url"; 23 const char kUrlKey[] = "url";
24 const char kWhitelistKey[] = "whitelist"; 24 const char kWhitelistKey[] = "whitelist";
25 25
26 namespace { 26 namespace {
27 27
28 bool g_load_in_process = false; 28 bool g_load_in_process = false;
29 29
30 std::string ReadFileOnBlockingThread(const base::FilePath& path) { 30 std::string ReadFileOnBlockingThread(const base::FilePath& path) {
31 base::TimeTicks start = base::TimeTicks::Now(); 31 SCOPED_UMA_HISTOGRAM_TIMER("ManagedUsers.Whitelist.ReadDuration");
32 std::string contents; 32 std::string contents;
33 base::ReadFileToString(path, &contents); 33 base::ReadFileToString(path, &contents);
34 UMA_HISTOGRAM_TIMES("ManagedUsers.Whitelist.ReadDuration",
35 base::TimeTicks::Now() - start);
36 return contents; 34 return contents;
37 } 35 }
38 36
39 void HandleError(const base::FilePath& path, const std::string& error) { 37 void HandleError(const base::FilePath& path, const std::string& error) {
40 LOG(ERROR) << "Couldn't load site list " << path.value() << ": " << error; 38 LOG(ERROR) << "Couldn't load site list " << path.value() << ": " << error;
41 } 39 }
42 40
43 // Takes a DictionaryValue entry from the JSON file and fills the whitelist 41 // Takes a DictionaryValue entry from the JSON file and fills the whitelist
44 // (via URL patterns or hostname hashes) and the URL in the corresponding Site 42 // (via URL patterns or hostname hashes) and the URL in the corresponding Site
45 // struct. 43 // struct.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 191
194 base::ListValue* sites = nullptr; 192 base::ListValue* sites = nullptr;
195 if (!dict->GetList(kSitesKey, &sites)) { 193 if (!dict->GetList(kSitesKey, &sites)) {
196 LOG(ERROR) << "Site list " << path.value() 194 LOG(ERROR) << "Site list " << path.value()
197 << " does not contain any sites"; 195 << " does not contain any sites";
198 return; 196 return;
199 } 197 }
200 198
201 callback.Run(make_scoped_refptr(new SupervisedUserSiteList(*sites))); 199 callback.Run(make_scoped_refptr(new SupervisedUserSiteList(*sites)));
202 } 200 }
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