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

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

Issue 2777093009: [Memory UMA] Return a memory summary struct with the ack message (Closed)
Patch Set: Readd the extra_process_dump map Created 3 years, 8 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 <utility> 10 #include <utility>
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 base::WaitableEvent event(WaitableEvent::ResetPolicy::MANUAL, 109 base::WaitableEvent event(WaitableEvent::ResetPolicy::MANUAL,
110 WaitableEvent::InitialState::NOT_SIGNALED); 110 WaitableEvent::InitialState::NOT_SIGNALED);
111 task_runner->PostTask(from_here, std::move(task)); 111 task_runner->PostTask(from_here, std::move(task));
112 task_runner->PostTask( 112 task_runner->PostTask(
113 FROM_HERE, base::Bind(&WaitableEvent::Signal, base::Unretained(&event))); 113 FROM_HERE, base::Bind(&WaitableEvent::Signal, base::Unretained(&event)));
114 // The SequencedTaskRunner guarantees that |event| will only be signaled after 114 // The SequencedTaskRunner guarantees that |event| will only be signaled after
115 // |task| is executed. 115 // |task| is executed.
116 event.Wait(); 116 event.Wait();
117 } 117 }
118 118
119 // Adapts a ProcessMemoryDumpCallback into a GlobalMemoryDumpCallback by
120 // trimming off the result argument and calling the global callback.
121 // TODO (fmeawad): we should keep the results for verification, but currently
122 // all results are empty.
123 void ProcessDumpCallbackAdapter(
124 GlobalMemoryDumpCallback callback,
125 uint64_t dump_guid,
126 bool success,
127 const base::Optional<base::trace_event::MemoryDumpCallbackResult>&) {
128 callback.Run(dump_guid, success);
129 }
130
119 // Testing MemoryDumpManagerDelegate which, by default, short-circuits dump 131 // Testing MemoryDumpManagerDelegate which, by default, short-circuits dump
120 // requests locally to the MemoryDumpManager instead of performing IPC dances. 132 // requests locally to the MemoryDumpManager instead of performing IPC dances.
121 class MemoryDumpManagerDelegateForTesting : public MemoryDumpManagerDelegate { 133 class MemoryDumpManagerDelegateForTesting : public MemoryDumpManagerDelegate {
122 public: 134 public:
123 MemoryDumpManagerDelegateForTesting(bool is_coordinator) 135 MemoryDumpManagerDelegateForTesting(bool is_coordinator)
124 : is_coordinator_(is_coordinator) { 136 : is_coordinator_(is_coordinator) {
125 ON_CALL(*this, RequestGlobalMemoryDump(_, _)) 137 ON_CALL(*this, RequestGlobalMemoryDump(_, _))
126 .WillByDefault(Invoke( 138 .WillByDefault(Invoke(
127 this, &MemoryDumpManagerDelegateForTesting::CreateProcessDump)); 139 this, &MemoryDumpManagerDelegateForTesting::CreateGlobalDump));
Primiano Tucci (use gerrit) 2017/04/07 15:31:36 Insrtead of defining an extra metod just to wrap t
fmeawad 2017/04/10 20:20:19 Done.
128 } 140 }
129 141
130 MOCK_METHOD2(RequestGlobalMemoryDump, 142 MOCK_METHOD2(RequestGlobalMemoryDump,
131 void(const MemoryDumpRequestArgs& args, 143 void(const MemoryDumpRequestArgs& args,
132 const MemoryDumpCallback& callback)); 144 const GlobalMemoryDumpCallback& callback));
133 145
134 bool IsCoordinator() const override { return is_coordinator_; } 146 bool IsCoordinator() const override { return is_coordinator_; }
135 147
136 // Promote the CreateProcessDump to public so it can be used by test fixtures. 148 // Promote the CreateProcessDump to public so it can be used by test fixtures.
137 using MemoryDumpManagerDelegate::CreateProcessDump; 149 using MemoryDumpManagerDelegate::CreateProcessDump;
138 150
139 private: 151 private:
140 bool is_coordinator_; 152 bool is_coordinator_;
153
154 void CreateGlobalDump(const MemoryDumpRequestArgs& args,
155 const GlobalMemoryDumpCallback& callback) {
156 ProcessMemoryDumpCallback process_callback =
157 Bind(&ProcessDumpCallbackAdapter, callback);
158 CreateProcessDump(args, process_callback);
159 }
141 }; 160 };
142 161
143 class MockMemoryDumpProvider : public MemoryDumpProvider { 162 class MockMemoryDumpProvider : public MemoryDumpProvider {
144 public: 163 public:
145 MOCK_METHOD0(Destructor, void()); 164 MOCK_METHOD0(Destructor, void());
146 MOCK_METHOD2(OnMemoryDump, 165 MOCK_METHOD2(OnMemoryDump,
147 bool(const MemoryDumpArgs& args, ProcessMemoryDump* pmd)); 166 bool(const MemoryDumpArgs& args, ProcessMemoryDump* pmd));
148 MOCK_METHOD1(PollFastMemoryTotal, void(uint64_t* memory_total)); 167 MOCK_METHOD1(PollFastMemoryTotal, void(uint64_t* memory_total));
149 MOCK_METHOD0(SuspendFastMemoryPolling, void()); 168 MOCK_METHOD0(SuspendFastMemoryPolling, void());
150 169
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 246 }
228 247
229 void TearDown() override { 248 void TearDown() override {
230 MemoryDumpManager::SetInstanceForTesting(nullptr); 249 MemoryDumpManager::SetInstanceForTesting(nullptr);
231 delegate_ = nullptr; 250 delegate_ = nullptr;
232 mdm_.reset(); 251 mdm_.reset();
233 message_loop_.reset(); 252 message_loop_.reset();
234 TraceLog::DeleteForTesting(); 253 TraceLog::DeleteForTesting();
235 } 254 }
236 255
237 // Turns a Closure into a MemoryDumpCallback, keeping track of the callback 256 // Turns a Closure into a GlobalMemoryDumpCallback, keeping track of the
238 // result and taking care of posting the closure on the correct task runner. 257 // callback result and taking care of posting the closure on the correct task
239 void DumpCallbackAdapter(scoped_refptr<SingleThreadTaskRunner> task_runner, 258 // runner.
240 Closure closure, 259 void GlobalDumpCallbackAdapter(
241 uint64_t dump_guid, 260 scoped_refptr<SingleThreadTaskRunner> task_runner,
242 bool success) { 261 Closure closure,
262 uint64_t dump_guid,
263 bool success) {
243 last_callback_success_ = success; 264 last_callback_success_ = success;
244 task_runner->PostTask(FROM_HERE, closure); 265 task_runner->PostTask(FROM_HERE, closure);
245 } 266 }
246 267
247 void PollFastMemoryTotal(uint64_t* memory_total) { 268 void PollFastMemoryTotal(uint64_t* memory_total) {
248 mdm_->PollFastMemoryTotal(memory_total); 269 mdm_->PollFastMemoryTotal(memory_total);
249 } 270 }
250 271
251 protected: 272 protected:
252 void InitializeMemoryDumpManager(bool is_coordinator) { 273 void InitializeMemoryDumpManager(bool is_coordinator) {
253 mdm_->set_dumper_registrations_ignored_for_testing(true); 274 mdm_->set_dumper_registrations_ignored_for_testing(true);
254 delegate_ = new MemoryDumpManagerDelegateForTesting(is_coordinator); 275 delegate_ = new MemoryDumpManagerDelegateForTesting(is_coordinator);
255 mdm_->Initialize(base::WrapUnique(delegate_)); 276 mdm_->Initialize(base::WrapUnique(delegate_));
256 } 277 }
257 278
258 void RequestGlobalDumpAndWait(MemoryDumpType dump_type, 279 void RequestGlobalDumpAndWait(MemoryDumpType dump_type,
259 MemoryDumpLevelOfDetail level_of_detail) { 280 MemoryDumpLevelOfDetail level_of_detail) {
260 RunLoop run_loop; 281 RunLoop run_loop;
261 MemoryDumpCallback callback = 282 GlobalMemoryDumpCallback callback = Bind(
262 Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this), 283 &MemoryDumpManagerTest::GlobalDumpCallbackAdapter, Unretained(this),
263 ThreadTaskRunnerHandle::Get(), run_loop.QuitClosure()); 284 ThreadTaskRunnerHandle::Get(), run_loop.QuitClosure());
264 mdm_->RequestGlobalDump(dump_type, level_of_detail, callback); 285 mdm_->RequestGlobalDump(dump_type, level_of_detail, callback);
265 run_loop.Run(); 286 run_loop.Run();
266 } 287 }
267 288
268 void EnableTracingWithLegacyCategories(const char* category) { 289 void EnableTracingWithLegacyCategories(const char* category) {
269 TraceLog::GetInstance()->SetEnabled(TraceConfig(category, ""), 290 TraceLog::GetInstance()->SetEnabled(TraceConfig(category, ""),
270 TraceLog::RECORDING_MODE); 291 TraceLog::RECORDING_MODE);
271 } 292 }
272 293
273 void EnableTracingWithTraceConfig(const std::string& trace_config) { 294 void EnableTracingWithTraceConfig(const std::string& trace_config) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0); 332 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0);
312 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 333 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
313 MemoryDumpLevelOfDetail::DETAILED); 334 MemoryDumpLevelOfDetail::DETAILED);
314 DisableTracing(); 335 DisableTracing();
315 336
316 // Now repeat enabling the memory category and check that the dumper is 337 // Now repeat enabling the memory category and check that the dumper is
317 // invoked this time. 338 // invoked this time.
318 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 339 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
319 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(3); 340 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(3);
320 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(3).WillRepeatedly(Return(true)); 341 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(3).WillRepeatedly(Return(true));
321 for (int i = 0; i < 3; ++i) 342 for (int i = 0; i < 3; ++i) {
322 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 343 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
323 MemoryDumpLevelOfDetail::DETAILED); 344 MemoryDumpLevelOfDetail::DETAILED);
345 }
324 DisableTracing(); 346 DisableTracing();
325 347
326 mdm_->UnregisterDumpProvider(&mdp); 348 mdm_->UnregisterDumpProvider(&mdp);
327 349
328 // Finally check the unregister logic: the delegate will be invoked but not 350 // Finally check the unregister logic: the delegate will be invoked but not
329 // the dump provider, as it has been unregistered. 351 // the dump provider, as it has been unregistered.
330 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 352 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
331 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(3); 353 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(3);
332 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0); 354 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0);
333 355
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 .Times(Between(0, kPollsToQuit - 1)) 830 .Times(Between(0, kPollsToQuit - 1))
809 .WillRepeatedly(Return()); 831 .WillRepeatedly(Return());
810 832
811 MemoryDumpScheduler::SetPollingIntervalForTesting(1); 833 MemoryDumpScheduler::SetPollingIntervalForTesting(1);
812 EnableTracingWithTraceConfig( 834 EnableTracingWithTraceConfig(
813 TraceConfigMemoryTestUtil::GetTraceConfig_PeakDetectionTrigger(3)); 835 TraceConfigMemoryTestUtil::GetTraceConfig_PeakDetectionTrigger(3));
814 836
815 int last_poll_to_request_dump = -2; 837 int last_poll_to_request_dump = -2;
816 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)) 838 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _))
817 .Times(testing::AtLeast(2)) 839 .Times(testing::AtLeast(2))
818 .WillRepeatedly(Invoke([&last_poll_to_request_dump, &call_count]( 840 .WillRepeatedly(
819 const MemoryDumpRequestArgs& args, 841 Invoke([&last_poll_to_request_dump, &call_count](
820 const MemoryDumpCallback& callback) -> void { 842 const MemoryDumpRequestArgs& args,
821 // Minimum number of polls between dumps must be 3 (polling interval is 843 const GlobalMemoryDumpCallback& callback) -> void {
822 // 1ms). 844 // Minimum number of polls between dumps must be 3 (polling interval
823 EXPECT_GE(call_count - last_poll_to_request_dump, 3); 845 // is 1ms).
824 last_poll_to_request_dump = call_count; 846 EXPECT_GE(call_count - last_poll_to_request_dump, 3);
825 })); 847 last_poll_to_request_dump = call_count;
848 }));
826 849
827 run_loop.Run(); 850 run_loop.Run();
828 DisableTracing(); 851 DisableTracing();
829 mdm_->UnregisterAndDeleteDumpProviderSoon(std::move(mdp1)); 852 mdm_->UnregisterAndDeleteDumpProviderSoon(std::move(mdp1));
830 } 853 }
831 854
832 // If a thread (with a dump provider living on it) is torn down during a dump 855 // If a thread (with a dump provider living on it) is torn down during a dump
833 // its dump provider should be skipped but the dump itself should succeed. 856 // its dump provider should be skipped but the dump itself should succeed.
834 TEST_F(MemoryDumpManagerTest, TearDownThreadWhileDumping) { 857 TEST_F(MemoryDumpManagerTest, TearDownThreadWhileDumping) {
835 InitializeMemoryDumpManager(false /* is_coordinator */); 858 InitializeMemoryDumpManager(false /* is_coordinator */);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 const int kHeavyDumpPeriodMs = kHeavyDumpRate * kLightDumpPeriodMs; 1019 const int kHeavyDumpPeriodMs = kHeavyDumpRate * kLightDumpPeriodMs;
997 // The expected sequence with light=1ms, heavy=5ms is H,L,L,L,L,H,... 1020 // The expected sequence with light=1ms, heavy=5ms is H,L,L,L,L,H,...
998 testing::InSequence sequence; 1021 testing::InSequence sequence;
999 EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsDetailedDump(), _)); 1022 EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsDetailedDump(), _));
1000 EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLightDump(), _)) 1023 EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLightDump(), _))
1001 .Times(kHeavyDumpRate - 1); 1024 .Times(kHeavyDumpRate - 1);
1002 EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsDetailedDump(), _)); 1025 EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsDetailedDump(), _));
1003 EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLightDump(), _)) 1026 EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLightDump(), _))
1004 .Times(kHeavyDumpRate - 2); 1027 .Times(kHeavyDumpRate - 2);
1005 EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLightDump(), _)) 1028 EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLightDump(), _))
1006 .WillOnce(Invoke([quit_closure](const MemoryDumpRequestArgs& args, 1029 .WillOnce(
1007 const MemoryDumpCallback& callback) { 1030 Invoke([quit_closure](const MemoryDumpRequestArgs& args,
1008 ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure); 1031 const GlobalMemoryDumpCallback& callback) {
1009 })); 1032 ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure);
1033 }));
1010 1034
1011 // Swallow all the final spurious calls until tracing gets disabled. 1035 // Swallow all the final spurious calls until tracing gets disabled.
1012 EXPECT_CALL(delegate, RequestGlobalMemoryDump(_, _)).Times(AnyNumber()); 1036 EXPECT_CALL(delegate, RequestGlobalMemoryDump(_, _)).Times(AnyNumber());
1013 1037
1014 EnableTracingWithTraceConfig( 1038 EnableTracingWithTraceConfig(
1015 TraceConfigMemoryTestUtil::GetTraceConfig_PeriodicTriggers( 1039 TraceConfigMemoryTestUtil::GetTraceConfig_PeriodicTriggers(
1016 kLightDumpPeriodMs, kHeavyDumpPeriodMs)); 1040 kLightDumpPeriodMs, kHeavyDumpPeriodMs));
1017 run_loop.Run(); 1041 run_loop.Run();
1018 DisableTracing(); 1042 DisableTracing();
1019 } 1043 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 // MemoryDumpManager.dump_thread_ has been shut down. 1081 // MemoryDumpManager.dump_thread_ has been shut down.
1058 return true; 1082 return true;
1059 })); 1083 }));
1060 1084
1061 // |unbound_mdp| should never be invoked because the thread for unbound dump 1085 // |unbound_mdp| should never be invoked because the thread for unbound dump
1062 // providers has been shutdown in the meanwhile. 1086 // providers has been shutdown in the meanwhile.
1063 EXPECT_CALL(unbound_mdp, OnMemoryDump(_, _)).Times(0); 1087 EXPECT_CALL(unbound_mdp, OnMemoryDump(_, _)).Times(0);
1064 1088
1065 last_callback_success_ = true; 1089 last_callback_success_ = true;
1066 RunLoop run_loop; 1090 RunLoop run_loop;
1067 MemoryDumpCallback callback = 1091 GlobalMemoryDumpCallback callback =
1068 Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this), 1092 Bind(&MemoryDumpManagerTest::GlobalDumpCallbackAdapter, Unretained(this),
1069 ThreadTaskRunnerHandle::Get(), run_loop.QuitClosure()); 1093 ThreadTaskRunnerHandle::Get(), run_loop.QuitClosure());
1070 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, 1094 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
1071 MemoryDumpLevelOfDetail::DETAILED, callback); 1095 MemoryDumpLevelOfDetail::DETAILED, callback);
1072 DisableTracing(); 1096 DisableTracing();
1073 tracing_disabled_event.Signal(); 1097 tracing_disabled_event.Signal();
1074 run_loop.Run(); 1098 run_loop.Run();
1075 1099
1076 EXPECT_FALSE(last_callback_success_); 1100 EXPECT_FALSE(last_callback_success_);
1077 } 1101 }
1078 1102
(...skipping 10 matching lines...) Expand all
1089 1113
1090 // Create both same-thread MDP and another MDP with dedicated thread 1114 // Create both same-thread MDP and another MDP with dedicated thread
1091 MockMemoryDumpProvider mdp1; 1115 MockMemoryDumpProvider mdp1;
1092 RegisterDumpProvider(&mdp1, nullptr); 1116 RegisterDumpProvider(&mdp1, nullptr);
1093 MockMemoryDumpProvider mdp2; 1117 MockMemoryDumpProvider mdp2;
1094 RegisterDumpProvider(&mdp2, mdp_thread->task_runner(), kDefaultOptions); 1118 RegisterDumpProvider(&mdp2, mdp_thread->task_runner(), kDefaultOptions);
1095 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 1119 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
1096 1120
1097 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)) 1121 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _))
1098 .WillOnce(Invoke([this](const MemoryDumpRequestArgs& args, 1122 .WillOnce(Invoke([this](const MemoryDumpRequestArgs& args,
1099 const MemoryDumpCallback& callback) { 1123 const GlobalMemoryDumpCallback& callback) {
1100 DisableTracing(); 1124 DisableTracing();
1101 delegate_->CreateProcessDump(args, callback); 1125 ProcessMemoryDumpCallback process_callback =
1126 Bind(&ProcessDumpCallbackAdapter, callback);
1127 delegate_->CreateProcessDump(args, process_callback);
1102 })); 1128 }));
1103 1129
1104 // If tracing is disabled for current session CreateProcessDump() should NOT 1130 // If tracing is disabled for current session CreateProcessDump() should NOT
1105 // request dumps from providers. Real-world regression: crbug.com/600570 . 1131 // request dumps from providers. Real-world regression: crbug.com/600570 .
1106 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).Times(0); 1132 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).Times(0);
1107 EXPECT_CALL(mdp2, OnMemoryDump(_, _)).Times(0); 1133 EXPECT_CALL(mdp2, OnMemoryDump(_, _)).Times(0);
1108 1134
1109 last_callback_success_ = true; 1135 last_callback_success_ = true;
1110 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 1136 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
1111 MemoryDumpLevelOfDetail::DETAILED); 1137 MemoryDumpLevelOfDetail::DETAILED);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 TEST_F(MemoryDumpManagerTest, TestBackgroundTracingSetup) { 1284 TEST_F(MemoryDumpManagerTest, TestBackgroundTracingSetup) {
1259 InitializeMemoryDumpManager(true /* is_coordinator */); 1285 InitializeMemoryDumpManager(true /* is_coordinator */);
1260 1286
1261 RunLoop run_loop; 1287 RunLoop run_loop;
1262 auto quit_closure = run_loop.QuitClosure(); 1288 auto quit_closure = run_loop.QuitClosure();
1263 1289
1264 testing::InSequence sequence; 1290 testing::InSequence sequence;
1265 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(IsBackgroundDump(), _)) 1291 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(IsBackgroundDump(), _))
1266 .Times(5); 1292 .Times(5);
1267 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(IsBackgroundDump(), _)) 1293 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(IsBackgroundDump(), _))
1268 .WillOnce(Invoke([quit_closure](const MemoryDumpRequestArgs& args, 1294 .WillOnce(
1269 const MemoryDumpCallback& callback) { 1295 Invoke([quit_closure](const MemoryDumpRequestArgs& args,
1270 ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure); 1296 const GlobalMemoryDumpCallback& callback) {
1271 })); 1297 ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure);
1298 }));
1272 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(AnyNumber()); 1299 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(AnyNumber());
1273 1300
1274 EnableTracingWithTraceConfig( 1301 EnableTracingWithTraceConfig(
1275 TraceConfigMemoryTestUtil::GetTraceConfig_BackgroundTrigger( 1302 TraceConfigMemoryTestUtil::GetTraceConfig_BackgroundTrigger(
1276 1 /* period_ms */)); 1303 1 /* period_ms */));
1277 1304
1278 // Only background mode dumps should be allowed with the trace config. 1305 // Only background mode dumps should be allowed with the trace config.
1279 last_callback_success_ = false; 1306 last_callback_success_ = false;
1280 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 1307 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
1281 MemoryDumpLevelOfDetail::LIGHT); 1308 MemoryDumpLevelOfDetail::LIGHT);
(...skipping 20 matching lines...) Expand all
1302 thread.Start(); 1329 thread.Start();
1303 RegisterDumpProvider(&mdp1, thread.task_runner(), kDefaultOptions, 1330 RegisterDumpProvider(&mdp1, thread.task_runner(), kDefaultOptions,
1304 "BlacklistTestDumpProvider"); 1331 "BlacklistTestDumpProvider");
1305 // Unregistering on wrong thread should not crash. 1332 // Unregistering on wrong thread should not crash.
1306 mdm_->UnregisterDumpProvider(&mdp1); 1333 mdm_->UnregisterDumpProvider(&mdp1);
1307 thread.Stop(); 1334 thread.Stop();
1308 } 1335 }
1309 1336
1310 } // namespace trace_event 1337 } // namespace trace_event
1311 } // namespace base 1338 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698