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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 IDBParseKeyPath(keyPath.string(), keyPathElements, error); | 396 IDBParseKeyPath(keyPath.string(), keyPathElements, error); |
397 ASSERT(error == IDBKeyPathParseErrorNone); | 397 ASSERT(error == IDBKeyPathParseErrorNone); |
398 | 398 |
399 if (!keyPathElements.size()) | 399 if (!keyPathElements.size()) |
400 return false; | 400 return false; |
401 | 401 |
402 v8::Handle<v8::Value> v8Value(scriptValue.v8Value()); | 402 v8::Handle<v8::Value> v8Value(scriptValue.v8Value()); |
403 return canInjectNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.
size() - 1, state->context()->GetIsolate()); | 403 return canInjectNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.
size() - 1, state->context()->GetIsolate()); |
404 } | 404 } |
405 | 405 |
406 ScriptValue idbAnyToScriptValue(DOMRequestState* state, PassRefPtr<IDBAny> any) | 406 ScriptValue idbAnyToScriptValue(NewScriptState* scriptState, PassRefPtr<IDBAny>
any) |
407 { | 407 { |
408 v8::Isolate* isolate = state ? state->isolate() : v8::Isolate::GetCurrent(); | 408 v8::Isolate* isolate = scriptState->isolate(); |
409 ASSERT(isolate->InContext()); | |
410 v8::Local<v8::Context> context = state ? state->context() : isolate->GetCurr
entContext(); | |
411 v8::HandleScope handleScope(isolate); | 409 v8::HandleScope handleScope(isolate); |
412 v8::Handle<v8::Value> v8Value(toV8(any.get(), context->Global(), isolate)); | 410 v8::Handle<v8::Value> v8Value(toV8(any.get(), scriptState->context()->Global
(), isolate)); |
413 return ScriptValue(v8Value, isolate); | 411 return ScriptValue(v8Value, isolate); |
414 } | 412 } |
415 | 413 |
416 ScriptValue idbKeyToScriptValue(DOMRequestState* state, PassRefPtr<IDBKey> key) | 414 ScriptValue idbKeyToScriptValue(NewScriptState* scriptState, PassRefPtr<IDBKey>
key) |
417 { | 415 { |
418 v8::Isolate* isolate = state ? state->isolate() : v8::Isolate::GetCurrent(); | 416 v8::Isolate* isolate = scriptState->isolate(); |
419 ASSERT(isolate->InContext()); | |
420 v8::Local<v8::Context> context = state ? state->context() : isolate->GetCurr
entContext(); | |
421 v8::HandleScope handleScope(isolate); | 417 v8::HandleScope handleScope(isolate); |
422 v8::Handle<v8::Value> v8Value(toV8(key.get(), context->Global(), isolate)); | 418 v8::Handle<v8::Value> v8Value(toV8(key.get(), scriptState->context()->Global
(), isolate)); |
423 return ScriptValue(v8Value, isolate); | 419 return ScriptValue(v8Value, isolate); |
424 } | 420 } |
425 | 421 |
426 PassRefPtr<IDBKey> scriptValueToIDBKey(DOMRequestState* state, const ScriptValue
& scriptValue) | 422 PassRefPtr<IDBKey> scriptValueToIDBKey(DOMRequestState* state, const ScriptValue
& scriptValue) |
427 { | 423 { |
428 v8::Isolate* isolate = state ? state->isolate() : v8::Isolate::GetCurrent(); | 424 v8::Isolate* isolate = state ? state->isolate() : v8::Isolate::GetCurrent(); |
429 ASSERT(isolate->InContext()); | 425 ASSERT(isolate->InContext()); |
430 v8::HandleScope handleScope(isolate); | 426 v8::HandleScope handleScope(isolate); |
431 v8::Handle<v8::Value> v8Value(scriptValue.v8Value()); | 427 v8::Handle<v8::Value> v8Value(scriptValue.v8Value()); |
432 return createIDBKeyFromValue(v8Value, isolate); | 428 return createIDBKeyFromValue(v8Value, isolate); |
433 } | 429 } |
434 | 430 |
435 PassRefPtr<IDBKeyRange> scriptValueToIDBKeyRange(DOMRequestState* state, const S
criptValue& scriptValue) | 431 PassRefPtr<IDBKeyRange> scriptValueToIDBKeyRange(DOMRequestState* state, const S
criptValue& scriptValue) |
436 { | 432 { |
437 v8::Isolate* isolate = state ? state->isolate() : v8::Isolate::GetCurrent(); | 433 v8::Isolate* isolate = state ? state->isolate() : v8::Isolate::GetCurrent(); |
438 v8::HandleScope handleScope(isolate); | 434 v8::HandleScope handleScope(isolate); |
439 v8::Handle<v8::Value> value(scriptValue.v8Value()); | 435 v8::Handle<v8::Value> value(scriptValue.v8Value()); |
440 return V8IDBKeyRange::toNativeWithTypeCheck(isolate, value); | 436 return V8IDBKeyRange::toNativeWithTypeCheck(isolate, value); |
441 } | 437 } |
442 | 438 |
443 #ifndef NDEBUG | 439 #ifndef NDEBUG |
444 void assertPrimaryKeyValidOrInjectable(DOMRequestState* state, PassRefPtr<Shared
Buffer> buffer, PassRefPtr<IDBKey> prpKey, const IDBKeyPath& keyPath) | 440 void assertPrimaryKeyValidOrInjectable(DOMRequestState* state, PassRefPtr<Shared
Buffer> buffer, PassRefPtr<IDBKey> prpKey, const IDBKeyPath& keyPath) |
445 { | 441 { |
446 RefPtr<IDBKey> key(prpKey); | 442 RefPtr<IDBKey> key(prpKey); |
447 | 443 |
448 DOMRequestState::Scope scope(*state); | 444 DOMRequestState::Scope scope(*state); |
449 v8::Isolate* isolate = state ? state->isolate() : v8::Isolate::GetCurrent(); | 445 v8::Isolate* isolate = state ? state->isolate() : v8::Isolate::GetCurrent(); |
450 | 446 |
451 ScriptValue keyValue = idbKeyToScriptValue(state, key); | 447 ScriptValue keyValue = idbKeyToScriptValue(state->scriptState(), key); |
452 ScriptValue scriptValue(deserializeIDBValueBuffer(buffer.get(), isolate), is
olate); | 448 ScriptValue scriptValue(deserializeIDBValueBuffer(buffer.get(), isolate), is
olate); |
453 | 449 |
454 // This assertion is about already persisted data, so allow experimental typ
es. | 450 // This assertion is about already persisted data, so allow experimental typ
es. |
455 const bool allowExperimentalTypes = true; | 451 const bool allowExperimentalTypes = true; |
456 RefPtr<IDBKey> expectedKey = createIDBKeyFromScriptValueAndKeyPath(scriptVal
ue, keyPath, isolate, allowExperimentalTypes); | 452 RefPtr<IDBKey> expectedKey = createIDBKeyFromScriptValueAndKeyPath(scriptVal
ue, keyPath, isolate, allowExperimentalTypes); |
457 ASSERT(!expectedKey || expectedKey->isEqual(key.get())); | 453 ASSERT(!expectedKey || expectedKey->isEqual(key.get())); |
458 | 454 |
459 bool injected = injectV8KeyIntoV8Value(keyValue.v8Value(), scriptValue.v8Val
ue(), keyPath, isolate); | 455 bool injected = injectV8KeyIntoV8Value(keyValue.v8Value(), scriptValue.v8Val
ue(), keyPath, isolate); |
460 ASSERT_UNUSED(injected, injected); | 456 ASSERT_UNUSED(injected, injected); |
461 } | 457 } |
462 #endif | 458 #endif |
463 | 459 |
464 } // namespace WebCore | 460 } // namespace WebCore |
OLD | NEW |