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

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

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

Powered by Google App Engine
This is Rietveld 408576698