chromium/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_manager.cc

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_manager.h"

#include <memory>
#include <optional>
#include <type_traits>

#include "base/callback_list.h"
#include "base/cancelable_callback.h"
#include "base/check.h"
#include "base/containers/circular_deque.h"
#include "base/containers/map_util.h"
#include "base/containers/unique_ptr_adapters.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/functional/overloaded.h"
#include "base/location.h"
#include "base/memory/raw_ref.h"
#include "base/memory/weak_ptr.h"
#include "base/rand_util.h"
#include "base/ranges/algorithm.h"
#include "base/scoped_observation.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "base/types/expected.h"
#include "base/types/expected_macros.h"
#include "base/values.h"
#include "chrome/browser/profiles/keep_alive/profile_keep_alive_types.h"
#include "chrome/browser/profiles/keep_alive/scoped_profile_keep_alive.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/web_applications/isolated_web_apps/error/uma_logging.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_apply_update_command.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_install_command_helper.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_install_source.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_storage_location.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_apply_task.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_apply_waiter.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_discovery_task.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_manager.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_url_info.h"
#include "chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_external_install_options.h"
#include "chrome/browser/web_applications/web_app_command_scheduler.h"
#include "chrome/browser/web_applications/web_app_install_manager.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/browser/web_applications/web_app_registrar.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "components/keep_alive_registry/keep_alive_types.h"
#include "components/keep_alive_registry/scoped_keep_alive.h"
#include "components/prefs/pref_service.h"
#include "components/web_package/signed_web_bundles/signed_web_bundle_id.h"
#include "components/webapps/common/web_app_id.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/isolated_web_apps_policy.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
#include "url/gurl.h"

