From db156865e7ffe9981c780a48b3a9704feac77352 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Sat, 9 Dec 2017 22:59:28 +0530 Subject: [PATCH] pref store needs to be loaded on a thread that allows IO --- brightray/browser/browser_context.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/brightray/browser/browser_context.cc b/brightray/browser/browser_context.cc index 0dbb71747968..e7d45b7b9083 100644 --- a/brightray/browser/browser_context.cc +++ b/brightray/browser/browser_context.cc @@ -7,6 +7,7 @@ #include "base/files/file_path.h" #include "base/path_service.h" #include "base/strings/string_util.h" +#include "base/threading/thread_restrictions.h" #include "brightray/browser/brightray_paths.h" #include "brightray/browser/browser_client.h" #include "brightray/browser/inspectable_web_contents_impl.h" @@ -101,9 +102,13 @@ BrowserContext::~BrowserContext() { void BrowserContext::InitPrefs() { auto prefs_path = GetPath().Append(FILE_PATH_LITERAL("Preferences")); PrefServiceFactory prefs_factory; - prefs_factory.SetUserPrefsFile(prefs_path, - JsonPrefStore::GetTaskRunnerForFile( - prefs_path, BrowserThread::GetBlockingPool()).get()); + scoped_refptr pref_store = + base::MakeRefCounted(prefs_path); + { + base::ThreadRestrictions::ScopedAllowIO allow_io; + pref_store->ReadPrefs(); // Synchronous. + } + prefs_factory.set_user_prefs(pref_store); auto registry = make_scoped_refptr(new PrefRegistrySimple); RegisterInternalPrefs(registry.get());