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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 #include "wtf/Float64Array.h" | 69 #include "wtf/Float64Array.h" |
70 #include "wtf/Int16Array.h" | 70 #include "wtf/Int16Array.h" |
71 #include "wtf/Int32Array.h" | 71 #include "wtf/Int32Array.h" |
72 #include "wtf/Int8Array.h" | 72 #include "wtf/Int8Array.h" |
73 #include "wtf/RefCounted.h" | 73 #include "wtf/RefCounted.h" |
74 #include "wtf/Uint16Array.h" | 74 #include "wtf/Uint16Array.h" |
75 #include "wtf/Uint32Array.h" | 75 #include "wtf/Uint32Array.h" |
76 #include "wtf/Uint8Array.h" | 76 #include "wtf/Uint8Array.h" |
77 #include "wtf/Uint8ClampedArray.h" | 77 #include "wtf/Uint8ClampedArray.h" |
78 #include "wtf/Vector.h" | 78 #include "wtf/Vector.h" |
| 79 #include "wtf/text/StringBuffer.h" |
79 #include "wtf/text/StringUTF8Adaptor.h" | 80 #include "wtf/text/StringUTF8Adaptor.h" |
80 | 81 |
81 // FIXME: consider crashing in debug mode on deserialization errors | 82 // FIXME: consider crashing in debug mode on deserialization errors |
82 // NOTE: be sure to change wireFormatVersion as necessary! | 83 // NOTE: be sure to change wireFormatVersion as necessary! |
83 | 84 |
84 namespace WebCore { | 85 namespace WebCore { |
85 | 86 |
86 namespace { | 87 namespace { |
87 | 88 |
88 // This code implements the HTML5 Structured Clone algorithm: | 89 // This code implements the HTML5 Structured Clone algorithm: |
(...skipping 2154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2243 PassRefPtr<SerializedScriptValue> SerializedScriptValue::createFromWire(const St
ring& data) | 2244 PassRefPtr<SerializedScriptValue> SerializedScriptValue::createFromWire(const St
ring& data) |
2244 { | 2245 { |
2245 return adoptRef(new SerializedScriptValue(data)); | 2246 return adoptRef(new SerializedScriptValue(data)); |
2246 } | 2247 } |
2247 | 2248 |
2248 PassRefPtr<SerializedScriptValue> SerializedScriptValue::createFromWireBytes(con
st Vector<uint8_t>& data) | 2249 PassRefPtr<SerializedScriptValue> SerializedScriptValue::createFromWireBytes(con
st Vector<uint8_t>& data) |
2249 { | 2250 { |
2250 // Decode wire data from big endian to host byte order. | 2251 // Decode wire data from big endian to host byte order. |
2251 ASSERT(!(data.size() % sizeof(UChar))); | 2252 ASSERT(!(data.size() % sizeof(UChar))); |
2252 size_t length = data.size() / sizeof(UChar); | 2253 size_t length = data.size() / sizeof(UChar); |
2253 Vector<UChar> buffer(length); | 2254 StringBuffer<UChar> buffer(length); |
2254 const UChar* src = reinterpret_cast<const UChar*>(data.data()); | 2255 const UChar* src = reinterpret_cast<const UChar*>(data.data()); |
2255 UChar* dst = buffer.data(); | 2256 UChar* dst = buffer.characters(); |
2256 for (size_t i = 0; i < length; i++) | 2257 for (size_t i = 0; i < length; i++) |
2257 dst[i] = ntohs(src[i]); | 2258 dst[i] = ntohs(src[i]); |
2258 | 2259 |
2259 return createFromWire(String::adopt(buffer)); | 2260 return createFromWire(String::adopt(buffer)); |
2260 } | 2261 } |
2261 | 2262 |
2262 PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(const String& da
ta) | 2263 PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(const String& da
ta) |
2263 { | 2264 { |
2264 return create(data, v8::Isolate::GetCurrent()); | 2265 return create(data, v8::Isolate::GetCurrent()); |
2265 } | 2266 } |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2527 v8::V8::AdjustAmountOfExternalAllocatedMemory(-m_externallyAllocatedMemo
ry); | 2528 v8::V8::AdjustAmountOfExternalAllocatedMemory(-m_externallyAllocatedMemo
ry); |
2528 } | 2529 } |
2529 } | 2530 } |
2530 | 2531 |
2531 uint32_t SerializedScriptValue::wireFormatVersion() | 2532 uint32_t SerializedScriptValue::wireFormatVersion() |
2532 { | 2533 { |
2533 return WebCore::wireFormatVersion; | 2534 return WebCore::wireFormatVersion; |
2534 } | 2535 } |
2535 | 2536 |
2536 } // namespace WebCore | 2537 } // namespace WebCore |
OLD | NEW |