| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "core/dom/ExceptionCode.h" | 36 #include "core/dom/ExceptionCode.h" |
| 37 #include "core/dom/ExecutionContext.h" | 37 #include "core/dom/ExecutionContext.h" |
| 38 #include "modules/indexeddb/IDBAny.h" | 38 #include "modules/indexeddb/IDBAny.h" |
| 39 #include "modules/indexeddb/IDBCursorWithValue.h" | 39 #include "modules/indexeddb/IDBCursorWithValue.h" |
| 40 #include "modules/indexeddb/IDBDatabase.h" | 40 #include "modules/indexeddb/IDBDatabase.h" |
| 41 #include "modules/indexeddb/IDBKeyPath.h" | 41 #include "modules/indexeddb/IDBKeyPath.h" |
| 42 #include "modules/indexeddb/IDBTracing.h" | 42 #include "modules/indexeddb/IDBTracing.h" |
| 43 #include "platform/Histogram.h" | 43 #include "platform/Histogram.h" |
| 44 #include "platform/SharedBuffer.h" | 44 #include "platform/SharedBuffer.h" |
| 45 #include "platform/bindings/ScriptState.h" | 45 #include "platform/bindings/ScriptState.h" |
| 46 #include "platform/wtf/PtrUtil.h" |
| 46 #include "public/platform/WebBlobInfo.h" | 47 #include "public/platform/WebBlobInfo.h" |
| 47 #include "public/platform/WebData.h" | 48 #include "public/platform/WebData.h" |
| 48 #include "public/platform/WebVector.h" | 49 #include "public/platform/WebVector.h" |
| 49 #include "public/platform/modules/indexeddb/WebIDBKey.h" | 50 #include "public/platform/modules/indexeddb/WebIDBKey.h" |
| 50 #include "public/platform/modules/indexeddb/WebIDBKeyRange.h" | 51 #include "public/platform/modules/indexeddb/WebIDBKeyRange.h" |
| 51 #include "v8/include/v8.h" | 52 #include "v8/include/v8.h" |
| 52 | 53 |
| 53 using blink::WebBlobInfo; | 54 using blink::WebBlobInfo; |
| 54 using blink::WebIDBCallbacks; | 55 using blink::WebIDBCallbacks; |
| 55 using blink::WebIDBCursor; | 56 using blink::WebIDBCursor; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 DOMStringList* index_names = DOMStringList::Create(); | 121 DOMStringList* index_names = DOMStringList::Create(); |
| 121 for (const auto& it : Metadata().indexes) | 122 for (const auto& it : Metadata().indexes) |
| 122 index_names->Append(it.value->name); | 123 index_names->Append(it.value->name); |
| 123 index_names->Sort(); | 124 index_names->Sort(); |
| 124 return index_names; | 125 return index_names; |
| 125 } | 126 } |
| 126 | 127 |
| 127 IDBRequest* IDBObjectStore::get(ScriptState* script_state, | 128 IDBRequest* IDBObjectStore::get(ScriptState* script_state, |
| 128 const ScriptValue& key, | 129 const ScriptValue& key, |
| 129 ExceptionState& exception_state) { | 130 ExceptionState& exception_state) { |
| 130 IDB_TRACE("IDBObjectStore::get"); | 131 IDB_TRACE("IDBObjectStore::getCall"); |
| 132 IDBRequest::AsyncTraceState metrics("IDBObjectStore::get", this); |
| 131 if (IsDeleted()) { | 133 if (IsDeleted()) { |
| 132 exception_state.ThrowDOMException( | 134 exception_state.ThrowDOMException( |
| 133 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); | 135 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); |
| 134 return nullptr; | 136 return nullptr; |
| 135 } | 137 } |
| 136 if (!transaction_->IsActive()) { | 138 if (!transaction_->IsActive()) { |
| 137 exception_state.ThrowDOMException(kTransactionInactiveError, | 139 exception_state.ThrowDOMException(kTransactionInactiveError, |
| 138 transaction_->InactiveErrorMessage()); | 140 transaction_->InactiveErrorMessage()); |
| 139 return nullptr; | 141 return nullptr; |
| 140 } | 142 } |
| 141 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( | 143 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( |
| 142 ExecutionContext::From(script_state), key, exception_state); | 144 ExecutionContext::From(script_state), key, exception_state); |
| 143 if (exception_state.HadException()) | 145 if (exception_state.HadException()) |
| 144 return nullptr; | 146 return nullptr; |
| 145 if (!key_range) { | 147 if (!key_range) { |
| 146 exception_state.ThrowDOMException( | 148 exception_state.ThrowDOMException( |
| 147 kDataError, IDBDatabase::kNoKeyOrKeyRangeErrorMessage); | 149 kDataError, IDBDatabase::kNoKeyOrKeyRangeErrorMessage); |
| 148 return nullptr; | 150 return nullptr; |
| 149 } | 151 } |
| 150 if (!BackendDB()) { | 152 if (!BackendDB()) { |
| 151 exception_state.ThrowDOMException(kInvalidStateError, | 153 exception_state.ThrowDOMException(kInvalidStateError, |
| 152 IDBDatabase::kDatabaseClosedErrorMessage); | 154 IDBDatabase::kDatabaseClosedErrorMessage); |
| 153 return nullptr; | 155 return nullptr; |
| 154 } | 156 } |
| 155 | 157 |
| 156 IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this), | 158 IDBRequest* request = |
| 157 transaction_.Get()); | 159 IDBRequest::Create(script_state, IDBAny::Create(this), transaction_.Get(), |
| 160 std::move(metrics)); |
| 158 BackendDB()->Get(transaction_->Id(), Id(), IDBIndexMetadata::kInvalidId, | 161 BackendDB()->Get(transaction_->Id(), Id(), IDBIndexMetadata::kInvalidId, |
| 159 key_range, /*key_only=*/false, | 162 key_range, /*key_only=*/false, |
| 160 request->CreateWebCallbacks().release()); | 163 request->CreateWebCallbacks().release()); |
| 161 return request; | 164 return request; |
| 162 } | 165 } |
| 163 | 166 |
| 164 IDBRequest* IDBObjectStore::getKey(ScriptState* script_state, | 167 IDBRequest* IDBObjectStore::getKey(ScriptState* script_state, |
| 165 const ScriptValue& key, | 168 const ScriptValue& key, |
| 166 ExceptionState& exception_state) { | 169 ExceptionState& exception_state) { |
| 167 IDB_TRACE("IDBObjectStore::getKey"); | 170 IDB_TRACE("IDBObjectStore::getKeyCall"); |
| 171 IDBRequest::AsyncTraceState metrics("IDBObjectStore::getKey", this); |
| 168 if (IsDeleted()) { | 172 if (IsDeleted()) { |
| 169 exception_state.ThrowDOMException( | 173 exception_state.ThrowDOMException( |
| 170 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); | 174 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); |
| 171 return nullptr; | 175 return nullptr; |
| 172 } | 176 } |
| 173 if (!transaction_->IsActive()) { | 177 if (!transaction_->IsActive()) { |
| 174 exception_state.ThrowDOMException(kTransactionInactiveError, | 178 exception_state.ThrowDOMException(kTransactionInactiveError, |
| 175 transaction_->InactiveErrorMessage()); | 179 transaction_->InactiveErrorMessage()); |
| 176 return nullptr; | 180 return nullptr; |
| 177 } | 181 } |
| 178 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( | 182 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( |
| 179 ExecutionContext::From(script_state), key, exception_state); | 183 ExecutionContext::From(script_state), key, exception_state); |
| 180 if (exception_state.HadException()) | 184 if (exception_state.HadException()) |
| 181 return nullptr; | 185 return nullptr; |
| 182 if (!key_range) { | 186 if (!key_range) { |
| 183 exception_state.ThrowDOMException( | 187 exception_state.ThrowDOMException( |
| 184 kDataError, IDBDatabase::kNoKeyOrKeyRangeErrorMessage); | 188 kDataError, IDBDatabase::kNoKeyOrKeyRangeErrorMessage); |
| 185 return nullptr; | 189 return nullptr; |
| 186 } | 190 } |
| 187 if (!BackendDB()) { | 191 if (!BackendDB()) { |
| 188 exception_state.ThrowDOMException(kInvalidStateError, | 192 exception_state.ThrowDOMException(kInvalidStateError, |
| 189 IDBDatabase::kDatabaseClosedErrorMessage); | 193 IDBDatabase::kDatabaseClosedErrorMessage); |
| 190 return nullptr; | 194 return nullptr; |
| 191 } | 195 } |
| 192 | 196 |
| 193 IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this), | 197 IDBRequest* request = |
| 194 transaction_.Get()); | 198 IDBRequest::Create(script_state, IDBAny::Create(this), transaction_.Get(), |
| 199 std::move(metrics)); |
| 195 BackendDB()->Get(transaction_->Id(), Id(), IDBIndexMetadata::kInvalidId, | 200 BackendDB()->Get(transaction_->Id(), Id(), IDBIndexMetadata::kInvalidId, |
| 196 key_range, /*key_only=*/true, | 201 key_range, /*key_only=*/true, |
| 197 request->CreateWebCallbacks().release()); | 202 request->CreateWebCallbacks().release()); |
| 198 return request; | 203 return request; |
| 199 } | 204 } |
| 200 | 205 |
| 201 IDBRequest* IDBObjectStore::getAll(ScriptState* script_state, | 206 IDBRequest* IDBObjectStore::getAll(ScriptState* script_state, |
| 202 const ScriptValue& key_range, | 207 const ScriptValue& key_range, |
| 203 ExceptionState& exception_state) { | 208 ExceptionState& exception_state) { |
| 204 return getAll(script_state, key_range, std::numeric_limits<uint32_t>::max(), | 209 return getAll(script_state, key_range, std::numeric_limits<uint32_t>::max(), |
| 205 exception_state); | 210 exception_state); |
| 206 } | 211 } |
| 207 | 212 |
| 208 IDBRequest* IDBObjectStore::getAll(ScriptState* script_state, | 213 IDBRequest* IDBObjectStore::getAll(ScriptState* script_state, |
| 209 const ScriptValue& key_range, | 214 const ScriptValue& key_range, |
| 210 unsigned long max_count, | 215 unsigned long max_count, |
| 211 ExceptionState& exception_state) { | 216 ExceptionState& exception_state) { |
| 212 IDB_TRACE("IDBObjectStore::getAll"); | 217 IDB_TRACE("IDBObjectStore::getAllCall"); |
| 218 IDBRequest::AsyncTraceState metrics("IDBObjectStore::getAll", this); |
| 213 if (!max_count) | 219 if (!max_count) |
| 214 max_count = std::numeric_limits<uint32_t>::max(); | 220 max_count = std::numeric_limits<uint32_t>::max(); |
| 215 | 221 |
| 216 if (IsDeleted()) { | 222 if (IsDeleted()) { |
| 217 exception_state.ThrowDOMException( | 223 exception_state.ThrowDOMException( |
| 218 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); | 224 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); |
| 219 return nullptr; | 225 return nullptr; |
| 220 } | 226 } |
| 221 if (!transaction_->IsActive()) { | 227 if (!transaction_->IsActive()) { |
| 222 exception_state.ThrowDOMException(kTransactionInactiveError, | 228 exception_state.ThrowDOMException(kTransactionInactiveError, |
| 223 transaction_->InactiveErrorMessage()); | 229 transaction_->InactiveErrorMessage()); |
| 224 return nullptr; | 230 return nullptr; |
| 225 } | 231 } |
| 226 IDBKeyRange* range = IDBKeyRange::FromScriptValue( | 232 IDBKeyRange* range = IDBKeyRange::FromScriptValue( |
| 227 ExecutionContext::From(script_state), key_range, exception_state); | 233 ExecutionContext::From(script_state), key_range, exception_state); |
| 228 if (exception_state.HadException()) | 234 if (exception_state.HadException()) |
| 229 return nullptr; | 235 return nullptr; |
| 230 if (!BackendDB()) { | 236 if (!BackendDB()) { |
| 231 exception_state.ThrowDOMException(kInvalidStateError, | 237 exception_state.ThrowDOMException(kInvalidStateError, |
| 232 IDBDatabase::kDatabaseClosedErrorMessage); | 238 IDBDatabase::kDatabaseClosedErrorMessage); |
| 233 return nullptr; | 239 return nullptr; |
| 234 } | 240 } |
| 235 | 241 |
| 236 IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this), | 242 IDBRequest* request = |
| 237 transaction_.Get()); | 243 IDBRequest::Create(script_state, IDBAny::Create(this), transaction_.Get(), |
| 244 std::move(metrics)); |
| 238 BackendDB()->GetAll(transaction_->Id(), Id(), IDBIndexMetadata::kInvalidId, | 245 BackendDB()->GetAll(transaction_->Id(), Id(), IDBIndexMetadata::kInvalidId, |
| 239 range, max_count, false, | 246 range, max_count, false, |
| 240 request->CreateWebCallbacks().release()); | 247 request->CreateWebCallbacks().release()); |
| 241 return request; | 248 return request; |
| 242 } | 249 } |
| 243 | 250 |
| 244 IDBRequest* IDBObjectStore::getAllKeys(ScriptState* script_state, | 251 IDBRequest* IDBObjectStore::getAllKeys(ScriptState* script_state, |
| 245 const ScriptValue& key_range, | 252 const ScriptValue& key_range, |
| 246 ExceptionState& exception_state) { | 253 ExceptionState& exception_state) { |
| 247 return getAllKeys(script_state, key_range, | 254 return getAllKeys(script_state, key_range, |
| 248 std::numeric_limits<uint32_t>::max(), exception_state); | 255 std::numeric_limits<uint32_t>::max(), exception_state); |
| 249 } | 256 } |
| 250 | 257 |
| 251 IDBRequest* IDBObjectStore::getAllKeys(ScriptState* script_state, | 258 IDBRequest* IDBObjectStore::getAllKeys(ScriptState* script_state, |
| 252 const ScriptValue& key_range, | 259 const ScriptValue& key_range, |
| 253 unsigned long max_count, | 260 unsigned long max_count, |
| 254 ExceptionState& exception_state) { | 261 ExceptionState& exception_state) { |
| 255 IDB_TRACE("IDBObjectStore::getAll"); | 262 IDB_TRACE("IDBObjectStore::getAllKeysCall"); |
| 263 IDBRequest::AsyncTraceState metrics("IDBObjectStore::getAllKeys", this); |
| 256 if (!max_count) | 264 if (!max_count) |
| 257 max_count = std::numeric_limits<uint32_t>::max(); | 265 max_count = std::numeric_limits<uint32_t>::max(); |
| 258 | 266 |
| 259 if (IsDeleted()) { | 267 if (IsDeleted()) { |
| 260 exception_state.ThrowDOMException( | 268 exception_state.ThrowDOMException( |
| 261 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); | 269 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); |
| 262 return nullptr; | 270 return nullptr; |
| 263 } | 271 } |
| 264 if (!transaction_->IsActive()) { | 272 if (!transaction_->IsActive()) { |
| 265 exception_state.ThrowDOMException(kTransactionInactiveError, | 273 exception_state.ThrowDOMException(kTransactionInactiveError, |
| 266 transaction_->InactiveErrorMessage()); | 274 transaction_->InactiveErrorMessage()); |
| 267 return nullptr; | 275 return nullptr; |
| 268 } | 276 } |
| 269 IDBKeyRange* range = IDBKeyRange::FromScriptValue( | 277 IDBKeyRange* range = IDBKeyRange::FromScriptValue( |
| 270 ExecutionContext::From(script_state), key_range, exception_state); | 278 ExecutionContext::From(script_state), key_range, exception_state); |
| 271 if (exception_state.HadException()) | 279 if (exception_state.HadException()) |
| 272 return nullptr; | 280 return nullptr; |
| 273 if (!BackendDB()) { | 281 if (!BackendDB()) { |
| 274 exception_state.ThrowDOMException(kInvalidStateError, | 282 exception_state.ThrowDOMException(kInvalidStateError, |
| 275 IDBDatabase::kDatabaseClosedErrorMessage); | 283 IDBDatabase::kDatabaseClosedErrorMessage); |
| 276 return nullptr; | 284 return nullptr; |
| 277 } | 285 } |
| 278 | 286 |
| 279 IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this), | 287 IDBRequest* request = |
| 280 transaction_.Get()); | 288 IDBRequest::Create(script_state, IDBAny::Create(this), transaction_.Get(), |
| 289 std::move(metrics)); |
| 281 BackendDB()->GetAll(transaction_->Id(), Id(), IDBIndexMetadata::kInvalidId, | 290 BackendDB()->GetAll(transaction_->Id(), Id(), IDBIndexMetadata::kInvalidId, |
| 282 range, max_count, true, | 291 range, max_count, true, |
| 283 request->CreateWebCallbacks().release()); | 292 request->CreateWebCallbacks().release()); |
| 284 return request; | 293 return request; |
| 285 } | 294 } |
| 286 | 295 |
| 287 static void GenerateIndexKeysForValue(v8::Isolate* isolate, | 296 static void GenerateIndexKeysForValue(v8::Isolate* isolate, |
| 288 const IDBIndexMetadata& index_metadata, | 297 const IDBIndexMetadata& index_metadata, |
| 289 const ScriptValue& object_value, | 298 const ScriptValue& object_value, |
| 290 IndexKeys* index_keys) { | 299 IndexKeys* index_keys) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 316 for (const IDBKey* key : array) | 325 for (const IDBKey* key : array) |
| 317 key_type_histogram.Count(static_cast<int>(key->GetType())); | 326 key_type_histogram.Count(static_cast<int>(key->GetType())); |
| 318 index_keys->AppendVector(array); | 327 index_keys->AppendVector(array); |
| 319 } | 328 } |
| 320 } | 329 } |
| 321 | 330 |
| 322 IDBRequest* IDBObjectStore::add(ScriptState* script_state, | 331 IDBRequest* IDBObjectStore::add(ScriptState* script_state, |
| 323 const ScriptValue& value, | 332 const ScriptValue& value, |
| 324 const ScriptValue& key, | 333 const ScriptValue& key, |
| 325 ExceptionState& exception_state) { | 334 ExceptionState& exception_state) { |
| 326 IDB_TRACE("IDBObjectStore::add"); | 335 IDB_TRACE("IDBObjectStore::addCall"); |
| 327 return put(script_state, kWebIDBPutModeAddOnly, IDBAny::Create(this), value, | 336 return put(script_state, kWebIDBPutModeAddOnly, IDBAny::Create(this), value, |
| 328 key, exception_state); | 337 key, exception_state); |
| 329 } | 338 } |
| 330 | 339 |
| 331 IDBRequest* IDBObjectStore::put(ScriptState* script_state, | 340 IDBRequest* IDBObjectStore::put(ScriptState* script_state, |
| 332 const ScriptValue& value, | 341 const ScriptValue& value, |
| 333 const ScriptValue& key, | 342 const ScriptValue& key, |
| 334 ExceptionState& exception_state) { | 343 ExceptionState& exception_state) { |
| 335 IDB_TRACE("IDBObjectStore::put"); | 344 IDB_TRACE("IDBObjectStore::putCall"); |
| 336 return put(script_state, kWebIDBPutModeAddOrUpdate, IDBAny::Create(this), | 345 return put(script_state, kWebIDBPutModeAddOrUpdate, IDBAny::Create(this), |
| 337 value, key, exception_state); | 346 value, key, exception_state); |
| 338 } | 347 } |
| 339 | 348 |
| 340 IDBRequest* IDBObjectStore::put(ScriptState* script_state, | 349 IDBRequest* IDBObjectStore::put(ScriptState* script_state, |
| 341 WebIDBPutMode put_mode, | 350 WebIDBPutMode put_mode, |
| 342 IDBAny* source, | 351 IDBAny* source, |
| 343 const ScriptValue& value, | 352 const ScriptValue& value, |
| 344 const ScriptValue& key_value, | 353 const ScriptValue& key_value, |
| 345 ExceptionState& exception_state) { | 354 ExceptionState& exception_state) { |
| 346 IDBKey* key = key_value.IsUndefined() | 355 IDBKey* key = key_value.IsUndefined() |
| 347 ? nullptr | 356 ? nullptr |
| 348 : ScriptValue::To<IDBKey*>(script_state->GetIsolate(), | 357 : ScriptValue::To<IDBKey*>(script_state->GetIsolate(), |
| 349 key_value, exception_state); | 358 key_value, exception_state); |
| 350 if (exception_state.HadException()) | 359 if (exception_state.HadException()) |
| 351 return nullptr; | 360 return nullptr; |
| 352 return put(script_state, put_mode, source, value, key, exception_state); | 361 return put(script_state, put_mode, source, value, key, exception_state); |
| 353 } | 362 } |
| 354 | 363 |
| 355 IDBRequest* IDBObjectStore::put(ScriptState* script_state, | 364 IDBRequest* IDBObjectStore::put(ScriptState* script_state, |
| 356 WebIDBPutMode put_mode, | 365 WebIDBPutMode put_mode, |
| 357 IDBAny* source, | 366 IDBAny* source, |
| 358 const ScriptValue& value, | 367 const ScriptValue& value, |
| 359 IDBKey* key, | 368 IDBKey* key, |
| 360 ExceptionState& exception_state) { | 369 ExceptionState& exception_state) { |
| 370 const char* tracing_name = nullptr; |
| 371 switch (put_mode) { |
| 372 case kWebIDBPutModeAddOrUpdate: |
| 373 tracing_name = "IDBObjectStore::put"; |
| 374 break; |
| 375 case kWebIDBPutModeAddOnly: |
| 376 tracing_name = "IDBObjectStore::add"; |
| 377 break; |
| 378 case kWebIDBPutModeCursorUpdate: |
| 379 tracing_name = "IDBCursor::update"; |
| 380 break; |
| 381 } |
| 382 IDBRequest::AsyncTraceState metrics(tracing_name, this); |
| 361 if (IsDeleted()) { | 383 if (IsDeleted()) { |
| 362 exception_state.ThrowDOMException( | 384 exception_state.ThrowDOMException( |
| 363 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); | 385 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); |
| 364 return nullptr; | 386 return nullptr; |
| 365 } | 387 } |
| 366 if (!transaction_->IsActive()) { | 388 if (!transaction_->IsActive()) { |
| 367 exception_state.ThrowDOMException(kTransactionInactiveError, | 389 exception_state.ThrowDOMException(kTransactionInactiveError, |
| 368 transaction_->InactiveErrorMessage()); | 390 transaction_->InactiveErrorMessage()); |
| 369 return nullptr; | 391 return nullptr; |
| 370 } | 392 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 clone = DeserializeScriptValue(script_state, serialized_value.Get(), | 520 clone = DeserializeScriptValue(script_state, serialized_value.Get(), |
| 499 &blob_info); | 521 &blob_info); |
| 500 } | 522 } |
| 501 IndexKeys keys; | 523 IndexKeys keys; |
| 502 GenerateIndexKeysForValue(script_state->GetIsolate(), *it.value, clone, | 524 GenerateIndexKeysForValue(script_state->GetIsolate(), *it.value, clone, |
| 503 &keys); | 525 &keys); |
| 504 index_ids.push_back(it.key); | 526 index_ids.push_back(it.key); |
| 505 index_keys.push_back(keys); | 527 index_keys.push_back(keys); |
| 506 } | 528 } |
| 507 | 529 |
| 508 IDBRequest* request = | 530 IDBRequest* request = IDBRequest::Create( |
| 509 IDBRequest::Create(script_state, source, transaction_.Get()); | 531 script_state, source, transaction_.Get(), std::move(metrics)); |
| 510 Vector<char> wire_bytes; | 532 Vector<char> wire_bytes; |
| 511 serialized_value->ToWireBytes(wire_bytes); | 533 serialized_value->ToWireBytes(wire_bytes); |
| 512 RefPtr<SharedBuffer> value_buffer = SharedBuffer::AdoptVector(wire_bytes); | 534 RefPtr<SharedBuffer> value_buffer = SharedBuffer::AdoptVector(wire_bytes); |
| 513 | 535 |
| 514 request->StorePutOperationBlobs(serialized_value->BlobDataHandles()); | 536 request->StorePutOperationBlobs(serialized_value->BlobDataHandles()); |
| 515 | 537 |
| 516 BackendDB()->Put(transaction_->Id(), Id(), WebData(value_buffer), blob_info, | 538 BackendDB()->Put(transaction_->Id(), Id(), WebData(value_buffer), blob_info, |
| 517 key, static_cast<WebIDBPutMode>(put_mode), | 539 key, static_cast<WebIDBPutMode>(put_mode), |
| 518 request->CreateWebCallbacks().release(), index_ids, | 540 request->CreateWebCallbacks().release(), index_ids, |
| 519 index_keys); | 541 index_keys); |
| 520 return request; | 542 return request; |
| 521 } | 543 } |
| 522 | 544 |
| 523 IDBRequest* IDBObjectStore::deleteFunction(ScriptState* script_state, | 545 IDBRequest* IDBObjectStore::deleteFunction(ScriptState* script_state, |
| 524 const ScriptValue& key, | 546 const ScriptValue& key, |
| 525 ExceptionState& exception_state) { | 547 ExceptionState& exception_state) { |
| 526 IDB_TRACE("IDBObjectStore::delete"); | 548 IDB_TRACE("IDBObjectStore::deleteCall"); |
| 549 IDBRequest::AsyncTraceState metrics("IDBObjectStore::delete", this); |
| 527 if (IsDeleted()) { | 550 if (IsDeleted()) { |
| 528 exception_state.ThrowDOMException( | 551 exception_state.ThrowDOMException( |
| 529 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); | 552 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); |
| 530 return nullptr; | 553 return nullptr; |
| 531 } | 554 } |
| 532 if (!transaction_->IsActive()) { | 555 if (!transaction_->IsActive()) { |
| 533 exception_state.ThrowDOMException(kTransactionInactiveError, | 556 exception_state.ThrowDOMException(kTransactionInactiveError, |
| 534 transaction_->InactiveErrorMessage()); | 557 transaction_->InactiveErrorMessage()); |
| 535 return nullptr; | 558 return nullptr; |
| 536 } | 559 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 548 exception_state.ThrowDOMException( | 571 exception_state.ThrowDOMException( |
| 549 kDataError, IDBDatabase::kNoKeyOrKeyRangeErrorMessage); | 572 kDataError, IDBDatabase::kNoKeyOrKeyRangeErrorMessage); |
| 550 return nullptr; | 573 return nullptr; |
| 551 } | 574 } |
| 552 if (!BackendDB()) { | 575 if (!BackendDB()) { |
| 553 exception_state.ThrowDOMException(kInvalidStateError, | 576 exception_state.ThrowDOMException(kInvalidStateError, |
| 554 IDBDatabase::kDatabaseClosedErrorMessage); | 577 IDBDatabase::kDatabaseClosedErrorMessage); |
| 555 return nullptr; | 578 return nullptr; |
| 556 } | 579 } |
| 557 | 580 |
| 558 IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this), | 581 IDBRequest* request = |
| 559 transaction_.Get()); | 582 IDBRequest::Create(script_state, IDBAny::Create(this), transaction_.Get(), |
| 583 std::move(metrics)); |
| 560 BackendDB()->DeleteRange(transaction_->Id(), Id(), key_range, | 584 BackendDB()->DeleteRange(transaction_->Id(), Id(), key_range, |
| 561 request->CreateWebCallbacks().release()); | 585 request->CreateWebCallbacks().release()); |
| 562 return request; | 586 return request; |
| 563 } | 587 } |
| 564 | 588 |
| 565 IDBRequest* IDBObjectStore::clear(ScriptState* script_state, | 589 IDBRequest* IDBObjectStore::clear(ScriptState* script_state, |
| 566 ExceptionState& exception_state) { | 590 ExceptionState& exception_state) { |
| 567 IDB_TRACE("IDBObjectStore::clear"); | 591 IDB_TRACE("IDBObjectStore::clearCall"); |
| 592 IDBRequest::AsyncTraceState metrics("IDBObjectStore::clear", this); |
| 568 if (IsDeleted()) { | 593 if (IsDeleted()) { |
| 569 exception_state.ThrowDOMException( | 594 exception_state.ThrowDOMException( |
| 570 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); | 595 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); |
| 571 return nullptr; | 596 return nullptr; |
| 572 } | 597 } |
| 573 if (!transaction_->IsActive()) { | 598 if (!transaction_->IsActive()) { |
| 574 exception_state.ThrowDOMException(kTransactionInactiveError, | 599 exception_state.ThrowDOMException(kTransactionInactiveError, |
| 575 transaction_->InactiveErrorMessage()); | 600 transaction_->InactiveErrorMessage()); |
| 576 return nullptr; | 601 return nullptr; |
| 577 } | 602 } |
| 578 if (transaction_->IsReadOnly()) { | 603 if (transaction_->IsReadOnly()) { |
| 579 exception_state.ThrowDOMException( | 604 exception_state.ThrowDOMException( |
| 580 kReadOnlyError, IDBDatabase::kTransactionReadOnlyErrorMessage); | 605 kReadOnlyError, IDBDatabase::kTransactionReadOnlyErrorMessage); |
| 581 return nullptr; | 606 return nullptr; |
| 582 } | 607 } |
| 583 if (!BackendDB()) { | 608 if (!BackendDB()) { |
| 584 exception_state.ThrowDOMException(kInvalidStateError, | 609 exception_state.ThrowDOMException(kInvalidStateError, |
| 585 IDBDatabase::kDatabaseClosedErrorMessage); | 610 IDBDatabase::kDatabaseClosedErrorMessage); |
| 586 return nullptr; | 611 return nullptr; |
| 587 } | 612 } |
| 588 | 613 |
| 589 IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this), | 614 IDBRequest* request = |
| 590 transaction_.Get()); | 615 IDBRequest::Create(script_state, IDBAny::Create(this), transaction_.Get(), |
| 616 std::move(metrics)); |
| 591 BackendDB()->Clear(transaction_->Id(), Id(), | 617 BackendDB()->Clear(transaction_->Id(), Id(), |
| 592 request->CreateWebCallbacks().release()); | 618 request->CreateWebCallbacks().release()); |
| 593 return request; | 619 return request; |
| 594 } | 620 } |
| 595 | 621 |
| 596 namespace { | 622 namespace { |
| 597 // This class creates the index keys for a given index by extracting | 623 // This class creates the index keys for a given index by extracting |
| 598 // them from the SerializedScriptValue, for all the existing values in | 624 // them from the SerializedScriptValue, for all the existing values in |
| 599 // the object store. It only needs to be kept alive by virtue of being | 625 // the object store. It only needs to be kept alive by virtue of being |
| 600 // a listener on an IDBRequest object, in the same way that JavaScript | 626 // a listener on an IDBRequest object, in the same way that JavaScript |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 object_store_id_(object_store_id), | 658 object_store_id_(object_store_id), |
| 633 index_metadata_(std::move(index_metadata)) { | 659 index_metadata_(std::move(index_metadata)) { |
| 634 DCHECK(index_metadata_.Get()); | 660 DCHECK(index_metadata_.Get()); |
| 635 } | 661 } |
| 636 | 662 |
| 637 const IDBIndexMetadata& IndexMetadata() const { return *index_metadata_; } | 663 const IDBIndexMetadata& IndexMetadata() const { return *index_metadata_; } |
| 638 | 664 |
| 639 void handleEvent(ExecutionContext* execution_context, Event* event) override { | 665 void handleEvent(ExecutionContext* execution_context, Event* event) override { |
| 640 if (!script_state_->ContextIsValid()) | 666 if (!script_state_->ContextIsValid()) |
| 641 return; | 667 return; |
| 668 IDB_TRACE("IDBObjectStore::IndexPopulator::handleEvent"); |
| 642 | 669 |
| 643 DCHECK_EQ(ExecutionContext::From(script_state_.Get()), execution_context); | 670 DCHECK_EQ(ExecutionContext::From(script_state_.Get()), execution_context); |
| 644 DCHECK_EQ(event->type(), EventTypeNames::success); | 671 DCHECK_EQ(event->type(), EventTypeNames::success); |
| 645 EventTarget* target = event->target(); | 672 EventTarget* target = event->target(); |
| 646 IDBRequest* request = static_cast<IDBRequest*>(target); | 673 IDBRequest* request = static_cast<IDBRequest*>(target); |
| 647 | 674 |
| 648 if (!database_->Backend()) // If database is stopped? | 675 if (!database_->Backend()) // If database is stopped? |
| 649 return; | 676 return; |
| 650 | 677 |
| 651 ScriptState::Scope scope(script_state_.Get()); | 678 ScriptState::Scope scope(script_state_.Get()); |
| 652 | 679 |
| 653 IDBAny* cursor_any = request->ResultAsAny(); | 680 IDBAny* cursor_any = request->ResultAsAny(); |
| 654 IDBCursorWithValue* cursor = nullptr; | 681 IDBCursorWithValue* cursor = nullptr; |
| 655 if (cursor_any->GetType() == IDBAny::kIDBCursorWithValueType) | 682 if (cursor_any->GetType() == IDBAny::kIDBCursorWithValueType) |
| 656 cursor = cursor_any->IdbCursorWithValue(); | 683 cursor = cursor_any->IdbCursorWithValue(); |
| 657 | 684 |
| 658 Vector<int64_t> index_ids; | 685 Vector<int64_t> index_ids; |
| 659 index_ids.push_back(IndexMetadata().id); | 686 index_ids.push_back(IndexMetadata().id); |
| 660 if (cursor && !cursor->IsDeleted()) { | 687 if (cursor && !cursor->IsDeleted()) { |
| 661 cursor->Continue(nullptr, nullptr, ASSERT_NO_EXCEPTION); | 688 cursor->Continue( |
| 689 nullptr, nullptr, ASSERT_NO_EXCEPTION, |
| 690 IDBRequest::AsyncTraceState("IDBCursor::continue", this)); |
| 662 | 691 |
| 663 IDBKey* primary_key = cursor->IdbPrimaryKey(); | 692 IDBKey* primary_key = cursor->IdbPrimaryKey(); |
| 664 ScriptValue value = cursor->value(script_state_.Get()); | 693 ScriptValue value = cursor->value(script_state_.Get()); |
| 665 | 694 |
| 666 IndexKeys index_keys; | 695 IndexKeys index_keys; |
| 667 GenerateIndexKeysForValue(script_state_->GetIsolate(), IndexMetadata(), | 696 GenerateIndexKeysForValue(script_state_->GetIsolate(), IndexMetadata(), |
| 668 value, &index_keys); | 697 value, &index_keys); |
| 669 | 698 |
| 670 HeapVector<IndexKeys> index_keys_list; | 699 HeapVector<IndexKeys> index_keys_list; |
| 671 index_keys_list.push_back(index_keys); | 700 index_keys_list.push_back(index_keys); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 688 const int64_t object_store_id_; | 717 const int64_t object_store_id_; |
| 689 RefPtr<const IDBIndexMetadata> index_metadata_; | 718 RefPtr<const IDBIndexMetadata> index_metadata_; |
| 690 }; | 719 }; |
| 691 } // namespace | 720 } // namespace |
| 692 | 721 |
| 693 IDBIndex* IDBObjectStore::createIndex(ScriptState* script_state, | 722 IDBIndex* IDBObjectStore::createIndex(ScriptState* script_state, |
| 694 const String& name, | 723 const String& name, |
| 695 const IDBKeyPath& key_path, | 724 const IDBKeyPath& key_path, |
| 696 const IDBIndexParameters& options, | 725 const IDBIndexParameters& options, |
| 697 ExceptionState& exception_state) { | 726 ExceptionState& exception_state) { |
| 698 IDB_TRACE("IDBObjectStore::createIndex"); | 727 IDB_TRACE("IDBObjectStore::createIndexCall"); |
| 728 IDBRequest::AsyncTraceState metrics("IDBObjectStore::createIndex", this); |
| 699 if (!transaction_->IsVersionChange()) { | 729 if (!transaction_->IsVersionChange()) { |
| 700 exception_state.ThrowDOMException( | 730 exception_state.ThrowDOMException( |
| 701 kInvalidStateError, | 731 kInvalidStateError, |
| 702 IDBDatabase::kNotVersionChangeTransactionErrorMessage); | 732 IDBDatabase::kNotVersionChangeTransactionErrorMessage); |
| 703 return nullptr; | 733 return nullptr; |
| 704 } | 734 } |
| 705 if (IsDeleted()) { | 735 if (IsDeleted()) { |
| 706 exception_state.ThrowDOMException( | 736 exception_state.ThrowDOMException( |
| 707 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); | 737 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); |
| 708 return nullptr; | 738 return nullptr; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 IDBIndex* index = IDBIndex::Create(index_metadata, this, transaction_.Get()); | 776 IDBIndex* index = IDBIndex::Create(index_metadata, this, transaction_.Get()); |
| 747 index_map_.Set(name, index); | 777 index_map_.Set(name, index); |
| 748 metadata_->indexes.Set(index_id, index_metadata); | 778 metadata_->indexes.Set(index_id, index_metadata); |
| 749 | 779 |
| 750 DCHECK(!exception_state.HadException()); | 780 DCHECK(!exception_state.HadException()); |
| 751 if (exception_state.HadException()) | 781 if (exception_state.HadException()) |
| 752 return nullptr; | 782 return nullptr; |
| 753 | 783 |
| 754 IDBRequest* index_request = | 784 IDBRequest* index_request = |
| 755 openCursor(script_state, nullptr, kWebIDBCursorDirectionNext, | 785 openCursor(script_state, nullptr, kWebIDBCursorDirectionNext, |
| 756 kWebIDBTaskTypePreemptive); | 786 kWebIDBTaskTypePreemptive, std::move(metrics)); |
| 757 index_request->PreventPropagation(); | 787 index_request->PreventPropagation(); |
| 758 | 788 |
| 759 // This is kept alive by being the success handler of the request, which is in | 789 // This is kept alive by being the success handler of the request, which is in |
| 760 // turn kept alive by the owning transaction. | 790 // turn kept alive by the owning transaction. |
| 761 IndexPopulator* index_populator = IndexPopulator::Create( | 791 IndexPopulator* index_populator = IndexPopulator::Create( |
| 762 script_state, transaction()->db(), transaction_->Id(), Id(), | 792 script_state, transaction()->db(), transaction_->Id(), Id(), |
| 763 std::move(index_metadata)); | 793 std::move(index_metadata)); |
| 764 index_request->setOnsuccess(index_populator); | 794 index_request->setOnsuccess(index_populator); |
| 765 return index; | 795 return index; |
| 766 } | 796 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 transaction_->IndexDeleted(it->value); | 868 transaction_->IndexDeleted(it->value); |
| 839 it->value->MarkDeleted(); | 869 it->value->MarkDeleted(); |
| 840 index_map_.erase(name); | 870 index_map_.erase(name); |
| 841 } | 871 } |
| 842 } | 872 } |
| 843 | 873 |
| 844 IDBRequest* IDBObjectStore::openCursor(ScriptState* script_state, | 874 IDBRequest* IDBObjectStore::openCursor(ScriptState* script_state, |
| 845 const ScriptValue& range, | 875 const ScriptValue& range, |
| 846 const String& direction_string, | 876 const String& direction_string, |
| 847 ExceptionState& exception_state) { | 877 ExceptionState& exception_state) { |
| 848 IDB_TRACE("IDBObjectStore::openCursor"); | 878 IDB_TRACE("IDBObjectStore::openCursorCall"); |
| 879 IDBRequest::AsyncTraceState metrics("IDBObjectStore::openCursor", this); |
| 849 if (IsDeleted()) { | 880 if (IsDeleted()) { |
| 850 exception_state.ThrowDOMException( | 881 exception_state.ThrowDOMException( |
| 851 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); | 882 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); |
| 852 return nullptr; | 883 return nullptr; |
| 853 } | 884 } |
| 854 if (!transaction_->IsActive()) { | 885 if (!transaction_->IsActive()) { |
| 855 exception_state.ThrowDOMException(kTransactionInactiveError, | 886 exception_state.ThrowDOMException(kTransactionInactiveError, |
| 856 transaction_->InactiveErrorMessage()); | 887 transaction_->InactiveErrorMessage()); |
| 857 return nullptr; | 888 return nullptr; |
| 858 } | 889 } |
| 859 | 890 |
| 860 WebIDBCursorDirection direction = | 891 WebIDBCursorDirection direction = |
| 861 IDBCursor::StringToDirection(direction_string); | 892 IDBCursor::StringToDirection(direction_string); |
| 862 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( | 893 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( |
| 863 ExecutionContext::From(script_state), range, exception_state); | 894 ExecutionContext::From(script_state), range, exception_state); |
| 864 if (exception_state.HadException()) | 895 if (exception_state.HadException()) |
| 865 return nullptr; | 896 return nullptr; |
| 866 | 897 |
| 867 if (!BackendDB()) { | 898 if (!BackendDB()) { |
| 868 exception_state.ThrowDOMException(kInvalidStateError, | 899 exception_state.ThrowDOMException(kInvalidStateError, |
| 869 IDBDatabase::kDatabaseClosedErrorMessage); | 900 IDBDatabase::kDatabaseClosedErrorMessage); |
| 870 return nullptr; | 901 return nullptr; |
| 871 } | 902 } |
| 872 | 903 |
| 873 return openCursor(script_state, key_range, direction, kWebIDBTaskTypeNormal); | 904 return openCursor(script_state, key_range, direction, kWebIDBTaskTypeNormal, |
| 905 std::move(metrics)); |
| 874 } | 906 } |
| 875 | 907 |
| 876 IDBRequest* IDBObjectStore::openCursor(ScriptState* script_state, | 908 IDBRequest* IDBObjectStore::openCursor(ScriptState* script_state, |
| 877 IDBKeyRange* range, | 909 IDBKeyRange* range, |
| 878 WebIDBCursorDirection direction, | 910 WebIDBCursorDirection direction, |
| 879 WebIDBTaskType task_type) { | 911 WebIDBTaskType task_type, |
| 880 IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this), | 912 IDBRequest::AsyncTraceState metrics) { |
| 881 transaction_.Get()); | 913 IDBRequest* request = |
| 914 IDBRequest::Create(script_state, IDBAny::Create(this), transaction_.Get(), |
| 915 std::move(metrics)); |
| 882 request->SetCursorDetails(IndexedDB::kCursorKeyAndValue, direction); | 916 request->SetCursorDetails(IndexedDB::kCursorKeyAndValue, direction); |
| 883 | 917 |
| 884 BackendDB()->OpenCursor(transaction_->Id(), Id(), | 918 BackendDB()->OpenCursor(transaction_->Id(), Id(), |
| 885 IDBIndexMetadata::kInvalidId, range, direction, false, | 919 IDBIndexMetadata::kInvalidId, range, direction, false, |
| 886 task_type, request->CreateWebCallbacks().release()); | 920 task_type, request->CreateWebCallbacks().release()); |
| 887 return request; | 921 return request; |
| 888 } | 922 } |
| 889 | 923 |
| 890 IDBRequest* IDBObjectStore::openKeyCursor(ScriptState* script_state, | 924 IDBRequest* IDBObjectStore::openKeyCursor(ScriptState* script_state, |
| 891 const ScriptValue& range, | 925 const ScriptValue& range, |
| 892 const String& direction_string, | 926 const String& direction_string, |
| 893 ExceptionState& exception_state) { | 927 ExceptionState& exception_state) { |
| 894 IDB_TRACE("IDBObjectStore::openKeyCursor"); | 928 IDB_TRACE("IDBObjectStore::openKeyCursorCall"); |
| 929 IDBRequest::AsyncTraceState metrics("IDBObjectStore::openKeyCursor", this); |
| 895 if (IsDeleted()) { | 930 if (IsDeleted()) { |
| 896 exception_state.ThrowDOMException( | 931 exception_state.ThrowDOMException( |
| 897 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); | 932 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); |
| 898 return nullptr; | 933 return nullptr; |
| 899 } | 934 } |
| 900 if (!transaction_->IsActive()) { | 935 if (!transaction_->IsActive()) { |
| 901 exception_state.ThrowDOMException(kTransactionInactiveError, | 936 exception_state.ThrowDOMException(kTransactionInactiveError, |
| 902 transaction_->InactiveErrorMessage()); | 937 transaction_->InactiveErrorMessage()); |
| 903 return nullptr; | 938 return nullptr; |
| 904 } | 939 } |
| 905 | 940 |
| 906 WebIDBCursorDirection direction = | 941 WebIDBCursorDirection direction = |
| 907 IDBCursor::StringToDirection(direction_string); | 942 IDBCursor::StringToDirection(direction_string); |
| 908 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( | 943 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( |
| 909 ExecutionContext::From(script_state), range, exception_state); | 944 ExecutionContext::From(script_state), range, exception_state); |
| 910 if (exception_state.HadException()) | 945 if (exception_state.HadException()) |
| 911 return nullptr; | 946 return nullptr; |
| 912 | 947 |
| 913 if (!BackendDB()) { | 948 if (!BackendDB()) { |
| 914 exception_state.ThrowDOMException(kInvalidStateError, | 949 exception_state.ThrowDOMException(kInvalidStateError, |
| 915 IDBDatabase::kDatabaseClosedErrorMessage); | 950 IDBDatabase::kDatabaseClosedErrorMessage); |
| 916 return nullptr; | 951 return nullptr; |
| 917 } | 952 } |
| 918 | 953 |
| 919 IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this), | 954 IDBRequest* request = |
| 920 transaction_.Get()); | 955 IDBRequest::Create(script_state, IDBAny::Create(this), transaction_.Get(), |
| 956 std::move(metrics)); |
| 921 request->SetCursorDetails(IndexedDB::kCursorKeyOnly, direction); | 957 request->SetCursorDetails(IndexedDB::kCursorKeyOnly, direction); |
| 922 | 958 |
| 923 BackendDB()->OpenCursor(transaction_->Id(), Id(), | 959 BackendDB()->OpenCursor(transaction_->Id(), Id(), |
| 924 IDBIndexMetadata::kInvalidId, key_range, direction, | 960 IDBIndexMetadata::kInvalidId, key_range, direction, |
| 925 true, kWebIDBTaskTypeNormal, | 961 true, kWebIDBTaskTypeNormal, |
| 926 request->CreateWebCallbacks().release()); | 962 request->CreateWebCallbacks().release()); |
| 927 return request; | 963 return request; |
| 928 } | 964 } |
| 929 | 965 |
| 930 IDBRequest* IDBObjectStore::count(ScriptState* script_state, | 966 IDBRequest* IDBObjectStore::count(ScriptState* script_state, |
| 931 const ScriptValue& range, | 967 const ScriptValue& range, |
| 932 ExceptionState& exception_state) { | 968 ExceptionState& exception_state) { |
| 933 IDB_TRACE("IDBObjectStore::count"); | 969 IDB_TRACE("IDBObjectStore::countCall"); |
| 970 IDBRequest::AsyncTraceState metrics("IDBObjectStore::count", this); |
| 934 if (IsDeleted()) { | 971 if (IsDeleted()) { |
| 935 exception_state.ThrowDOMException( | 972 exception_state.ThrowDOMException( |
| 936 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); | 973 kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage); |
| 937 return nullptr; | 974 return nullptr; |
| 938 } | 975 } |
| 939 if (!transaction_->IsActive()) { | 976 if (!transaction_->IsActive()) { |
| 940 exception_state.ThrowDOMException(kTransactionInactiveError, | 977 exception_state.ThrowDOMException(kTransactionInactiveError, |
| 941 transaction_->InactiveErrorMessage()); | 978 transaction_->InactiveErrorMessage()); |
| 942 return nullptr; | 979 return nullptr; |
| 943 } | 980 } |
| 944 | 981 |
| 945 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( | 982 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( |
| 946 ExecutionContext::From(script_state), range, exception_state); | 983 ExecutionContext::From(script_state), range, exception_state); |
| 947 if (exception_state.HadException()) | 984 if (exception_state.HadException()) |
| 948 return nullptr; | 985 return nullptr; |
| 949 | 986 |
| 950 if (!BackendDB()) { | 987 if (!BackendDB()) { |
| 951 exception_state.ThrowDOMException(kInvalidStateError, | 988 exception_state.ThrowDOMException(kInvalidStateError, |
| 952 IDBDatabase::kDatabaseClosedErrorMessage); | 989 IDBDatabase::kDatabaseClosedErrorMessage); |
| 953 return nullptr; | 990 return nullptr; |
| 954 } | 991 } |
| 955 | 992 |
| 956 IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this), | 993 IDBRequest* request = |
| 957 transaction_.Get()); | 994 IDBRequest::Create(script_state, IDBAny::Create(this), transaction_.Get(), |
| 995 std::move(metrics)); |
| 958 BackendDB()->Count(transaction_->Id(), Id(), IDBIndexMetadata::kInvalidId, | 996 BackendDB()->Count(transaction_->Id(), Id(), IDBIndexMetadata::kInvalidId, |
| 959 key_range, request->CreateWebCallbacks().release()); | 997 key_range, request->CreateWebCallbacks().release()); |
| 960 return request; | 998 return request; |
| 961 } | 999 } |
| 962 | 1000 |
| 963 void IDBObjectStore::MarkDeleted() { | 1001 void IDBObjectStore::MarkDeleted() { |
| 964 DCHECK(transaction_->IsVersionChange()) | 1002 DCHECK(transaction_->IsVersionChange()) |
| 965 << "An object store got deleted outside a versionchange transaction."; | 1003 << "An object store got deleted outside a versionchange transaction."; |
| 966 | 1004 |
| 967 deleted_ = true; | 1005 deleted_ = true; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 } | 1097 } |
| 1060 } | 1098 } |
| 1061 return IDBIndexMetadata::kInvalidId; | 1099 return IDBIndexMetadata::kInvalidId; |
| 1062 } | 1100 } |
| 1063 | 1101 |
| 1064 WebIDBDatabase* IDBObjectStore::BackendDB() const { | 1102 WebIDBDatabase* IDBObjectStore::BackendDB() const { |
| 1065 return transaction_->BackendDB(); | 1103 return transaction_->BackendDB(); |
| 1066 } | 1104 } |
| 1067 | 1105 |
| 1068 } // namespace blink | 1106 } // namespace blink |
| OLD | NEW |