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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.cpp

Issue 2747163002: Bindings: Manage multiple DOMWrapperWorlds for worklets (2) (Closed)
Patch Set: address review comments & may fix use-after-free bug in the test Created 3 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
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorldTest.cpp ('k') | no next file » | 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // This is equivalent to swapping the byte order of the two bytes (x, 0), 168 // This is equivalent to swapping the byte order of the two bytes (x, 0),
169 // depending on endianness. 169 // depending on endianness.
170 if (m_dataBufferSize % 2) 170 if (m_dataBufferSize % 2)
171 dst[wireSizeBytes / 2 - 1] = m_dataBuffer[m_dataBufferSize - 1] << 8; 171 dst[wireSizeBytes / 2 - 1] = m_dataBuffer[m_dataBufferSize - 1] << 8;
172 } 172 }
173 173
174 static void accumulateArrayBuffersForAllWorlds( 174 static void accumulateArrayBuffersForAllWorlds(
175 v8::Isolate* isolate, 175 v8::Isolate* isolate,
176 DOMArrayBuffer* object, 176 DOMArrayBuffer* object,
177 Vector<v8::Local<v8::ArrayBuffer>, 4>& buffers) { 177 Vector<v8::Local<v8::ArrayBuffer>, 4>& buffers) {
178 if (isMainThread()) { 178 Vector<RefPtr<DOMWrapperWorld>> worlds;
179 Vector<RefPtr<DOMWrapperWorld>> worlds; 179 DOMWrapperWorld::allWorldsInCurrentThread(worlds);
180 DOMWrapperWorld::allWorldsInMainThread(worlds); 180 for (const auto& world : worlds) {
181 for (size_t i = 0; i < worlds.size(); i++) { 181 v8::Local<v8::Object> wrapper = world->domDataStore().get(object, isolate);
182 v8::Local<v8::Object> wrapper =
183 worlds[i]->domDataStore().get(object, isolate);
184 if (!wrapper.IsEmpty())
185 buffers.push_back(v8::Local<v8::ArrayBuffer>::Cast(wrapper));
186 }
187 } else {
188 v8::Local<v8::Object> wrapper =
189 DOMWrapperWorld::current(isolate).domDataStore().get(object, isolate);
190 if (!wrapper.IsEmpty()) 182 if (!wrapper.IsEmpty())
191 buffers.push_back(v8::Local<v8::ArrayBuffer>::Cast(wrapper)); 183 buffers.push_back(v8::Local<v8::ArrayBuffer>::Cast(wrapper));
192 } 184 }
193 } 185 }
194 186
195 std::unique_ptr<SerializedScriptValue::ImageBitmapContentsArray> 187 std::unique_ptr<SerializedScriptValue::ImageBitmapContentsArray>
196 SerializedScriptValue::transferImageBitmapContents( 188 SerializedScriptValue::transferImageBitmapContents(
197 v8::Isolate* isolate, 189 v8::Isolate* isolate,
198 const ImageBitmapArray& imageBitmaps, 190 const ImageBitmapArray& imageBitmaps,
199 ExceptionState& exceptionState) { 191 ExceptionState& exceptionState) {
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 for (size_t i = 0; i < m_arrayBufferContentsArray->size(); ++i) { 476 for (size_t i = 0; i < m_arrayBufferContentsArray->size(); ++i) {
485 WTF::ArrayBufferContents& buffer = m_arrayBufferContentsArray->at(i); 477 WTF::ArrayBufferContents& buffer = m_arrayBufferContentsArray->at(i);
486 buffer.adjustExternalAllocatedMemoryUponContextTransfer( 478 buffer.adjustExternalAllocatedMemoryUponContextTransfer(
487 WTF::ArrayBufferContents::Enter); 479 WTF::ArrayBufferContents::Enter);
488 } 480 }
489 m_adjustTransferableExternalAllocationOnContextTransfer = false; 481 m_adjustTransferableExternalAllocationOnContextTransfer = false;
490 } 482 }
491 } 483 }
492 484
493 } // namespace blink 485 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorldTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698