| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 namespace blink { | 59 namespace blink { |
| 60 | 60 |
| 61 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serialize(v8::Isolate*
isolate, v8::Local<v8::Value> value, Transferables* transferables, WebBlobInfoAr
ray* blobInfo, ExceptionState& exception) | 61 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serialize(v8::Isolate*
isolate, v8::Local<v8::Value> value, Transferables* transferables, WebBlobInfoAr
ray* blobInfo, ExceptionState& exception) |
| 62 { | 62 { |
| 63 return SerializedScriptValueFactory::instance().create(isolate, value, trans
ferables, blobInfo, exception); | 63 return SerializedScriptValueFactory::instance().create(isolate, value, trans
ferables, blobInfo, exception); |
| 64 } | 64 } |
| 65 | 65 |
| 66 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serialize(const String&
str) | 66 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serialize(const String&
str) |
| 67 { | 67 { |
| 68 return SerializedScriptValueFactory::instance().create(str); | 68 return create(ScriptValueSerializer::serializeWTFString(str)); |
| 69 } | 69 } |
| 70 | 70 |
| 71 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serializeAndSwallowExce
ptions(v8::Isolate* isolate, v8::Local<v8::Value> value) | 71 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serializeAndSwallowExce
ptions(v8::Isolate* isolate, v8::Local<v8::Value> value) |
| 72 { | 72 { |
| 73 TrackExceptionState exceptionState; | 73 TrackExceptionState exceptionState; |
| 74 return serialize(isolate, value, nullptr, nullptr, exceptionState); | 74 return serialize(isolate, value, nullptr, nullptr, exceptionState); |
| 75 } | 75 } |
| 76 | 76 |
| 77 PassRefPtr<SerializedScriptValue> SerializedScriptValue::create() | 77 PassRefPtr<SerializedScriptValue> SerializedScriptValue::create() |
| 78 { | 78 { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // used in a context other than Worker's onmessage environment and the prese
nce of | 118 // used in a context other than Worker's onmessage environment and the prese
nce of |
| 119 // current v8 context is not guaranteed. Avoid calling v8 then. | 119 // current v8 context is not guaranteed. Avoid calling v8 then. |
| 120 if (m_externallyAllocatedMemory) { | 120 if (m_externallyAllocatedMemory) { |
| 121 ASSERT(v8::Isolate::GetCurrent()); | 121 ASSERT(v8::Isolate::GetCurrent()); |
| 122 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte
rnallyAllocatedMemory); | 122 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte
rnallyAllocatedMemory); |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 | 125 |
| 126 PassRefPtr<SerializedScriptValue> SerializedScriptValue::nullValue() | 126 PassRefPtr<SerializedScriptValue> SerializedScriptValue::nullValue() |
| 127 { | 127 { |
| 128 SerializedScriptValueWriter writer; | 128 return create(ScriptValueSerializer::serializeNullValue()); |
| 129 writer.writeNull(); | |
| 130 return create(writer.takeWireString()); | |
| 131 } | 129 } |
| 132 | 130 |
| 133 // Convert serialized string to big endian wire data. | 131 // Convert serialized string to big endian wire data. |
| 134 void SerializedScriptValue::toWireBytes(Vector<char>& result) const | 132 void SerializedScriptValue::toWireBytes(Vector<char>& result) const |
| 135 { | 133 { |
| 136 ASSERT(result.isEmpty()); | 134 ASSERT(result.isEmpty()); |
| 137 size_t length = m_data.length(); | 135 size_t length = m_data.length(); |
| 138 result.resize(length * sizeof(UChar)); | 136 result.resize(length * sizeof(UChar)); |
| 139 UChar* dst = reinterpret_cast<UChar*>(result.data()); | 137 UChar* dst = reinterpret_cast<UChar*>(result.data()); |
| 140 | 138 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length()); | 350 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length()); |
| 353 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(m_externall
yAllocatedMemory); | 351 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(m_externall
yAllocatedMemory); |
| 354 } | 352 } |
| 355 | 353 |
| 356 bool SerializedScriptValue::containsTransferableArrayBuffer() const | 354 bool SerializedScriptValue::containsTransferableArrayBuffer() const |
| 357 { | 355 { |
| 358 return m_arrayBufferContentsArray && !m_arrayBufferContentsArray->isEmpty(); | 356 return m_arrayBufferContentsArray && !m_arrayBufferContentsArray->isEmpty(); |
| 359 } | 357 } |
| 360 | 358 |
| 361 } // namespace blink | 359 } // namespace blink |
| OLD | NEW |