Commit 0318db13 authored by Alan Cutter's avatar Alan Cutter Committed by Commit Bot

Rename bookmark app sync install methods to be general

This is a simple rename in preparation to reuse
EnqueueInstallAppFromSync for BMO sync install:
https://chromium-review.googlesource.com/c/chromium/src/+/2251563

Bug: 1090227
Change-Id: I748dfe0c07803777924cdea0a841816c2e65249b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2251558Reviewed-by: default avatarAlexey Baskakov <loyso@chromium.org>
Commit-Queue: Alexey Baskakov <loyso@chromium.org>
Auto-Submit: Alan Cutter <alancutter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#780166}
parent 388c3850
...@@ -63,7 +63,7 @@ void WebAppInstallManager::Start() { ...@@ -63,7 +63,7 @@ void WebAppInstallManager::Start() {
DCHECK(!started_); DCHECK(!started_);
started_ = true; started_ = true;
MaybeEnqueuePendingBookmarkAppInstalls(); MaybeEnqueuePendingAppSyncInstalls();
} }
void WebAppInstallManager::Shutdown() { void WebAppInstallManager::Shutdown() {
...@@ -177,20 +177,20 @@ void WebAppInstallManager::InstallBookmarkAppFromSync( ...@@ -177,20 +177,20 @@ void WebAppInstallManager::InstallBookmarkAppFromSync(
// ExtensionSyncService::ApplyBookmarkAppSyncData() while |this| is not // ExtensionSyncService::ApplyBookmarkAppSyncData() while |this| is not
// |started_|. // |started_|.
if (started_) { if (started_) {
EnqueueInstallBookmarkAppFromSync( EnqueueInstallAppFromSync(bookmark_app_id, std::move(web_application_info),
bookmark_app_id, std::move(web_application_info), std::move(callback)); std::move(callback));
} else { } else {
BookmarkAppInstallRequest request; AppSyncInstallRequest request;
request.bookmark_app_id = bookmark_app_id; request.sync_app_id = bookmark_app_id;
request.web_application_info = std::move(web_application_info); request.web_application_info = std::move(web_application_info);
request.callback = std::move(callback); request.callback = std::move(callback);
pending_bookmark_app_installs_.push_back(std::move(request)); pending_app_sync_installs_.push_back(std::move(request));
} }
} }
void WebAppInstallManager::EnqueueInstallBookmarkAppFromSync( void WebAppInstallManager::EnqueueInstallAppFromSync(
const AppId& bookmark_app_id, const AppId& sync_app_id,
std::unique_ptr<WebApplicationInfo> web_application_info, std::unique_ptr<WebApplicationInfo> web_application_info,
OnceInstallCallback callback) { OnceInstallCallback callback) {
DCHECK(started_); DCHECK(started_);
...@@ -198,13 +198,13 @@ void WebAppInstallManager::EnqueueInstallBookmarkAppFromSync( ...@@ -198,13 +198,13 @@ void WebAppInstallManager::EnqueueInstallBookmarkAppFromSync(
// Skip sync update if app exists. // Skip sync update if app exists.
// All manifest fields will be set locally via update (see crbug.com/926083) // All manifest fields will be set locally via update (see crbug.com/926083)
// so we must not sync them in order to avoid a device-to-device sync war. // so we must not sync them in order to avoid a device-to-device sync war.
if (registrar()->IsInstalled(bookmark_app_id)) { if (registrar()->IsInstalled(sync_app_id)) {
std::move(callback).Run(bookmark_app_id, std::move(callback).Run(sync_app_id,
InstallResultCode::kSuccessAlreadyInstalled); InstallResultCode::kSuccessAlreadyInstalled);
return; return;
} }
// If bookmark_app_id is not installed enqueue full background installation // If sync_app_id is not installed enqueue full background installation
// flow. This install may produce a web app or an extension-based bookmark // flow. This install may produce a web app or an extension-based bookmark
// app, depending on the BMO flag. // app, depending on the BMO flag.
GURL launch_url = web_application_info->app_url; GURL launch_url = web_application_info->app_url;
...@@ -213,7 +213,7 @@ void WebAppInstallManager::EnqueueInstallBookmarkAppFromSync( ...@@ -213,7 +213,7 @@ void WebAppInstallManager::EnqueueInstallBookmarkAppFromSync(
profile(), registrar(), shortcut_manager(), file_handler_manager(), profile(), registrar(), shortcut_manager(), file_handler_manager(),
finalizer(), data_retriever_factory_.Run()); finalizer(), data_retriever_factory_.Run());
task->ExpectAppId(bookmark_app_id); task->ExpectAppId(sync_app_id);
task->SetInstallParams(CreateSyncInstallParams( task->SetInstallParams(CreateSyncInstallParams(
launch_url, web_application_info->title, launch_url, web_application_info->title,
web_application_info->open_as_window ? DisplayMode::kStandalone web_application_info->open_as_window ? DisplayMode::kStandalone
...@@ -221,8 +221,8 @@ void WebAppInstallManager::EnqueueInstallBookmarkAppFromSync( ...@@ -221,8 +221,8 @@ void WebAppInstallManager::EnqueueInstallBookmarkAppFromSync(
OnceInstallCallback task_completed_callback = base::BindOnce( OnceInstallCallback task_completed_callback = base::BindOnce(
&WebAppInstallManager:: &WebAppInstallManager::
LoadAndInstallWebAppFromManifestWithFallbackCompleted_ForBookmarkAppSync, LoadAndInstallWebAppFromManifestWithFallbackCompleted_ForAppSync,
base::Unretained(this), bookmark_app_id, std::move(web_application_info), base::Unretained(this), sync_app_id, std::move(web_application_info),
std::move(callback)); std::move(callback));
base::OnceClosure start_task = base::BindOnce( base::OnceClosure start_task = base::BindOnce(
...@@ -335,19 +335,19 @@ void WebAppInstallManager::SetUrlLoaderForTesting( ...@@ -335,19 +335,19 @@ void WebAppInstallManager::SetUrlLoaderForTesting(
url_loader_ = std::move(url_loader); url_loader_ = std::move(url_loader);
} }
void WebAppInstallManager::MaybeEnqueuePendingBookmarkAppInstalls() { void WebAppInstallManager::MaybeEnqueuePendingAppSyncInstalls() {
for (BookmarkAppInstallRequest& request : pending_bookmark_app_installs_) { for (AppSyncInstallRequest& request : pending_app_sync_installs_) {
EnqueueInstallBookmarkAppFromSync(request.bookmark_app_id, EnqueueInstallAppFromSync(request.sync_app_id,
std::move(request.web_application_info), std::move(request.web_application_info),
std::move(request.callback)); std::move(request.callback));
} }
pending_bookmark_app_installs_.clear(); pending_app_sync_installs_.clear();
} }
void WebAppInstallManager:: void WebAppInstallManager::
LoadAndInstallWebAppFromManifestWithFallbackCompleted_ForBookmarkAppSync( LoadAndInstallWebAppFromManifestWithFallbackCompleted_ForAppSync(
const AppId& bookmark_app_id, const AppId& sync_app_id,
std::unique_ptr<WebApplicationInfo> web_application_info, std::unique_ptr<WebApplicationInfo> web_application_info,
OnceInstallCallback callback, OnceInstallCallback callback,
const AppId& web_app_id, const AppId& web_app_id,
...@@ -355,7 +355,7 @@ void WebAppInstallManager:: ...@@ -355,7 +355,7 @@ void WebAppInstallManager::
// TODO(loyso): Record |code| for this specific case in // TODO(loyso): Record |code| for this specific case in
// Webapp.BookmarkAppInstalledAfterSyncResult UMA. // Webapp.BookmarkAppInstalledAfterSyncResult UMA.
if (IsSuccess(code)) { if (IsSuccess(code)) {
DCHECK_EQ(bookmark_app_id, web_app_id); DCHECK_EQ(sync_app_id, web_app_id);
std::move(callback).Run(web_app_id, code); std::move(callback).Run(web_app_id, code);
return; return;
} }
...@@ -525,13 +525,11 @@ void WebAppInstallManager::OnWebContentsReady(WebAppUrlLoader::Result result) { ...@@ -525,13 +525,11 @@ void WebAppInstallManager::OnWebContentsReady(WebAppUrlLoader::Result result) {
MaybeStartQueuedTask(); MaybeStartQueuedTask();
} }
WebAppInstallManager::BookmarkAppInstallRequest::BookmarkAppInstallRequest() = WebAppInstallManager::AppSyncInstallRequest::AppSyncInstallRequest() = default;
default;
WebAppInstallManager::BookmarkAppInstallRequest::BookmarkAppInstallRequest( WebAppInstallManager::AppSyncInstallRequest::AppSyncInstallRequest(
BookmarkAppInstallRequest&&) = default; AppSyncInstallRequest&&) = default;
WebAppInstallManager::BookmarkAppInstallRequest::~BookmarkAppInstallRequest() = WebAppInstallManager::AppSyncInstallRequest::~AppSyncInstallRequest() = default;
default;
} // namespace web_app } // namespace web_app
...@@ -92,16 +92,16 @@ class WebAppInstallManager final : public InstallManager, ...@@ -92,16 +92,16 @@ class WebAppInstallManager final : public InstallManager,
FRIEND_TEST_ALL_PREFIXES(WebAppInstallManagerTest, FRIEND_TEST_ALL_PREFIXES(WebAppInstallManagerTest,
TaskQueueWebContentsReadyRace); TaskQueueWebContentsReadyRace);
void MaybeEnqueuePendingBookmarkAppInstalls(); void MaybeEnqueuePendingAppSyncInstalls();
void EnqueueInstallBookmarkAppFromSync( void EnqueueInstallAppFromSync(
const AppId& bookmark_app_id, const AppId& sync_app_id,
std::unique_ptr<WebApplicationInfo> web_application_info, std::unique_ptr<WebApplicationInfo> web_application_info,
OnceInstallCallback callback); OnceInstallCallback callback);
bool IsAppIdAlreadyEnqueued(const AppId& app_id) const; bool IsAppIdAlreadyEnqueued(const AppId& app_id) const;
// On failure will attempt a fallback install only loading icon URLs. // On failure will attempt a fallback install only loading icon URLs.
void LoadAndInstallWebAppFromManifestWithFallbackCompleted_ForBookmarkAppSync( void LoadAndInstallWebAppFromManifestWithFallbackCompleted_ForAppSync(
const AppId& bookmark_app_id, const AppId& sync_app_id,
std::unique_ptr<WebApplicationInfo> web_application_info, std::unique_ptr<WebApplicationInfo> web_application_info,
OnceInstallCallback callback, OnceInstallCallback callback,
const AppId& web_app_id, const AppId& web_app_id,
...@@ -154,16 +154,16 @@ class WebAppInstallManager final : public InstallManager, ...@@ -154,16 +154,16 @@ class WebAppInstallManager final : public InstallManager,
TaskQueue task_queue_; TaskQueue task_queue_;
bool is_running_queued_task_ = false; bool is_running_queued_task_ = false;
struct BookmarkAppInstallRequest { struct AppSyncInstallRequest {
BookmarkAppInstallRequest(); AppSyncInstallRequest();
BookmarkAppInstallRequest(BookmarkAppInstallRequest&&); AppSyncInstallRequest(AppSyncInstallRequest&&);
~BookmarkAppInstallRequest(); ~AppSyncInstallRequest();
AppId bookmark_app_id; AppId sync_app_id;
std::unique_ptr<WebApplicationInfo> web_application_info; std::unique_ptr<WebApplicationInfo> web_application_info;
OnceInstallCallback callback; OnceInstallCallback callback;
}; };
std::vector<BookmarkAppInstallRequest> pending_bookmark_app_installs_; std::vector<AppSyncInstallRequest> pending_app_sync_installs_;
// A single WebContents, shared between tasks in |task_queue_|. // A single WebContents, shared between tasks in |task_queue_|.
std::unique_ptr<content::WebContents> web_contents_; std::unique_ptr<content::WebContents> web_contents_;
......
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