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

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: fix-build-error 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_scheduler/post_task.h"
20 #include "base/threading/sequenced_worker_pool.h"
21 #include "base/version.h" 20 #include "base/version.h"
22 #include "build/build_config.h" 21 #include "build/build_config.h"
23 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
24 #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h " 23 #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h "
25 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/profiles/profile_attributes_entry.h" 25 #include "chrome/browser/profiles/profile_attributes_entry.h"
27 #include "chrome/browser/profiles/profile_attributes_storage.h" 26 #include "chrome/browser/profiles/profile_attributes_storage.h"
28 #include "chrome/browser/profiles/profile_manager.h" 27 #include "chrome/browser/profiles/profile_manager.h"
29 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 28 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
30 #include "chrome/browser/signin/signin_manager_factory.h" 29 #include "chrome/browser/signin/signin_manager_factory.h"
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 void SupervisedUserService::OnSiteListsChanged( 746 void SupervisedUserService::OnSiteListsChanged(
748 const std::vector<scoped_refptr<SupervisedUserSiteList> >& site_lists) { 747 const std::vector<scoped_refptr<SupervisedUserSiteList> >& site_lists) {
749 whitelists_ = site_lists; 748 whitelists_ = site_lists;
750 url_filter_.LoadWhitelists(site_lists); 749 url_filter_.LoadWhitelists(site_lists);
751 } 750 }
752 751
753 void SupervisedUserService::LoadBlacklist(const base::FilePath& path, 752 void SupervisedUserService::LoadBlacklist(const base::FilePath& path,
754 const GURL& url) { 753 const GURL& url) {
755 DCHECK(blacklist_state_ == BlacklistLoadState::NOT_LOADED); 754 DCHECK(blacklist_state_ == BlacklistLoadState::NOT_LOADED);
756 blacklist_state_ = BlacklistLoadState::LOAD_STARTED; 755 blacklist_state_ = BlacklistLoadState::LOAD_STARTED;
757 base::PostTaskAndReplyWithResult( 756 base::PostTaskWithTraitsAndReplyWithResult(
758 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
759 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN).get(),
760 FROM_HERE, 757 FROM_HERE,
761 base::Bind(&base::PathExists, path), 758 base::TaskTraits()
762 base::Bind(&SupervisedUserService::OnBlacklistFileChecked, 759 .MayBlock()
763 weak_ptr_factory_.GetWeakPtr(), path, url)); 760 .WithPriority(base::TaskPriority::BACKGROUND)
761 .WithShutdownBehavior(
762 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN),
763 base::BindOnce(&base::PathExists, path),
764 base::BindOnce(&SupervisedUserService::OnBlacklistFileChecked,
765 weak_ptr_factory_.GetWeakPtr(), path, url));
764 } 766 }
765 767
766 void SupervisedUserService::OnBlacklistFileChecked(const base::FilePath& path, 768 void SupervisedUserService::OnBlacklistFileChecked(const base::FilePath& path,
767 const GURL& url, 769 const GURL& url,
768 bool file_exists) { 770 bool file_exists) {
769 DCHECK(blacklist_state_ == BlacklistLoadState::LOAD_STARTED); 771 DCHECK(blacklist_state_ == BlacklistLoadState::LOAD_STARTED);
770 if (file_exists) { 772 if (file_exists) {
771 LoadBlacklistFromFile(path); 773 LoadBlacklistFromFile(path);
772 return; 774 return;
773 } 775 }
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 base::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); 1210 base::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile"));
1209 1211
1210 is_profile_active_ = profile_became_active; 1212 is_profile_active_ = profile_became_active;
1211 } 1213 }
1212 #endif // !defined(OS_ANDROID) 1214 #endif // !defined(OS_ANDROID)
1213 1215
1214 void SupervisedUserService::OnSiteListUpdated() { 1216 void SupervisedUserService::OnSiteListUpdated() {
1215 for (SupervisedUserServiceObserver& observer : observer_list_) 1217 for (SupervisedUserServiceObserver& observer : observer_list_)
1216 observer.OnURLFilterChanged(); 1218 observer.OnURLFilterChanged();
1217 } 1219 }
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