30 const std::string&
name, int64_t version,
31 const std::vector<std::string>& store_names)
33 object_store_names(new dom::DOMStringList(store_names)),
35 connection_(connection) {
42 IDBDatabase::~IDBDatabase() {}
48 tracer->
Trace(&version_change_trans_);
56 if (!version_change_trans_)
60 if (!version_change_trans_->active ||
61 !version_change_trans_->sqlite_transaction) {
68 if (!parameters || !parameters->keyPath.empty() || !parameters->autoIncrement)
85 version_change_trans_->sqlite_transaction->CreateObjectStore(
db_name,
90 version_change_trans_->AddObjectStore(name);
100 if (!version_change_trans_)
104 if (!version_change_trans_->active ||
105 !version_change_trans_->sqlite_transaction) {
119 version_change_trans_->sqlite_transaction->DeleteObjectStore(
db_name,
124 version_change_trans_->DeleteObjectStore(name);
130 variant<std::string, std::vector<std::string>> store_names,
136 if (version_change_trans_ || close_pending_)
141 std::vector<std::string> scope;
142 if (holds_alternative<std::string>(store_names))
143 scope.emplace_back(get<std::string>(store_names));
145 scope = get<std::vector<std::string>>(store_names);
149 for (
const std::string&
name : scope) {
163 "Transaction mode must be 'readonly' or 'readwrite'");
171 std::shared_ptr<SqliteConnection> connection = connection_;
174 [ret, connection]() { ret->DoCommit(connection.get()); });
180 if (!close_pending_) {
181 close_pending_ =
true;
ExceptionOr< RefPtr< IDBObjectStore > > CreateObjectStore(const std::string &name, optional< IDBObjectStoreParameters > parameters)
ExceptionOr< void > DeleteObjectStore(const std::string &name)
DEFINE_STRUCT_SPECIAL_METHODS_COPYABLE(IDBObjectStoreParameters)
void Trace(const Traceable *ptr)
Member< dom::DOMStringList > object_store_names
IDBDatabase(std::shared_ptr< SqliteConnection > connection, const std::string &name, int64_t version, const std::vector< std::string > &store_names)
static JsManagerImpl * Instance()
void Trace(memory::HeapTracer *tracer) const override
void RemoveElement(List *list, Elem &&elem)
ExceptionOr< RefPtr< IDBTransaction > > Transaction(variant< std::string, std::vector< std::string >> store_names, optional< IDBTransactionMode > mode)
T value_or(U &&default_value) const &
const std::string db_name
std::shared_ptr< ThreadEvent< impl::RetOf< Func > > > AddInternalTask(TaskPriority priority, const std::string &name, Func &&callback)
static JsError TypeError(const std::string &message)
static JsError DOMException(ExceptionCode code)
Listener on_version_change
void Trace(memory::HeapTracer *tracer) const override
void AddListenerField(EventType type, Listener *on_field)
TaskRunner * MainThread()