blob: a7228db951df9aa6c75c68db39da938db4a0a18d [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <map>
#include <vector>
#include "base/callback_forward.h"
#include "chrome/browser/web_applications/components/web_app_helpers.h"
namespace web_app {
class WebApp;
using Registry = std::map<AppId, std::unique_ptr<WebApp>>;
// An abstract database for the registry persistence.
// Exclusively used from the UI thread.
class AbstractWebAppDatabase {
virtual ~AbstractWebAppDatabase() = default;
using OnceRegistryOpenedCallback =
base::OnceCallback<void(Registry registry)>;
// Open existing or create new DB. Read all data and return it via callback.
virtual void OpenDatabase(OnceRegistryOpenedCallback callback) = 0;
// |OpenDatabase| must have been called and completed before using any other
// methods. Otherwise, it fails with DCHECK.
virtual void WriteWebApp(const WebApp& web_app) = 0;
virtual void DeleteWebApps(std::vector<AppId> app_ids) = 0;
} // namespace web_app