| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 return IDBKey::createBinary(SharedBuffer::create(start, length)); | 211 return IDBKey::createBinary(SharedBuffer::create(start, length)); |
| 212 } | 212 } |
| 213 } | 213 } |
| 214 if (value->IsArray()) { | 214 if (value->IsArray()) { |
| 215 v8::Local<v8::Array> array = value.As<v8::Array>(); | 215 v8::Local<v8::Array> array = value.As<v8::Array>(); |
| 216 | 216 |
| 217 if (stack.contains(array)) | 217 if (stack.contains(array)) |
| 218 return nullptr; | 218 return nullptr; |
| 219 if (stack.size() >= maximumDepth) | 219 if (stack.size() >= maximumDepth) |
| 220 return nullptr; | 220 return nullptr; |
| 221 stack.append(array); | 221 stack.push_back(array); |
| 222 | 222 |
| 223 IDBKey::KeyArray subkeys; | 223 IDBKey::KeyArray subkeys; |
| 224 uint32_t length = array->Length(); | 224 uint32_t length = array->Length(); |
| 225 v8::TryCatch block(isolate); | 225 v8::TryCatch block(isolate); |
| 226 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 226 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
| 227 for (uint32_t i = 0; i < length; ++i) { | 227 for (uint32_t i = 0; i < length; ++i) { |
| 228 if (!v8CallBoolean(array->HasOwnProperty(context, i))) | 228 if (!v8CallBoolean(array->HasOwnProperty(context, i))) |
| 229 return nullptr; | 229 return nullptr; |
| 230 v8::Local<v8::Value> item; | 230 v8::Local<v8::Value> item; |
| 231 if (!v8Call(array->Get(context, i), item, block)) { | 231 if (!v8Call(array->Get(context, i), item, block)) { |
| 232 exceptionState.rethrowV8Exception(block.Exception()); | 232 exceptionState.rethrowV8Exception(block.Exception()); |
| 233 return nullptr; | 233 return nullptr; |
| 234 } | 234 } |
| 235 IDBKey* subkey = createIDBKeyFromValue( | 235 IDBKey* subkey = createIDBKeyFromValue( |
| 236 isolate, item, stack, exceptionState, allowExperimentalTypes); | 236 isolate, item, stack, exceptionState, allowExperimentalTypes); |
| 237 if (!subkey) | 237 if (!subkey) |
| 238 subkeys.append(IDBKey::createInvalid()); | 238 subkeys.push_back(IDBKey::createInvalid()); |
| 239 else | 239 else |
| 240 subkeys.append(subkey); | 240 subkeys.push_back(subkey); |
| 241 } | 241 } |
| 242 | 242 |
| 243 stack.pop_back(); | 243 stack.pop_back(); |
| 244 return IDBKey::createArray(subkeys); | 244 return IDBKey::createArray(subkeys); |
| 245 } | 245 } |
| 246 return nullptr; | 246 return nullptr; |
| 247 } | 247 } |
| 248 | 248 |
| 249 static IDBKey* createIDBKeyFromValue(v8::Isolate* isolate, | 249 static IDBKey* createIDBKeyFromValue(v8::Isolate* isolate, |
| 250 v8::Local<v8::Value> value, | 250 v8::Local<v8::Value> value, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 ASSERT(!keyPath.isNull()); | 369 ASSERT(!keyPath.isNull()); |
| 370 v8::HandleScope handleScope(isolate); | 370 v8::HandleScope handleScope(isolate); |
| 371 if (keyPath.getType() == IDBKeyPath::ArrayType) { | 371 if (keyPath.getType() == IDBKeyPath::ArrayType) { |
| 372 IDBKey::KeyArray result; | 372 IDBKey::KeyArray result; |
| 373 const Vector<String>& array = keyPath.array(); | 373 const Vector<String>& array = keyPath.array(); |
| 374 for (size_t i = 0; i < array.size(); ++i) { | 374 for (size_t i = 0; i < array.size(); ++i) { |
| 375 IDBKey* key = createIDBKeyFromValueAndKeyPath( | 375 IDBKey* key = createIDBKeyFromValueAndKeyPath( |
| 376 isolate, value, array[i], exceptionState, allowExperimentalTypes); | 376 isolate, value, array[i], exceptionState, allowExperimentalTypes); |
| 377 if (!key) | 377 if (!key) |
| 378 return nullptr; | 378 return nullptr; |
| 379 result.append(key); | 379 result.push_back(key); |
| 380 } | 380 } |
| 381 return IDBKey::createArray(result); | 381 return IDBKey::createArray(result); |
| 382 } | 382 } |
| 383 | 383 |
| 384 ASSERT(keyPath.getType() == IDBKeyPath::StringType); | 384 ASSERT(keyPath.getType() == IDBKeyPath::StringType); |
| 385 return createIDBKeyFromValueAndKeyPath( | 385 return createIDBKeyFromValueAndKeyPath( |
| 386 isolate, value, keyPath.string(), exceptionState, allowExperimentalTypes); | 386 isolate, value, keyPath.string(), exceptionState, allowExperimentalTypes); |
| 387 } | 387 } |
| 388 | 388 |
| 389 // Deserialize just the value data & blobInfo from the given IDBValue. | 389 // Deserialize just the value data & blobInfo from the given IDBValue. |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 if (expectedKey && expectedKey->isEqual(value->primaryKey())) | 617 if (expectedKey && expectedKey->isEqual(value->primaryKey())) |
| 618 return; | 618 return; |
| 619 | 619 |
| 620 bool injected = injectV8KeyIntoV8Value( | 620 bool injected = injectV8KeyIntoV8Value( |
| 621 isolate, keyValue.v8Value(), scriptValue.v8Value(), value->keyPath()); | 621 isolate, keyValue.v8Value(), scriptValue.v8Value(), value->keyPath()); |
| 622 DCHECK(injected); | 622 DCHECK(injected); |
| 623 } | 623 } |
| 624 #endif | 624 #endif |
| 625 | 625 |
| 626 } // namespace blink | 626 } // namespace blink |
| OLD | NEW |