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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 return adoptRef(new SerializedScriptValue(String::adopt(buffer))); | 110 return adoptRef(new SerializedScriptValue(String::adopt(buffer))); |
111 } | 111 } |
112 | 112 |
113 SerializedScriptValue::SerializedScriptValue() | 113 SerializedScriptValue::SerializedScriptValue() |
114 : m_externallyAllocatedMemory(0) {} | 114 : m_externallyAllocatedMemory(0) {} |
115 | 115 |
116 SerializedScriptValue::SerializedScriptValue(const String& wireData) | 116 SerializedScriptValue::SerializedScriptValue(const String& wireData) |
117 : m_data(wireData.isolatedCopy()), m_externallyAllocatedMemory(0) {} | 117 : m_data(wireData.isolatedCopy()), m_externallyAllocatedMemory(0) {} |
118 | 118 |
119 SerializedScriptValue::~SerializedScriptValue() { | 119 SerializedScriptValue::~SerializedScriptValue() { |
120 // If the allocated memory was not registered before, then this class is likel
y | 120 // If the allocated memory was not registered before, then this class is |
121 // used in a context other than Worker's onmessage environment and the presenc
e of | 121 // likely used in a context other than Worker's onmessage environment and the |
122 // current v8 context is not guaranteed. Avoid calling v8 then. | 122 // presence of current v8 context is not guaranteed. Avoid calling v8 then. |
123 if (m_externallyAllocatedMemory) { | 123 if (m_externallyAllocatedMemory) { |
124 ASSERT(v8::Isolate::GetCurrent()); | 124 ASSERT(v8::Isolate::GetCurrent()); |
125 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory( | 125 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory( |
126 -m_externallyAllocatedMemory); | 126 -m_externallyAllocatedMemory); |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 PassRefPtr<SerializedScriptValue> SerializedScriptValue::nullValue() { | 130 PassRefPtr<SerializedScriptValue> SerializedScriptValue::nullValue() { |
131 return create(ScriptValueSerializer::serializeNullValue()); | 131 return create(ScriptValueSerializer::serializeNullValue()); |
132 } | 132 } |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length()); | 408 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length()); |
409 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory( | 409 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory( |
410 m_externallyAllocatedMemory); | 410 m_externallyAllocatedMemory); |
411 } | 411 } |
412 | 412 |
413 bool SerializedScriptValue::containsTransferableArrayBuffer() const { | 413 bool SerializedScriptValue::containsTransferableArrayBuffer() const { |
414 return m_arrayBufferContentsArray && !m_arrayBufferContentsArray->isEmpty(); | 414 return m_arrayBufferContentsArray && !m_arrayBufferContentsArray->isEmpty(); |
415 } | 415 } |
416 | 416 |
417 } // namespace blink | 417 } // namespace blink |
OLD | NEW |