| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #include "platform/blob/BlobData.h" | 51 #include "platform/blob/BlobData.h" |
| 52 #include "platform/heap/Handle.h" | 52 #include "platform/heap/Handle.h" |
| 53 #include "wtf/Assertions.h" | 53 #include "wtf/Assertions.h" |
| 54 #include "wtf/ByteOrder.h" | 54 #include "wtf/ByteOrder.h" |
| 55 #include "wtf/Vector.h" | 55 #include "wtf/Vector.h" |
| 56 #include "wtf/text/StringBuffer.h" | 56 #include "wtf/text/StringBuffer.h" |
| 57 #include "wtf/text/StringHash.h" | 57 #include "wtf/text/StringHash.h" |
| 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) |
| 62 { |
| 63 return SerializedScriptValueFactory::instance().create(isolate, value, trans
ferables, blobInfo, exception); |
| 64 } |
| 65 |
| 66 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serialize(const String&
str) |
| 67 { |
| 68 return SerializedScriptValueFactory::instance().create(str); |
| 69 } |
| 70 |
| 71 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serializeAndSwallowExce
ptions(v8::Isolate* isolate, v8::Local<v8::Value> value) |
| 72 { |
| 73 TrackExceptionState exceptionState; |
| 74 return serialize(isolate, value, nullptr, nullptr, exceptionState); |
| 75 } |
| 76 |
| 61 PassRefPtr<SerializedScriptValue> SerializedScriptValue::create() | 77 PassRefPtr<SerializedScriptValue> SerializedScriptValue::create() |
| 62 { | 78 { |
| 63 return adoptRef(new SerializedScriptValue); | 79 return adoptRef(new SerializedScriptValue); |
| 64 } | 80 } |
| 65 | 81 |
| 66 PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(const String& da
ta) | 82 PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(const String& da
ta) |
| 67 { | 83 { |
| 68 return adoptRef(new SerializedScriptValue(data)); | 84 return adoptRef(new SerializedScriptValue(data)); |
| 69 } | 85 } |
| 70 | 86 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 if (m_externallyAllocatedMemory) { | 120 if (m_externallyAllocatedMemory) { |
| 105 ASSERT(v8::Isolate::GetCurrent()); | 121 ASSERT(v8::Isolate::GetCurrent()); |
| 106 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte
rnallyAllocatedMemory); | 122 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte
rnallyAllocatedMemory); |
| 107 } | 123 } |
| 108 } | 124 } |
| 109 | 125 |
| 110 PassRefPtr<SerializedScriptValue> SerializedScriptValue::nullValue() | 126 PassRefPtr<SerializedScriptValue> SerializedScriptValue::nullValue() |
| 111 { | 127 { |
| 112 SerializedScriptValueWriter writer; | 128 SerializedScriptValueWriter writer; |
| 113 writer.writeNull(); | 129 writer.writeNull(); |
| 114 String wireData = writer.takeWireString(); | 130 return create(writer.takeWireString()); |
| 115 return adoptRef(new SerializedScriptValue(wireData)); | |
| 116 } | 131 } |
| 117 | 132 |
| 118 // Convert serialized string to big endian wire data. | 133 // Convert serialized string to big endian wire data. |
| 119 void SerializedScriptValue::toWireBytes(Vector<char>& result) const | 134 void SerializedScriptValue::toWireBytes(Vector<char>& result) const |
| 120 { | 135 { |
| 121 ASSERT(result.isEmpty()); | 136 ASSERT(result.isEmpty()); |
| 122 size_t length = m_data.length(); | 137 size_t length = m_data.length(); |
| 123 result.resize(length * sizeof(UChar)); | 138 result.resize(length * sizeof(UChar)); |
| 124 UChar* dst = reinterpret_cast<UChar*>(result.data()); | 139 UChar* dst = reinterpret_cast<UChar*>(result.data()); |
| 125 | 140 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length()); | 352 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length()); |
| 338 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(m_externall
yAllocatedMemory); | 353 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(m_externall
yAllocatedMemory); |
| 339 } | 354 } |
| 340 | 355 |
| 341 bool SerializedScriptValue::containsTransferableArrayBuffer() const | 356 bool SerializedScriptValue::containsTransferableArrayBuffer() const |
| 342 { | 357 { |
| 343 return m_arrayBufferContentsArray && !m_arrayBufferContentsArray->isEmpty(); | 358 return m_arrayBufferContentsArray && !m_arrayBufferContentsArray->isEmpty(); |
| 344 } | 359 } |
| 345 | 360 |
| 346 } // namespace blink | 361 } // namespace blink |
| OLD | NEW |