| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 switch (key->type()) { | 89 switch (key->type()) { |
| 90 case IDBKey::InvalidType: | 90 case IDBKey::InvalidType: |
| 91 case IDBKey::MinType: | 91 case IDBKey::MinType: |
| 92 ASSERT_NOT_REACHED(); | 92 ASSERT_NOT_REACHED(); |
| 93 return v8Undefined(); | 93 return v8Undefined(); |
| 94 case IDBKey::NumberType: | 94 case IDBKey::NumberType: |
| 95 return v8::Number::New(isolate, key->number()); | 95 return v8::Number::New(isolate, key->number()); |
| 96 case IDBKey::StringType: | 96 case IDBKey::StringType: |
| 97 return v8String(isolate, key->string()); | 97 return v8String(isolate, key->string()); |
| 98 case IDBKey::BinaryType: | 98 case IDBKey::BinaryType: |
| 99 // Experimental feature: binary keys | 99 { |
| 100 // https://w3c.github.io/IndexedDB/#steps-to-convert-a-key-to-a-value | 100 // Experimental feature: binary keys |
| 101 return toV8(DOMArrayBuffer::create(reinterpret_cast<const unsigned char*
>(key->binary()->data()), key->binary()->size()), creationContext, isolate); | 101 // https://w3c.github.io/IndexedDB/#steps-to-convert-a-key-to-a-valu
e |
| 102 |
| 103 // TODO(junov): crbug.com/536816 Find a more graceful way to handle
allocation |
| 104 // failures with createOrNull. It would be possible to throw a Range
Error |
| 105 // from here but the consequences of such a change need to be consid
ered |
| 106 // carefully. |
| 107 RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::deprecatedCreateOrCr
ash(reinterpret_cast<const unsigned char*>(key->binary()->data()), key->binary()
->size()); |
| 108 return toV8(buffer, creationContext, isolate); |
| 109 } |
| 102 case IDBKey::DateType: | 110 case IDBKey::DateType: |
| 103 return v8::Date::New(context, key->date()).ToLocalChecked(); | 111 return v8::Date::New(context, key->date()).ToLocalChecked(); |
| 104 case IDBKey::ArrayType: | 112 case IDBKey::ArrayType: |
| 105 { | 113 { |
| 106 v8::Local<v8::Array> array = v8::Array::New(isolate, key->array().si
ze()); | 114 v8::Local<v8::Array> array = v8::Array::New(isolate, key->array().si
ze()); |
| 107 for (size_t i = 0; i < key->array().size(); ++i) { | 115 for (size_t i = 0; i < key->array().size(); ++i) { |
| 108 v8::Local<v8::Value> value = toV8(key->array()[i].get(), creatio
nContext, isolate); | 116 v8::Local<v8::Value> value = toV8(key->array()[i].get(), creatio
nContext, isolate); |
| 109 if (value.IsEmpty()) | 117 if (value.IsEmpty()) |
| 110 value = v8::Undefined(isolate); | 118 value = v8::Undefined(isolate); |
| 111 if (!v8CallBoolean(array->CreateDataProperty(context, i, value))
) | 119 if (!v8CallBoolean(array->CreateDataProperty(context, i, value))
) |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 ASSERT(!exceptionState.hadException()); | 519 ASSERT(!exceptionState.hadException()); |
| 512 if (expectedKey && expectedKey->isEqual(value->primaryKey())) | 520 if (expectedKey && expectedKey->isEqual(value->primaryKey())) |
| 513 return; | 521 return; |
| 514 | 522 |
| 515 bool injected = injectV8KeyIntoV8Value(isolate, keyValue.v8Value(), scriptVa
lue.v8Value(), value->keyPath()); | 523 bool injected = injectV8KeyIntoV8Value(isolate, keyValue.v8Value(), scriptVa
lue.v8Value(), value->keyPath()); |
| 516 ASSERT_UNUSED(injected, injected); | 524 ASSERT_UNUSED(injected, injected); |
| 517 } | 525 } |
| 518 #endif | 526 #endif |
| 519 | 527 |
| 520 } // namespace blink | 528 } // namespace blink |
| OLD | NEW |