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

Unified Diff: third_party/WebKit/Source/wtf/typed_arrays/ArrayBufferContents.h

Issue 2734173002: postMessage(): transfer allocation costs along with value. (Closed)
Patch Set: rebased upto r455878 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
« no previous file with comments | « third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/typed_arrays/ArrayBufferContents.h
diff --git a/third_party/WebKit/Source/wtf/typed_arrays/ArrayBufferContents.h b/third_party/WebKit/Source/wtf/typed_arrays/ArrayBufferContents.h
index 6984c552981a1df8e54a9de95aa1398bece46161..2bd5903ddf6eacff831c5f022c7e37eaa8c5709c 100644
--- a/third_party/WebKit/Source/wtf/typed_arrays/ArrayBufferContents.h
+++ b/third_party/WebKit/Source/wtf/typed_arrays/ArrayBufferContents.h
@@ -102,6 +102,29 @@ class WTF_EXPORT ArrayBufferContents {
s_adjustAmountOfExternalAllocatedMemoryFunction = function;
}
+ enum LeaveOrEnter {
+ Leave,
+ Enter,
+ };
+
+ // Externally allocated memory is kept track of per context (isolate),
+ // hence when moving ArrayBufferContents to another context, its
+ // externally allocated memory needs to be registered with its
+ // destination context.
+ //
+ // Expose |adjustExternalAllocatedMemoryUponContextTransfer| in order to do
+ // so, which postMessage() implementations make use of when transferring
+ // array buffers.
+ void adjustExternalAllocatedMemoryUponContextTransfer(
+ LeaveOrEnter direction) {
+ int64_t diff = static_cast<int64_t>(sizeInBytes());
+ if (!diff)
+ return;
+ if (direction == Leave)
+ diff = -diff;
+ m_holder->adjustAmountOfExternalAllocatedMemory(diff);
+ }
+
private:
static void* allocateMemoryWithFlags(size_t, InitializationPolicy, int);
@@ -126,11 +149,12 @@ class WTF_EXPORT ArrayBufferContents {
unsigned sizeInBytes() const { return m_sizeInBytes; }
bool isShared() const { return m_isShared == Shared; }
- private:
void adjustAmountOfExternalAllocatedMemory(int64_t diff) {
checkIfAdjustAmountOfExternalAllocatedMemoryIsConsistent();
s_adjustAmountOfExternalAllocatedMemoryFunction(diff);
}
+
+ private:
void adjustAmountOfExternalAllocatedMemory(unsigned diff) {
adjustAmountOfExternalAllocatedMemory(static_cast<int64_t>(diff));
}
« no previous file with comments | « third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698