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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 IDBDatabase::kTransactionFinishedErrorMessage); | 146 IDBDatabase::kTransactionFinishedErrorMessage); |
147 return nullptr; | 147 return nullptr; |
148 } | 148 } |
149 if (!transaction_->IsActive()) { | 149 if (!transaction_->IsActive()) { |
150 exception_state.ThrowDOMException( | 150 exception_state.ThrowDOMException( |
151 kTransactionInactiveError, | 151 kTransactionInactiveError, |
152 IDBDatabase::kTransactionInactiveErrorMessage); | 152 IDBDatabase::kTransactionInactiveErrorMessage); |
153 return nullptr; | 153 return nullptr; |
154 } | 154 } |
155 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( | 155 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( |
156 script_state->GetExecutionContext(), key, exception_state); | 156 ExecutionContext::From(script_state), key, exception_state); |
157 if (exception_state.HadException()) | 157 if (exception_state.HadException()) |
158 return nullptr; | 158 return nullptr; |
159 if (!key_range) { | 159 if (!key_range) { |
160 exception_state.ThrowDOMException( | 160 exception_state.ThrowDOMException( |
161 kDataError, IDBDatabase::kNoKeyOrKeyRangeErrorMessage); | 161 kDataError, IDBDatabase::kNoKeyOrKeyRangeErrorMessage); |
162 return nullptr; | 162 return nullptr; |
163 } | 163 } |
164 if (!BackendDB()) { | 164 if (!BackendDB()) { |
165 exception_state.ThrowDOMException(kInvalidStateError, | 165 exception_state.ThrowDOMException(kInvalidStateError, |
166 IDBDatabase::kDatabaseClosedErrorMessage); | 166 IDBDatabase::kDatabaseClosedErrorMessage); |
(...skipping 23 matching lines...) Expand all Loading... |
190 IDBDatabase::kTransactionFinishedErrorMessage); | 190 IDBDatabase::kTransactionFinishedErrorMessage); |
191 return nullptr; | 191 return nullptr; |
192 } | 192 } |
193 if (!transaction_->IsActive()) { | 193 if (!transaction_->IsActive()) { |
194 exception_state.ThrowDOMException( | 194 exception_state.ThrowDOMException( |
195 kTransactionInactiveError, | 195 kTransactionInactiveError, |
196 IDBDatabase::kTransactionInactiveErrorMessage); | 196 IDBDatabase::kTransactionInactiveErrorMessage); |
197 return nullptr; | 197 return nullptr; |
198 } | 198 } |
199 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( | 199 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( |
200 script_state->GetExecutionContext(), key, exception_state); | 200 ExecutionContext::From(script_state), key, exception_state); |
201 if (exception_state.HadException()) | 201 if (exception_state.HadException()) |
202 return nullptr; | 202 return nullptr; |
203 if (!key_range) { | 203 if (!key_range) { |
204 exception_state.ThrowDOMException( | 204 exception_state.ThrowDOMException( |
205 kDataError, IDBDatabase::kNoKeyOrKeyRangeErrorMessage); | 205 kDataError, IDBDatabase::kNoKeyOrKeyRangeErrorMessage); |
206 return nullptr; | 206 return nullptr; |
207 } | 207 } |
208 if (!BackendDB()) { | 208 if (!BackendDB()) { |
209 exception_state.ThrowDOMException(kInvalidStateError, | 209 exception_state.ThrowDOMException(kInvalidStateError, |
210 IDBDatabase::kDatabaseClosedErrorMessage); | 210 IDBDatabase::kDatabaseClosedErrorMessage); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 IDBDatabase::kTransactionFinishedErrorMessage); | 245 IDBDatabase::kTransactionFinishedErrorMessage); |
246 return nullptr; | 246 return nullptr; |
247 } | 247 } |
248 if (!transaction_->IsActive()) { | 248 if (!transaction_->IsActive()) { |
249 exception_state.ThrowDOMException( | 249 exception_state.ThrowDOMException( |
250 kTransactionInactiveError, | 250 kTransactionInactiveError, |
251 IDBDatabase::kTransactionInactiveErrorMessage); | 251 IDBDatabase::kTransactionInactiveErrorMessage); |
252 return nullptr; | 252 return nullptr; |
253 } | 253 } |
254 IDBKeyRange* range = IDBKeyRange::FromScriptValue( | 254 IDBKeyRange* range = IDBKeyRange::FromScriptValue( |
255 script_state->GetExecutionContext(), key_range, exception_state); | 255 ExecutionContext::From(script_state), key_range, exception_state); |
256 if (exception_state.HadException()) | 256 if (exception_state.HadException()) |
257 return nullptr; | 257 return nullptr; |
258 if (!BackendDB()) { | 258 if (!BackendDB()) { |
259 exception_state.ThrowDOMException(kInvalidStateError, | 259 exception_state.ThrowDOMException(kInvalidStateError, |
260 IDBDatabase::kDatabaseClosedErrorMessage); | 260 IDBDatabase::kDatabaseClosedErrorMessage); |
261 return nullptr; | 261 return nullptr; |
262 } | 262 } |
263 | 263 |
264 IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this), | 264 IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this), |
265 transaction_.Get()); | 265 transaction_.Get()); |
(...skipping 29 matching lines...) Expand all Loading... |
295 IDBDatabase::kTransactionFinishedErrorMessage); | 295 IDBDatabase::kTransactionFinishedErrorMessage); |
296 return nullptr; | 296 return nullptr; |
297 } | 297 } |
298 if (!transaction_->IsActive()) { | 298 if (!transaction_->IsActive()) { |
299 exception_state.ThrowDOMException( | 299 exception_state.ThrowDOMException( |
300 kTransactionInactiveError, | 300 kTransactionInactiveError, |
301 IDBDatabase::kTransactionInactiveErrorMessage); | 301 IDBDatabase::kTransactionInactiveErrorMessage); |
302 return nullptr; | 302 return nullptr; |
303 } | 303 } |
304 IDBKeyRange* range = IDBKeyRange::FromScriptValue( | 304 IDBKeyRange* range = IDBKeyRange::FromScriptValue( |
305 script_state->GetExecutionContext(), key_range, exception_state); | 305 ExecutionContext::From(script_state), key_range, exception_state); |
306 if (exception_state.HadException()) | 306 if (exception_state.HadException()) |
307 return nullptr; | 307 return nullptr; |
308 if (!BackendDB()) { | 308 if (!BackendDB()) { |
309 exception_state.ThrowDOMException(kInvalidStateError, | 309 exception_state.ThrowDOMException(kInvalidStateError, |
310 IDBDatabase::kDatabaseClosedErrorMessage); | 310 IDBDatabase::kDatabaseClosedErrorMessage); |
311 return nullptr; | 311 return nullptr; |
312 } | 312 } |
313 | 313 |
314 IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this), | 314 IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this), |
315 transaction_.Get()); | 315 transaction_.Get()); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 kReadOnlyError, IDBDatabase::kTransactionReadOnlyErrorMessage); | 415 kReadOnlyError, IDBDatabase::kTransactionReadOnlyErrorMessage); |
416 return nullptr; | 416 return nullptr; |
417 } | 417 } |
418 | 418 |
419 v8::Isolate* isolate = script_state->GetIsolate(); | 419 v8::Isolate* isolate = script_state->GetIsolate(); |
420 DCHECK(isolate->InContext()); | 420 DCHECK(isolate->InContext()); |
421 Vector<WebBlobInfo> blob_info; | 421 Vector<WebBlobInfo> blob_info; |
422 SerializedScriptValue::SerializeOptions options; | 422 SerializedScriptValue::SerializeOptions options; |
423 options.blob_info = &blob_info; | 423 options.blob_info = &blob_info; |
424 options.write_wasm_to_stream = | 424 options.write_wasm_to_stream = |
425 script_state->GetExecutionContext()->IsSecureContext(); | 425 ExecutionContext::From(script_state)->IsSecureContext(); |
426 RefPtr<SerializedScriptValue> serialized_value = | 426 RefPtr<SerializedScriptValue> serialized_value = |
427 SerializedScriptValue::Serialize(isolate, value.V8Value(), options, | 427 SerializedScriptValue::Serialize(isolate, value.V8Value(), options, |
428 exception_state); | 428 exception_state); |
429 if (exception_state.HadException()) | 429 if (exception_state.HadException()) |
430 return nullptr; | 430 return nullptr; |
431 | 431 |
432 // Keys that need to be extracted must be taken from a clone so that | 432 // Keys that need to be extracted must be taken from a clone so that |
433 // side effects (i.e. getters) are not triggered. Construct the | 433 // side effects (i.e. getters) are not triggered. Construct the |
434 // clone lazily since the operation may be expensive. | 434 // clone lazily since the operation may be expensive. |
435 ScriptValue clone; | 435 ScriptValue clone; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 IDBDatabase::kTransactionInactiveErrorMessage); | 576 IDBDatabase::kTransactionInactiveErrorMessage); |
577 return nullptr; | 577 return nullptr; |
578 } | 578 } |
579 if (transaction_->IsReadOnly()) { | 579 if (transaction_->IsReadOnly()) { |
580 exception_state.ThrowDOMException( | 580 exception_state.ThrowDOMException( |
581 kReadOnlyError, IDBDatabase::kTransactionReadOnlyErrorMessage); | 581 kReadOnlyError, IDBDatabase::kTransactionReadOnlyErrorMessage); |
582 return nullptr; | 582 return nullptr; |
583 } | 583 } |
584 | 584 |
585 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( | 585 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( |
586 script_state->GetExecutionContext(), key, exception_state); | 586 ExecutionContext::From(script_state), key, exception_state); |
587 if (exception_state.HadException()) | 587 if (exception_state.HadException()) |
588 return nullptr; | 588 return nullptr; |
589 if (!key_range) { | 589 if (!key_range) { |
590 exception_state.ThrowDOMException( | 590 exception_state.ThrowDOMException( |
591 kDataError, IDBDatabase::kNoKeyOrKeyRangeErrorMessage); | 591 kDataError, IDBDatabase::kNoKeyOrKeyRangeErrorMessage); |
592 return nullptr; | 592 return nullptr; |
593 } | 593 } |
594 if (!BackendDB()) { | 594 if (!BackendDB()) { |
595 exception_state.ThrowDOMException(kInvalidStateError, | 595 exception_state.ThrowDOMException(kInvalidStateError, |
596 IDBDatabase::kDatabaseClosedErrorMessage); | 596 IDBDatabase::kDatabaseClosedErrorMessage); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 index_metadata_(std::move(index_metadata)) { | 682 index_metadata_(std::move(index_metadata)) { |
683 DCHECK(index_metadata_.Get()); | 683 DCHECK(index_metadata_.Get()); |
684 } | 684 } |
685 | 685 |
686 const IDBIndexMetadata& IndexMetadata() const { return *index_metadata_; } | 686 const IDBIndexMetadata& IndexMetadata() const { return *index_metadata_; } |
687 | 687 |
688 void handleEvent(ExecutionContext* execution_context, Event* event) override { | 688 void handleEvent(ExecutionContext* execution_context, Event* event) override { |
689 if (!script_state_->ContextIsValid()) | 689 if (!script_state_->ContextIsValid()) |
690 return; | 690 return; |
691 | 691 |
692 DCHECK_EQ(script_state_->GetExecutionContext(), execution_context); | 692 DCHECK_EQ(ExecutionContext::From(script_state_.Get()), execution_context); |
693 DCHECK_EQ(event->type(), EventTypeNames::success); | 693 DCHECK_EQ(event->type(), EventTypeNames::success); |
694 EventTarget* target = event->target(); | 694 EventTarget* target = event->target(); |
695 IDBRequest* request = static_cast<IDBRequest*>(target); | 695 IDBRequest* request = static_cast<IDBRequest*>(target); |
696 | 696 |
697 if (!database_->Backend()) // If database is stopped? | 697 if (!database_->Backend()) // If database is stopped? |
698 return; | 698 return; |
699 | 699 |
700 ScriptState::Scope scope(script_state_.Get()); | 700 ScriptState::Scope scope(script_state_.Get()); |
701 | 701 |
702 IDBAny* cursor_any = request->ResultAsAny(); | 702 IDBAny* cursor_any = request->ResultAsAny(); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 if (!transaction_->IsActive()) { | 923 if (!transaction_->IsActive()) { |
924 exception_state.ThrowDOMException( | 924 exception_state.ThrowDOMException( |
925 kTransactionInactiveError, | 925 kTransactionInactiveError, |
926 IDBDatabase::kTransactionInactiveErrorMessage); | 926 IDBDatabase::kTransactionInactiveErrorMessage); |
927 return nullptr; | 927 return nullptr; |
928 } | 928 } |
929 | 929 |
930 WebIDBCursorDirection direction = | 930 WebIDBCursorDirection direction = |
931 IDBCursor::StringToDirection(direction_string); | 931 IDBCursor::StringToDirection(direction_string); |
932 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( | 932 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( |
933 script_state->GetExecutionContext(), range, exception_state); | 933 ExecutionContext::From(script_state), range, exception_state); |
934 if (exception_state.HadException()) | 934 if (exception_state.HadException()) |
935 return nullptr; | 935 return nullptr; |
936 | 936 |
937 if (!BackendDB()) { | 937 if (!BackendDB()) { |
938 exception_state.ThrowDOMException(kInvalidStateError, | 938 exception_state.ThrowDOMException(kInvalidStateError, |
939 IDBDatabase::kDatabaseClosedErrorMessage); | 939 IDBDatabase::kDatabaseClosedErrorMessage); |
940 return nullptr; | 940 return nullptr; |
941 } | 941 } |
942 | 942 |
943 return openCursor(script_state, key_range, direction, kWebIDBTaskTypeNormal); | 943 return openCursor(script_state, key_range, direction, kWebIDBTaskTypeNormal); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 if (!transaction_->IsActive()) { | 976 if (!transaction_->IsActive()) { |
977 exception_state.ThrowDOMException( | 977 exception_state.ThrowDOMException( |
978 kTransactionInactiveError, | 978 kTransactionInactiveError, |
979 IDBDatabase::kTransactionInactiveErrorMessage); | 979 IDBDatabase::kTransactionInactiveErrorMessage); |
980 return nullptr; | 980 return nullptr; |
981 } | 981 } |
982 | 982 |
983 WebIDBCursorDirection direction = | 983 WebIDBCursorDirection direction = |
984 IDBCursor::StringToDirection(direction_string); | 984 IDBCursor::StringToDirection(direction_string); |
985 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( | 985 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( |
986 script_state->GetExecutionContext(), range, exception_state); | 986 ExecutionContext::From(script_state), range, exception_state); |
987 if (exception_state.HadException()) | 987 if (exception_state.HadException()) |
988 return nullptr; | 988 return nullptr; |
989 | 989 |
990 if (!BackendDB()) { | 990 if (!BackendDB()) { |
991 exception_state.ThrowDOMException(kInvalidStateError, | 991 exception_state.ThrowDOMException(kInvalidStateError, |
992 IDBDatabase::kDatabaseClosedErrorMessage); | 992 IDBDatabase::kDatabaseClosedErrorMessage); |
993 return nullptr; | 993 return nullptr; |
994 } | 994 } |
995 | 995 |
996 IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this), | 996 IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this), |
(...skipping 23 matching lines...) Expand all Loading... |
1020 return nullptr; | 1020 return nullptr; |
1021 } | 1021 } |
1022 if (!transaction_->IsActive()) { | 1022 if (!transaction_->IsActive()) { |
1023 exception_state.ThrowDOMException( | 1023 exception_state.ThrowDOMException( |
1024 kTransactionInactiveError, | 1024 kTransactionInactiveError, |
1025 IDBDatabase::kTransactionInactiveErrorMessage); | 1025 IDBDatabase::kTransactionInactiveErrorMessage); |
1026 return nullptr; | 1026 return nullptr; |
1027 } | 1027 } |
1028 | 1028 |
1029 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( | 1029 IDBKeyRange* key_range = IDBKeyRange::FromScriptValue( |
1030 script_state->GetExecutionContext(), range, exception_state); | 1030 ExecutionContext::From(script_state), range, exception_state); |
1031 if (exception_state.HadException()) | 1031 if (exception_state.HadException()) |
1032 return nullptr; | 1032 return nullptr; |
1033 | 1033 |
1034 if (!BackendDB()) { | 1034 if (!BackendDB()) { |
1035 exception_state.ThrowDOMException(kInvalidStateError, | 1035 exception_state.ThrowDOMException(kInvalidStateError, |
1036 IDBDatabase::kDatabaseClosedErrorMessage); | 1036 IDBDatabase::kDatabaseClosedErrorMessage); |
1037 return nullptr; | 1037 return nullptr; |
1038 } | 1038 } |
1039 | 1039 |
1040 IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this), | 1040 IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this), |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 } | 1143 } |
1144 } | 1144 } |
1145 return IDBIndexMetadata::kInvalidId; | 1145 return IDBIndexMetadata::kInvalidId; |
1146 } | 1146 } |
1147 | 1147 |
1148 WebIDBDatabase* IDBObjectStore::BackendDB() const { | 1148 WebIDBDatabase* IDBObjectStore::BackendDB() const { |
1149 return transaction_->BackendDB(); | 1149 return transaction_->BackendDB(); |
1150 } | 1150 } |
1151 | 1151 |
1152 } // namespace blink | 1152 } // namespace blink |
OLD | NEW |