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

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

Issue 23450039: Pass isolate to ScriptValue constructor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master 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
« no previous file with comments | « Source/bindings/v8/ScriptValue.cpp ('k') | Source/bindings/v8/WorkerScriptController.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 2492 matching lines...) Expand 10 before | Expand all | Expand 10 after
2503 Deserializer deserializer(reader, messagePorts, m_arrayBufferContentsArray.g et()); 2503 Deserializer deserializer(reader, messagePorts, m_arrayBufferContentsArray.g et());
2504 2504
2505 // deserialize() can run arbitrary script (e.g., setters), which could resul t in |this| being destroyed. 2505 // deserialize() can run arbitrary script (e.g., setters), which could resul t in |this| being destroyed.
2506 // Holding a RefPtr ensures we are alive (along with our internal data) thro ughout the operation. 2506 // Holding a RefPtr ensures we are alive (along with our internal data) thro ughout the operation.
2507 RefPtr<SerializedScriptValue> protect(this); 2507 RefPtr<SerializedScriptValue> protect(this);
2508 return deserializer.deserialize(); 2508 return deserializer.deserialize();
2509 } 2509 }
2510 2510
2511 ScriptValue SerializedScriptValue::deserializeForInspector(ScriptState* scriptSt ate) 2511 ScriptValue SerializedScriptValue::deserializeForInspector(ScriptState* scriptSt ate)
2512 { 2512 {
2513 v8::HandleScope handleScope(scriptState->isolate()); 2513 v8::Isolate* isolate = scriptState->isolate();
2514 v8::HandleScope handleScope(isolate);
2514 v8::Context::Scope contextScope(scriptState->context()); 2515 v8::Context::Scope contextScope(scriptState->context());
2515 2516
2516 return ScriptValue(deserialize(scriptState->isolate())); 2517 return ScriptValue(deserialize(isolate), isolate);
2517 } 2518 }
2518 2519
2519 void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext() 2520 void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext()
2520 { 2521 {
2521 if (m_externallyAllocatedMemory) 2522 if (m_externallyAllocatedMemory)
2522 return; 2523 return;
2523 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length()); 2524 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length());
2524 v8::V8::AdjustAmountOfExternalAllocatedMemory(m_externallyAllocatedMemory); 2525 v8::V8::AdjustAmountOfExternalAllocatedMemory(m_externallyAllocatedMemory);
2525 } 2526 }
2526 2527
2527 SerializedScriptValue::~SerializedScriptValue() 2528 SerializedScriptValue::~SerializedScriptValue()
2528 { 2529 {
2529 // If the allocated memory was not registered before, then this class is lik ely 2530 // If the allocated memory was not registered before, then this class is lik ely
2530 // used in a context other then Worker's onmessage environment and the prese nce of 2531 // used in a context other then Worker's onmessage environment and the prese nce of
2531 // current v8 context is not guaranteed. Avoid calling v8 then. 2532 // current v8 context is not guaranteed. Avoid calling v8 then.
2532 if (m_externallyAllocatedMemory) { 2533 if (m_externallyAllocatedMemory) {
2533 ASSERT(v8::Isolate::GetCurrent()); 2534 ASSERT(v8::Isolate::GetCurrent());
2534 v8::V8::AdjustAmountOfExternalAllocatedMemory(-m_externallyAllocatedMemo ry); 2535 v8::V8::AdjustAmountOfExternalAllocatedMemory(-m_externallyAllocatedMemo ry);
2535 } 2536 }
2536 } 2537 }
2537 2538
2538 uint32_t SerializedScriptValue::wireFormatVersion() 2539 uint32_t SerializedScriptValue::wireFormatVersion()
2539 { 2540 {
2540 return WebCore::wireFormatVersion; 2541 return WebCore::wireFormatVersion;
2541 } 2542 }
2542 2543
2543 } // namespace WebCore 2544 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/ScriptValue.cpp ('k') | Source/bindings/v8/WorkerScriptController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698