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

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

Issue 1413723004: Revert of Make ImageBitmap Transferable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 /* 1 /*
2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2009, 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 30 matching lines...) Expand all
41 41
42 class ArrayBufferContents; 42 class ArrayBufferContents;
43 43
44 } 44 }
45 45
46 namespace blink { 46 namespace blink {
47 47
48 class BlobDataHandle; 48 class BlobDataHandle;
49 class DOMArrayBufferBase; 49 class DOMArrayBufferBase;
50 class ExceptionState; 50 class ExceptionState;
51 class ImageBitmap;
52 class MessagePort; 51 class MessagePort;
53 class WebBlobInfo; 52 class WebBlobInfo;
54 53
55 typedef HeapVector<Member<MessagePort>, 1> MessagePortArray; 54 typedef HeapVector<Member<MessagePort>, 1> MessagePortArray;
56 typedef Vector<RefPtr<DOMArrayBufferBase>, 1> ArrayBufferArray; 55 typedef Vector<RefPtr<DOMArrayBufferBase>, 1> ArrayBufferArray;
57 typedef HashMap<String, RefPtr<BlobDataHandle>> BlobDataHandleMap; 56 typedef HashMap<String, RefPtr<BlobDataHandle>> BlobDataHandleMap;
58 typedef Vector<WebBlobInfo> WebBlobInfoArray; 57 typedef Vector<WebBlobInfo> WebBlobInfoArray;
59 typedef WillBeHeapVector<RefPtrWillBeMember<ImageBitmap>, 1> ImageBitmapArray;
60 58
61 class CORE_EXPORT SerializedScriptValue : public ThreadSafeRefCounted<Serialized ScriptValue> { 59 class CORE_EXPORT SerializedScriptValue : public ThreadSafeRefCounted<Serialized ScriptValue> {
62 public: 60 public:
63 // Increment this for each incompatible change to the wire format. 61 // Increment this for each incompatible change to the wire format.
64 // Version 2: Added StringUCharTag for UChar v8 strings. 62 // Version 2: Added StringUCharTag for UChar v8 strings.
65 // Version 3: Switched to using uuids as blob data identifiers. 63 // Version 3: Switched to using uuids as blob data identifiers.
66 // Version 4: Extended File serialization to be complete. 64 // Version 4: Extended File serialization to be complete.
67 // Version 5: Added CryptoKeyTag for Key objects. 65 // Version 5: Added CryptoKeyTag for Key objects.
68 // Version 6: Added indexed serialization for File, Blob, and FileList. 66 // Version 6: Added indexed serialization for File, Blob, and FileList.
69 // Version 7: Extended File serialization with user visibility. 67 // Version 7: Extended File serialization with user visibility.
(...skipping 14 matching lines...) Expand all
84 82
85 // Deserializes the value (in the current context). Returns a null value in 83 // Deserializes the value (in the current context). Returns a null value in
86 // case of failure. 84 // case of failure.
87 v8::Local<v8::Value> deserialize(MessagePortArray* = 0); 85 v8::Local<v8::Value> deserialize(MessagePortArray* = 0);
88 v8::Local<v8::Value> deserialize(v8::Isolate*, MessagePortArray* = 0, const WebBlobInfoArray* = 0); 86 v8::Local<v8::Value> deserialize(v8::Isolate*, MessagePortArray* = 0, const WebBlobInfoArray* = 0);
89 87
90 // Helper function which pulls the values out of a JS sequence and into a Me ssagePortArray. 88 // Helper function which pulls the values out of a JS sequence and into a Me ssagePortArray.
91 // Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL spec and section 8.3.3 89 // Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL spec and section 8.3.3
92 // of the HTML5 spec and generates exceptions as appropriate. 90 // of the HTML5 spec and generates exceptions as appropriate.
93 // Returns true if the array was filled, or false if the passed value was no t of an appropriate type. 91 // Returns true if the array was filled, or false if the passed value was no t of an appropriate type.
94 static bool extractTransferables(v8::Isolate*, v8::Local<v8::Value>, int, Me ssagePortArray&, ArrayBufferArray&, ImageBitmapArray&, ExceptionState&); 92 static bool extractTransferables(v8::Isolate*, v8::Local<v8::Value>, int, Me ssagePortArray&, ArrayBufferArray&, ExceptionState&);
95 93
96 // Informs the V8 about external memory allocated and owned by this object. Large values should contribute 94 // Informs the V8 about external memory allocated and owned by this object. Large values should contribute
97 // to GC counters to eventually trigger a GC, otherwise flood of postMessage () can cause OOM. 95 // to GC counters to eventually trigger a GC, otherwise flood of postMessage () can cause OOM.
98 // Ok to invoke multiple times (only adds memory once). 96 // Ok to invoke multiple times (only adds memory once).
99 // The memory registration is revoked automatically in destructor. 97 // The memory registration is revoked automatically in destructor.
100 void registerMemoryAllocatedWithCurrentScriptContext(); 98 void registerMemoryAllocatedWithCurrentScriptContext();
101 99
102 // Returns true if the value contains a transferable ArrayBuffer. 100 // Returns true if the value contains a transferable ArrayBuffer.
103 bool containsTransferableArrayBuffer() const; 101 bool containsTransferableArrayBuffer() const;
104 102
105 private: 103 private:
106 // The followings are private, but used by SerializedScriptValueFactory. 104 // The followings are private, but used by SerializedScriptValueFactory.
107 enum StringDataMode { 105 enum StringDataMode {
108 StringValue, 106 StringValue,
109 WireData 107 WireData
110 }; 108 };
111 typedef Vector<WTF::ArrayBufferContents, 1> ArrayBufferContentsArray; 109 typedef Vector<WTF::ArrayBufferContents, 1> ArrayBufferContentsArray;
112 110
113 SerializedScriptValue(); 111 SerializedScriptValue();
114 explicit SerializedScriptValue(const String& wireData); 112 explicit SerializedScriptValue(const String& wireData);
115 113
116 BlobDataHandleMap& blobDataHandles() { return m_blobDataHandles; } 114 BlobDataHandleMap& blobDataHandles() { return m_blobDataHandles; }
117 String& data() { return m_data; } 115 String& data() { return m_data; }
118 void setData(const String& data) { m_data = data; } 116 void setData(const String& data) { m_data = data; }
119 void transferArrayBuffers(v8::Isolate*, ArrayBufferArray&, ExceptionState&); 117 void transferArrayBuffers(v8::Isolate*, ArrayBufferArray&, ExceptionState&);
120 void transferImageBitmaps(v8::Isolate*, ImageBitmapArray&, ExceptionState&);
121 ArrayBufferContentsArray* arrayBufferContentsArray() { return m_arrayBufferC ontentsArray.get(); } 118 ArrayBufferContentsArray* arrayBufferContentsArray() { return m_arrayBufferC ontentsArray.get(); }
122 ImageBitmapArray* imageBitmapArray() { return m_imageBitmapsArray.get(); }
123 119
124 static PassOwnPtr<ArrayBufferContentsArray> createArrayBuffers(v8::Isolate*, ArrayBufferArray&, ExceptionState&); 120 static PassOwnPtr<ArrayBufferContentsArray> createArrayBuffers(v8::Isolate*, ArrayBufferArray&, ExceptionState&);
125 static PassOwnPtrWillBeRawPtr<ImageBitmapArray> createImageBitmaps(v8::Isola te*, ImageBitmapArray&, ExceptionState&);
126 121
127 private: 122 private:
128 String m_data; 123 String m_data;
129 OwnPtr<ArrayBufferContentsArray> m_arrayBufferContentsArray; 124 OwnPtr<ArrayBufferContentsArray> m_arrayBufferContentsArray;
130 OwnPtrWillBePersistent<ImageBitmapArray> m_imageBitmapsArray;
131 BlobDataHandleMap m_blobDataHandles; 125 BlobDataHandleMap m_blobDataHandles;
132 intptr_t m_externallyAllocatedMemory; 126 intptr_t m_externallyAllocatedMemory;
133 127
134 friend class SerializedScriptValueFactory; 128 friend class SerializedScriptValueFactory;
135 }; 129 };
136 130
137 } // namespace blink 131 } // namespace blink
138 132
139 #endif // SerializedScriptValue_h 133 #endif // SerializedScriptValue_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698