| 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/trace_event/memory_dump_manager.h" | 5 #include "base/trace_event/memory_dump_manager.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/memory/ref_counted_memory.h" | 14 #include "base/memory/ref_counted_memory.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 18 #include "base/synchronization/waitable_event.h" | 18 #include "base/synchronization/waitable_event.h" |
| 19 #include "base/test/test_io_thread.h" | 19 #include "base/test/test_io_thread.h" |
| 20 #include "base/test/trace_event_analyzer.h" | 20 #include "base/test/trace_event_analyzer.h" |
| 21 #include "base/threading/platform_thread.h" | 21 #include "base/threading/platform_thread.h" |
| 22 #include "base/threading/sequenced_worker_pool.h" | 22 #include "base/threading/sequenced_worker_pool.h" |
| 23 #include "base/threading/thread.h" | 23 #include "base/threading/thread.h" |
| 24 #include "base/threading/thread_task_runner_handle.h" | 24 #include "base/threading/thread_task_runner_handle.h" |
| 25 #include "base/trace_event/memory_dump_provider.h" | 25 #include "base/trace_event/memory_dump_provider.h" |
| 26 #include "base/trace_event/memory_infra_background_whitelist.h" |
| 26 #include "base/trace_event/process_memory_dump.h" | 27 #include "base/trace_event/process_memory_dump.h" |
| 27 #include "base/trace_event/trace_buffer.h" | 28 #include "base/trace_event/trace_buffer.h" |
| 28 #include "base/trace_event/trace_config_memory_test_util.h" | 29 #include "base/trace_event/trace_config_memory_test_util.h" |
| 29 #include "testing/gmock/include/gmock/gmock.h" | 30 #include "testing/gmock/include/gmock/gmock.h" |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
| 31 | 32 |
| 32 using testing::_; | 33 using testing::_; |
| 33 using testing::AnyNumber; | 34 using testing::AnyNumber; |
| 34 using testing::AtMost; | 35 using testing::AtMost; |
| 35 using testing::Between; | 36 using testing::Between; |
| (...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(2); | 1106 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(2); |
| 1106 for (int i = 0; i < 2; ++i) { | 1107 for (int i = 0; i < 2; ++i) { |
| 1107 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, | 1108 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, |
| 1108 MemoryDumpLevelOfDetail::DETAILED); | 1109 MemoryDumpLevelOfDetail::DETAILED); |
| 1109 } | 1110 } |
| 1110 DisableTracing(); | 1111 DisableTracing(); |
| 1111 } | 1112 } |
| 1112 | 1113 |
| 1113 TEST_F(MemoryDumpManagerTest, TestWhitelistingMDP) { | 1114 TEST_F(MemoryDumpManagerTest, TestWhitelistingMDP) { |
| 1114 InitializeMemoryDumpManager(false /* is_coordinator */); | 1115 InitializeMemoryDumpManager(false /* is_coordinator */); |
| 1115 mdm_->set_dump_provider_whitelist_for_testing(kTestMDPWhitelist); | 1116 SetDumpProviderWhitelistForTesting(kTestMDPWhitelist); |
| 1116 std::unique_ptr<MockMemoryDumpProvider> mdp1(new MockMemoryDumpProvider); | 1117 std::unique_ptr<MockMemoryDumpProvider> mdp1(new MockMemoryDumpProvider); |
| 1117 RegisterDumpProvider(mdp1.get()); | 1118 RegisterDumpProvider(mdp1.get()); |
| 1118 std::unique_ptr<MockMemoryDumpProvider> mdp2(new MockMemoryDumpProvider); | 1119 std::unique_ptr<MockMemoryDumpProvider> mdp2(new MockMemoryDumpProvider); |
| 1119 RegisterDumpProvider(mdp2.get(), nullptr, kDefaultOptions, | 1120 RegisterDumpProvider(mdp2.get(), nullptr, kDefaultOptions, |
| 1120 kWhitelistedMDPName); | 1121 kWhitelistedMDPName); |
| 1121 | 1122 |
| 1122 EXPECT_CALL(*mdp1, OnMemoryDump(_, _)).Times(0); | 1123 EXPECT_CALL(*mdp1, OnMemoryDump(_, _)).Times(0); |
| 1123 EXPECT_CALL(*mdp2, OnMemoryDump(_, _)).Times(1).WillOnce(Return(true)); | 1124 EXPECT_CALL(*mdp2, OnMemoryDump(_, _)).Times(1).WillOnce(Return(true)); |
| 1124 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); | 1125 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); |
| 1125 | 1126 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1148 | 1149 |
| 1149 EnableTracingWithTraceConfig( | 1150 EnableTracingWithTraceConfig( |
| 1150 TraceConfigMemoryTestUtil::GetTraceConfig_BackgroundTrigger()); | 1151 TraceConfigMemoryTestUtil::GetTraceConfig_BackgroundTrigger()); |
| 1151 ASSERT_TRUE(IsPeriodicDumpingEnabled()); | 1152 ASSERT_TRUE(IsPeriodicDumpingEnabled()); |
| 1152 run_loop.Run(); | 1153 run_loop.Run(); |
| 1153 DisableTracing(); | 1154 DisableTracing(); |
| 1154 } | 1155 } |
| 1155 | 1156 |
| 1156 } // namespace trace_event | 1157 } // namespace trace_event |
| 1157 } // namespace base | 1158 } // namespace base |
| OLD | NEW |