34 ExceptionOr<Any> ReadAndLoad(SqliteTransaction* transaction,
35 const std::string& db_name,
37 bool allow_not_found) {
38 std::vector<uint8_t> data;
40 transaction->GetData(db_name, store_name, key, &data);
50 if (!proto.ParseFromArray(data.data(), data.size())) {
52 "Invalid data stored in database");
71 ReadAndLoad(transaction, db->db_name, store->store_name, key_,
73 if (holds_alternative<JsError>(data))
84 value_(
std::move(value)),
86 no_override_(no_override) {}
95 std::vector<uint8_t> ignored;
96 status = transaction->
GetData(db->db_name, store->store_name, key_.
value(),
109 if (!value_.SerializeToString(&data))
111 std::vector<uint8_t> data_vec(data.begin(), data.end());
114 status = transaction->
UpdateData(db->db_name, store->store_name,
115 key_.
value(), data_vec);
118 transaction->
AddData(db->db_name, store->store_name, data_vec, &key);
137 transaction->
DeleteData(db->db_name, store->store_name, key_);
153 tracer->
Trace(&cursor_);
163 for (uint32_t i = 0; i <
count; i++) {
166 db->db_name, store->store_name, position, ascending, &new_key);
169 cursor_->value =
Any();
179 ReadAndLoad(transaction, db->db_name, store->store_name, position.
value(),
181 if (holds_alternative<JsError>(data))
184 cursor_->key = position;
185 cursor_->value = get<Any>(data);
186 cursor_->got_value =
true;
DatabaseStatus DeleteData(const std::string &db_name, const std::string &store_name, int64_t key)
Any LoadFromProto(const proto::Value &value)
IDBStoreRequest(optional< variant< Member< IDBObjectStore >, Member< IDBCursor >>> source, RefPtr< IDBTransaction > transaction, proto::Value value, optional< IdbKeyType > key, bool no_override)
IDBIterateCursorRequest(optional< variant< Member< IDBObjectStore >, Member< IDBCursor >>> source, RefPtr< IDBTransaction > transaction, RefPtr< IDBCursor > cursor, uint32_t count)
void Trace(memory::HeapTracer *tracer) const override
IDBDeleteRequest(optional< variant< Member< IDBObjectStore >, Member< IDBCursor >>> source, RefPtr< IDBTransaction > transaction, IdbKeyType key)
void PerformOperation(SqliteTransaction *transaction) override
DatabaseStatus GetData(const std::string &db_name, const std::string &store_name, int64_t key, std::vector< uint8_t > *data)
DatabaseStatus AddData(const std::string &db_name, const std::string &store_name, const std::vector< uint8_t > &data, int64_t *key)
DatabaseStatus UpdateData(const std::string &db_name, const std::string &store_name, int64_t key, const std::vector< uint8_t > &data)
optional< variant< Member< IDBObjectStore >, Member< IDBCursor > > > source
const T & value() const &
~IDBGetRequest() override
~IDBStoreRequest() override
void CompleteError(JsError error)
void Trace(memory::HeapTracer *tracer) const override
void PerformOperation(SqliteTransaction *transaction) override
void Trace(const Traceable *ptr)
void CompleteSuccess(Any result)
T value_or(U &&default_value) const &
DatabaseStatus FindData(const std::string &db_name, const std::string &store_name, optional< int64_t > key, bool ascending, int64_t *found_key)
void PerformOperation(SqliteTransaction *transaction) override
~IDBIterateCursorRequest() override
static JsError DOMException(ExceptionCode code)
~IDBDeleteRequest() override
void PerformOperation(SqliteTransaction *transaction) override
IDBGetRequest(optional< variant< Member< IDBObjectStore >, Member< IDBCursor >>> source, RefPtr< IDBTransaction > transaction, IdbKeyType key)