| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/child/child_thread_impl.h" | 5 #include "content/child/child_thread_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 ScopedVector<base::DiscardableMemory> instances; | 87 ScopedVector<base::DiscardableMemory> instances; |
| 88 for (size_t i = 0; i < kNumberOfInstances; ++i) { | 88 for (size_t i = 0; i < kNumberOfInstances; ++i) { |
| 89 std::unique_ptr<base::DiscardableMemory> memory = | 89 std::unique_ptr<base::DiscardableMemory> memory = |
| 90 child_discardable_shared_memory_manager() | 90 child_discardable_shared_memory_manager() |
| 91 ->AllocateLockedDiscardableMemory(kLargeSize); | 91 ->AllocateLockedDiscardableMemory(kLargeSize); |
| 92 ASSERT_TRUE(memory); | 92 ASSERT_TRUE(memory); |
| 93 void* addr = memory->data(); | 93 void* addr = memory->data(); |
| 94 ASSERT_NE(nullptr, addr); | 94 ASSERT_NE(nullptr, addr); |
| 95 memory->Unlock(); | 95 memory->Unlock(); |
| 96 instances.push_back(std::move(memory)); | 96 instances.push_back(std::move(memory)); |
| 97 |
| 98 if (i % 10 == 0) { |
| 99 size_t s = 0; |
| 100 for (auto& m : instances) { |
| 101 if (m->Lock()) { |
| 102 s += kLargeSize; |
| 103 m->Unlock(); |
| 104 } |
| 105 } |
| 106 fprintf(stderr, "EEE s=%luMB\n", s / 1024/1024); |
| 107 } |
| 97 } | 108 } |
| 98 } | 109 } |
| 99 | 110 |
| 100 IN_PROC_BROWSER_TEST_F(ChildThreadImplBrowserTest, | 111 IN_PROC_BROWSER_TEST_F(ChildThreadImplBrowserTest, |
| 101 ReleaseFreeDiscardableMemory) { | 112 ReleaseFreeDiscardableMemory) { |
| 102 const size_t kSize = 1024 * 1024; // 1MiB. | 113 const size_t kSize = 1024 * 1024; // 1MiB. |
| 103 | 114 |
| 104 std::unique_ptr<base::DiscardableMemory> memory = | 115 std::unique_ptr<base::DiscardableMemory> memory = |
| 105 child_discardable_shared_memory_manager() | 116 child_discardable_shared_memory_manager() |
| 106 ->AllocateLockedDiscardableMemory(kSize); | 117 ->AllocateLockedDiscardableMemory(kSize); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 121 if (!discardable_memory::DiscardableSharedMemoryManager::current() | 132 if (!discardable_memory::DiscardableSharedMemoryManager::current() |
| 122 ->GetBytesAllocated()) | 133 ->GetBytesAllocated()) |
| 123 break; | 134 break; |
| 124 } | 135 } |
| 125 | 136 |
| 126 EXPECT_LT(base::TimeTicks::Now(), end); | 137 EXPECT_LT(base::TimeTicks::Now(), end); |
| 127 } | 138 } |
| 128 | 139 |
| 129 } // namespace | 140 } // namespace |
| 130 } // namespace content | 141 } // namespace content |
| OLD | NEW |