Commit 28dc239e authored by Istiaque Ahmed's avatar Istiaque Ahmed Committed by Commit Bot

[TaskScheduler] Make ExternalPrefLoader use sequence instead of FILE thread.

Bug: 689520
Change-Id: I65adecbed9babdb9d09fdf05f3daebcb966360ac
Reviewed-on: https://chromium-review.googlesource.com/587669
Commit-Queue: Istiaque Ahmed <lazyboy@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491584}
parent 379beabb
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "base/path_service.h" #include "base/path_service.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/task_scheduler/lazy_task_runner.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/defaults.h" #include "chrome/browser/defaults.h"
#include "chrome/browser/prefs/pref_service_syncable_util.h" #include "chrome/browser/prefs/pref_service_syncable_util.h"
...@@ -26,6 +27,7 @@ ...@@ -26,6 +27,7 @@
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "components/sync_preferences/pref_service_syncable.h" #include "components/sync_preferences/pref_service_syncable.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "extensions/browser/extension_file_task_runner.h"
using content::BrowserThread; using content::BrowserThread;
...@@ -36,7 +38,7 @@ base::FilePath::CharType kExternalExtensionJson[] = ...@@ -36,7 +38,7 @@ base::FilePath::CharType kExternalExtensionJson[] =
std::set<base::FilePath> GetPrefsCandidateFilesFromFolder( std::set<base::FilePath> GetPrefsCandidateFilesFromFolder(
const base::FilePath& external_extension_search_path) { const base::FilePath& external_extension_search_path) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); base::ThreadRestrictions::AssertIOAllowed();
std::set<base::FilePath> external_extension_paths; std::set<base::FilePath> external_extension_paths;
...@@ -144,9 +146,8 @@ void ExternalPrefLoader::StartLoading() { ...@@ -144,9 +146,8 @@ void ExternalPrefLoader::StartLoading() {
} }
} }
} else { } else {
BrowserThread::PostTask( GetExtensionFileTaskRunner()->PostTask(
BrowserThread::FILE, FROM_HERE, FROM_HERE, base::BindOnce(&ExternalPrefLoader::LoadOnFileThread, this));
base::BindOnce(&ExternalPrefLoader::LoadOnFileThread, this));
} }
} }
...@@ -185,15 +186,14 @@ void ExternalPrefLoader::PostLoadAndRemoveObservers() { ...@@ -185,15 +186,14 @@ void ExternalPrefLoader::PostLoadAndRemoveObservers() {
DCHECK(service); DCHECK(service);
service->RemoveObserver(this); service->RemoveObserver(this);
BrowserThread::PostTask( GetExtensionFileTaskRunner()->PostTask(
BrowserThread::FILE, FROM_HERE, FROM_HERE, base::BindOnce(&ExternalPrefLoader::LoadOnFileThread, this));
base::BindOnce(&ExternalPrefLoader::LoadOnFileThread, this));
} }
void ExternalPrefLoader::LoadOnFileThread() { void ExternalPrefLoader::LoadOnFileThread() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); base::ThreadRestrictions::AssertIOAllowed();
std::unique_ptr<base::DictionaryValue> prefs(new base::DictionaryValue); auto prefs = base::MakeUnique<base::DictionaryValue>();
// TODO(skerner): Some values of base_path_id_ will cause // TODO(skerner): Some values of base_path_id_ will cause
// PathService::Get() to return false, because the path does // PathService::Get() to return false, because the path does
...@@ -233,7 +233,7 @@ void ExternalPrefLoader::LoadOnFileThread() { ...@@ -233,7 +233,7 @@ void ExternalPrefLoader::LoadOnFileThread() {
void ExternalPrefLoader::ReadExternalExtensionPrefFile( void ExternalPrefLoader::ReadExternalExtensionPrefFile(
base::DictionaryValue* prefs) { base::DictionaryValue* prefs) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); base::ThreadRestrictions::AssertIOAllowed();
CHECK(NULL != prefs); CHECK(NULL != prefs);
base::FilePath json_file = base_path_.Append(kExternalExtensionJson); base::FilePath json_file = base_path_.Append(kExternalExtensionJson);
...@@ -271,7 +271,7 @@ void ExternalPrefLoader::ReadExternalExtensionPrefFile( ...@@ -271,7 +271,7 @@ void ExternalPrefLoader::ReadExternalExtensionPrefFile(
void ExternalPrefLoader::ReadStandaloneExtensionPrefFiles( void ExternalPrefLoader::ReadStandaloneExtensionPrefFiles(
base::DictionaryValue* prefs) { base::DictionaryValue* prefs) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); base::ThreadRestrictions::AssertIOAllowed();
CHECK(NULL != prefs); CHECK(NULL != prefs);
// First list the potential .json candidates. // First list the potential .json candidates.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment