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

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: 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_runner_util.h"
15 #include "base/threading/sequenced_worker_pool.h" 15 #include "base/task_scheduler/post_task.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "content/public/browser/browser_thread.h"
18 #include "url/gurl.h" 17 #include "url/gurl.h"
19 18
20 const int kLegacyWhitelistFormatVersion = 2; 19 const int kLegacyWhitelistFormatVersion = 2;
21 const int kWhitelistFormatVersion = 1; 20 const int kWhitelistFormatVersion = 1;
22 21
23 const char kEntryPointUrlKey[] = "entry_point_url"; 22 const char kEntryPointUrlKey[] = "entry_point_url";
24 const char kHostnameHashesKey[] = "hostname_hashes"; 23 const char kHostnameHashesKey[] = "hostname_hashes";
25 const char kLegacyWhitelistFormatVersionKey[] = "version"; 24 const char kLegacyWhitelistFormatVersionKey[] = "version";
26 const char kSitelistFormatVersionKey[] = "sitelist_version"; 25 const char kSitelistFormatVersionKey[] = "sitelist_version";
27 const char kWhitelistKey[] = "whitelist"; 26 const char kWhitelistKey[] = "whitelist";
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // This just returns the first sizeof(size_t) bytes of |bytes_|. 84 // This just returns the first sizeof(size_t) bytes of |bytes_|.
86 return *reinterpret_cast<const size_t*>(bytes_.data()); 85 return *reinterpret_cast<const size_t*>(bytes_.data());
87 } 86 }
88 87
89 void SupervisedUserSiteList::Load(const std::string& id, 88 void SupervisedUserSiteList::Load(const std::string& id,
90 const base::string16& title, 89 const base::string16& title,
91 const base::FilePath& large_icon_path, 90 const base::FilePath& large_icon_path,
92 const base::FilePath& path, 91 const base::FilePath& path,
93 const LoadedCallback& callback) { 92 const LoadedCallback& callback) {
94 base::PostTaskAndReplyWithResult( 93 base::PostTaskAndReplyWithResult(
95 content::BrowserThread::GetBlockingPool() 94 base::CreateTaskRunnerWithTraits(
Bernhard Bauer 2017/04/25 14:20:21 Can you use PostTaskWithTraitsAndReplyWithResult()
fdoray 2017/04/26 19:33:50 Done.
96 ->GetTaskRunnerWithShutdownBehavior( 95 base::TaskTraits()
97 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN) 96 .MayBlock()
97 .WithPriority(base::TaskPriority::BACKGROUND)
98 .WithShutdownBehavior(
99 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN))
98 .get(), 100 .get(),
99 FROM_HERE, base::Bind(&ReadFileOnBlockingThread, path), 101 FROM_HERE, base::Bind(&ReadFileOnBlockingThread, path),
100 base::Bind(&SupervisedUserSiteList::OnJsonLoaded, id, title, 102 base::Bind(&SupervisedUserSiteList::OnJsonLoaded, id, title,
101 large_icon_path, path, base::TimeTicks::Now(), callback)); 103 large_icon_path, path, base::TimeTicks::Now(), callback));
102 } 104 }
103 105
104 SupervisedUserSiteList::SupervisedUserSiteList( 106 SupervisedUserSiteList::SupervisedUserSiteList(
105 const std::string& id, 107 const std::string& id,
106 const base::string16& title, 108 const base::string16& title,
107 const GURL& entry_point, 109 const GURL& entry_point,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 base::ListValue* patterns = nullptr; 193 base::ListValue* patterns = nullptr;
192 dict->GetList(kWhitelistKey, &patterns); 194 dict->GetList(kWhitelistKey, &patterns);
193 195
194 base::ListValue* hostname_hashes = nullptr; 196 base::ListValue* hostname_hashes = nullptr;
195 dict->GetList(kHostnameHashesKey, &hostname_hashes); 197 dict->GetList(kHostnameHashesKey, &hostname_hashes);
196 198
197 callback.Run(make_scoped_refptr( 199 callback.Run(make_scoped_refptr(
198 new SupervisedUserSiteList(id, title, GURL(entry_point_url), 200 new SupervisedUserSiteList(id, title, GURL(entry_point_url),
199 large_icon_path, patterns, hostname_hashes))); 201 large_icon_path, patterns, hostname_hashes)));
200 } 202 }
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