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

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

Issue 2741793003: Accurate transfer of SerializedScriptValue allocation costs. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.h b/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.h
index e74e3dfd8b5f3a190600d1d26a335f5663dd7ab5..e62beb43276575356555856fcc55b703fd4668a5 100644
--- a/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.h
+++ b/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.h
@@ -139,10 +139,24 @@ class CORE_EXPORT SerializedScriptValue
// Upon passing a serialized value from one context to another (via a
// postMessage()), the allocation amounts it has registered with the
// 'origining' context must be discharged, as the 'target' context will assume
- // ownership of value. This method takes care of the first part of the
- // external allocation bookkeeping, the above registration method the other
- // half.
- void unregisterMemoryAllocatedByCurrentScriptContext();
+ // ownership of the value. As we're potentially working across threads, this
+ // transfer of cost is handled in three stages:
+ //
+ // - prepareForTransferringContext(): prepares and marks this
+ // SerializedScriptValue as being destined for transfer to another
+ // context.
+ // - finalizeTransferringContext(): checks if the transfer was successful,
+ // and if so, discounts allocation costs from the context just left.
+ // - registerMemoryAllocatedWithCurrentScriptContext() - called by the
+ // 'target' once ownership has been assumed. It registers the allocation
+ // costs of the resources that the SerializedScriptValue holds onto in
+ // that new context.
+ //
+ // The first two are called by 'origining' context, before and after actual
+ // transfer.
+ //
+ void prepareForTransferringContext();
+ void finalizeTransferringContext();
const uint8_t* data() const { return m_dataBuffer.get(); }
size_t dataLengthInBytes() const { return m_dataBufferSize; }

Powered by Google App Engine
This is Rietveld 408576698