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

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

Issue 2061903002: Use ThreadTaskRunnerHandle instead of MessageLoop::current() in base/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR danakj 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') | no next file » | 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 void InitializeMemoryDumpManager(bool is_coordinator) { 219 void InitializeMemoryDumpManager(bool is_coordinator) {
220 mdm_->set_dumper_registrations_ignored_for_testing(true); 220 mdm_->set_dumper_registrations_ignored_for_testing(true);
221 mdm_->Initialize(delegate_.get(), is_coordinator); 221 mdm_->Initialize(delegate_.get(), is_coordinator);
222 } 222 }
223 223
224 void RequestGlobalDumpAndWait(MemoryDumpType dump_type, 224 void RequestGlobalDumpAndWait(MemoryDumpType dump_type,
225 MemoryDumpLevelOfDetail level_of_detail) { 225 MemoryDumpLevelOfDetail level_of_detail) {
226 RunLoop run_loop; 226 RunLoop run_loop;
227 MemoryDumpCallback callback = 227 MemoryDumpCallback callback =
228 Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this), 228 Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this),
229 MessageLoop::current()->task_runner(), run_loop.QuitClosure()); 229 ThreadTaskRunnerHandle::Get(), run_loop.QuitClosure());
230 mdm_->RequestGlobalDump(dump_type, level_of_detail, callback); 230 mdm_->RequestGlobalDump(dump_type, level_of_detail, callback);
231 run_loop.Run(); 231 run_loop.Run();
232 } 232 }
233 233
234 void EnableTracingWithLegacyCategories(const char* category) { 234 void EnableTracingWithLegacyCategories(const char* category) {
235 TraceLog::GetInstance()->SetEnabled(TraceConfig(category, ""), 235 TraceLog::GetInstance()->SetEnabled(TraceConfig(category, ""),
236 TraceLog::RECORDING_MODE); 236 TraceLog::RECORDING_MODE);
237 } 237 }
238 238
239 void EnableTracingWithTraceConfig(const std::string& trace_config) { 239 void EnableTracingWithTraceConfig(const std::string& trace_config) {
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 })); 935 }));
936 936
937 // |unbound_mdp| should never be invoked because the thread for unbound dump 937 // |unbound_mdp| should never be invoked because the thread for unbound dump
938 // providers has been shutdown in the meanwhile. 938 // providers has been shutdown in the meanwhile.
939 EXPECT_CALL(unbound_mdp, OnMemoryDump(_, _)).Times(0); 939 EXPECT_CALL(unbound_mdp, OnMemoryDump(_, _)).Times(0);
940 940
941 last_callback_success_ = true; 941 last_callback_success_ = true;
942 RunLoop run_loop; 942 RunLoop run_loop;
943 MemoryDumpCallback callback = 943 MemoryDumpCallback callback =
944 Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this), 944 Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this),
945 MessageLoop::current()->task_runner(), run_loop.QuitClosure()); 945 ThreadTaskRunnerHandle::Get(), run_loop.QuitClosure());
946 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, 946 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
947 MemoryDumpLevelOfDetail::DETAILED, callback); 947 MemoryDumpLevelOfDetail::DETAILED, callback);
948 DisableTracing(); 948 DisableTracing();
949 tracing_disabled_event.Signal(); 949 tracing_disabled_event.Signal();
950 run_loop.Run(); 950 run_loop.Run();
951 951
952 EXPECT_FALSE(last_callback_success_); 952 EXPECT_FALSE(last_callback_success_);
953 } 953 }
954 954
955 // Tests against race conditions that can happen if tracing is disabled before 955 // Tests against race conditions that can happen if tracing is disabled before
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 1149
1150 EnableTracingWithTraceConfig( 1150 EnableTracingWithTraceConfig(
1151 TraceConfigMemoryTestUtil::GetTraceConfig_BackgroundTrigger()); 1151 TraceConfigMemoryTestUtil::GetTraceConfig_BackgroundTrigger());
1152 ASSERT_TRUE(IsPeriodicDumpingEnabled()); 1152 ASSERT_TRUE(IsPeriodicDumpingEnabled());
1153 run_loop.Run(); 1153 run_loop.Run();
1154 DisableTracing(); 1154 DisableTracing();
1155 } 1155 }
1156 1156
1157 } // namespace trace_event 1157 } // namespace trace_event
1158 } // namespace base 1158 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/memory_dump_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698