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

Side by Side Diff: base/memory/discardable_shared_memory_unittest.cc

Issue 1409743002: Re-land: base: Use MADV_REMOVE instead of ftruncate to purge discardable memory segments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/memory/discardable_shared_memory.h" 6 #include "base/memory/discardable_shared_memory.h"
7 #include "base/process/process_metrics.h" 7 #include "base/process/process_metrics.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace base { 10 namespace base {
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 memory.SetNow(Time::FromDoubleT(1)); 336 memory.SetNow(Time::FromDoubleT(1));
337 memory.Unlock(0, 0); 337 memory.Unlock(0, 0);
338 338
339 // Lock and unlock memory. 339 // Lock and unlock memory.
340 auto lock_rv = memory.Lock(0, 0); 340 auto lock_rv = memory.Lock(0, 0);
341 EXPECT_EQ(DiscardableSharedMemory::SUCCESS, lock_rv); 341 EXPECT_EQ(DiscardableSharedMemory::SUCCESS, lock_rv);
342 memory.SetNow(Time::FromDoubleT(2)); 342 memory.SetNow(Time::FromDoubleT(2));
343 memory.Unlock(0, 0); 343 memory.Unlock(0, 0);
344 } 344 }
345 345
346 #if defined(DISCARDABLE_SHARED_MEMORY_SHRINKING)
347 TEST(DiscardableSharedMemoryTest, Shrink) {
348 const uint32 kDataSize = 1024;
349
350 TestDiscardableSharedMemory memory;
351 bool rv = memory.CreateAndMap(kDataSize);
352 ASSERT_TRUE(rv);
353
354 EXPECT_NE(0u, memory.mapped_size());
355
356 // Mapped size should be 0 after shrinking memory segment.
357 memory.Shrink();
358 EXPECT_EQ(0u, memory.mapped_size());
359 }
360 #endif
361
362 } // namespace 346 } // namespace
363 } // namespace base 347 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698