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

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

Issue 2741793003: Accurate transfer of SerializedScriptValue allocation costs. (Closed)
Patch Set: simplify, revert postMessage() status tracking 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // Informs V8 about external memory allocated and owned by this object. 132 // Informs V8 about external memory allocated and owned by this object.
133 // Large values should contribute to GC counters to eventually trigger a GC, 133 // Large values should contribute to GC counters to eventually trigger a GC,
134 // otherwise flood of postMessage() can cause OOM. 134 // otherwise flood of postMessage() can cause OOM.
135 // Ok to invoke multiple times (only adds memory once). 135 // Ok to invoke multiple times (only adds memory once).
136 // The memory registration is revoked automatically in destructor. 136 // The memory registration is revoked automatically in destructor.
137 void registerMemoryAllocatedWithCurrentScriptContext(); 137 void registerMemoryAllocatedWithCurrentScriptContext();
138 138
139 // Upon passing a serialized value from one context to another (via a 139 // Upon passing a serialized value from one context to another (via a
140 // postMessage()), the allocation amounts it has registered with the 140 // postMessage()), the allocation amounts it has registered with the
141 // 'origining' context must be discharged, as the 'target' context will assume 141 // 'origining' context must be discharged, as the 'target' context will assume
142 // ownership of value. This method takes care of the first part of the 142 // ownership of the value. As we're potentially working across threads, this
143 // external allocation bookkeeping, the above registration method the other 143 // transfer of cost is handled by multiple stages:
144 // half. 144 //
145 void unregisterMemoryAllocatedByCurrentScriptContext(); 145 // - prepareForTransferringContext(): prepares and marks this
146 // SerializedScriptValue as being destined for transfer to another
147 // context.
148 // [- attempt to transfer (e.g., postMessage) the value]
149 // - finalizeTransferringContext(): if the transfer was successful,
150 // discount allocation costs from the context just left.
151 //
152 // - registerMemoryAllocatedWithCurrentScriptContext() - called by the
153 // 'target' once ownership has been assumed. It registers the allocation
154 // costs of the resources that the SerializedScriptValue holds onto in
155 // that new context.
156 //
157 void prepareForTransferringContext();
158 void finalizeTransferringContext();
146 159
147 const uint8_t* data() const { return m_dataBuffer.get(); } 160 const uint8_t* data() const { return m_dataBuffer.get(); }
148 size_t dataLengthInBytes() const { return m_dataBufferSize; } 161 size_t dataLengthInBytes() const { return m_dataBufferSize; }
149 162
150 BlobDataHandleMap& blobDataHandles() { return m_blobDataHandles; } 163 BlobDataHandleMap& blobDataHandles() { return m_blobDataHandles; }
151 ArrayBufferContentsArray* getArrayBufferContentsArray() { 164 ArrayBufferContentsArray* getArrayBufferContentsArray() {
152 return m_arrayBufferContentsArray.get(); 165 return m_arrayBufferContentsArray.get();
153 } 166 }
154 ImageBitmapContentsArray* getImageBitmapContentsArray() { 167 ImageBitmapContentsArray* getImageBitmapContentsArray() {
155 return m_imageBitmapContentsArray.get(); 168 return m_imageBitmapContentsArray.get();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 v8::Local<v8::Value> value, 213 v8::Local<v8::Value> value,
201 ExceptionState& exceptionState) { 214 ExceptionState& exceptionState) {
202 return SerializedScriptValue::serialize(isolate, value, nullptr, nullptr, 215 return SerializedScriptValue::serialize(isolate, value, nullptr, nullptr,
203 exceptionState); 216 exceptionState);
204 } 217 }
205 }; 218 };
206 219
207 } // namespace blink 220 } // namespace blink
208 221
209 #endif // SerializedScriptValue_h 222 #endif // SerializedScriptValue_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698