Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: Source/bindings/v8/SerializedScriptValue.cpp

Issue 182513003: Remove m_domDataStoreList from V8PerIsolateData (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/bindings/v8/DOMWrapperWorld.cpp ('k') | Source/bindings/v8/V8PerIsolateData.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2313 matching lines...) Expand 10 before | Expand all | Expand 10 after
2324 for (size_t i = 0; i < length; i++) 2324 for (size_t i = 0; i < length; i++)
2325 dst[i] = htons(src[i]); 2325 dst[i] = htons(src[i]);
2326 } 2326 }
2327 } 2327 }
2328 2328
2329 SerializedScriptValue::SerializedScriptValue() 2329 SerializedScriptValue::SerializedScriptValue()
2330 : m_externallyAllocatedMemory(0) 2330 : m_externallyAllocatedMemory(0)
2331 { 2331 {
2332 } 2332 }
2333 2333
2334 inline void neuterBinding(ArrayBuffer* object) 2334 static void neuterArrayBufferInAllWorlds(ArrayBuffer* object)
2335 { 2335 {
2336 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 2336 v8::Isolate* isolate = v8::Isolate::GetCurrent();
2337 Vector<DOMDataStore*>& allStores = V8PerIsolateData::from(isolate)->allStore s(); 2337 if (isMainThread()) {
2338 for (size_t i = 0; i < allStores.size(); i++) { 2338 Vector<RefPtr<DOMWrapperWorld> > worlds;
2339 v8::Handle<v8::Object> wrapper = allStores[i]->get<V8ArrayBuffer>(object , isolate); 2339 DOMWrapperWorld::allWorldsInMainThread(worlds);
haraken 2014/02/27 05:00:51 This CL keeps the current behavior, but I don't fu
dcarney 2014/02/27 07:20:51 the arraybuffer might only exist in one world, but
2340 for (size_t i = 0; i < worlds.size(); i++) {
2341 v8::Handle<v8::Object> wrapper = worlds[i]->domDataStore().get<V8Arr ayBuffer>(object, isolate);
2342 if (!wrapper.IsEmpty()) {
2343 ASSERT(wrapper->IsArrayBuffer());
2344 v8::Handle<v8::ArrayBuffer>::Cast(wrapper)->Neuter();
2345 }
2346 }
2347 } else {
2348 v8::Handle<v8::Object> wrapper = DOMWrapperWorld::current(isolate)->domD ataStore().get<V8ArrayBuffer>(object, isolate);
2340 if (!wrapper.IsEmpty()) { 2349 if (!wrapper.IsEmpty()) {
2341 ASSERT(wrapper->IsArrayBuffer()); 2350 ASSERT(wrapper->IsArrayBuffer());
2342 v8::Handle<v8::ArrayBuffer>::Cast(wrapper)->Neuter(); 2351 v8::Handle<v8::ArrayBuffer>::Cast(wrapper)->Neuter();
2343 } 2352 }
2344 } 2353 }
2345 } 2354 }
2346 2355
2347 PassOwnPtr<SerializedScriptValue::ArrayBufferContentsArray> SerializedScriptValu e::transferArrayBuffers(ArrayBufferArray& arrayBuffers, ExceptionState& exceptio nState, v8::Isolate* isolate) 2356 PassOwnPtr<SerializedScriptValue::ArrayBufferContentsArray> SerializedScriptValu e::transferArrayBuffers(ArrayBufferArray& arrayBuffers, ExceptionState& exceptio nState, v8::Isolate* isolate)
2348 { 2357 {
2349 ASSERT(arrayBuffers.size()); 2358 ASSERT(arrayBuffers.size());
(...skipping 12 matching lines...) Expand all
2362 if (visited.contains(arrayBuffers[i].get())) 2371 if (visited.contains(arrayBuffers[i].get()))
2363 continue; 2372 continue;
2364 visited.add(arrayBuffers[i].get()); 2373 visited.add(arrayBuffers[i].get());
2365 2374
2366 bool result = arrayBuffers[i]->transfer(contents->at(i)); 2375 bool result = arrayBuffers[i]->transfer(contents->at(i));
2367 if (!result) { 2376 if (!result) {
2368 exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at ind ex " + String::number(i) + " could not be transferred."); 2377 exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at ind ex " + String::number(i) + " could not be transferred.");
2369 return nullptr; 2378 return nullptr;
2370 } 2379 }
2371 2380
2372 neuterBinding(arrayBuffers[i].get()); 2381 neuterArrayBufferInAllWorlds(arrayBuffers[i].get());
2373 } 2382 }
2374 return contents.release(); 2383 return contents.release();
2375 } 2384 }
2376 2385
2377 SerializedScriptValue::SerializedScriptValue(v8::Handle<v8::Value> value, Messag ePortArray* messagePorts, ArrayBufferArray* arrayBuffers, ExceptionState& except ionState, v8::Isolate* isolate) 2386 SerializedScriptValue::SerializedScriptValue(v8::Handle<v8::Value> value, Messag ePortArray* messagePorts, ArrayBufferArray* arrayBuffers, ExceptionState& except ionState, v8::Isolate* isolate)
2378 : m_externallyAllocatedMemory(0) 2387 : m_externallyAllocatedMemory(0)
2379 { 2388 {
2380 Writer writer(isolate); 2389 Writer writer(isolate);
2381 Serializer::Status status; 2390 Serializer::Status status;
2382 String errorMessage; 2391 String errorMessage;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2452 // If the allocated memory was not registered before, then this class is lik ely 2461 // 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 2462 // 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. 2463 // current v8 context is not guaranteed. Avoid calling v8 then.
2455 if (m_externallyAllocatedMemory) { 2464 if (m_externallyAllocatedMemory) {
2456 ASSERT(v8::Isolate::GetCurrent()); 2465 ASSERT(v8::Isolate::GetCurrent());
2457 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte rnallyAllocatedMemory); 2466 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte rnallyAllocatedMemory);
2458 } 2467 }
2459 } 2468 }
2460 2469
2461 } // namespace WebCore 2470 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/DOMWrapperWorld.cpp ('k') | Source/bindings/v8/V8PerIsolateData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698