OLD | NEW |
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 Loading... |
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 |
OLD | NEW |