Fix NetworkService startup assertion with multi-threaded message loop (see issue #2622).

When using multi-threaded message loop mode the PrefService needs to be created
on the UI thread.

To test: Run `cefclient --enable-network-service --multi-threaded-message-loop`.
The application should start successfully.
This commit is contained in:
Marshall Greenblatt 2019-04-26 17:17:24 -04:00
parent cc80175e89
commit 4e089766a5
1 changed files with 9 additions and 8 deletions

View File

@ -45,14 +45,6 @@ void ChromeBrowserProcessStub::Initialize() {
// Initialize this early before any code tries to check feature flags.
content::SetUpFieldTrialsAndFeatureList();
const CefSettings& settings = CefContext::Get()->settings();
const base::FilePath& cache_path =
base::FilePath(CefString(&settings.cache_path));
// Used for very early NetworkService initialization.
local_state_ = browser_prefs::CreatePrefService(
nullptr, cache_path, !!settings.persist_user_preferences);
initialized_ = true;
}
@ -160,6 +152,15 @@ ProfileManager* ChromeBrowserProcessStub::profile_manager() {
PrefService* ChromeBrowserProcessStub::local_state() {
DCHECK(initialized_);
if (!local_state_) {
const CefSettings& settings = CefContext::Get()->settings();
const base::FilePath& cache_path =
base::FilePath(CefString(&settings.cache_path));
// Used for very early NetworkService initialization.
local_state_ = browser_prefs::CreatePrefService(
nullptr, cache_path, !!settings.persist_user_preferences);
}
return local_state_.get();
}