Commit 47e6e3d4 authored by Yann Dago's avatar Yann Dago Committed by Commit Bot

LBS: Synchronously load rules from prefs at first load

Bug: 1002307
Change-Id: Idb6c44387a7e8f89127610a8a7ac2524919ad145
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1802539Reviewed-by: default avatarNicolas Ouellet-Payeur <nicolaso@chromium.org>
Commit-Queue: Yann Dago <ydago@chromium.org>
Cr-Commit-Position: refs/heads/master@{#696782}
parent bc63d69f
...@@ -230,12 +230,11 @@ BrowserSwitcherService::BrowserSwitcherService(Profile* profile) ...@@ -230,12 +230,11 @@ BrowserSwitcherService::BrowserSwitcherService(Profile* profile)
BrowserSwitcherService::~BrowserSwitcherService() = default; BrowserSwitcherService::~BrowserSwitcherService() = default;
void BrowserSwitcherService::Init() { void BrowserSwitcherService::Init() {
LoadRulesFromPrefs();
StartDownload(fetch_delay()); StartDownload(fetch_delay());
} }
void BrowserSwitcherService::StartDownload(base::TimeDelta delay) { void BrowserSwitcherService::StartDownload(base::TimeDelta delay) {
LoadRulesFromPrefs();
// This destroys the previous XmlDownloader, which cancels any scheduled // This destroys the previous XmlDownloader, which cancels any scheduled
// refresh operations. // refresh operations.
sitelist_downloader_ = std::make_unique<XmlDownloader>( sitelist_downloader_ = std::make_unique<XmlDownloader>(
......
...@@ -148,6 +148,8 @@ class BrowserSwitcherService : public KeyedService { ...@@ -148,6 +148,8 @@ class BrowserSwitcherService : public KeyedService {
// happens. // happens.
virtual void LoadRulesFromPrefs(); virtual void LoadRulesFromPrefs();
void Init();
protected: protected:
virtual void OnAllRulesetsParsed(); virtual void OnAllRulesetsParsed();
virtual void OnBrowserSwitcherPrefsChanged( virtual void OnBrowserSwitcherPrefsChanged(
...@@ -163,8 +165,6 @@ class BrowserSwitcherService : public KeyedService { ...@@ -163,8 +165,6 @@ class BrowserSwitcherService : public KeyedService {
// events and trigger a re-download immediately. // events and trigger a re-download immediately.
friend class ::BrowserSwitchHandler; friend class ::BrowserSwitchHandler;
void Init();
void OnExternalSitelistParsed(ParsedXml xml); void OnExternalSitelistParsed(ParsedXml xml);
void OnExternalGreylistParsed(ParsedXml xml); void OnExternalGreylistParsed(ParsedXml xml);
......
...@@ -50,7 +50,10 @@ BrowserSwitcherServiceFactory::~BrowserSwitcherServiceFactory() {} ...@@ -50,7 +50,10 @@ BrowserSwitcherServiceFactory::~BrowserSwitcherServiceFactory() {}
KeyedService* BrowserSwitcherServiceFactory::BuildServiceInstanceFor( KeyedService* BrowserSwitcherServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const { content::BrowserContext* context) const {
return new BrowserSwitcherServiceImpl(Profile::FromBrowserContext(context)); auto* instance =
new BrowserSwitcherServiceImpl(Profile::FromBrowserContext(context));
instance->Init();
return instance;
} }
content::BrowserContext* BrowserSwitcherServiceFactory::GetBrowserContextToUse( content::BrowserContext* BrowserSwitcherServiceFactory::GetBrowserContextToUse(
......
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