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 2278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2289 return adoptRef(new SerializedScriptValue(wireData)); | 2289 return adoptRef(new SerializedScriptValue(wireData)); |
2290 } | 2290 } |
2291 | 2291 |
2292 PassRefPtr<SerializedScriptValue> SerializedScriptValue::create() | 2292 PassRefPtr<SerializedScriptValue> SerializedScriptValue::create() |
2293 { | 2293 { |
2294 return adoptRef(new SerializedScriptValue()); | 2294 return adoptRef(new SerializedScriptValue()); |
2295 } | 2295 } |
2296 | 2296 |
2297 PassRefPtr<SerializedScriptValue> SerializedScriptValue::nullValue() | 2297 PassRefPtr<SerializedScriptValue> SerializedScriptValue::nullValue() |
2298 { | 2298 { |
2299 return nullValue(v8::Isolate::GetCurrent()); | 2299 v8::Isolate* isolate = 0; |
haraken
2014/02/25 01:14:38
I'm not really happy about this.
When we have an
jsbell
2014/02/25 17:42:10
Okay. Since this is just packing bytes into a buff
| |
2300 } | |
2301 | |
2302 PassRefPtr<SerializedScriptValue> SerializedScriptValue::nullValue(v8::Isolate* isolate) | |
2303 { | |
2304 Writer writer(isolate); | 2300 Writer writer(isolate); |
2305 writer.writeNull(); | 2301 writer.writeNull(); |
2306 String wireData = writer.takeWireString(); | 2302 String wireData = writer.takeWireString(); |
2307 return adoptRef(new SerializedScriptValue(wireData)); | 2303 return adoptRef(new SerializedScriptValue(wireData)); |
2308 } | 2304 } |
2305 | |
2306 PassRefPtr<SerializedScriptValue> SerializedScriptValue::numberValue(double numb er) | |
2307 { | |
2308 v8::Isolate* isolate = 0; | |
haraken
2014/02/25 01:14:38
Ditto.
| |
2309 Writer writer(isolate); | |
2310 writer.writeNumber(number); | |
2311 String wireData = writer.takeWireString(); | |
2312 return adoptRef(new SerializedScriptValue(wireData)); | |
2313 } | |
2309 | 2314 |
2310 // Convert serialized string to big endian wire data. | 2315 // Convert serialized string to big endian wire data. |
2311 void SerializedScriptValue::toWireBytes(Vector<char>& result) const | 2316 void SerializedScriptValue::toWireBytes(Vector<char>& result) const |
2312 { | 2317 { |
2313 ASSERT(result.isEmpty()); | 2318 ASSERT(result.isEmpty()); |
2314 size_t length = m_data.length(); | 2319 size_t length = m_data.length(); |
2315 result.resize(length * sizeof(UChar)); | 2320 result.resize(length * sizeof(UChar)); |
2316 UChar* dst = reinterpret_cast<UChar*>(result.data()); | 2321 UChar* dst = reinterpret_cast<UChar*>(result.data()); |
2317 | 2322 |
2318 if (m_data.is8Bit()) { | 2323 if (m_data.is8Bit()) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2452 // If the allocated memory was not registered before, then this class is lik ely | 2457 // If the allocated memory was not registered before, then this class is lik ely |
2453 // used in a context other then Worker's onmessage environment and the prese nce of | 2458 // used in a context other then Worker's onmessage environment and the prese nce of |
2454 // current v8 context is not guaranteed. Avoid calling v8 then. | 2459 // current v8 context is not guaranteed. Avoid calling v8 then. |
2455 if (m_externallyAllocatedMemory) { | 2460 if (m_externallyAllocatedMemory) { |
2456 ASSERT(v8::Isolate::GetCurrent()); | 2461 ASSERT(v8::Isolate::GetCurrent()); |
2457 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte rnallyAllocatedMemory); | 2462 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte rnallyAllocatedMemory); |
2458 } | 2463 } |
2459 } | 2464 } |
2460 | 2465 |
2461 } // namespace WebCore | 2466 } // namespace WebCore |
OLD | NEW |