blob: eaf3420c718cd49b04fca634631b554ef6f04df7 [file] [log] [blame]
Evan Stade1a8d9d42024-09-10 19:37:191// Copyright 2012 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CONTENT_BROWSER_INDEXED_DB_INSTANCE_DATABASE_CALLBACKS_H_
6#define CONTENT_BROWSER_INDEXED_DB_INSTANCE_DATABASE_CALLBACKS_H_
7
8#include <stdint.h>
9
10#include "content/common/content_export.h"
11#include "mojo/public/cpp/bindings/associated_remote.h"
12#include "mojo/public/cpp/bindings/pending_associated_remote.h"
13#include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom.h"
14
Evan Stadecbb1e002024-09-13 20:06:5715namespace content::indexed_db {
16class DatabaseError;
17class Transaction;
Evan Stade1a8d9d42024-09-10 19:37:1918
19// This class serves as a thin wrapper around `IDBDatabaseCallbacks` and no-ops
20// any operations invoked after `OnForcedClose()`.
Evan Stadecbb1e002024-09-13 20:06:5721class CONTENT_EXPORT DatabaseCallbacks {
Evan Stade1a8d9d42024-09-10 19:37:1922 public:
Evan Stadecbb1e002024-09-13 20:06:5723 explicit DatabaseCallbacks(
Evan Stade1a8d9d42024-09-10 19:37:1924 mojo::PendingAssociatedRemote<blink::mojom::IDBDatabaseCallbacks>
25 callbacks_remote);
Evan Stadecbb1e002024-09-13 20:06:5726 ~DatabaseCallbacks();
Evan Stade1a8d9d42024-09-10 19:37:1927
Evan Stadecbb1e002024-09-13 20:06:5728 DatabaseCallbacks(const DatabaseCallbacks&) = delete;
29 DatabaseCallbacks& operator=(const DatabaseCallbacks&) = delete;
Evan Stade1a8d9d42024-09-10 19:37:1930
31 void OnForcedClose();
32 void OnVersionChange(int64_t old_version, int64_t new_version);
Evan Stadecbb1e002024-09-13 20:06:5733 void OnAbort(const Transaction& transaction, const DatabaseError& error);
34 void OnComplete(const Transaction& transaction);
Evan Stade1a8d9d42024-09-10 19:37:1935
36 private:
37 bool complete_ = false;
38 mojo::AssociatedRemote<blink::mojom::IDBDatabaseCallbacks> callbacks_;
39};
40
Evan Stadecbb1e002024-09-13 20:06:5741} // namespace content::indexed_db
Evan Stade1a8d9d42024-09-10 19:37:1942
43#endif // CONTENT_BROWSER_INDEXED_DB_INSTANCE_DATABASE_CALLBACKS_H_