| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "modules/indexeddb/IDBKeyPath.h" | 44 #include "modules/indexeddb/IDBKeyPath.h" |
| 45 #include "modules/indexeddb/IDBKeyRange.h" | 45 #include "modules/indexeddb/IDBKeyRange.h" |
| 46 #include "modules/indexeddb/IDBTracing.h" | 46 #include "modules/indexeddb/IDBTracing.h" |
| 47 #include "platform/RuntimeEnabledFeatures.h" | 47 #include "platform/RuntimeEnabledFeatures.h" |
| 48 #include "platform/SharedBuffer.h" | 48 #include "platform/SharedBuffer.h" |
| 49 #include "wtf/ArrayBufferView.h" | 49 #include "wtf/ArrayBufferView.h" |
| 50 #include "wtf/MathExtras.h" | 50 #include "wtf/MathExtras.h" |
| 51 #include "wtf/Uint8Array.h" | 51 #include "wtf/Uint8Array.h" |
| 52 #include "wtf/Vector.h" | 52 #include "wtf/Vector.h" |
| 53 | 53 |
| 54 namespace WebCore { | 54 namespace blink { |
| 55 | 55 |
| 56 static v8::Handle<v8::Value> deserializeIDBValueBuffer(v8::Isolate*, SharedBuffe
r*, const Vector<blink::WebBlobInfo>*); | 56 static v8::Handle<v8::Value> deserializeIDBValueBuffer(v8::Isolate*, SharedBuffe
r*, const Vector<blink::WebBlobInfo>*); |
| 57 | 57 |
| 58 static v8::Handle<v8::Value> toV8(const IDBKeyPath& value, v8::Handle<v8::Object
> creationContext, v8::Isolate* isolate) | 58 static v8::Handle<v8::Value> toV8(const IDBKeyPath& value, v8::Handle<v8::Object
> creationContext, v8::Isolate* isolate) |
| 59 { | 59 { |
| 60 switch (value.type()) { | 60 switch (value.type()) { |
| 61 case IDBKeyPath::NullType: | 61 case IDBKeyPath::NullType: |
| 62 return v8::Null(isolate); | 62 return v8::Null(isolate); |
| 63 case IDBKeyPath::StringType: | 63 case IDBKeyPath::StringType: |
| 64 return v8String(isolate, value.string()); | 64 return v8String(isolate, value.string()); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 { | 171 { |
| 172 if (value->IsNumber() && !std::isnan(value->NumberValue())) | 172 if (value->IsNumber() && !std::isnan(value->NumberValue())) |
| 173 return IDBKey::createNumber(value->NumberValue()); | 173 return IDBKey::createNumber(value->NumberValue()); |
| 174 if (value->IsString()) | 174 if (value->IsString()) |
| 175 return IDBKey::createString(toCoreString(value.As<v8::String>())); | 175 return IDBKey::createString(toCoreString(value.As<v8::String>())); |
| 176 if (value->IsDate() && !std::isnan(value->NumberValue())) | 176 if (value->IsDate() && !std::isnan(value->NumberValue())) |
| 177 return IDBKey::createDate(value->NumberValue()); | 177 return IDBKey::createDate(value->NumberValue()); |
| 178 if (value->IsUint8Array() && (allowExperimentalTypes || RuntimeEnabledFeatur
es::indexedDBExperimentalEnabled())) { | 178 if (value->IsUint8Array() && (allowExperimentalTypes || RuntimeEnabledFeatur
es::indexedDBExperimentalEnabled())) { |
| 179 // Per discussion in https://www.w3.org/Bugs/Public/show_bug.cgi?id=2333
2 the | 179 // Per discussion in https://www.w3.org/Bugs/Public/show_bug.cgi?id=2333
2 the |
| 180 // input type is constrained to Uint8Array to match the output type. | 180 // input type is constrained to Uint8Array to match the output type. |
| 181 ArrayBufferView* view = WebCore::V8ArrayBufferView::toNative(value->ToOb
ject()); | 181 ArrayBufferView* view = blink::V8ArrayBufferView::toNative(value->ToObje
ct()); |
| 182 const char* start = static_cast<const char*>(view->baseAddress()); | 182 const char* start = static_cast<const char*>(view->baseAddress()); |
| 183 size_t length = view->byteLength(); | 183 size_t length = view->byteLength(); |
| 184 return IDBKey::createBinary(SharedBuffer::create(start, length)); | 184 return IDBKey::createBinary(SharedBuffer::create(start, length)); |
| 185 } | 185 } |
| 186 if (value->IsArray()) { | 186 if (value->IsArray()) { |
| 187 v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(value); | 187 v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(value); |
| 188 | 188 |
| 189 if (stack.contains(array)) | 189 if (stack.contains(array)) |
| 190 return 0; | 190 return 0; |
| 191 if (stack.size() >= maximumDepth) | 191 if (stack.size() >= maximumDepth) |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 // This assertion is about already persisted data, so allow experimental typ
es. | 451 // This assertion is about already persisted data, so allow experimental typ
es. |
| 452 const bool allowExperimentalTypes = true; | 452 const bool allowExperimentalTypes = true; |
| 453 IDBKey* expectedKey = createIDBKeyFromScriptValueAndKeyPathInternal(isolate,
scriptValue, keyPath, allowExperimentalTypes); | 453 IDBKey* expectedKey = createIDBKeyFromScriptValueAndKeyPathInternal(isolate,
scriptValue, keyPath, allowExperimentalTypes); |
| 454 ASSERT(!expectedKey || expectedKey->isEqual(key)); | 454 ASSERT(!expectedKey || expectedKey->isEqual(key)); |
| 455 | 455 |
| 456 bool injected = injectV8KeyIntoV8Value(isolate, keyValue.v8Value(), scriptVa
lue.v8Value(), keyPath); | 456 bool injected = injectV8KeyIntoV8Value(isolate, keyValue.v8Value(), scriptVa
lue.v8Value(), keyPath); |
| 457 ASSERT_UNUSED(injected, injected); | 457 ASSERT_UNUSED(injected, injected); |
| 458 } | 458 } |
| 459 #endif | 459 #endif |
| 460 | 460 |
| 461 } // namespace WebCore | 461 } // namespace blink |
| OLD | NEW |