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 24 matching lines...) Expand all Loading... |
35 #include "V8DOMFileSystem.h" | 35 #include "V8DOMFileSystem.h" |
36 #include "V8File.h" | 36 #include "V8File.h" |
37 #include "V8FileList.h" | 37 #include "V8FileList.h" |
38 #include "V8ImageData.h" | 38 #include "V8ImageData.h" |
39 #include "V8MessagePort.h" | 39 #include "V8MessagePort.h" |
40 #include "bindings/v8/ExceptionState.h" | 40 #include "bindings/v8/ExceptionState.h" |
41 #include "bindings/v8/ScriptScope.h" | 41 #include "bindings/v8/ScriptScope.h" |
42 #include "bindings/v8/ScriptState.h" | 42 #include "bindings/v8/ScriptState.h" |
43 #include "bindings/v8/V8Binding.h" | 43 #include "bindings/v8/V8Binding.h" |
44 #include "bindings/v8/V8Utilities.h" | 44 #include "bindings/v8/V8Utilities.h" |
| 45 #include "bindings/v8/WorkerScriptController.h" |
45 #include "bindings/v8/custom/V8ArrayBufferCustom.h" | 46 #include "bindings/v8/custom/V8ArrayBufferCustom.h" |
46 #include "bindings/v8/custom/V8ArrayBufferViewCustom.h" | 47 #include "bindings/v8/custom/V8ArrayBufferViewCustom.h" |
47 #include "bindings/v8/custom/V8DataViewCustom.h" | 48 #include "bindings/v8/custom/V8DataViewCustom.h" |
48 #include "bindings/v8/custom/V8Float32ArrayCustom.h" | 49 #include "bindings/v8/custom/V8Float32ArrayCustom.h" |
49 #include "bindings/v8/custom/V8Float64ArrayCustom.h" | 50 #include "bindings/v8/custom/V8Float64ArrayCustom.h" |
50 #include "bindings/v8/custom/V8Int16ArrayCustom.h" | 51 #include "bindings/v8/custom/V8Int16ArrayCustom.h" |
51 #include "bindings/v8/custom/V8Int32ArrayCustom.h" | 52 #include "bindings/v8/custom/V8Int32ArrayCustom.h" |
52 #include "bindings/v8/custom/V8Int8ArrayCustom.h" | 53 #include "bindings/v8/custom/V8Int8ArrayCustom.h" |
53 #include "bindings/v8/custom/V8Uint16ArrayCustom.h" | 54 #include "bindings/v8/custom/V8Uint16ArrayCustom.h" |
54 #include "bindings/v8/custom/V8Uint32ArrayCustom.h" | 55 #include "bindings/v8/custom/V8Uint32ArrayCustom.h" |
(...skipping 2260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2315 for (size_t i = 0; i < length; i++) | 2316 for (size_t i = 0; i < length; i++) |
2316 dst[i] = htons(src[i]); | 2317 dst[i] = htons(src[i]); |
2317 } | 2318 } |
2318 } | 2319 } |
2319 | 2320 |
2320 SerializedScriptValue::SerializedScriptValue() | 2321 SerializedScriptValue::SerializedScriptValue() |
2321 : m_externallyAllocatedMemory(0) | 2322 : m_externallyAllocatedMemory(0) |
2322 { | 2323 { |
2323 } | 2324 } |
2324 | 2325 |
2325 inline void neuterBinding(ArrayBuffer* object) | 2326 static void neuterArrayBufferInAllWorlds(ArrayBuffer* object) |
2326 { | 2327 { |
2327 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 2328 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
2328 Vector<DOMDataStore*>& allStores = V8PerIsolateData::from(isolate)->allStore
s(); | 2329 if (isMainThread()) { |
2329 for (size_t i = 0; i < allStores.size(); i++) { | 2330 Vector<RefPtr<DOMWrapperWorld> > worlds; |
2330 v8::Handle<v8::Object> wrapper = allStores[i]->get<V8ArrayBuffer>(object
, isolate); | 2331 DOMWrapperWorld::allWorldsInMainThread(worlds); |
| 2332 for (size_t i = 0; i < worlds.size(); i++) { |
| 2333 v8::Handle<v8::Object> wrapper = worlds[i]->domDataStore().get<V8Arr
ayBuffer>(object, isolate); |
| 2334 if (!wrapper.IsEmpty()) { |
| 2335 ASSERT(wrapper->IsArrayBuffer()); |
| 2336 v8::Handle<v8::ArrayBuffer>::Cast(wrapper)->Neuter(); |
| 2337 } |
| 2338 } |
| 2339 } else { |
| 2340 v8::Handle<v8::Object> wrapper = WorkerScriptController::controllerForCo
ntext(isolate)->world()->domDataStore().get<V8ArrayBuffer>(object, isolate); |
2331 if (!wrapper.IsEmpty()) { | 2341 if (!wrapper.IsEmpty()) { |
2332 ASSERT(wrapper->IsArrayBuffer()); | 2342 ASSERT(wrapper->IsArrayBuffer()); |
2333 v8::Handle<v8::ArrayBuffer>::Cast(wrapper)->Neuter(); | 2343 v8::Handle<v8::ArrayBuffer>::Cast(wrapper)->Neuter(); |
2334 } | 2344 } |
2335 } | 2345 } |
2336 } | 2346 } |
2337 | 2347 |
2338 PassOwnPtr<SerializedScriptValue::ArrayBufferContentsArray> SerializedScriptValu
e::transferArrayBuffers(ArrayBufferArray& arrayBuffers, ExceptionState& exceptio
nState, v8::Isolate* isolate) | 2348 PassOwnPtr<SerializedScriptValue::ArrayBufferContentsArray> SerializedScriptValu
e::transferArrayBuffers(ArrayBufferArray& arrayBuffers, ExceptionState& exceptio
nState, v8::Isolate* isolate) |
2339 { | 2349 { |
2340 ASSERT(arrayBuffers.size()); | 2350 ASSERT(arrayBuffers.size()); |
(...skipping 12 matching lines...) Expand all Loading... |
2353 if (visited.contains(arrayBuffers[i].get())) | 2363 if (visited.contains(arrayBuffers[i].get())) |
2354 continue; | 2364 continue; |
2355 visited.add(arrayBuffers[i].get()); | 2365 visited.add(arrayBuffers[i].get()); |
2356 | 2366 |
2357 bool result = arrayBuffers[i]->transfer(contents->at(i)); | 2367 bool result = arrayBuffers[i]->transfer(contents->at(i)); |
2358 if (!result) { | 2368 if (!result) { |
2359 exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at ind
ex " + String::number(i) + " could not be transferred."); | 2369 exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at ind
ex " + String::number(i) + " could not be transferred."); |
2360 return nullptr; | 2370 return nullptr; |
2361 } | 2371 } |
2362 | 2372 |
2363 neuterBinding(arrayBuffers[i].get()); | 2373 neuterArrayBufferInAllWorlds(arrayBuffers[i].get()); |
2364 } | 2374 } |
2365 return contents.release(); | 2375 return contents.release(); |
2366 } | 2376 } |
2367 | 2377 |
2368 SerializedScriptValue::SerializedScriptValue(v8::Handle<v8::Value> value, Messag
ePortArray* messagePorts, ArrayBufferArray* arrayBuffers, ExceptionState& except
ionState, v8::Isolate* isolate) | 2378 SerializedScriptValue::SerializedScriptValue(v8::Handle<v8::Value> value, Messag
ePortArray* messagePorts, ArrayBufferArray* arrayBuffers, ExceptionState& except
ionState, v8::Isolate* isolate) |
2369 : m_externallyAllocatedMemory(0) | 2379 : m_externallyAllocatedMemory(0) |
2370 { | 2380 { |
2371 Writer writer; | 2381 Writer writer; |
2372 Serializer::Status status; | 2382 Serializer::Status status; |
2373 String errorMessage; | 2383 String errorMessage; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2443 // If the allocated memory was not registered before, then this class is lik
ely | 2453 // If the allocated memory was not registered before, then this class is lik
ely |
2444 // used in a context other then Worker's onmessage environment and the prese
nce of | 2454 // used in a context other then Worker's onmessage environment and the prese
nce of |
2445 // current v8 context is not guaranteed. Avoid calling v8 then. | 2455 // current v8 context is not guaranteed. Avoid calling v8 then. |
2446 if (m_externallyAllocatedMemory) { | 2456 if (m_externallyAllocatedMemory) { |
2447 ASSERT(v8::Isolate::GetCurrent()); | 2457 ASSERT(v8::Isolate::GetCurrent()); |
2448 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte
rnallyAllocatedMemory); | 2458 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte
rnallyAllocatedMemory); |
2449 } | 2459 } |
2450 } | 2460 } |
2451 | 2461 |
2452 } // namespace WebCore | 2462 } // namespace WebCore |
OLD | NEW |