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

Unified Diff: base/memory/discardable_shared_memory.cc

Issue 1374213002: [tracing] Display the locked size of discardable memory segment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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: base/memory/discardable_shared_memory.cc
diff --git a/base/memory/discardable_shared_memory.cc b/base/memory/discardable_shared_memory.cc
index 0f85c1fe903d612ecf055043c1a0d84d362ddbf7..25b29b5400ac04e92156032336ffe8a22414b679 100644
--- a/base/memory/discardable_shared_memory.cc
+++ b/base/memory/discardable_shared_memory.cc
@@ -160,6 +160,18 @@ bool DiscardableSharedMemory::Unmap() {
return true;
}
+size_t DiscardableSharedMemory::LockedSize() const {
+ if (!shared_memory_.memory())
+ return 0;
+
+ SharedState result(subtle::NoBarrier_Load(
+ &SharedStateFromSharedMemory(shared_memory_)->value.i));
+
+ return result.GetLockState() == SharedState::LOCKED
+ ? locked_page_count_ * base::GetPageSize()
+ : 0;
+}
+
DiscardableSharedMemory::LockResult DiscardableSharedMemory::Lock(
size_t offset, size_t length) {
DCHECK_EQ(AlignToPageSize(offset), offset);

Powered by Google App Engine
This is Rietveld 408576698