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 1967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1978 , m_arrayBuffers(arrayBufferContents ? arrayBufferContents->size() : 0) | 1978 , m_arrayBuffers(arrayBufferContents ? arrayBufferContents->size() : 0) |
1979 , m_version(0) | 1979 , m_version(0) |
1980 { | 1980 { |
1981 } | 1981 } |
1982 | 1982 |
1983 v8::Handle<v8::Value> deserialize() | 1983 v8::Handle<v8::Value> deserialize() |
1984 { | 1984 { |
1985 if (!m_reader.readVersion(m_version) || m_version > wireFormatVersion) | 1985 if (!m_reader.readVersion(m_version) || m_version > wireFormatVersion) |
1986 return v8NullWithCheck(m_reader.getIsolate()); | 1986 return v8NullWithCheck(m_reader.getIsolate()); |
1987 m_reader.setVersion(m_version); | 1987 m_reader.setVersion(m_version); |
1988 v8::HandleScope scope; | 1988 v8::HandleScope scope(m_reader.getIsolate()); |
1989 while (!m_reader.isEof()) { | 1989 while (!m_reader.isEof()) { |
1990 if (!doDeserialize()) | 1990 if (!doDeserialize()) |
1991 return v8NullWithCheck(m_reader.getIsolate()); | 1991 return v8NullWithCheck(m_reader.getIsolate()); |
1992 } | 1992 } |
1993 if (stackDepth() != 1 || m_openCompositeReferenceStack.size()) | 1993 if (stackDepth() != 1 || m_openCompositeReferenceStack.size()) |
1994 return v8NullWithCheck(m_reader.getIsolate()); | 1994 return v8NullWithCheck(m_reader.getIsolate()); |
1995 v8::Handle<v8::Value> result = scope.Close(element(0)); | 1995 v8::Handle<v8::Value> result = scope.Close(element(0)); |
1996 return result; | 1996 return result; |
1997 } | 1997 } |
1998 | 1998 |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2500 Deserializer deserializer(reader, messagePorts, m_arrayBufferContentsArray.g
et()); | 2500 Deserializer deserializer(reader, messagePorts, m_arrayBufferContentsArray.g
et()); |
2501 | 2501 |
2502 // deserialize() can run arbitrary script (e.g., setters), which could resul
t in |this| being destroyed. | 2502 // deserialize() can run arbitrary script (e.g., setters), which could resul
t in |this| being destroyed. |
2503 // Holding a RefPtr ensures we are alive (along with our internal data) thro
ughout the operation. | 2503 // Holding a RefPtr ensures we are alive (along with our internal data) thro
ughout the operation. |
2504 RefPtr<SerializedScriptValue> protect(this); | 2504 RefPtr<SerializedScriptValue> protect(this); |
2505 return deserializer.deserialize(); | 2505 return deserializer.deserialize(); |
2506 } | 2506 } |
2507 | 2507 |
2508 ScriptValue SerializedScriptValue::deserializeForInspector(ScriptState* scriptSt
ate) | 2508 ScriptValue SerializedScriptValue::deserializeForInspector(ScriptState* scriptSt
ate) |
2509 { | 2509 { |
2510 v8::HandleScope handleScope; | 2510 v8::HandleScope handleScope(scriptState->isolate()); |
2511 v8::Context::Scope contextScope(scriptState->context()); | 2511 v8::Context::Scope contextScope(scriptState->context()); |
2512 | 2512 |
2513 return ScriptValue(deserialize(scriptState->isolate())); | 2513 return ScriptValue(deserialize(scriptState->isolate())); |
2514 } | 2514 } |
2515 | 2515 |
2516 void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext() | 2516 void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext() |
2517 { | 2517 { |
2518 if (m_externallyAllocatedMemory) | 2518 if (m_externallyAllocatedMemory) |
2519 return; | 2519 return; |
2520 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length()); | 2520 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length()); |
(...skipping 10 matching lines...) Expand all Loading... |
2531 v8::V8::AdjustAmountOfExternalAllocatedMemory(-m_externallyAllocatedMemo
ry); | 2531 v8::V8::AdjustAmountOfExternalAllocatedMemory(-m_externallyAllocatedMemo
ry); |
2532 } | 2532 } |
2533 } | 2533 } |
2534 | 2534 |
2535 uint32_t SerializedScriptValue::wireFormatVersion() | 2535 uint32_t SerializedScriptValue::wireFormatVersion() |
2536 { | 2536 { |
2537 return WebCore::wireFormatVersion; | 2537 return WebCore::wireFormatVersion; |
2538 } | 2538 } |
2539 | 2539 |
2540 } // namespace WebCore | 2540 } // namespace WebCore |
OLD | NEW |