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

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

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "bindings/core/v8/ScriptValueSerializer.h" 5 #include "bindings/core/v8/ScriptValueSerializer.h"
6 6
7 #include "bindings/core/v8/Transferables.h" 7 #include "bindings/core/v8/Transferables.h"
8 #include "bindings/core/v8/V8ArrayBuffer.h" 8 #include "bindings/core/v8/V8ArrayBuffer.h"
9 #include "bindings/core/v8/V8ArrayBufferView.h" 9 #include "bindings/core/v8/V8ArrayBufferView.h"
10 #include "bindings/core/v8/V8Blob.h" 10 #include "bindings/core/v8/V8Blob.h"
(...skipping 11 matching lines...) Expand all
22 #include "core/dom/DOMTypedArray.h" 22 #include "core/dom/DOMTypedArray.h"
23 #include "core/fileapi/Blob.h" 23 #include "core/fileapi/Blob.h"
24 #include "core/fileapi/File.h" 24 #include "core/fileapi/File.h"
25 #include "core/fileapi/FileList.h" 25 #include "core/fileapi/FileList.h"
26 #include "platform/RuntimeEnabledFeatures.h" 26 #include "platform/RuntimeEnabledFeatures.h"
27 #include "public/platform/Platform.h" 27 #include "public/platform/Platform.h"
28 #include "public/platform/WebBlobInfo.h" 28 #include "public/platform/WebBlobInfo.h"
29 #include "wtf/DateMath.h" 29 #include "wtf/DateMath.h"
30 #include "wtf/text/StringHash.h" 30 #include "wtf/text/StringHash.h"
31 #include "wtf/text/StringUTF8Adaptor.h" 31 #include "wtf/text/StringUTF8Adaptor.h"
32 #include <memory>
33 32
34 // FIXME: consider crashing in debug mode on deserialization errors 33 // FIXME: consider crashing in debug mode on deserialization errors
35 // NOTE: be sure to change wireFormatVersion as necessary! 34 // NOTE: be sure to change wireFormatVersion as necessary!
36 35
37 namespace blink { 36 namespace blink {
38 37
39 // This code implements the HTML5 Structured Clone algorithm: 38 // This code implements the HTML5 Structured Clone algorithm:
40 // http://www.whatwg.org/specs/web-apps/current-work/multipage/urls.html#safe-pa ssing-of-structured-data 39 // http://www.whatwg.org/specs/web-apps/current-work/multipage/urls.html#safe-pa ssing-of-structured-data
41 40
42 // ZigZag encoding helps VarInt encoding stay small for negative 41 // ZigZag encoding helps VarInt encoding stay small for negative
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 if (!imageBitmap) 1099 if (!imageBitmap)
1101 return nullptr; 1100 return nullptr;
1102 if (imageBitmap->isNeutered()) 1101 if (imageBitmap->isNeutered())
1103 return handleError(DataCloneError, "An ImageBitmap is detached and could not be cloned.", next); 1102 return handleError(DataCloneError, "An ImageBitmap is detached and could not be cloned.", next);
1104 1103
1105 uint32_t index; 1104 uint32_t index;
1106 if (m_transferredImageBitmaps.tryGet(object, &index)) { 1105 if (m_transferredImageBitmaps.tryGet(object, &index)) {
1107 m_writer.writeTransferredImageBitmap(index); 1106 m_writer.writeTransferredImageBitmap(index);
1108 } else { 1107 } else {
1109 greyObject(object); 1108 greyObject(object);
1110 std::unique_ptr<uint8_t[]> pixelData = imageBitmap->copyBitmapData(Premu ltiplyAlpha); 1109 OwnPtr<uint8_t[]> pixelData = imageBitmap->copyBitmapData(PremultiplyAlp ha);
1111 m_writer.writeImageBitmap(imageBitmap->width(), imageBitmap->height(), p ixelData.get(), imageBitmap->width() * imageBitmap->height() * 4); 1110 m_writer.writeImageBitmap(imageBitmap->width(), imageBitmap->height(), p ixelData.get(), imageBitmap->width() * imageBitmap->height() * 4);
1112 } 1111 }
1113 return nullptr; 1112 return nullptr;
1114 } 1113 }
1115 1114
1116 void ScriptValueSerializer::writeRegExp(v8::Local<v8::Value> value) 1115 void ScriptValueSerializer::writeRegExp(v8::Local<v8::Value> value)
1117 { 1116 {
1118 v8::Local<v8::RegExp> regExp = value.As<v8::RegExp>(); 1117 v8::Local<v8::RegExp> regExp = value.As<v8::RegExp>();
1119 m_writer.writeRegExp(regExp->GetSource(), regExp->GetFlags()); 1118 m_writer.writeRegExp(regExp->GetSource(), regExp->GetFlags());
1120 } 1119 }
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after
2401 return false; 2400 return false;
2402 uint32_t objectReference = m_openCompositeReferenceStack[m_openCompositeRefe renceStack.size() - 1]; 2401 uint32_t objectReference = m_openCompositeReferenceStack[m_openCompositeRefe renceStack.size() - 1];
2403 m_openCompositeReferenceStack.shrink(m_openCompositeReferenceStack.size() - 1); 2402 m_openCompositeReferenceStack.shrink(m_openCompositeReferenceStack.size() - 1);
2404 if (objectReference >= m_objectPool.size()) 2403 if (objectReference >= m_objectPool.size())
2405 return false; 2404 return false;
2406 *object = m_objectPool[objectReference]; 2405 *object = m_objectPool[objectReference];
2407 return true; 2406 return true;
2408 } 2407 }
2409 2408
2410 } // namespace blink 2409 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698