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

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

Issue 2041583003: [tracing] Introduce "allowed_dump_modes" for memory dump config (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@background_config
Patch Set: Change mode to int. 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
« no previous file with comments | « base/trace_event/memory_dump_manager.cc ('k') | base/trace_event/memory_dump_request_args.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 332
333 // Checks that the SharedSessionState object is acqually shared over time. 333 // Checks that the SharedSessionState object is acqually shared over time.
334 TEST_F(MemoryDumpManagerTest, SharedSessionState) { 334 TEST_F(MemoryDumpManagerTest, SharedSessionState) {
335 InitializeMemoryDumpManager(false /* is_coordinator */); 335 InitializeMemoryDumpManager(false /* is_coordinator */);
336 MockMemoryDumpProvider mdp1; 336 MockMemoryDumpProvider mdp1;
337 MockMemoryDumpProvider mdp2; 337 MockMemoryDumpProvider mdp2;
338 RegisterDumpProvider(&mdp1); 338 RegisterDumpProvider(&mdp1);
339 RegisterDumpProvider(&mdp2); 339 RegisterDumpProvider(&mdp2);
340 340
341 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 341 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
342 const MemoryDumpSessionState* session_state = mdm_->session_state().get(); 342 const MemoryDumpSessionState* session_state =
343 mdm_->session_state_for_testing().get();
343 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(2); 344 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(2);
344 EXPECT_CALL(mdp1, OnMemoryDump(_, _)) 345 EXPECT_CALL(mdp1, OnMemoryDump(_, _))
345 .Times(2) 346 .Times(2)
346 .WillRepeatedly(Invoke([session_state](const MemoryDumpArgs&, 347 .WillRepeatedly(Invoke([session_state](const MemoryDumpArgs&,
347 ProcessMemoryDump* pmd) -> bool { 348 ProcessMemoryDump* pmd) -> bool {
348 EXPECT_EQ(session_state, pmd->session_state().get()); 349 EXPECT_EQ(session_state, pmd->session_state().get());
349 return true; 350 return true;
350 })); 351 }));
351 EXPECT_CALL(mdp2, OnMemoryDump(_, _)) 352 EXPECT_CALL(mdp2, OnMemoryDump(_, _))
352 .Times(2) 353 .Times(2)
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(IsBackgroundDump(), _)) 1144 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(IsBackgroundDump(), _))
1144 .WillOnce(Invoke([quit_closure](const MemoryDumpRequestArgs& args, 1145 .WillOnce(Invoke([quit_closure](const MemoryDumpRequestArgs& args,
1145 const MemoryDumpCallback& callback) { 1146 const MemoryDumpCallback& callback) {
1146 ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure); 1147 ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure);
1147 })); 1148 }));
1148 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(AnyNumber()); 1149 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(AnyNumber());
1149 1150
1150 EnableTracingWithTraceConfig( 1151 EnableTracingWithTraceConfig(
1151 TraceConfigMemoryTestUtil::GetTraceConfig_BackgroundTrigger( 1152 TraceConfigMemoryTestUtil::GetTraceConfig_BackgroundTrigger(
1152 1 /* period_ms */)); 1153 1 /* period_ms */));
1154
1155 // Only background mode dumps should be allowed with the trace config.
1156 last_callback_success_ = false;
1157 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
1158 MemoryDumpLevelOfDetail::LIGHT);
1159 EXPECT_FALSE(last_callback_success_);
1160 last_callback_success_ = false;
1161 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
1162 MemoryDumpLevelOfDetail::DETAILED);
1163 EXPECT_FALSE(last_callback_success_);
1164
1153 ASSERT_TRUE(IsPeriodicDumpingEnabled()); 1165 ASSERT_TRUE(IsPeriodicDumpingEnabled());
1154 run_loop.Run(); 1166 run_loop.Run();
1155 DisableTracing(); 1167 DisableTracing();
1156 } 1168 }
1157 1169
1158 } // namespace trace_event 1170 } // namespace trace_event
1159 } // namespace base 1171 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/memory_dump_manager.cc ('k') | base/trace_event/memory_dump_request_args.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698