Commit 19006ca0 authored by Eugene But's avatar Eugene But Committed by Commit Bot

[ios] Fix crash during synthetic crash report generation

App used to crash because BreadcrumbPersistentStorageManager did not
exist during synthetic crash report generation. This CL moves
BreadcrumbPersistentStorageManager creation from
ApplicationContextImpl::OnAppEnterForeground to
ApplicationContextImpl::PreMainMessageLoopRun, so that Storage Manager
is available in MobileSessionShutdownMetricsProvider::ProvidePreviousSessionData

Bug: 1143779
Change-Id: I2673cdc0383a52b87b2e041d4413c9348f2f8b47
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2508636
Commit-Queue: Eugene But <eugenebut@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Reviewed-by: default avatarMike Dougherty <michaeldo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823366}
parent 2daf24b1
......@@ -155,6 +155,22 @@ void ApplicationContextImpl::PreMainMessageLoopRun() {
browser_policy_connector->Init(GetLocalState(),
GetSharedURLLoaderFactory());
}
if (base::FeatureList::IsEnabled(kLogBreadcrumbs)) {
breadcrumb_manager_ = std::make_unique<BreadcrumbManager>();
application_breadcrumbs_logger_ =
std::make_unique<ApplicationBreadcrumbsLogger>(
breadcrumb_manager_.get());
base::FilePath storage_dir;
bool result = base::PathService::Get(ios::DIR_USER_DATA, &storage_dir);
DCHECK(result);
breadcrumb_persistent_storage_manager_ =
std::make_unique<BreadcrumbPersistentStorageManager>(storage_dir);
application_breadcrumbs_logger_->SetPersistentStorageManager(
breadcrumb_persistent_storage_manager_.get());
}
}
void ApplicationContextImpl::StartTearDown() {
......@@ -224,22 +240,6 @@ void ApplicationContextImpl::OnAppEnterForeground() {
ukm::UkmService* ukm_service = GetMetricsServicesManager()->GetUkmService();
if (ukm_service)
ukm_service->OnAppEnterForeground();
if (base::FeatureList::IsEnabled(kLogBreadcrumbs) && !breadcrumb_manager_) {
breadcrumb_manager_ = std::make_unique<BreadcrumbManager>();
application_breadcrumbs_logger_ =
std::make_unique<ApplicationBreadcrumbsLogger>(
breadcrumb_manager_.get());
base::FilePath storage_dir;
bool result = base::PathService::Get(ios::DIR_USER_DATA, &storage_dir);
DCHECK(result);
breadcrumb_persistent_storage_manager_ =
std::make_unique<BreadcrumbPersistentStorageManager>(storage_dir);
application_breadcrumbs_logger_->SetPersistentStorageManager(
breadcrumb_persistent_storage_manager_.get());
}
}
void ApplicationContextImpl::OnAppEnterBackground() {
......
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