Commit 955059fc authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

favicons: don't create FaviconService if HistoryService is null

My suspicion is history initialization is failing. I'm adding some
logging to verify that.

No doubt if faviconservice creation returns null there will be other
places assuming non-null that need to be fixed.

BUG=1024959, 1052127
TEST=none

Change-Id: I425e0b32d8543f46c1db7f18b232bbd65c898b94
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2057093Reviewed-by: default avatarWez <wez@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741561}
parent 3d706992
......@@ -7,7 +7,6 @@
#include <memory>
#include "base/bind.h"
#include "base/memory/ptr_util.h"
#include "base/memory/singleton.h"
#include "chrome/browser/favicon/chrome_favicon_client.h"
#include "chrome/browser/history/history_service_factory.h"
......@@ -22,10 +21,17 @@ namespace {
std::unique_ptr<KeyedService> BuildFaviconService(
content::BrowserContext* context) {
Profile* profile = Profile::FromBrowserContext(context);
return std::make_unique<favicon::FaviconServiceImpl>(
base::WrapUnique(new ChromeFaviconClient(profile)),
history::HistoryService* history_service =
HistoryServiceFactory::GetForProfile(profile,
ServiceAccessType::EXPLICIT_ACCESS));
ServiceAccessType::EXPLICIT_ACCESS);
// |history_service| may be null, most likely because initialization failed.
if (!history_service) {
// This is rare enough that it's worth logging.
LOG(WARNING) << "FaviconService not created as HistoryService is null";
return nullptr;
}
return std::make_unique<favicon::FaviconServiceImpl>(
std::make_unique<ChromeFaviconClient>(profile), history_service);
}
} // namespace
......
......@@ -965,8 +965,12 @@ bool HistoryService::Init(
base::BindRepeating(base::IgnoreResult(&HistoryService::ScheduleDBTask),
base::Unretained(this)));
if (visit_delegate_ && !visit_delegate_->Init(this))
if (visit_delegate_ && !visit_delegate_->Init(this)) {
// This is rare enough that it's worth logging.
LOG(WARNING) << "HistoryService::Init() failed by way of "
"VisitDelegate::Init failing";
return false;
}
if (history_client_)
history_client_->OnHistoryServiceCreated(this);
......
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