File: power_bookmark_database.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (75 lines) | stat: -rw-r--r-- 3,119 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_POWER_BOOKMARKS_STORAGE_POWER_BOOKMARK_DATABASE_H_
#define COMPONENTS_POWER_BOOKMARKS_STORAGE_POWER_BOOKMARK_DATABASE_H_

#include <memory>
#include <vector>

#include "components/power_bookmarks/common/power.h"
#include "components/power_bookmarks/common/power_overview.h"
#include "components/power_bookmarks/storage/power_bookmark_sync_bridge.h"
#include "url/gurl.h"

namespace power_bookmarks {

struct SearchParams;

// Interface for the database layer of the Power Bookmark database.
class PowerBookmarkDatabase : public PowerBookmarkSyncBridge::Delegate {
 public:
  virtual ~PowerBookmarkDatabase() = default;

  // Initialises internal database. Must be called prior to any other usage.
  virtual bool Init() = 0;

  // Returns whether the database is currently open.
  virtual bool IsOpen() = 0;

  // Returns a vector of Powers for the given `url`. Use `power_type` to
  // restrict which type is returned or use POWER_TYPE_UNSPECIFIED to return
  // everything.
  virtual std::vector<std::unique_ptr<Power>> GetPowersForURL(
      const GURL& url,
      const sync_pb::PowerBookmarkSpecifics::PowerType& power_type) = 0;

  // Returns a vector of PowerOverviews for the given `power_type`.
  virtual std::vector<std::unique_ptr<PowerOverview>> GetPowerOverviewsForType(
      const sync_pb::PowerBookmarkSpecifics::PowerType& power_type) = 0;

  // Returns a vector of Powers for the given `search_params`.
  virtual std::vector<std::unique_ptr<Power>> GetPowersForSearchParams(
      const SearchParams& search_params) = 0;

  // Returns a vector of PowerOverviews for the given `search_params`.
  virtual std::vector<std::unique_ptr<PowerOverview>>
  GetPowerOverviewsForSearchParams(const SearchParams& search_params) = 0;

  // Create the given `power` in the database. If it already exists, then it
  // will be updated. Returns whether the operation was successful.
  virtual bool CreatePower(std::unique_ptr<Power> power) = 0;

  // Update the given `power` in the database. If it doesn't exist, then it
  // will be created instead. Returns the updated power if the operation was
  // successful or nullptr otherwise.
  virtual std::unique_ptr<Power> UpdatePower(std::unique_ptr<Power> power) = 0;

  // Delete the given `guid` in the database, if it exists. Returns whether
  // the operation was successful.
  virtual bool DeletePower(const base::Uuid& guid) = 0;

  // Delete all powers for the given `url`. Use `power_type` to restrict which
  // type is deleted or use POWER_TYPE_UNSPECIFIED to delete everything.
  // Returns whether the operation was successfaul and all deleted guids in
  // deleted_guids as output if provided.
  virtual bool DeletePowersForURL(
      const GURL& url,
      const sync_pb::PowerBookmarkSpecifics::PowerType& power_type,
      std::vector<std::string>* deleted_guids = nullptr) = 0;
};

}  // namespace power_bookmarks

#endif  // COMPONENTS_POWER_BOOKMARKS_STORAGE_POWER_BOOKMARK_DATABASE_H_