// Copyright 2013 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_SERVICES_STORAGE_INDEXED_DB_TRANSACTIONAL_LEVELDB_TRANSACTIONAL_LEVELDB_TRANSACTION_H_ #define COMPONENTS_SERVICES_STORAGE_INDEXED_DB_TRANSACTIONAL_LEVELDB_TRANSACTIONAL_LEVELDB_TRANSACTION_H_ #include <memory> #include <set> #include <string> #include <string_view> #include "base/containers/flat_set.h" #include "base/functional/callback.h" #include "base/gtest_prod_util.h" #include "base/memory/raw_ptr.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "components/services/storage/indexed_db/scopes/leveldb_scope_deletion_mode.h" #include "third_party/leveldatabase/src/include/leveldb/status.h" namespace content { class TransactionalLevelDBDatabase; class TransactionalLevelDBIterator; class LevelDBScope; class LevelDBWriteBatch; // Represents a transaction on top of a TransactionalLevelDBDatabase, and is // backed by a LevelDBScope. This class is not thread-safe. // Isolation: Read committed // All changes written using this transaction are readable through the Get() // method and iterators returned by CreateIterator(). They are NOT invisible // to other readers - if a key is written to using this transaction and read // from in a different transaction or on the database, it might read what was // written here. // Atomicity: // All changes in this transaction will be either fully written or fully // reverted. It uses the LevelDBScopes system to guarantee this. If this class // is destructed before Commit() is called, then it will be rolled back. // Destruction: // On destruction, if the transaction is not committed, it will be rolled // back. In a single-sequence scopes setup, this can actually tear down the // whole IndexedDBOriginState! So be careful when destroying this object. class TransactionalLevelDBTransaction : public base::RefCounted<TransactionalLevelDBTransaction> { … }; // Reads go straight to the database, ignoring any writes cached in // write_batch_. Writes are accumulated in a leveldb::WriteBatch and written on // |Commit()|. // TODO(dmurph): Remove this and have users just use the database and a // WriteBatch. class LevelDBDirectTransaction { … }; } // namespace content #endif // COMPONENTS_SERVICES_STORAGE_INDEXED_DB_TRANSACTIONAL_LEVELDB_TRANSACTIONAL_LEVELDB_TRANSACTION_H_