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

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

Issue 23450039: Pass isolate to ScriptValue constructor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove useless member Created 7 years, 3 months 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 return createIDBKeyFromScriptValueAndKeyPath(value, keyPath.string(), isolat e); 245 return createIDBKeyFromScriptValueAndKeyPath(value, keyPath.string(), isolat e);
246 } 246 }
247 247
248 ScriptValue deserializeIDBValue(DOMRequestState* state, PassRefPtr<SerializedScr iptValue> prpValue) 248 ScriptValue deserializeIDBValue(DOMRequestState* state, PassRefPtr<SerializedScr iptValue> prpValue)
249 { 249 {
250 ASSERT(v8::Context::InContext()); 250 ASSERT(v8::Context::InContext());
251 v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate: :GetCurrent(); 251 v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate: :GetCurrent();
252 v8::HandleScope handleScope(isolate); 252 v8::HandleScope handleScope(isolate);
253 RefPtr<SerializedScriptValue> serializedValue = prpValue; 253 RefPtr<SerializedScriptValue> serializedValue = prpValue;
254 if (serializedValue) 254 if (serializedValue)
255 return ScriptValue(serializedValue->deserialize()); 255 return ScriptValue(serializedValue->deserialize(), isolate);
256 return ScriptValue(v8::Null(isolate)); 256 return ScriptValue(v8::Null(isolate), isolate);
257 } 257 }
258 258
259 ScriptValue deserializeIDBValueBuffer(DOMRequestState* state, PassRefPtr<SharedB uffer> prpBuffer) 259 ScriptValue deserializeIDBValueBuffer(DOMRequestState* state, PassRefPtr<SharedB uffer> prpBuffer)
260 { 260 {
261 ASSERT(v8::Context::InContext()); 261 ASSERT(v8::Context::InContext());
262 v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate: :GetCurrent(); 262 v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate: :GetCurrent();
263 v8::HandleScope handleScope(isolate); 263 v8::HandleScope handleScope(isolate);
264 RefPtr<SharedBuffer> buffer = prpBuffer; 264 RefPtr<SharedBuffer> buffer = prpBuffer;
265 if (buffer) { 265 if (buffer) {
266 // FIXME: The extra copy here can be eliminated by allowing SerializedSc riptValue to take a raw const char* or const uint8_t*. 266 // FIXME: The extra copy here can be eliminated by allowing SerializedSc riptValue to take a raw const char* or const uint8_t*.
267 Vector<uint8_t> value; 267 Vector<uint8_t> value;
268 value.append(buffer->data(), buffer->size()); 268 value.append(buffer->data(), buffer->size());
269 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::c reateFromWireBytes(value); 269 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::c reateFromWireBytes(value);
270 return ScriptValue(serializedValue->deserialize()); 270 return ScriptValue(serializedValue->deserialize(), isolate);
271 } 271 }
272 return ScriptValue(v8::Null(isolate)); 272 return ScriptValue(v8::Null(isolate), isolate);
273 } 273 }
274 274
275 bool injectIDBKeyIntoScriptValue(DOMRequestState* state, PassRefPtr<IDBKey> key, ScriptValue& value, const IDBKeyPath& keyPath) 275 bool injectIDBKeyIntoScriptValue(DOMRequestState* state, PassRefPtr<IDBKey> key, ScriptValue& value, const IDBKeyPath& keyPath)
276 { 276 {
277 IDB_TRACE("injectIDBKeyIntoScriptValue"); 277 IDB_TRACE("injectIDBKeyIntoScriptValue");
278 ASSERT(v8::Context::InContext()); 278 ASSERT(v8::Context::InContext());
279 279
280 ASSERT(keyPath.type() == IDBKeyPath::StringType); 280 ASSERT(keyPath.type() == IDBKeyPath::StringType);
281 Vector<String> keyPathElements; 281 Vector<String> keyPathElements;
282 IDBKeyPathParseError error; 282 IDBKeyPathParseError error;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 v8::Handle<v8::Value> v8Value(scriptValue.v8Value()); 314 v8::Handle<v8::Value> v8Value(scriptValue.v8Value());
315 return canInjectNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements. size() - 1, state->context()->GetIsolate()); 315 return canInjectNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements. size() - 1, state->context()->GetIsolate());
316 } 316 }
317 317
318 ScriptValue idbKeyToScriptValue(DOMRequestState* state, PassRefPtr<IDBKey> key) 318 ScriptValue idbKeyToScriptValue(DOMRequestState* state, PassRefPtr<IDBKey> key)
319 { 319 {
320 ASSERT(v8::Context::InContext()); 320 ASSERT(v8::Context::InContext());
321 v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate: :GetCurrent(); 321 v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate: :GetCurrent();
322 v8::HandleScope handleScope(isolate); 322 v8::HandleScope handleScope(isolate);
323 v8::Handle<v8::Value> v8Value(idbKeyToV8Value(key.get(), state->context()->G etIsolate())); 323 v8::Handle<v8::Value> v8Value(idbKeyToV8Value(key.get(), state->context()->G etIsolate()));
324 return ScriptValue(v8Value); 324 return ScriptValue(v8Value, isolate);
325 } 325 }
326 326
327 PassRefPtr<IDBKey> scriptValueToIDBKey(DOMRequestState* state, const ScriptValue & scriptValue) 327 PassRefPtr<IDBKey> scriptValueToIDBKey(DOMRequestState* state, const ScriptValue & scriptValue)
328 { 328 {
329 ASSERT(v8::Context::InContext()); 329 ASSERT(v8::Context::InContext());
330 v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate: :GetCurrent(); 330 v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate: :GetCurrent();
331 v8::HandleScope handleScope(isolate); 331 v8::HandleScope handleScope(isolate);
332 v8::Handle<v8::Value> v8Value(scriptValue.v8Value()); 332 v8::Handle<v8::Value> v8Value(scriptValue.v8Value());
333 return createIDBKeyFromValue(v8Value, isolate); 333 return createIDBKeyFromValue(v8Value, isolate);
334 } 334 }
335 335
336 PassRefPtr<IDBKeyRange> scriptValueToIDBKeyRange(DOMRequestState* state, const S criptValue& scriptValue) 336 PassRefPtr<IDBKeyRange> scriptValueToIDBKeyRange(DOMRequestState* state, const S criptValue& scriptValue)
337 { 337 {
338 v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate: :GetCurrent(); 338 v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate: :GetCurrent();
339 v8::HandleScope handleScope(isolate); 339 v8::HandleScope handleScope(isolate);
340 v8::Handle<v8::Value> value(scriptValue.v8Value()); 340 v8::Handle<v8::Value> value(scriptValue.v8Value());
341 if (V8IDBKeyRange::HasInstance(value, isolate, worldType(isolate))) 341 if (V8IDBKeyRange::HasInstance(value, isolate, worldType(isolate)))
342 return V8IDBKeyRange::toNative(value.As<v8::Object>()); 342 return V8IDBKeyRange::toNative(value.As<v8::Object>());
343 return 0; 343 return 0;
344 } 344 }
345 345
346 } // namespace WebCore 346 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698