| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "content/child/child_discardable_shared_memory_manager.h" | 7 #include "content/child/child_discardable_shared_memory_manager.h" |
| 8 #include "content/child/child_thread_impl.h" | 8 #include "content/child/child_thread_impl.h" |
| 9 #include "content/common/host_discardable_shared_memory_manager.h" | 9 #include "content/common/host_discardable_shared_memory_manager.h" |
| 10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 } | 42 } |
| 43 | 43 |
| 44 static void UnlockMemory(base::DiscardableMemoryShmemChunk* memory) { | 44 static void UnlockMemory(base::DiscardableMemoryShmemChunk* memory) { |
| 45 memory->Unlock(); | 45 memory->Unlock(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 static void FreeMemory(scoped_ptr<base::DiscardableMemoryShmemChunk> memory) { | 48 static void FreeMemory(scoped_ptr<base::DiscardableMemoryShmemChunk> memory) { |
| 49 } | 49 } |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 #if defined(OS_WIN) | |
| 53 #define MAYBE_LockMemory DISABLED_LockMemory | |
| 54 #else | |
| 55 #define MAYBE_LockMemory LockMemory | |
| 56 #endif | |
| 57 | |
| 58 IN_PROC_BROWSER_TEST_F(ChildDiscardableSharedMemoryManagerBrowserTest, | 52 IN_PROC_BROWSER_TEST_F(ChildDiscardableSharedMemoryManagerBrowserTest, |
| 59 MAYBE_LockMemory) { | 53 DISABLED_LockMemory) { |
| 60 const size_t kSize = 1024 * 1024; // 1MiB. | 54 const size_t kSize = 1024 * 1024; // 1MiB. |
| 61 | 55 |
| 62 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); | 56 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); |
| 63 | 57 |
| 64 scoped_ptr<base::DiscardableMemoryShmemChunk> memory; | 58 scoped_ptr<base::DiscardableMemoryShmemChunk> memory; |
| 65 PostTaskToInProcessRendererAndWait(base::Bind( | 59 PostTaskToInProcessRendererAndWait(base::Bind( |
| 66 &ChildDiscardableSharedMemoryManagerBrowserTest::AllocateLockedMemory, | 60 &ChildDiscardableSharedMemoryManagerBrowserTest::AllocateLockedMemory, |
| 67 kSize, &memory)); | 61 kSize, &memory)); |
| 68 | 62 |
| 69 ASSERT_TRUE(memory); | 63 ASSERT_TRUE(memory); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 84 | 78 |
| 85 // Should fail as memory should have been purged. | 79 // Should fail as memory should have been purged. |
| 86 EXPECT_FALSE(result); | 80 EXPECT_FALSE(result); |
| 87 | 81 |
| 88 PostTaskToInProcessRendererAndWait( | 82 PostTaskToInProcessRendererAndWait( |
| 89 base::Bind(&ChildDiscardableSharedMemoryManagerBrowserTest::FreeMemory, | 83 base::Bind(&ChildDiscardableSharedMemoryManagerBrowserTest::FreeMemory, |
| 90 base::Passed(&memory))); | 84 base::Passed(&memory))); |
| 91 } | 85 } |
| 92 | 86 |
| 93 IN_PROC_BROWSER_TEST_F(ChildDiscardableSharedMemoryManagerBrowserTest, | 87 IN_PROC_BROWSER_TEST_F(ChildDiscardableSharedMemoryManagerBrowserTest, |
| 94 AddressSpace) { | 88 DISABLED_AddressSpace) { |
| 95 const size_t kLargeSize = 4 * 1024 * 1024; // 4MiB. | 89 const size_t kLargeSize = 4 * 1024 * 1024; // 4MiB. |
| 96 const size_t kNumberOfInstances = 1024 + 1; // >4GiB total. | 90 const size_t kNumberOfInstances = 1024 + 1; // >4GiB total. |
| 97 | 91 |
| 98 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); | 92 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); |
| 99 | 93 |
| 100 scoped_ptr<base::DiscardableMemoryShmemChunk> instances[kNumberOfInstances]; | 94 scoped_ptr<base::DiscardableMemoryShmemChunk> instances[kNumberOfInstances]; |
| 101 for (auto& memory : instances) { | 95 for (auto& memory : instances) { |
| 102 PostTaskToInProcessRendererAndWait(base::Bind( | 96 PostTaskToInProcessRendererAndWait(base::Bind( |
| 103 &ChildDiscardableSharedMemoryManagerBrowserTest::AllocateLockedMemory, | 97 &ChildDiscardableSharedMemoryManagerBrowserTest::AllocateLockedMemory, |
| 104 kLargeSize, &memory)); | 98 kLargeSize, &memory)); |
| 105 ASSERT_TRUE(memory); | 99 ASSERT_TRUE(memory); |
| 106 void* addr = memory->Memory(); | 100 void* addr = memory->Memory(); |
| 107 ASSERT_NE(nullptr, addr); | 101 ASSERT_NE(nullptr, addr); |
| 108 PostTaskToInProcessRendererAndWait(base::Bind( | 102 PostTaskToInProcessRendererAndWait(base::Bind( |
| 109 &ChildDiscardableSharedMemoryManagerBrowserTest::UnlockMemory, | 103 &ChildDiscardableSharedMemoryManagerBrowserTest::UnlockMemory, |
| 110 memory.get())); | 104 memory.get())); |
| 111 } | 105 } |
| 112 | 106 |
| 113 for (auto& memory : instances) { | 107 for (auto& memory : instances) { |
| 114 PostTaskToInProcessRendererAndWait( | 108 PostTaskToInProcessRendererAndWait( |
| 115 base::Bind(&ChildDiscardableSharedMemoryManagerBrowserTest::FreeMemory, | 109 base::Bind(&ChildDiscardableSharedMemoryManagerBrowserTest::FreeMemory, |
| 116 base::Passed(&memory))); | 110 base::Passed(&memory))); |
| 117 } | 111 } |
| 118 } | 112 } |
| 119 | 113 |
| 120 } // content | 114 } // content |
| OLD | NEW |