Commit 945fcd73 authored by Alexey Baskakov's avatar Alexey Baskakov Committed by Commit Bot

WebApp: Call RegistryOpenedCallback asynchronously.

We should break down this synchronous call chain:

web_app::WebAppSyncBridge::CommitUpdate()
web_app::ScopedRegistryUpdate::~ScopedRegistryUpdate()
web_app::WebAppInstallFinalizer::UninstallWebApp()
web_app::WebAppInstallFinalizer::UninstallWebAppOrRemoveSource()
web_app::WebAppInstallFinalizer::UninstallExternalWebApp()
web_app::InstallFinalizer::UninstallExternalWebAppByUrl()
web_app::PendingAppManagerImpl::UninstallApps()
web_app::PendingAppManager::SynchronizeInstalledApps()
web_app::ExternalWebAppManager::OnScanForExternalWebApps()
web_app::ExternalWebAppManager::ScanForExternalWebApps()
web_app::ExternalWebAppManager::Start()
web_app::WebAppProvider::OnRegistryControllerReady()
web_app::WebAppSyncBridge::OnDatabaseOpened()
web_app::WebAppDatabase::OnAllMetadataRead()
syncer::ModelTypeStoreImpl::ReadAllMetadataDone()

WebAppSyncBridge::OnDatabaseOpened() must not cause immediate
WebAppSyncBridge::CommitUpdate() on same `this`.

Bug: 1084939
Change-Id: Ib32c52780a647a0985418c0f92985f041869f104
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2212236Reviewed-by: default avatarEric Willigers <ericwilligers@chromium.org>
Commit-Queue: Alexey Baskakov <loyso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771473}
parent 059d75ea
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "chrome/browser/web_applications/components/web_app_helpers.h" #include "chrome/browser/web_applications/components/web_app_helpers.h"
#include "chrome/browser/web_applications/components/web_app_utils.h" #include "chrome/browser/web_applications/components/web_app_utils.h"
#include "chrome/browser/web_applications/web_app.h" #include "chrome/browser/web_applications/web_app.h"
...@@ -414,8 +415,11 @@ void WebAppDatabase::OnAllMetadataRead( ...@@ -414,8 +415,11 @@ void WebAppDatabase::OnAllMetadataRead(
registry.emplace(app_id, std::move(web_app)); registry.emplace(app_id, std::move(web_app));
} }
std::move(callback).Run(std::move(registry), std::move(metadata_batch));
opened_ = true; opened_ = true;
base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), std::move(registry),
std::move(metadata_batch)));
} }
void WebAppDatabase::OnDataWritten( void WebAppDatabase::OnDataWritten(
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/containers/flat_set.h" #include "base/containers/flat_set.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/util/type_safety/pass_key.h" #include "base/util/type_safety/pass_key.h"
#include "chrome/browser/web_applications/components/web_app_helpers.h" #include "chrome/browser/web_applications/components/web_app_helpers.h"
#include "chrome/browser/web_applications/components/web_app_utils.h" #include "chrome/browser/web_applications/components/web_app_utils.h"
...@@ -315,9 +316,11 @@ void WebAppSyncBridge::OnDatabaseOpened( ...@@ -315,9 +316,11 @@ void WebAppSyncBridge::OnDatabaseOpened(
change_processor()->ModelReadyToSync(std::move(metadata_batch)); change_processor()->ModelReadyToSync(std::move(metadata_batch));
registrar_->InitRegistry(std::move(registry)); registrar_->InitRegistry(std::move(registry));
std::move(callback).Run();
MaybeInstallAppsInSyncInstall(); MaybeInstallAppsInSyncInstall();
base::SequencedTaskRunnerHandle::Get()->PostTask(FROM_HERE,
std::move(callback));
} }
void WebAppSyncBridge::OnDataWritten(CommitCallback callback, bool success) { void WebAppSyncBridge::OnDataWritten(CommitCallback callback, bool success) {
......
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