namespace web_app {

// This helper class acts similarly to `IsolatedWebAppUpdateDiscoveryTask`, the
// difference being that this class is for discovering local updates for
// dev-mode installed IWAs.
class IsolatedWebAppUpdateManager::LocalDevModeUpdateDiscoverer {};

IsolatedWebAppUpdateManager::IsolatedWebAppUpdateManager(
    Profile& profile,
    base::TimeDelta update_discovery_frequency)
    :{}

IsolatedWebAppUpdateManager::~IsolatedWebAppUpdateManager() = default;

void IsolatedWebAppUpdateManager::SetProvider(base::PassKey<WebAppProvider>,
                                              WebAppProvider& provider) {}

void IsolatedWebAppUpdateManager::Start() {}

void IsolatedWebAppUpdateManager::DelayedStart() {}

void IsolatedWebAppUpdateManager::Shutdown() {}

base::Value IsolatedWebAppUpdateManager::AsDebugValue() const {}

bool IsolatedWebAppUpdateManager::IsUpdateBeingApplied(
    base::PassKey<IsolatedWebAppURLLoaderFactory>,
    const webapps::AppId app_id) const {}

void IsolatedWebAppUpdateManager::PrioritizeUpdateAndWait(
    base::PassKey<IsolatedWebAppURLLoaderFactory>,
    const webapps::AppId& app_id,
    base::OnceCallback<void(IsolatedWebAppUpdateApplyTask::CompletionStatus)>
        callback) {}

void IsolatedWebAppUpdateManager::PrioritizeUpdateAndWaitImpl(
    const webapps::AppId& app_id,
    base::OnceCallback<void(IsolatedWebAppUpdateApplyTask::CompletionStatus)>
        callback) {}

void IsolatedWebAppUpdateManager::SetEnableAutomaticUpdatesForTesting(
    bool automatic_updates_enabled) {}

void IsolatedWebAppUpdateManager::OnWebAppInstalled(
    const webapps::AppId& app_id) {}

void IsolatedWebAppUpdateManager::OnWebAppUninstalled(
    const webapps::AppId& app_id,
    webapps::WebappUninstallSource uninstall_source) {}

bool IsolatedWebAppUpdateManager::MaybeDiscoverUpdatesForApp(
    const webapps::AppId& app_id) {}

size_t IsolatedWebAppUpdateManager::DiscoverUpdatesNow() {}

void IsolatedWebAppUpdateManager::DiscoverApplyAndPrioritizeLocalDevModeUpdate(
    const IwaSourceDevModeWithFileOp& location,
    const IsolatedWebAppUrlInfo& url_info,
    base::OnceCallback<void(base::expected<base::Version, std::string>)>
        callback) {}

void IsolatedWebAppUpdateManager::OnComponentUpdateSuccess(
    const base::Version& component_version) {}

bool IsolatedWebAppUpdateManager::IsAnyIwaInstalled() {}

base::flat_map<web_package::SignedWebBundleId, GURL>
IsolatedWebAppUpdateManager::GetForceInstalledBundleIdToUpdateManifestUrlMap() {}

size_t IsolatedWebAppUpdateManager::QueueUpdateDiscoveryTasks() {}

bool IsolatedWebAppUpdateManager::MaybeQueueUpdateDiscoveryTask(
    const WebApp& web_app,
    const base::flat_map<web_package::SignedWebBundleId, GURL>&
        id_to_update_manifest_map) {}

void IsolatedWebAppUpdateManager::MaybeScheduleUpdateDiscoveryCheck() {}

void IsolatedWebAppUpdateManager::MaybeResetScheduledUpdateDiscoveryCheck() {}

void IsolatedWebAppUpdateManager::CreateUpdateApplyWaiter(
    const IsolatedWebAppUrlInfo& url_info,
    base::OnceClosure on_update_apply_task_created) {}

void IsolatedWebAppUpdateManager::OnUpdateDiscoveryTaskCompleted(
    std::unique_ptr<IsolatedWebAppUpdateDiscoveryTask> task,
    IsolatedWebAppUpdateDiscoveryTask::CompletionStatus status) {}

void IsolatedWebAppUpdateManager::TrackResultOfUpdateDiscoveryTask(
    IsolatedWebAppUpdateDiscoveryTask::CompletionStatus status) const {}

void IsolatedWebAppUpdateManager::OnUpdateApplyWaiterFinished(
    IsolatedWebAppUrlInfo url_info,
    base::OnceClosure on_update_apply_task_created,
    std::unique_ptr<ScopedKeepAlive> keep_alive,
    std::unique_ptr<ScopedProfileKeepAlive> profile_keep_alive) {}

void IsolatedWebAppUpdateManager::OnUpdateApplyTaskCompleted(
    std::unique_ptr<IsolatedWebAppUpdateApplyTask> task,
    IsolatedWebAppUpdateApplyTask::CompletionStatus status) {}

void IsolatedWebAppUpdateManager::TrackResultOfUpdateApplyTask(
    IsolatedWebAppUpdateApplyTask::CompletionStatus status) const {}

void IsolatedWebAppUpdateManager::OnLocalUpdateDiscovered(
    IsolatedWebAppUrlInfo url_info,
    base::OnceCallback<void(base::expected<base::Version, std::string>)>
        callback,
    base::expected<base::Version, std::string> update_discovery_result) {}

void IsolatedWebAppUpdateManager::OnLocalUpdateApplyTaskCreated(
    IsolatedWebAppUrlInfo url_info,
    base::Version update_version,
    base::OnceCallback<void(base::expected<base::Version, std::string>)>
        callback) {}

IsolatedWebAppUpdateManager::NextUpdateDiscoveryCheck::
    NextUpdateDiscoveryCheck() = default;

IsolatedWebAppUpdateManager::NextUpdateDiscoveryCheck::
    ~NextUpdateDiscoveryCheck() = default;

void IsolatedWebAppUpdateManager::NextUpdateDiscoveryCheck::ScheduleWithJitter(
    const base::TimeDelta& base_delay,
    base::OnceClosure callback) {}

std::optional<base::TimeTicks>
IsolatedWebAppUpdateManager::NextUpdateDiscoveryCheck::GetScheduledTime()
    const {}

bool IsolatedWebAppUpdateManager::NextUpdateDiscoveryCheck::IsScheduled()
    const {}

void IsolatedWebAppUpdateManager::NextUpdateDiscoveryCheck::Reset() {}

base::Value
IsolatedWebAppUpdateManager::NextUpdateDiscoveryCheck::AsDebugValue() const {}

IsolatedWebAppUpdateManager::TaskQueue::TaskQueue(
    IsolatedWebAppUpdateManager& update_manager)
    :{}

IsolatedWebAppUpdateManager::TaskQueue::~TaskQueue() = default;

base::Value IsolatedWebAppUpdateManager::TaskQueue::AsDebugValue() const {}

void IsolatedWebAppUpdateManager::TaskQueue::ClearUpdateDiscoveryLog() {}

void IsolatedWebAppUpdateManager::TaskQueue::Push(
    std::unique_ptr<IsolatedWebAppUpdateDiscoveryTask> task) {}

void IsolatedWebAppUpdateManager::TaskQueue::Push(
    std::unique_ptr<IsolatedWebAppUpdateApplyTask> task) {}

void IsolatedWebAppUpdateManager::TaskQueue::Clear() {}

bool IsolatedWebAppUpdateManager::TaskQueue::
    EnsureQueuedUpdateApplyTaskHasStarted(const webapps::AppId& app_id) {}

void IsolatedWebAppUpdateManager::TaskQueue::ClearNonStartedTasksOfApp(
    const webapps::AppId& app_id) {}

void IsolatedWebAppUpdateManager::TaskQueue::MaybeStartNextTask() {}

bool IsolatedWebAppUpdateManager::TaskQueue::IsUpdateApplyTaskQueued(
    const webapps::AppId& app_id) const {}

void IsolatedWebAppUpdateManager::TaskQueue::StartUpdateDiscoveryTask(
    IsolatedWebAppUpdateDiscoveryTask* task_ptr) {}

void IsolatedWebAppUpdateManager::TaskQueue::StartUpdateApplyTask(
    IsolatedWebAppUpdateApplyTask* task_ptr) {}

bool IsolatedWebAppUpdateManager::TaskQueue::IsAnyTaskRunning() const {}

void IsolatedWebAppUpdateManager::TaskQueue::OnUpdateDiscoveryTaskCompleted(
    IsolatedWebAppUpdateDiscoveryTask* task_ptr,
    IsolatedWebAppUpdateDiscoveryTask::CompletionStatus status) {}

void IsolatedWebAppUpdateManager::TaskQueue::OnUpdateApplyTaskCompleted(
    IsolatedWebAppUpdateApplyTask* task_ptr,
    IsolatedWebAppUpdateApplyTask::CompletionStatus status) {}

IsolatedWebAppUpdateError IsolatedWebAppUpdateManager::FromDiscoveryTaskError(
    const IsolatedWebAppUpdateDiscoveryTask::Error& error) const {}

}  // namespace web_app