Evan Stade | 1a8d9d4 | 2024-09-10 19:37:19 | [diff] [blame] | 1 | // 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 Stade | cbb1e00 | 2024-09-13 20:06:57 | [diff] [blame] | 15 | namespace content::indexed_db { |
| 16 | class DatabaseError; |
| 17 | class Transaction; |
Evan Stade | 1a8d9d4 | 2024-09-10 19:37:19 | [diff] [blame] | 18 | |
| 19 | // This class serves as a thin wrapper around `IDBDatabaseCallbacks` and no-ops |
| 20 | // any operations invoked after `OnForcedClose()`. |
Evan Stade | cbb1e00 | 2024-09-13 20:06:57 | [diff] [blame] | 21 | class CONTENT_EXPORT DatabaseCallbacks { |
Evan Stade | 1a8d9d4 | 2024-09-10 19:37:19 | [diff] [blame] | 22 | public: |
Evan Stade | cbb1e00 | 2024-09-13 20:06:57 | [diff] [blame] | 23 | explicit DatabaseCallbacks( |
Evan Stade | 1a8d9d4 | 2024-09-10 19:37:19 | [diff] [blame] | 24 | mojo::PendingAssociatedRemote<blink::mojom::IDBDatabaseCallbacks> |
| 25 | callbacks_remote); |
Evan Stade | cbb1e00 | 2024-09-13 20:06:57 | [diff] [blame] | 26 | ~DatabaseCallbacks(); |
Evan Stade | 1a8d9d4 | 2024-09-10 19:37:19 | [diff] [blame] | 27 | |
Evan Stade | cbb1e00 | 2024-09-13 20:06:57 | [diff] [blame] | 28 | DatabaseCallbacks(const DatabaseCallbacks&) = delete; |
| 29 | DatabaseCallbacks& operator=(const DatabaseCallbacks&) = delete; |
Evan Stade | 1a8d9d4 | 2024-09-10 19:37:19 | [diff] [blame] | 30 | |
| 31 | void OnForcedClose(); |
| 32 | void OnVersionChange(int64_t old_version, int64_t new_version); |
Evan Stade | cbb1e00 | 2024-09-13 20:06:57 | [diff] [blame] | 33 | void OnAbort(const Transaction& transaction, const DatabaseError& error); |
| 34 | void OnComplete(const Transaction& transaction); |
Evan Stade | 1a8d9d4 | 2024-09-10 19:37:19 | [diff] [blame] | 35 | |
| 36 | private: |
| 37 | bool complete_ = false; |
| 38 | mojo::AssociatedRemote<blink::mojom::IDBDatabaseCallbacks> callbacks_; |
| 39 | }; |
| 40 | |
Evan Stade | cbb1e00 | 2024-09-13 20:06:57 | [diff] [blame] | 41 | } // namespace content::indexed_db |
Evan Stade | 1a8d9d4 | 2024-09-10 19:37:19 | [diff] [blame] | 42 | |
| 43 | #endif // CONTENT_BROWSER_INDEXED_DB_INSTANCE_DATABASE_CALLBACKS_H_ |