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

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

Issue 2841643003: Use TaskScheduler instead of blocking pool in supervised_user_site_list.cc. (Closed)
Patch Set: self-review Created 3 years, 8 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/json/json_file_value_serializer.h" 10 #include "base/json/json_file_value_serializer.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/task_runner_util.h" 14 #include "base/task_scheduler/post_task.h"
15 #include "base/threading/sequenced_worker_pool.h"
16 #include "base/values.h" 15 #include "base/values.h"
17 #include "content/public/browser/browser_thread.h"
18 #include "url/gurl.h" 16 #include "url/gurl.h"
19 17
20 const int kLegacyWhitelistFormatVersion = 2; 18 const int kLegacyWhitelistFormatVersion = 2;
21 const int kWhitelistFormatVersion = 1; 19 const int kWhitelistFormatVersion = 1;
22 20
23 const char kEntryPointUrlKey[] = "entry_point_url"; 21 const char kEntryPointUrlKey[] = "entry_point_url";
24 const char kHostnameHashesKey[] = "hostname_hashes"; 22 const char kHostnameHashesKey[] = "hostname_hashes";
25 const char kLegacyWhitelistFormatVersionKey[] = "version"; 23 const char kLegacyWhitelistFormatVersionKey[] = "version";
26 const char kSitelistFormatVersionKey[] = "sitelist_version"; 24 const char kSitelistFormatVersionKey[] = "sitelist_version";
27 const char kWhitelistKey[] = "whitelist"; 25 const char kWhitelistKey[] = "whitelist";
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 size_t SupervisedUserSiteList::HostnameHash::hash() const { 82 size_t SupervisedUserSiteList::HostnameHash::hash() const {
85 // This just returns the first sizeof(size_t) bytes of |bytes_|. 83 // This just returns the first sizeof(size_t) bytes of |bytes_|.
86 return *reinterpret_cast<const size_t*>(bytes_.data()); 84 return *reinterpret_cast<const size_t*>(bytes_.data());
87 } 85 }
88 86
89 void SupervisedUserSiteList::Load(const std::string& id, 87 void SupervisedUserSiteList::Load(const std::string& id,
90 const base::string16& title, 88 const base::string16& title,
91 const base::FilePath& large_icon_path, 89 const base::FilePath& large_icon_path,
92 const base::FilePath& path, 90 const base::FilePath& path,
93 const LoadedCallback& callback) { 91 const LoadedCallback& callback) {
94 base::PostTaskAndReplyWithResult( 92 base::PostTaskWithTraitsAndReplyWithResult(
95 content::BrowserThread::GetBlockingPool() 93 FROM_HERE,
96 ->GetTaskRunnerWithShutdownBehavior( 94 base::TaskTraits()
97 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN) 95 .MayBlock()
98 .get(), 96 .WithPriority(base::TaskPriority::BACKGROUND)
99 FROM_HERE, base::Bind(&ReadFileOnBlockingThread, path), 97 .WithShutdownBehavior(
100 base::Bind(&SupervisedUserSiteList::OnJsonLoaded, id, title, 98 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN),
101 large_icon_path, path, base::TimeTicks::Now(), callback)); 99 base::BindOnce(&ReadFileOnBlockingThread, path),
100 base::BindOnce(&SupervisedUserSiteList::OnJsonLoaded, id, title,
101 large_icon_path, path, base::TimeTicks::Now(), callback));
102 } 102 }
103 103
104 SupervisedUserSiteList::SupervisedUserSiteList( 104 SupervisedUserSiteList::SupervisedUserSiteList(
105 const std::string& id, 105 const std::string& id,
106 const base::string16& title, 106 const base::string16& title,
107 const GURL& entry_point, 107 const GURL& entry_point,
108 const base::FilePath& large_icon_path, 108 const base::FilePath& large_icon_path,
109 const base::ListValue* patterns, 109 const base::ListValue* patterns,
110 const base::ListValue* hostname_hashes) 110 const base::ListValue* hostname_hashes)
111 : SupervisedUserSiteList(id, 111 : SupervisedUserSiteList(id,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 base::ListValue* patterns = nullptr; 191 base::ListValue* patterns = nullptr;
192 dict->GetList(kWhitelistKey, &patterns); 192 dict->GetList(kWhitelistKey, &patterns);
193 193
194 base::ListValue* hostname_hashes = nullptr; 194 base::ListValue* hostname_hashes = nullptr;
195 dict->GetList(kHostnameHashesKey, &hostname_hashes); 195 dict->GetList(kHostnameHashesKey, &hostname_hashes);
196 196
197 callback.Run(make_scoped_refptr( 197 callback.Run(make_scoped_refptr(
198 new SupervisedUserSiteList(id, title, GURL(entry_point_url), 198 new SupervisedUserSiteList(id, title, GURL(entry_point_url),
199 large_icon_path, patterns, hostname_hashes))); 199 large_icon_path, patterns, hostname_hashes)));
200 } 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