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

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

Issue 1904913002: When we can't neuter ArrayBuffers, we can't transfer them (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } else { 170 } else {
171 Vector<v8::Local<v8::ArrayBuffer>, 4> bufferHandles; 171 Vector<v8::Local<v8::ArrayBuffer>, 4> bufferHandles;
172 v8::HandleScope handleScope(isolate); 172 v8::HandleScope handleScope(isolate);
173 acculumateArrayBuffersForAllWorlds(isolate, static_cast<DOMArrayBuff er*>(arrayBuffers[i].get()), bufferHandles); 173 acculumateArrayBuffersForAllWorlds(isolate, static_cast<DOMArrayBuff er*>(arrayBuffers[i].get()), bufferHandles);
174 bool isNeuterable = true; 174 bool isNeuterable = true;
175 for (size_t j = 0; j < bufferHandles.size(); ++j) 175 for (size_t j = 0; j < bufferHandles.size(); ++j)
176 isNeuterable &= bufferHandles[j]->IsNeuterable(); 176 isNeuterable &= bufferHandles[j]->IsNeuterable();
177 177
178 DOMArrayBufferBase* toTransfer = arrayBuffers[i]; 178 DOMArrayBufferBase* toTransfer = arrayBuffers[i];
179 if (!isNeuterable) 179 if (!isNeuterable)
180 toTransfer = DOMArrayBuffer::create(arrayBuffers[i]->buffer()); 180 toTransfer = DOMArrayBuffer::create(arrayBuffers[i]->buffer()->d ata(), arrayBuffers[i]->buffer()->byteLength());
181 bool result = toTransfer->transfer(contents->at(i)); 181 bool result = toTransfer->transfer(contents->at(i));
182 if (!result) { 182 if (!result) {
183 exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at index " + String::number(i) + " could not be transferred."); 183 exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at index " + String::number(i) + " could not be transferred.");
184 return; 184 return;
185 } 185 }
186 186
187 if (isNeuterable) 187 if (isNeuterable)
188 for (size_t j = 0; j < bufferHandles.size(); ++j) 188 for (size_t j = 0; j < bufferHandles.size(); ++j)
189 bufferHandles[j]->Neuter(); 189 bufferHandles[j]->Neuter();
190 } 190 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length()); 281 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length());
282 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(m_externall yAllocatedMemory); 282 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(m_externall yAllocatedMemory);
283 } 283 }
284 284
285 bool SerializedScriptValue::containsTransferableArrayBuffer() const 285 bool SerializedScriptValue::containsTransferableArrayBuffer() const
286 { 286 {
287 return m_arrayBufferContentsArray && !m_arrayBufferContentsArray->isEmpty(); 287 return m_arrayBufferContentsArray && !m_arrayBufferContentsArray->isEmpty();
288 } 288 }
289 289
290 } // namespace blink 290 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698