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

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

Issue 2734173002: postMessage(): transfer allocation costs along with value. (Closed)
Patch Set: update comment Created 3 years, 9 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 static std::unique_ptr<ArrayBufferContentsArray> transferArrayBufferContents( 121 static std::unique_ptr<ArrayBufferContentsArray> transferArrayBufferContents(
122 v8::Isolate*, 122 v8::Isolate*,
123 const ArrayBufferArray&, 123 const ArrayBufferArray&,
124 ExceptionState&); 124 ExceptionState&);
125 125
126 static std::unique_ptr<ImageBitmapContentsArray> transferImageBitmapContents( 126 static std::unique_ptr<ImageBitmapContentsArray> transferImageBitmapContents(
127 v8::Isolate*, 127 v8::Isolate*,
128 const ImageBitmapArray&, 128 const ImageBitmapArray&,
129 ExceptionState&); 129 ExceptionState&);
130 130
131 // Informs the V8 about external memory allocated and owned by this object. 131 // Informs V8 about external memory allocated and owned by this object.
132 // Large values should contribute to GC counters to eventually trigger a GC, 132 // Large values should contribute to GC counters to eventually trigger a GC,
133 // otherwise flood of postMessage() can cause OOM. 133 // otherwise flood of postMessage() can cause OOM.
134 // Ok to invoke multiple times (only adds memory once). 134 // Ok to invoke multiple times (only adds memory once).
135 // The memory registration is revoked automatically in destructor. 135 // The memory registration is revoked automatically in destructor.
136 void registerMemoryAllocatedWithCurrentScriptContext(); 136 void registerMemoryAllocatedWithCurrentScriptContext();
137 137
138 // Upon passing a serialized value from one context to another (via a
139 // postMessage()), the allocation amounts it has registered with the
140 // 'origining' context must be discharged, as the 'target' context will assume
141 // ownership of value. This method takes care of the first part of the
142 // external allocation bookkeeping, the above registration method the other
143 // half.
144 void unregisterMemoryAllocatedByCurrentScriptContext();
jbroman 2017/03/07 18:00:04 Can you clarify why this is needed now? It looks l
sof 2017/03/07 19:14:03 - transferables (arraybuffers) will be accounted w
jbroman 2017/03/07 19:29:05 Ah, it wasn't obvious to me that this was intended
sof 2017/03/08 07:07:17 Added a method on ArrayBufferContents to handle th
145
138 const uint8_t* data() const { return m_dataBuffer.get(); } 146 const uint8_t* data() const { return m_dataBuffer.get(); }
139 size_t dataLengthInBytes() const { return m_dataBufferSize; } 147 size_t dataLengthInBytes() const { return m_dataBufferSize; }
140 148
141 BlobDataHandleMap& blobDataHandles() { return m_blobDataHandles; } 149 BlobDataHandleMap& blobDataHandles() { return m_blobDataHandles; }
142 ArrayBufferContentsArray* getArrayBufferContentsArray() { 150 ArrayBufferContentsArray* getArrayBufferContentsArray() {
143 return m_arrayBufferContentsArray.get(); 151 return m_arrayBufferContentsArray.get();
144 } 152 }
145 ImageBitmapContentsArray* getImageBitmapContentsArray() { 153 ImageBitmapContentsArray* getImageBitmapContentsArray() {
146 return m_imageBitmapContentsArray.get(); 154 return m_imageBitmapContentsArray.get();
147 } 155 }
(...skipping 30 matching lines...) Expand all
178 186
179 std::unique_ptr<ArrayBufferContentsArray> m_arrayBufferContentsArray; 187 std::unique_ptr<ArrayBufferContentsArray> m_arrayBufferContentsArray;
180 std::unique_ptr<ImageBitmapContentsArray> m_imageBitmapContentsArray; 188 std::unique_ptr<ImageBitmapContentsArray> m_imageBitmapContentsArray;
181 BlobDataHandleMap m_blobDataHandles; 189 BlobDataHandleMap m_blobDataHandles;
182 intptr_t m_externallyAllocatedMemory; 190 intptr_t m_externallyAllocatedMemory;
183 }; 191 };
184 192
185 } // namespace blink 193 } // namespace blink
186 194
187 #endif // SerializedScriptValue_h 195 #endif // SerializedScriptValue_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698