Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: base/trace_event/memory_dump_manager_unittest.cc

Issue 2006943003: [tracing] Sanitize process memory dumps for background mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@whitelist_mdp
Patch Set: Fixes. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(2); 1102 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(2);
1102 for (int i = 0; i < 2; ++i) { 1103 for (int i = 0; i < 2; ++i) {
1103 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 1104 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
1104 MemoryDumpLevelOfDetail::DETAILED); 1105 MemoryDumpLevelOfDetail::DETAILED);
1105 } 1106 }
1106 DisableTracing(); 1107 DisableTracing();
1107 } 1108 }
1108 1109
1109 TEST_F(MemoryDumpManagerTest, TestWhitelistingMDP) { 1110 TEST_F(MemoryDumpManagerTest, TestWhitelistingMDP) {
1110 InitializeMemoryDumpManager(false /* is_coordinator */); 1111 InitializeMemoryDumpManager(false /* is_coordinator */);
1111 mdm_->set_dump_provider_whitelist_for_testing(kTestMDPWhitelist); 1112 SetDumpProviderWhitelistForTesting(kTestMDPWhitelist);
1112 std::unique_ptr<MockMemoryDumpProvider> mdp1(new MockMemoryDumpProvider); 1113 std::unique_ptr<MockMemoryDumpProvider> mdp1(new MockMemoryDumpProvider);
1113 RegisterDumpProvider(mdp1.get()); 1114 RegisterDumpProvider(mdp1.get());
1114 std::unique_ptr<MockMemoryDumpProvider> mdp2(new MockMemoryDumpProvider); 1115 std::unique_ptr<MockMemoryDumpProvider> mdp2(new MockMemoryDumpProvider);
1115 RegisterDumpProvider(mdp2.get(), nullptr, kDefaultOptions, 1116 RegisterDumpProvider(mdp2.get(), nullptr, kDefaultOptions,
1116 kWhitelistedMDPName); 1117 kWhitelistedMDPName);
1117 1118
1118 EXPECT_CALL(*mdp1, OnMemoryDump(_, _)).Times(0); 1119 EXPECT_CALL(*mdp1, OnMemoryDump(_, _)).Times(0);
1119 EXPECT_CALL(*mdp2, OnMemoryDump(_, _)).Times(1).WillOnce(Return(true)); 1120 EXPECT_CALL(*mdp2, OnMemoryDump(_, _)).Times(1).WillOnce(Return(true));
1120 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); 1121 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1);
1121 1122
(...skipping 22 matching lines...) Expand all
1144 1145
1145 EnableTracingWithTraceConfig( 1146 EnableTracingWithTraceConfig(
1146 TraceConfigMemoryTestUtil::GetTraceConfig_BackgroundTrigger()); 1147 TraceConfigMemoryTestUtil::GetTraceConfig_BackgroundTrigger());
1147 ASSERT_TRUE(IsPeriodicDumpingEnabled()); 1148 ASSERT_TRUE(IsPeriodicDumpingEnabled());
1148 run_loop.Run(); 1149 run_loop.Run();
1149 DisableTracing(); 1150 DisableTracing();
1150 } 1151 }
1151 1152
1152 } // namespace trace_event 1153 } // namespace trace_event
1153 } // namespace base 1154 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698