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

Unified Diff: base/memory/discardable_shared_memory.cc

Issue 1057493005: Revert of base: Replace PurgeAndTruncate with Shrink function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 | « base/memory/discardable_shared_memory.h ('k') | base/memory/discardable_shared_memory_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/discardable_shared_memory.cc
diff --git a/base/memory/discardable_shared_memory.cc b/base/memory/discardable_shared_memory.cc
index 830d6b9d87fdde5438b2d1255c6dc07b62aabf93..49e93cdaf6f22a20e0a76fd0128b5aa8cdd743dd 100644
--- a/base/memory/discardable_shared_memory.cc
+++ b/base/memory/discardable_shared_memory.cc
@@ -325,6 +325,22 @@
return true;
}
+bool DiscardableSharedMemory::PurgeAndTruncate(Time current_time) {
+ if (!Purge(current_time))
+ return false;
+
+#if defined(OS_POSIX)
+ // Truncate shared memory to size of SharedState.
+ SharedMemoryHandle handle = shared_memory_.handle();
+ if (SharedMemory::IsHandleValid(handle)) {
+ if (HANDLE_EINTR(ftruncate(handle.fd, sizeof(SharedState))) != 0)
+ DPLOG(ERROR) << "ftruncate() failed";
+ }
+#endif
+
+ return true;
+}
+
bool DiscardableSharedMemory::IsMemoryResident() const {
DCHECK(shared_memory_.memory());
@@ -341,26 +357,6 @@
mapped_size_ = 0;
}
-#if defined(DISCARDABLE_SHARED_MEMORY_SHRINKING)
-void DiscardableSharedMemory::Shrink() {
-#if defined(OS_POSIX)
- SharedMemoryHandle handle = shared_memory_.handle();
- if (!SharedMemory::IsHandleValid(handle))
- return;
-
- // Truncate shared memory to size of SharedState.
- if (HANDLE_EINTR(
- ftruncate(handle.fd, AlignToPageSize(sizeof(SharedState)))) != 0) {
- DPLOG(ERROR) << "ftruncate() failed";
- return;
- }
- mapped_size_ = 0;
-#else
- NOTIMPLEMENTED();
-#endif
-}
-#endif
-
Time DiscardableSharedMemory::Now() const {
return Time::Now();
}
« no previous file with comments | « base/memory/discardable_shared_memory.h ('k') | base/memory/discardable_shared_memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698