| OLD | NEW | 
|---|
| 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 <stdint.h> | 5 #include <stdint.h> | 
| 6 | 6 | 
| 7 #include "base/memory/discardable_shared_memory.h" | 7 #include "base/memory/discardable_shared_memory.h" | 
| 8 #include "base/process/process_metrics.h" | 8 #include "base/process/process_metrics.h" | 
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" | 
| 10 | 10 | 
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 351   ASSERT_TRUE(rv); | 351   ASSERT_TRUE(rv); | 
| 352 | 352 | 
| 353   EXPECT_LE(0u, memory.mapped_size()); | 353   EXPECT_LE(0u, memory.mapped_size()); | 
| 354 | 354 | 
| 355   // Memory is initially locked. Unlock it. | 355   // Memory is initially locked. Unlock it. | 
| 356   memory.SetNow(Time::FromDoubleT(1)); | 356   memory.SetNow(Time::FromDoubleT(1)); | 
| 357   memory.Unlock(0, 0); | 357   memory.Unlock(0, 0); | 
| 358 | 358 | 
| 359   // Lock and unlock memory. | 359   // Lock and unlock memory. | 
| 360   DiscardableSharedMemory::LockResult lock_rv = memory.Lock(0, 0); | 360   DiscardableSharedMemory::LockResult lock_rv = memory.Lock(0, 0); | 
| 361   EXPECT_EQ(DiscardableSharedMemory::SUCCESS, lock_rv); | 361   EXPECT_NE(DiscardableSharedMemory::FAILED, lock_rv); | 
| 362   memory.SetNow(Time::FromDoubleT(2)); | 362   memory.SetNow(Time::FromDoubleT(2)); | 
| 363   memory.Unlock(0, 0); | 363   memory.Unlock(0, 0); | 
| 364 } | 364 } | 
| 365 | 365 | 
| 366 // This test checks that zero-filled pages are returned after purging a segment | 366 // This test checks that zero-filled pages are returned after purging a segment | 
| 367 // when DISCARDABLE_SHARED_MEMORY_ZERO_FILL_ON_DEMAND_PAGES_AFTER_PURGE is | 367 // when DISCARDABLE_SHARED_MEMORY_ZERO_FILL_ON_DEMAND_PAGES_AFTER_PURGE is | 
| 368 // defined and MADV_REMOVE is supported. | 368 // defined and MADV_REMOVE is supported. | 
| 369 #if defined(DISCARDABLE_SHARED_MEMORY_ZERO_FILL_ON_DEMAND_PAGES_AFTER_PURGE) | 369 #if defined(DISCARDABLE_SHARED_MEMORY_ZERO_FILL_ON_DEMAND_PAGES_AFTER_PURGE) | 
| 370 TEST(DiscardableSharedMemoryTest, ZeroFilledPagesAfterPurge) { | 370 TEST(DiscardableSharedMemoryTest, ZeroFilledPagesAfterPurge) { | 
| 371   const uint32_t kDataSize = 1024; | 371   const uint32_t kDataSize = 1024; | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 399 | 399 | 
| 400   // Check that reading memory after it has been purged is returning | 400   // Check that reading memory after it has been purged is returning | 
| 401   // zero-filled pages. | 401   // zero-filled pages. | 
| 402   uint8_t expected_data[kDataSize] = {}; | 402   uint8_t expected_data[kDataSize] = {}; | 
| 403   EXPECT_EQ(memcmp(memory2.memory(), expected_data, kDataSize), 0); | 403   EXPECT_EQ(memcmp(memory2.memory(), expected_data, kDataSize), 0); | 
| 404 } | 404 } | 
| 405 #endif | 405 #endif | 
| 406 | 406 | 
| 407 }  // namespace | 407 }  // namespace | 
| 408 }  // namespace base | 408 }  // namespace base | 
| OLD | NEW | 
|---|