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 "platform/web_process_memory_dump_impl.h" | 5 #include "platform/web_process_memory_dump.h" |
6 | 6 |
7 #include "base/memory/discardable_memory.h" | 7 #include "base/memory/discardable_memory.h" |
8 #include "base/test/test_discardable_memory_allocator.h" | 8 #include "base/test/test_discardable_memory_allocator.h" |
9 #include "base/trace_event/memory_allocator_dump.h" | 9 #include "base/trace_event/memory_allocator_dump.h" |
10 #include "base/trace_event/process_memory_dump.h" | 10 #include "base/trace_event/process_memory_dump.h" |
11 #include "base/trace_event/trace_event_argument.h" | 11 #include "base/trace_event/trace_event_argument.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "platform/web_memory_allocator_dump_impl.h" | 13 #include "platform/web_memory_allocator_dump.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "wtf/OwnPtr.h" | 15 #include "wtf/OwnPtr.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 | 18 |
19 // Tests that the Chromium<>Blink plumbing that exposes the MemoryInfra classes | 19 // Tests that the Chromium<>Blink plumbing that exposes the MemoryInfra classes |
20 // behaves correctly, performs the right transfers of memory ownerships and | 20 // behaves correctly, performs the right transfers of memory ownerships and |
21 // doesn't leak objects. | 21 // doesn't leak objects. |
22 TEST(WebProcessMemoryDumpImplTest, IntegrationTest) { | 22 TEST(WebProcessMemoryDumpTest, IntegrationTest) { |
23 std::unique_ptr<base::trace_event::TracedValue> traced_value( | 23 std::unique_ptr<base::trace_event::TracedValue> traced_value( |
24 new base::trace_event::TracedValue()); | 24 new base::trace_event::TracedValue()); |
25 | 25 |
26 std::unique_ptr<WebProcessMemoryDumpImpl> wpmd1(new WebProcessMemoryDumpImpl()
); | 26 std::unique_ptr<WebProcessMemoryDump> wpmd1(new WebProcessMemoryDump()); |
27 auto wmad1 = wpmd1->createMemoryAllocatorDump("1/1"); | 27 auto wmad1 = wpmd1->createMemoryAllocatorDump("1/1"); |
28 auto wmad2 = wpmd1->createMemoryAllocatorDump("1/2"); | 28 auto wmad2 = wpmd1->createMemoryAllocatorDump("1/2"); |
29 ASSERT_EQ(wmad1, wpmd1->getMemoryAllocatorDump("1/1")); | 29 ASSERT_EQ(wmad1, wpmd1->getMemoryAllocatorDump("1/1")); |
30 ASSERT_EQ(wmad2, wpmd1->getMemoryAllocatorDump("1/2")); | 30 ASSERT_EQ(wmad2, wpmd1->getMemoryAllocatorDump("1/2")); |
31 | 31 |
32 std::unique_ptr<WebProcessMemoryDumpImpl> wpmd2(new WebProcessMemoryDumpImpl()
); | 32 std::unique_ptr<WebProcessMemoryDump> wpmd2(new WebProcessMemoryDump()); |
33 wpmd2->createMemoryAllocatorDump("2/1"); | 33 wpmd2->createMemoryAllocatorDump("2/1"); |
34 wpmd2->createMemoryAllocatorDump("2/2"); | 34 wpmd2->createMemoryAllocatorDump("2/2"); |
35 | 35 |
36 wpmd1->takeAllDumpsFrom(wpmd2.get()); | 36 wpmd1->takeAllDumpsFrom(wpmd2.get()); |
37 | 37 |
38 // Make sure that wpmd2 still owns its own PMD, even if empty. | 38 // Make sure that wpmd2 still owns its own PMD, even if empty. |
39 ASSERT_NE(static_cast<base::trace_event::ProcessMemoryDump*>(nullptr), | 39 ASSERT_NE(static_cast<base::trace_event::ProcessMemoryDump*>(nullptr), |
40 wpmd2->process_memory_dump_); | 40 wpmd2->process_memory_dump_); |
41 ASSERT_EQ(wpmd2->owned_process_memory_dump_.get(), | 41 ASSERT_EQ(wpmd2->owned_process_memory_dump_.get(), |
42 wpmd2->process_memory_dump()); | 42 wpmd2->process_memory_dump()); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 auto discardable_memory = | 130 auto discardable_memory = |
131 discardable_memory_allocator.AllocateLockedDiscardableMemory(1024); | 131 discardable_memory_allocator.AllocateLockedDiscardableMemory(1024); |
132 wpmd1->createDiscardableMemoryAllocatorDump("1/discardable", | 132 wpmd1->createDiscardableMemoryAllocatorDump("1/discardable", |
133 discardable_memory.get()); | 133 discardable_memory.get()); |
134 discardable_memory->Unlock(); | 134 discardable_memory->Unlock(); |
135 | 135 |
136 wpmd1.reset(); | 136 wpmd1.reset(); |
137 } | 137 } |
138 | 138 |
139 } // namespace blink | 139 } // namespace blink |
OLD | NEW |