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

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

Issue 1394993004: Make ValueDeserializer::Deserialize return scoped_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix and add todo about not failed trybot Created 5 years, 2 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
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_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 11 matching lines...) Expand all
22 const char kUrlKey[] = "url"; 22 const char kUrlKey[] = "url";
23 const char kWhitelistKey[] = "whitelist"; 23 const char kWhitelistKey[] = "whitelist";
24 24
25 namespace { 25 namespace {
26 26
27 scoped_ptr<base::Value> ReadFileOnBlockingThread(const base::FilePath& path) { 27 scoped_ptr<base::Value> ReadFileOnBlockingThread(const base::FilePath& path) {
28 SCOPED_UMA_HISTOGRAM_TIMER("ManagedUsers.Whitelist.ReadDuration"); 28 SCOPED_UMA_HISTOGRAM_TIMER("ManagedUsers.Whitelist.ReadDuration");
29 JSONFileValueDeserializer deserializer(path); 29 JSONFileValueDeserializer deserializer(path);
30 int error_code; 30 int error_code;
31 std::string error_msg; 31 std::string error_msg;
32 scoped_ptr<base::Value> value( 32 scoped_ptr<base::Value> value =
33 deserializer.Deserialize(&error_code, &error_msg)); 33 deserializer.Deserialize(&error_code, &error_msg);
34 if (!value) { 34 if (!value) {
35 LOG(ERROR) << "Couldn't load site list " << path.value() << ": " 35 LOG(ERROR) << "Couldn't load site list " << path.value() << ": "
36 << error_msg; 36 << error_msg;
37 } 37 }
38 return value.Pass(); 38 return value.Pass();
39 } 39 }
40 40
41 // 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
42 // (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
43 // struct. 43 // struct.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 165 }
166 166
167 base::ListValue* sites = nullptr; 167 base::ListValue* sites = nullptr;
168 if (!dict->GetList(kSitesKey, &sites)) { 168 if (!dict->GetList(kSitesKey, &sites)) {
169 LOG(ERROR) << "Site list " << path.value() << " does not contain any sites"; 169 LOG(ERROR) << "Site list " << path.value() << " does not contain any sites";
170 return; 170 return;
171 } 171 }
172 172
173 callback.Run(make_scoped_refptr(new SupervisedUserSiteList(*sites))); 173 callback.Run(make_scoped_refptr(new SupervisedUserSiteList(*sites)));
174 } 174 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/tracked/pref_hash_browsertest.cc ('k') | chrome/browser/themes/browser_theme_pack_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698