OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 bool injectV8KeyIntoV8Value(v8::Isolate* isolate, | 448 bool injectV8KeyIntoV8Value(v8::Isolate* isolate, |
449 v8::Local<v8::Value> key, | 449 v8::Local<v8::Value> key, |
450 v8::Local<v8::Value> value, | 450 v8::Local<v8::Value> value, |
451 const IDBKeyPath& keyPath) { | 451 const IDBKeyPath& keyPath) { |
452 IDB_TRACE("injectIDBV8KeyIntoV8Value"); | 452 IDB_TRACE("injectIDBV8KeyIntoV8Value"); |
453 ASSERT(isolate->InContext()); | 453 ASSERT(isolate->InContext()); |
454 | 454 |
455 ASSERT(keyPath.getType() == IDBKeyPath::StringType); | 455 ASSERT(keyPath.getType() == IDBKeyPath::StringType); |
456 Vector<String> keyPathElements = parseKeyPath(keyPath.string()); | 456 Vector<String> keyPathElements = parseKeyPath(keyPath.string()); |
457 | 457 |
458 // The conbination of a key generator and an empty key path is forbidden by sp
ec. | 458 // The conbination of a key generator and an empty key path is forbidden by |
| 459 // spec. |
459 if (!keyPathElements.size()) { | 460 if (!keyPathElements.size()) { |
460 ASSERT_NOT_REACHED(); | 461 ASSERT_NOT_REACHED(); |
461 return false; | 462 return false; |
462 } | 463 } |
463 | 464 |
464 v8::HandleScope handleScope(isolate); | 465 v8::HandleScope handleScope(isolate); |
465 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 466 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
466 | 467 |
467 // For an object o = {} which should have keypath 'a.b.c' and key k, this | 468 // For an object o = {} which should have keypath 'a.b.c' and key k, this |
468 // populates o to be {a:{b:{}}}. This is only applied to deserialized | 469 // populates o to be {a:{b:{}}}. This is only applied to deserialized |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 // with implicit keys (i.e. a key path). It verifies that either the value | 599 // with implicit keys (i.e. a key path). It verifies that either the value |
599 // contains an implicit key matching the primary key (so it was correctly | 600 // contains an implicit key matching the primary key (so it was correctly |
600 // extracted when stored) or that the key can be inserted as an own property. | 601 // extracted when stored) or that the key can be inserted as an own property. |
601 void assertPrimaryKeyValidOrInjectable(ScriptState* scriptState, | 602 void assertPrimaryKeyValidOrInjectable(ScriptState* scriptState, |
602 const IDBValue* value) { | 603 const IDBValue* value) { |
603 ScriptState::Scope scope(scriptState); | 604 ScriptState::Scope scope(scriptState); |
604 v8::Isolate* isolate = scriptState->isolate(); | 605 v8::Isolate* isolate = scriptState->isolate(); |
605 ScriptValue keyValue = ScriptValue::from(scriptState, value->primaryKey()); | 606 ScriptValue keyValue = ScriptValue::from(scriptState, value->primaryKey()); |
606 ScriptValue scriptValue(scriptState, deserializeIDBValueData(isolate, value)); | 607 ScriptValue scriptValue(scriptState, deserializeIDBValueData(isolate, value)); |
607 | 608 |
608 // This assertion is about already persisted data, so allow experimental types
. | 609 // This assertion is about already persisted data, so allow experimental |
| 610 // types. |
609 const bool allowExperimentalTypes = true; | 611 const bool allowExperimentalTypes = true; |
610 TrackExceptionState exceptionState; | 612 TrackExceptionState exceptionState; |
611 IDBKey* expectedKey = createIDBKeyFromValueAndKeyPath( | 613 IDBKey* expectedKey = createIDBKeyFromValueAndKeyPath( |
612 isolate, scriptValue.v8Value(), value->keyPath(), exceptionState, | 614 isolate, scriptValue.v8Value(), value->keyPath(), exceptionState, |
613 allowExperimentalTypes); | 615 allowExperimentalTypes); |
614 ASSERT(!exceptionState.hadException()); | 616 ASSERT(!exceptionState.hadException()); |
615 if (expectedKey && expectedKey->isEqual(value->primaryKey())) | 617 if (expectedKey && expectedKey->isEqual(value->primaryKey())) |
616 return; | 618 return; |
617 | 619 |
618 bool injected = injectV8KeyIntoV8Value( | 620 bool injected = injectV8KeyIntoV8Value( |
619 isolate, keyValue.v8Value(), scriptValue.v8Value(), value->keyPath()); | 621 isolate, keyValue.v8Value(), scriptValue.v8Value(), value->keyPath()); |
620 ASSERT_UNUSED(injected, injected); | 622 ASSERT_UNUSED(injected, injected); |
621 } | 623 } |
622 #endif | 624 #endif |
623 | 625 |
624 } // namespace blink | 626 } // namespace blink |
OLD | NEW |