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 2473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2484 v8::Handle<v8::Value> SerializedScriptValue::deserialize(v8::Isolate* isolate, M
essagePortArray* messagePorts) | 2484 v8::Handle<v8::Value> SerializedScriptValue::deserialize(v8::Isolate* isolate, M
essagePortArray* messagePorts) |
2485 { | 2485 { |
2486 if (!m_data.impl()) | 2486 if (!m_data.impl()) |
2487 return v8NullWithCheck(isolate); | 2487 return v8NullWithCheck(isolate); |
2488 COMPILE_ASSERT(sizeof(BufferValueType) == 2, BufferValueTypeIsTwoBytes); | 2488 COMPILE_ASSERT(sizeof(BufferValueType) == 2, BufferValueTypeIsTwoBytes); |
2489 Reader reader(reinterpret_cast<const uint8_t*>(m_data.impl()->characters()),
2 * m_data.length(), isolate); | 2489 Reader reader(reinterpret_cast<const uint8_t*>(m_data.impl()->characters()),
2 * m_data.length(), isolate); |
2490 Deserializer deserializer(reader, messagePorts, m_arrayBufferContentsArray.g
et()); | 2490 Deserializer deserializer(reader, messagePorts, m_arrayBufferContentsArray.g
et()); |
2491 return deserializer.deserialize(); | 2491 return deserializer.deserialize(); |
2492 } | 2492 } |
2493 | 2493 |
2494 #if ENABLE(INSPECTOR) | |
2495 ScriptValue SerializedScriptValue::deserializeForInspector(ScriptState* scriptSt
ate) | 2494 ScriptValue SerializedScriptValue::deserializeForInspector(ScriptState* scriptSt
ate) |
2496 { | 2495 { |
2497 v8::HandleScope handleScope; | 2496 v8::HandleScope handleScope; |
2498 v8::Context::Scope contextScope(scriptState->context()); | 2497 v8::Context::Scope contextScope(scriptState->context()); |
2499 | 2498 |
2500 return ScriptValue(deserialize(scriptState->isolate())); | 2499 return ScriptValue(deserialize(scriptState->isolate())); |
2501 } | 2500 } |
2502 #endif | |
2503 | 2501 |
2504 void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext() | 2502 void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext() |
2505 { | 2503 { |
2506 if (m_externallyAllocatedMemory) | 2504 if (m_externallyAllocatedMemory) |
2507 return; | 2505 return; |
2508 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length()); | 2506 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length()); |
2509 v8::V8::AdjustAmountOfExternalAllocatedMemory(m_externallyAllocatedMemory); | 2507 v8::V8::AdjustAmountOfExternalAllocatedMemory(m_externallyAllocatedMemory); |
2510 } | 2508 } |
2511 | 2509 |
2512 SerializedScriptValue::~SerializedScriptValue() | 2510 SerializedScriptValue::~SerializedScriptValue() |
2513 { | 2511 { |
2514 // If the allocated memory was not registered before, then this class is lik
ely | 2512 // If the allocated memory was not registered before, then this class is lik
ely |
2515 // used in a context other then Worker's onmessage environment and the prese
nce of | 2513 // used in a context other then Worker's onmessage environment and the prese
nce of |
2516 // current v8 context is not guaranteed. Avoid calling v8 then. | 2514 // current v8 context is not guaranteed. Avoid calling v8 then. |
2517 if (m_externallyAllocatedMemory) { | 2515 if (m_externallyAllocatedMemory) { |
2518 ASSERT(v8::Isolate::GetCurrent()); | 2516 ASSERT(v8::Isolate::GetCurrent()); |
2519 v8::V8::AdjustAmountOfExternalAllocatedMemory(-m_externallyAllocatedMemo
ry); | 2517 v8::V8::AdjustAmountOfExternalAllocatedMemory(-m_externallyAllocatedMemo
ry); |
2520 } | 2518 } |
2521 } | 2519 } |
2522 | 2520 |
2523 uint32_t SerializedScriptValue::wireFormatVersion() | 2521 uint32_t SerializedScriptValue::wireFormatVersion() |
2524 { | 2522 { |
2525 return WebCore::wireFormatVersion; | 2523 return WebCore::wireFormatVersion; |
2526 } | 2524 } |
2527 | 2525 |
2528 } // namespace WebCore | 2526 } // namespace WebCore |
OLD | NEW |