Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: Source/bindings/v8/IDBBindingUtilities.cpp

Issue 18590006: Blob support for IDB [Blink] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: small cleanup Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 return 0; 244 return 0;
245 result.append(key); 245 result.append(key);
246 } 246 }
247 return IDBKey::createArray(result); 247 return IDBKey::createArray(result);
248 } 248 }
249 249
250 ASSERT(keyPath.type() == IDBKeyPath::StringType); 250 ASSERT(keyPath.type() == IDBKeyPath::StringType);
251 return createIDBKeyFromScriptValueAndKeyPath(value, keyPath.string(), isolat e); 251 return createIDBKeyFromScriptValueAndKeyPath(value, keyPath.string(), isolat e);
252 } 252 }
253 253
254 v8::Handle<v8::Value> deserializeIDBValueBuffer(SharedBuffer* buffer, v8::Isolat e* isolate) 254 v8::Handle<v8::Value> deserializeIDBValueBuffer(SharedBuffer* buffer, const Vect or<BlobInfo>* blobInfo, v8::Isolate* isolate)
255 { 255 {
256 ASSERT(v8::Context::InContext()); 256 ASSERT(v8::Context::InContext());
257 if (!buffer) 257 if (!buffer)
258 return v8::Null(isolate); 258 return v8::Null(isolate);
259 259
260 // FIXME: The extra copy here can be eliminated by allowing SerializedScript Value to take a raw const char* or const uint8_t*. 260 // FIXME: The extra copy here can be eliminated by allowing SerializedScript Value to take a raw const char* or const uint8_t*.
261 Vector<uint8_t> value; 261 Vector<uint8_t> value;
262 value.append(buffer->data(), buffer->size()); 262 value.append(buffer->data(), buffer->size());
263 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::creat eFromWireBytes(value); 263 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::creat eFromWireBytes(value);
264 return serializedValue->deserialize(isolate); 264 return serializedValue->deserialize(isolate, 0, blobInfo);
265 } 265 }
266 266
267 bool injectV8KeyIntoV8Value(v8::Handle<v8::Value> key, v8::Handle<v8::Value> val ue, const IDBKeyPath& keyPath, v8::Isolate* isolate) 267 bool injectV8KeyIntoV8Value(v8::Handle<v8::Value> key, v8::Handle<v8::Value> val ue, const IDBKeyPath& keyPath, v8::Isolate* isolate)
268 { 268 {
269 IDB_TRACE("injectIDBV8KeyIntoV8Value"); 269 IDB_TRACE("injectIDBV8KeyIntoV8Value");
270 ASSERT(v8::Context::InContext()); 270 ASSERT(v8::Context::InContext());
271 271
272 ASSERT(keyPath.type() == IDBKeyPath::StringType); 272 ASSERT(keyPath.type() == IDBKeyPath::StringType);
273 Vector<String> keyPathElements; 273 Vector<String> keyPathElements;
274 IDBKeyPathParseError error; 274 IDBKeyPathParseError error;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 { 338 {
339 v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate: :GetCurrent(); 339 v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate: :GetCurrent();
340 v8::HandleScope handleScope(isolate); 340 v8::HandleScope handleScope(isolate);
341 v8::Handle<v8::Value> value(scriptValue.v8Value()); 341 v8::Handle<v8::Value> value(scriptValue.v8Value());
342 if (V8IDBKeyRange::hasInstance(value, isolate, worldType(isolate))) 342 if (V8IDBKeyRange::hasInstance(value, isolate, worldType(isolate)))
343 return V8IDBKeyRange::toNative(value.As<v8::Object>()); 343 return V8IDBKeyRange::toNative(value.As<v8::Object>());
344 return 0; 344 return 0;
345 } 345 }
346 346
347 #ifndef NDEBUG 347 #ifndef NDEBUG
348 void assertPrimaryKeyValidOrInjectable(DOMRequestState* state, PassRefPtr<Shared Buffer> buffer, PassRefPtr<IDBKey> prpKey, const IDBKeyPath& keyPath) 348 void assertPrimaryKeyValidOrInjectable(DOMRequestState* state, PassRefPtr<Shared Buffer> buffer, const Vector<BlobInfo>* blobInfo, PassRefPtr<IDBKey> prpKey, con st IDBKeyPath& keyPath)
349 { 349 {
350 RefPtr<IDBKey> key(prpKey); 350 RefPtr<IDBKey> key(prpKey);
351 351
352 DOMRequestState::Scope scope(*state); 352 DOMRequestState::Scope scope(*state);
353 v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate: :GetCurrent(); 353 v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate: :GetCurrent();
354 354
355 ScriptValue keyValue = idbKeyToScriptValue(state, key); 355 ScriptValue keyValue = idbKeyToScriptValue(state, key);
356 ScriptValue scriptValue(deserializeIDBValueBuffer(buffer.get(), isolate), is olate); 356 ScriptValue scriptValue(deserializeIDBValueBuffer(buffer.get(), blobInfo, is olate), isolate);
357 357
358 RefPtr<IDBKey> expectedKey = createIDBKeyFromScriptValueAndKeyPath(state, sc riptValue, keyPath); 358 RefPtr<IDBKey> expectedKey = createIDBKeyFromScriptValueAndKeyPath(state, sc riptValue, keyPath);
359 ASSERT(!expectedKey || expectedKey->isEqual(key.get())); 359 ASSERT(!expectedKey || expectedKey->isEqual(key.get()));
360 360
361 bool injected = injectV8KeyIntoV8Value(keyValue.v8Value(), scriptValue.v8Val ue(), keyPath, isolate); 361 bool injected = injectV8KeyIntoV8Value(keyValue.v8Value(), scriptValue.v8Val ue(), keyPath, isolate);
362 ASSERT_UNUSED(injected, injected); 362 ASSERT_UNUSED(injected, injected);
363 } 363 }
364 #endif 364 #endif
365 365
366 } // namespace WebCore 366 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698