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

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

Issue 2414333003: WebMessaging: Send transferable ArrayBuffers by copy-and-neuter semantics (Closed)
Patch Set: remake Created 4 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // 4.1.15 of the WebIDL spec and section 8.3.3 of the HTML5 spec and generates 107 // 4.1.15 of the WebIDL spec and section 8.3.3 of the HTML5 spec and generates
108 // exceptions as appropriate. 108 // exceptions as appropriate.
109 // Returns true if the array was filled, or false if the passed value was not 109 // Returns true if the array was filled, or false if the passed value was not
110 // of an appropriate type. 110 // of an appropriate type.
111 static bool extractTransferables(v8::Isolate*, 111 static bool extractTransferables(v8::Isolate*,
112 v8::Local<v8::Value>, 112 v8::Local<v8::Value>,
113 int, 113 int,
114 Transferables&, 114 Transferables&,
115 ExceptionState&); 115 ExceptionState&);
116 116
117 // Helper function which pulls ArrayBufferContents out of an ArrayBufferArray
118 // and neuters the ArrayBufferArray. Returns nullptr if there is an
119 // exception.
120 static std::unique_ptr<ArrayBufferContentsArray> transferArrayBufferContents(
121 v8::Isolate*,
122 const ArrayBufferArray&,
123 ExceptionState&);
124
117 // Informs the V8 about external memory allocated and owned by this object. 125 // Informs the V8 about external memory allocated and owned by this object.
118 // Large values should contribute to GC counters to eventually trigger a GC, 126 // Large values should contribute to GC counters to eventually trigger a GC,
119 // otherwise flood of postMessage() can cause OOM. 127 // otherwise flood of postMessage() can cause OOM.
120 // Ok to invoke multiple times (only adds memory once). 128 // Ok to invoke multiple times (only adds memory once).
121 // The memory registration is revoked automatically in destructor. 129 // The memory registration is revoked automatically in destructor.
122 void registerMemoryAllocatedWithCurrentScriptContext(); 130 void registerMemoryAllocatedWithCurrentScriptContext();
123 131
124 // Returns true if the value contains a transferable ArrayBuffer.
125 bool containsTransferableArrayBuffer() const;
126
127 String& data() { return m_data; } 132 String& data() { return m_data; }
128 BlobDataHandleMap& blobDataHandles() { return m_blobDataHandles; } 133 BlobDataHandleMap& blobDataHandles() { return m_blobDataHandles; }
129 ArrayBufferContentsArray* getArrayBufferContentsArray() { 134 ArrayBufferContentsArray* getArrayBufferContentsArray() {
130 return m_arrayBufferContentsArray.get(); 135 return m_arrayBufferContentsArray.get();
131 } 136 }
132 ImageBitmapContentsArray* getImageBitmapContentsArray() { 137 ImageBitmapContentsArray* getImageBitmapContentsArray() {
133 return m_imageBitmapContentsArray.get(); 138 return m_imageBitmapContentsArray.get();
134 } 139 }
135 140
136 private: 141 private:
(...skipping 19 matching lines...) Expand all
156 String m_data; 161 String m_data;
157 std::unique_ptr<ArrayBufferContentsArray> m_arrayBufferContentsArray; 162 std::unique_ptr<ArrayBufferContentsArray> m_arrayBufferContentsArray;
158 std::unique_ptr<ImageBitmapContentsArray> m_imageBitmapContentsArray; 163 std::unique_ptr<ImageBitmapContentsArray> m_imageBitmapContentsArray;
159 BlobDataHandleMap m_blobDataHandles; 164 BlobDataHandleMap m_blobDataHandles;
160 intptr_t m_externallyAllocatedMemory; 165 intptr_t m_externallyAllocatedMemory;
161 }; 166 };
162 167
163 } // namespace blink 168 } // namespace blink
164 169
165 #endif // SerializedScriptValue_h 170 #endif // SerializedScriptValue_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698