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

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

Issue 2843583002: Use TaskScheduler instead of blocking pool in supervised_user_service.cc. (Closed)
Patch Set: Created 3 years, 7 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_service.h" 5 #include "chrome/browser/supervised_user/supervised_user_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/metrics/user_metrics.h" 15 #include "base/metrics/user_metrics.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/task_runner_util.h" 19 #include "base/task_runner_util.h"
20 #include "base/threading/sequenced_worker_pool.h" 20 #include "base/task_scheduler/post_task.h"
21 #include "base/version.h" 21 #include "base/version.h"
22 #include "build/build_config.h" 22 #include "build/build_config.h"
23 #include "chrome/browser/browser_process.h" 23 #include "chrome/browser/browser_process.h"
24 #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h " 24 #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h "
25 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/profiles/profile_attributes_entry.h" 26 #include "chrome/browser/profiles/profile_attributes_entry.h"
27 #include "chrome/browser/profiles/profile_attributes_storage.h" 27 #include "chrome/browser/profiles/profile_attributes_storage.h"
28 #include "chrome/browser/profiles/profile_manager.h" 28 #include "chrome/browser/profiles/profile_manager.h"
29 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 29 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
30 #include "chrome/browser/signin/signin_manager_factory.h" 30 #include "chrome/browser/signin/signin_manager_factory.h"
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 const std::vector<scoped_refptr<SupervisedUserSiteList> >& site_lists) { 748 const std::vector<scoped_refptr<SupervisedUserSiteList> >& site_lists) {
749 whitelists_ = site_lists; 749 whitelists_ = site_lists;
750 url_filter_.LoadWhitelists(site_lists); 750 url_filter_.LoadWhitelists(site_lists);
751 } 751 }
752 752
753 void SupervisedUserService::LoadBlacklist(const base::FilePath& path, 753 void SupervisedUserService::LoadBlacklist(const base::FilePath& path,
754 const GURL& url) { 754 const GURL& url) {
755 DCHECK(blacklist_state_ == BlacklistLoadState::NOT_LOADED); 755 DCHECK(blacklist_state_ == BlacklistLoadState::NOT_LOADED);
756 blacklist_state_ = BlacklistLoadState::LOAD_STARTED; 756 blacklist_state_ = BlacklistLoadState::LOAD_STARTED;
757 base::PostTaskAndReplyWithResult( 757 base::PostTaskAndReplyWithResult(
758 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( 758 base::CreateTaskRunnerWithTraits(
Bernhard Bauer 2017/04/25 14:18:23 Can you use PostTaskWithTraitsAndReplyWithResult()
fdoray 2017/04/27 13:03:17 Done.
759 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN).get(), 759 base::TaskTraits()
760 FROM_HERE, 760 .MayBlock()
761 base::Bind(&base::PathExists, path), 761 .WithPriority(base::TaskPriority::BACKGROUND)
762 .WithShutdownBehavior(
763 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN))
764 .get(),
765 FROM_HERE, base::Bind(&base::PathExists, path),
762 base::Bind(&SupervisedUserService::OnBlacklistFileChecked, 766 base::Bind(&SupervisedUserService::OnBlacklistFileChecked,
763 weak_ptr_factory_.GetWeakPtr(), path, url)); 767 weak_ptr_factory_.GetWeakPtr(), path, url));
764 } 768 }
765 769
766 void SupervisedUserService::OnBlacklistFileChecked(const base::FilePath& path, 770 void SupervisedUserService::OnBlacklistFileChecked(const base::FilePath& path,
767 const GURL& url, 771 const GURL& url,
768 bool file_exists) { 772 bool file_exists) {
769 DCHECK(blacklist_state_ == BlacklistLoadState::LOAD_STARTED); 773 DCHECK(blacklist_state_ == BlacklistLoadState::LOAD_STARTED);
770 if (file_exists) { 774 if (file_exists) {
771 LoadBlacklistFromFile(path); 775 LoadBlacklistFromFile(path);
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 base::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); 1212 base::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile"));
1209 1213
1210 is_profile_active_ = profile_became_active; 1214 is_profile_active_ = profile_became_active;
1211 } 1215 }
1212 #endif // !defined(OS_ANDROID) 1216 #endif // !defined(OS_ANDROID)
1213 1217
1214 void SupervisedUserService::OnSiteListUpdated() { 1218 void SupervisedUserService::OnSiteListUpdated() {
1215 for (SupervisedUserServiceObserver& observer : observer_list_) 1219 for (SupervisedUserServiceObserver& observer : observer_list_)
1216 observer.OnURLFilterChanged(); 1220 observer.OnURLFilterChanged();
1217 } 1221 }
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