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

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

Issue 2741203002: memory-infra: Finish moving to Mojo (3nd attempt) (Closed)
Patch Set: nit Created 3 years, 9 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>
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // |task| is executed. 112 // |task| is executed.
113 event.Wait(); 113 event.Wait();
114 } 114 }
115 115
116 } // namespace 116 } // namespace
117 117
118 // Testing MemoryDumpManagerDelegate which, by default, short-circuits dump 118 // Testing MemoryDumpManagerDelegate which, by default, short-circuits dump
119 // requests locally to the MemoryDumpManager instead of performing IPC dances. 119 // requests locally to the MemoryDumpManager instead of performing IPC dances.
120 class MemoryDumpManagerDelegateForTesting : public MemoryDumpManagerDelegate { 120 class MemoryDumpManagerDelegateForTesting : public MemoryDumpManagerDelegate {
121 public: 121 public:
122 MemoryDumpManagerDelegateForTesting() { 122 MemoryDumpManagerDelegateForTesting(bool is_coordinator)
123 : is_coordinator_(is_coordinator) {
123 ON_CALL(*this, RequestGlobalMemoryDump(_, _)) 124 ON_CALL(*this, RequestGlobalMemoryDump(_, _))
124 .WillByDefault(Invoke( 125 .WillByDefault(Invoke(
125 this, &MemoryDumpManagerDelegateForTesting::CreateProcessDump)); 126 this, &MemoryDumpManagerDelegateForTesting::CreateProcessDump));
126 } 127 }
127 128
128 MOCK_METHOD2(RequestGlobalMemoryDump, 129 MOCK_METHOD2(RequestGlobalMemoryDump,
129 void(const MemoryDumpRequestArgs& args, 130 void(const MemoryDumpRequestArgs& args,
130 const MemoryDumpCallback& callback)); 131 const MemoryDumpCallback& callback));
131 132
132 uint64_t GetTracingProcessId() const override { 133 bool IsCoordinator() const override { return is_coordinator_; }
133 NOTREACHED();
134 return MemoryDumpManager::kInvalidTracingProcessId;
135 }
136 134
137 // Promote the CreateProcessDump to public so it can be used by test fixtures. 135 // Promote the CreateProcessDump to public so it can be used by test fixtures.
138 using MemoryDumpManagerDelegate::CreateProcessDump; 136 using MemoryDumpManagerDelegate::CreateProcessDump;
137
138 private:
139 bool is_coordinator_;
139 }; 140 };
140 141
141 class MockMemoryDumpProvider : public MemoryDumpProvider { 142 class MockMemoryDumpProvider : public MemoryDumpProvider {
142 public: 143 public:
143 MOCK_METHOD0(Destructor, void()); 144 MOCK_METHOD0(Destructor, void());
144 MOCK_METHOD2(OnMemoryDump, 145 MOCK_METHOD2(OnMemoryDump,
145 bool(const MemoryDumpArgs& args, ProcessMemoryDump* pmd)); 146 bool(const MemoryDumpArgs& args, ProcessMemoryDump* pmd));
146 MOCK_METHOD1(PollFastMemoryTotal, void(uint64_t* memory_total)); 147 MOCK_METHOD1(PollFastMemoryTotal, void(uint64_t* memory_total));
147 MOCK_METHOD0(SuspendFastMemoryPolling, void()); 148 MOCK_METHOD0(SuspendFastMemoryPolling, void());
148 149
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 class MemoryDumpManagerTest : public testing::Test { 214 class MemoryDumpManagerTest : public testing::Test {
214 public: 215 public:
215 MemoryDumpManagerTest() : testing::Test(), kDefaultOptions() {} 216 MemoryDumpManagerTest() : testing::Test(), kDefaultOptions() {}
216 217
217 void SetUp() override { 218 void SetUp() override {
218 last_callback_success_ = false; 219 last_callback_success_ = false;
219 message_loop_.reset(new MessageLoop()); 220 message_loop_.reset(new MessageLoop());
220 mdm_.reset(new MemoryDumpManager()); 221 mdm_.reset(new MemoryDumpManager());
221 MemoryDumpManager::SetInstanceForTesting(mdm_.get()); 222 MemoryDumpManager::SetInstanceForTesting(mdm_.get());
222 ASSERT_EQ(mdm_.get(), MemoryDumpManager::GetInstance()); 223 ASSERT_EQ(mdm_.get(), MemoryDumpManager::GetInstance());
223 delegate_.reset(new MemoryDumpManagerDelegateForTesting);
224 } 224 }
225 225
226 void TearDown() override { 226 void TearDown() override {
227 MemoryDumpManager::SetInstanceForTesting(nullptr); 227 MemoryDumpManager::SetInstanceForTesting(nullptr);
228 delegate_.reset();
229 delegate_ptr_ = nullptr;
228 mdm_.reset(); 230 mdm_.reset();
229 delegate_.reset();
230 message_loop_.reset(); 231 message_loop_.reset();
231 TraceLog::DeleteForTesting(); 232 TraceLog::DeleteForTesting();
232 } 233 }
233 234
234 // Turns a Closure into a MemoryDumpCallback, keeping track of the callback 235 // Turns a Closure into a MemoryDumpCallback, keeping track of the callback
235 // result and taking care of posting the closure on the correct task runner. 236 // result and taking care of posting the closure on the correct task runner.
236 void DumpCallbackAdapter(scoped_refptr<SingleThreadTaskRunner> task_runner, 237 void DumpCallbackAdapter(scoped_refptr<SingleThreadTaskRunner> task_runner,
237 Closure closure, 238 Closure closure,
238 uint64_t dump_guid, 239 uint64_t dump_guid,
239 bool success) { 240 bool success) {
240 last_callback_success_ = success; 241 last_callback_success_ = success;
241 task_runner->PostTask(FROM_HERE, closure); 242 task_runner->PostTask(FROM_HERE, closure);
242 } 243 }
243 244
244 void PollFastMemoryTotal(uint64_t* memory_total) { 245 void PollFastMemoryTotal(uint64_t* memory_total) {
245 mdm_->PollFastMemoryTotal(memory_total); 246 mdm_->PollFastMemoryTotal(memory_total);
246 } 247 }
247 248
248 protected: 249 protected:
249 void InitializeMemoryDumpManager(bool is_coordinator) { 250 void InitializeMemoryDumpManager(bool is_coordinator) {
250 mdm_->set_dumper_registrations_ignored_for_testing(true); 251 mdm_->set_dumper_registrations_ignored_for_testing(true);
251 mdm_->Initialize(delegate_.get(), is_coordinator); 252 delegate_.reset(new MemoryDumpManagerDelegateForTesting(is_coordinator));
253 delegate_ptr_ = delegate_.get();
254 mdm_->Initialize(std::move(delegate_));
252 } 255 }
253 256
254 void RequestGlobalDumpAndWait(MemoryDumpType dump_type, 257 void RequestGlobalDumpAndWait(MemoryDumpType dump_type,
255 MemoryDumpLevelOfDetail level_of_detail) { 258 MemoryDumpLevelOfDetail level_of_detail) {
256 RunLoop run_loop; 259 RunLoop run_loop;
257 MemoryDumpCallback callback = 260 MemoryDumpCallback callback =
258 Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this), 261 Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this),
259 ThreadTaskRunnerHandle::Get(), run_loop.QuitClosure()); 262 ThreadTaskRunnerHandle::Get(), run_loop.QuitClosure());
260 mdm_->RequestGlobalDump(dump_type, level_of_detail, callback); 263 mdm_->RequestGlobalDump(dump_type, level_of_detail, callback);
261 run_loop.Run(); 264 run_loop.Run();
(...skipping 15 matching lines...) Expand all
277 return mdm_->dump_scheduler_->IsPeriodicTimerRunningForTesting(); 280 return mdm_->dump_scheduler_->IsPeriodicTimerRunningForTesting();
278 } 281 }
279 282
280 int GetMaxConsecutiveFailuresCount() const { 283 int GetMaxConsecutiveFailuresCount() const {
281 return MemoryDumpManager::kMaxConsecutiveFailuresCount; 284 return MemoryDumpManager::kMaxConsecutiveFailuresCount;
282 } 285 }
283 286
284 const MemoryDumpProvider::Options kDefaultOptions; 287 const MemoryDumpProvider::Options kDefaultOptions;
285 std::unique_ptr<MemoryDumpManager> mdm_; 288 std::unique_ptr<MemoryDumpManager> mdm_;
286 std::unique_ptr<MemoryDumpManagerDelegateForTesting> delegate_; 289 std::unique_ptr<MemoryDumpManagerDelegateForTesting> delegate_;
290 MemoryDumpManagerDelegateForTesting* delegate_ptr_;
Primiano Tucci (use gerrit) 2017/03/13 21:31:10 we do we need both here, unique_ptr has an operato
chiniforooshan 2017/03/14 16:06:36 No, actually. Know that the delegate is not a glob
Primiano Tucci (use gerrit) 2017/03/15 16:59:40 Ahh hold on, now I read it correctly. Yes, you are
chiniforooshan 2017/03/15 18:27:30 Done.
287 bool last_callback_success_; 291 bool last_callback_success_;
288 292
289 private: 293 private:
290 std::unique_ptr<MessageLoop> message_loop_; 294 std::unique_ptr<MessageLoop> message_loop_;
291 295
292 // We want our singleton torn down after each test. 296 // We want our singleton torn down after each test.
293 ShadowingAtExitManager at_exit_manager_; 297 ShadowingAtExitManager at_exit_manager_;
294 }; 298 };
295 299
296 // Basic sanity checks. Registers a memory dump provider and checks that it is 300 // Basic sanity checks. Registers a memory dump provider and checks that it is
297 // called, but only when memory-infra is enabled. 301 // called, but only when memory-infra is enabled.
298 TEST_F(MemoryDumpManagerTest, SingleDumper) { 302 TEST_F(MemoryDumpManagerTest, SingleDumper) {
299 InitializeMemoryDumpManager(false /* is_coordinator */); 303 InitializeMemoryDumpManager(false /* is_coordinator */);
300 MockMemoryDumpProvider mdp; 304 MockMemoryDumpProvider mdp;
301 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get()); 305 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get());
302 306
303 // Check that the dumper is not called if the memory category is not enabled. 307 // Check that the dumper is not called if the memory category is not enabled.
304 EnableTracingWithLegacyCategories("foobar-but-not-memory"); 308 EnableTracingWithLegacyCategories("foobar-but-not-memory");
305 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(0); 309 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(0);
306 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0); 310 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0);
307 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 311 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
308 MemoryDumpLevelOfDetail::DETAILED); 312 MemoryDumpLevelOfDetail::DETAILED);
309 DisableTracing(); 313 DisableTracing();
310 314
311 // Now repeat enabling the memory category and check that the dumper is 315 // Now repeat enabling the memory category and check that the dumper is
312 // invoked this time. 316 // invoked this time.
313 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 317 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
314 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(3); 318 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(3);
315 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(3).WillRepeatedly(Return(true)); 319 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(3).WillRepeatedly(Return(true));
316 for (int i = 0; i < 3; ++i) 320 for (int i = 0; i < 3; ++i)
317 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 321 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
318 MemoryDumpLevelOfDetail::DETAILED); 322 MemoryDumpLevelOfDetail::DETAILED);
319 DisableTracing(); 323 DisableTracing();
320 324
321 mdm_->UnregisterDumpProvider(&mdp); 325 mdm_->UnregisterDumpProvider(&mdp);
322 326
323 // Finally check the unregister logic: the delegate will be invoked but not 327 // Finally check the unregister logic: the delegate will be invoked but not
324 // the dump provider, as it has been unregistered. 328 // the dump provider, as it has been unregistered.
325 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 329 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
326 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(3); 330 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(3);
327 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0); 331 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0);
328 332
329 for (int i = 0; i < 3; ++i) { 333 for (int i = 0; i < 3; ++i) {
330 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 334 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
331 MemoryDumpLevelOfDetail::DETAILED); 335 MemoryDumpLevelOfDetail::DETAILED);
332 } 336 }
333 DisableTracing(); 337 DisableTracing();
334 } 338 }
335 339
336 // Checks that requesting dumps with high level of detail actually propagates 340 // Checks that requesting dumps with high level of detail actually propagates
337 // the level of the detail properly to OnMemoryDump() call on dump providers. 341 // the level of the detail properly to OnMemoryDump() call on dump providers.
338 TEST_F(MemoryDumpManagerTest, CheckMemoryDumpArgs) { 342 TEST_F(MemoryDumpManagerTest, CheckMemoryDumpArgs) {
339 InitializeMemoryDumpManager(false /* is_coordinator */); 343 InitializeMemoryDumpManager(false /* is_coordinator */);
340 MockMemoryDumpProvider mdp; 344 MockMemoryDumpProvider mdp;
341 345
342 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get()); 346 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get());
343 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 347 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
344 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); 348 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(1);
345 EXPECT_CALL(mdp, OnMemoryDump(IsDetailedDump(), _)).WillOnce(Return(true)); 349 EXPECT_CALL(mdp, OnMemoryDump(IsDetailedDump(), _)).WillOnce(Return(true));
346 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 350 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
347 MemoryDumpLevelOfDetail::DETAILED); 351 MemoryDumpLevelOfDetail::DETAILED);
348 DisableTracing(); 352 DisableTracing();
349 mdm_->UnregisterDumpProvider(&mdp); 353 mdm_->UnregisterDumpProvider(&mdp);
350 354
351 // Check that requesting dumps with low level of detail actually propagates to 355 // Check that requesting dumps with low level of detail actually propagates to
352 // OnMemoryDump() call on dump providers. 356 // OnMemoryDump() call on dump providers.
353 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get()); 357 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get());
354 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 358 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
355 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); 359 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(1);
356 EXPECT_CALL(mdp, OnMemoryDump(IsLightDump(), _)).WillOnce(Return(true)); 360 EXPECT_CALL(mdp, OnMemoryDump(IsLightDump(), _)).WillOnce(Return(true));
357 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 361 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
358 MemoryDumpLevelOfDetail::LIGHT); 362 MemoryDumpLevelOfDetail::LIGHT);
359 DisableTracing(); 363 DisableTracing();
360 mdm_->UnregisterDumpProvider(&mdp); 364 mdm_->UnregisterDumpProvider(&mdp);
361 } 365 }
362 366
363 // Checks that the SharedSessionState object is acqually shared over time. 367 // Checks that the SharedSessionState object is acqually shared over time.
364 TEST_F(MemoryDumpManagerTest, SharedSessionState) { 368 TEST_F(MemoryDumpManagerTest, SharedSessionState) {
365 InitializeMemoryDumpManager(false /* is_coordinator */); 369 InitializeMemoryDumpManager(false /* is_coordinator */);
366 MockMemoryDumpProvider mdp1; 370 MockMemoryDumpProvider mdp1;
367 MockMemoryDumpProvider mdp2; 371 MockMemoryDumpProvider mdp2;
368 RegisterDumpProvider(&mdp1, nullptr); 372 RegisterDumpProvider(&mdp1, nullptr);
369 RegisterDumpProvider(&mdp2, nullptr); 373 RegisterDumpProvider(&mdp2, nullptr);
370 374
371 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 375 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
372 const MemoryDumpSessionState* session_state = 376 const MemoryDumpSessionState* session_state =
373 mdm_->session_state_for_testing().get(); 377 mdm_->session_state_for_testing().get();
374 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(2); 378 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(2);
375 EXPECT_CALL(mdp1, OnMemoryDump(_, _)) 379 EXPECT_CALL(mdp1, OnMemoryDump(_, _))
376 .Times(2) 380 .Times(2)
377 .WillRepeatedly(Invoke([session_state](const MemoryDumpArgs&, 381 .WillRepeatedly(Invoke([session_state](const MemoryDumpArgs&,
378 ProcessMemoryDump* pmd) -> bool { 382 ProcessMemoryDump* pmd) -> bool {
379 EXPECT_EQ(session_state, pmd->session_state().get()); 383 EXPECT_EQ(session_state, pmd->session_state().get());
380 return true; 384 return true;
381 })); 385 }));
382 EXPECT_CALL(mdp2, OnMemoryDump(_, _)) 386 EXPECT_CALL(mdp2, OnMemoryDump(_, _))
383 .Times(2) 387 .Times(2)
384 .WillRepeatedly(Invoke([session_state](const MemoryDumpArgs&, 388 .WillRepeatedly(Invoke([session_state](const MemoryDumpArgs&,
(...skipping 12 matching lines...) Expand all
397 401
398 // Checks that the (Un)RegisterDumpProvider logic behaves sanely. 402 // Checks that the (Un)RegisterDumpProvider logic behaves sanely.
399 TEST_F(MemoryDumpManagerTest, MultipleDumpers) { 403 TEST_F(MemoryDumpManagerTest, MultipleDumpers) {
400 InitializeMemoryDumpManager(false /* is_coordinator */); 404 InitializeMemoryDumpManager(false /* is_coordinator */);
401 MockMemoryDumpProvider mdp1; 405 MockMemoryDumpProvider mdp1;
402 MockMemoryDumpProvider mdp2; 406 MockMemoryDumpProvider mdp2;
403 407
404 // Enable only mdp1. 408 // Enable only mdp1.
405 RegisterDumpProvider(&mdp1, ThreadTaskRunnerHandle::Get()); 409 RegisterDumpProvider(&mdp1, ThreadTaskRunnerHandle::Get());
406 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 410 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
407 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); 411 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(1);
408 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).WillOnce(Return(true)); 412 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).WillOnce(Return(true));
409 EXPECT_CALL(mdp2, OnMemoryDump(_, _)).Times(0); 413 EXPECT_CALL(mdp2, OnMemoryDump(_, _)).Times(0);
410 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 414 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
411 MemoryDumpLevelOfDetail::DETAILED); 415 MemoryDumpLevelOfDetail::DETAILED);
412 DisableTracing(); 416 DisableTracing();
413 417
414 // Invert: enable mdp1 and disable mdp2. 418 // Invert: enable mdp1 and disable mdp2.
415 mdm_->UnregisterDumpProvider(&mdp1); 419 mdm_->UnregisterDumpProvider(&mdp1);
416 RegisterDumpProvider(&mdp2, nullptr); 420 RegisterDumpProvider(&mdp2, nullptr);
417 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 421 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
418 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); 422 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(1);
419 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).Times(0); 423 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).Times(0);
420 EXPECT_CALL(mdp2, OnMemoryDump(_, _)).WillOnce(Return(true)); 424 EXPECT_CALL(mdp2, OnMemoryDump(_, _)).WillOnce(Return(true));
421 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 425 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
422 MemoryDumpLevelOfDetail::DETAILED); 426 MemoryDumpLevelOfDetail::DETAILED);
423 DisableTracing(); 427 DisableTracing();
424 428
425 // Enable both mdp1 and mdp2. 429 // Enable both mdp1 and mdp2.
426 RegisterDumpProvider(&mdp1, nullptr); 430 RegisterDumpProvider(&mdp1, nullptr);
427 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 431 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
428 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); 432 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(1);
429 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).WillOnce(Return(true)); 433 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).WillOnce(Return(true));
430 EXPECT_CALL(mdp2, OnMemoryDump(_, _)).WillOnce(Return(true)); 434 EXPECT_CALL(mdp2, OnMemoryDump(_, _)).WillOnce(Return(true));
431 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 435 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
432 MemoryDumpLevelOfDetail::DETAILED); 436 MemoryDumpLevelOfDetail::DETAILED);
433 DisableTracing(); 437 DisableTracing();
434 } 438 }
435 439
436 // Checks that the dump provider invocations depend only on the current 440 // Checks that the dump provider invocations depend only on the current
437 // registration state and not on previous registrations and dumps. 441 // registration state and not on previous registrations and dumps.
438 TEST_F(MemoryDumpManagerTest, RegistrationConsistency) { 442 TEST_F(MemoryDumpManagerTest, RegistrationConsistency) {
439 InitializeMemoryDumpManager(false /* is_coordinator */); 443 InitializeMemoryDumpManager(false /* is_coordinator */);
440 MockMemoryDumpProvider mdp; 444 MockMemoryDumpProvider mdp;
441 445
442 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get()); 446 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get());
443 447
444 { 448 {
445 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); 449 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(1);
446 EXPECT_CALL(mdp, OnMemoryDump(_, _)).WillOnce(Return(true)); 450 EXPECT_CALL(mdp, OnMemoryDump(_, _)).WillOnce(Return(true));
447 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 451 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
448 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 452 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
449 MemoryDumpLevelOfDetail::DETAILED); 453 MemoryDumpLevelOfDetail::DETAILED);
450 DisableTracing(); 454 DisableTracing();
451 } 455 }
452 456
453 mdm_->UnregisterDumpProvider(&mdp); 457 mdm_->UnregisterDumpProvider(&mdp);
454 458
455 { 459 {
456 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); 460 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(1);
457 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0); 461 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0);
458 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 462 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
459 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 463 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
460 MemoryDumpLevelOfDetail::DETAILED); 464 MemoryDumpLevelOfDetail::DETAILED);
461 DisableTracing(); 465 DisableTracing();
462 } 466 }
463 467
464 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get()); 468 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get());
465 mdm_->UnregisterDumpProvider(&mdp); 469 mdm_->UnregisterDumpProvider(&mdp);
466 470
467 { 471 {
468 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); 472 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(1);
469 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0); 473 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0);
470 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 474 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
471 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 475 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
472 MemoryDumpLevelOfDetail::DETAILED); 476 MemoryDumpLevelOfDetail::DETAILED);
473 DisableTracing(); 477 DisableTracing();
474 } 478 }
475 479
476 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get()); 480 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get());
477 mdm_->UnregisterDumpProvider(&mdp); 481 mdm_->UnregisterDumpProvider(&mdp);
478 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get()); 482 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get());
479 483
480 { 484 {
481 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); 485 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(1);
482 EXPECT_CALL(mdp, OnMemoryDump(_, _)).WillOnce(Return(true)); 486 EXPECT_CALL(mdp, OnMemoryDump(_, _)).WillOnce(Return(true));
483 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 487 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
484 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 488 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
485 MemoryDumpLevelOfDetail::DETAILED); 489 MemoryDumpLevelOfDetail::DETAILED);
486 DisableTracing(); 490 DisableTracing();
487 } 491 }
488 } 492 }
489 493
490 // Checks that the MemoryDumpManager respects the thread affinity when a 494 // Checks that the MemoryDumpManager respects the thread affinity when a
491 // MemoryDumpProvider specifies a task_runner(). The test starts creating 8 495 // MemoryDumpProvider specifies a task_runner(). The test starts creating 8
(...skipping 22 matching lines...) Expand all
514 .WillRepeatedly(Invoke( 518 .WillRepeatedly(Invoke(
515 [task_runner](const MemoryDumpArgs&, ProcessMemoryDump*) -> bool { 519 [task_runner](const MemoryDumpArgs&, ProcessMemoryDump*) -> bool {
516 EXPECT_TRUE(task_runner->RunsTasksOnCurrentThread()); 520 EXPECT_TRUE(task_runner->RunsTasksOnCurrentThread());
517 return true; 521 return true;
518 })); 522 }));
519 } 523 }
520 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 524 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
521 525
522 while (!threads.empty()) { 526 while (!threads.empty()) {
523 last_callback_success_ = false; 527 last_callback_success_ = false;
524 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); 528 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(1);
525 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 529 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
526 MemoryDumpLevelOfDetail::DETAILED); 530 MemoryDumpLevelOfDetail::DETAILED);
527 EXPECT_TRUE(last_callback_success_); 531 EXPECT_TRUE(last_callback_success_);
528 532
529 // Unregister a MDP and destroy one thread at each iteration to check the 533 // Unregister a MDP and destroy one thread at each iteration to check the
530 // live unregistration logic. The unregistration needs to happen on the same 534 // live unregistration logic. The unregistration needs to happen on the same
531 // thread the MDP belongs to. 535 // thread the MDP belongs to.
532 { 536 {
533 RunLoop run_loop; 537 RunLoop run_loop;
534 Closure unregistration = 538 Closure unregistration =
(...skipping 24 matching lines...) Expand all
559 RegisterDumpProviderWithSequencedTaskRunner(&mdps[0], task_runner1, 563 RegisterDumpProviderWithSequencedTaskRunner(&mdps[0], task_runner1,
560 kDefaultOptions); 564 kDefaultOptions);
561 RegisterDumpProviderWithSequencedTaskRunner(&mdps[1], task_runner2, 565 RegisterDumpProviderWithSequencedTaskRunner(&mdps[1], task_runner2,
562 kDefaultOptions); 566 kDefaultOptions);
563 RegisterDumpProviderWithSequencedTaskRunner(&mdps[2], task_runner2, 567 RegisterDumpProviderWithSequencedTaskRunner(&mdps[2], task_runner2,
564 kDefaultOptions); 568 kDefaultOptions);
565 // |mdps[0]| should be disabled permanently after first dump. 569 // |mdps[0]| should be disabled permanently after first dump.
566 EXPECT_CALL(mdps[0], OnMemoryDump(_, _)).Times(0); 570 EXPECT_CALL(mdps[0], OnMemoryDump(_, _)).Times(0);
567 EXPECT_CALL(mdps[1], OnMemoryDump(_, _)).Times(2); 571 EXPECT_CALL(mdps[1], OnMemoryDump(_, _)).Times(2);
568 EXPECT_CALL(mdps[2], OnMemoryDump(_, _)).Times(2); 572 EXPECT_CALL(mdps[2], OnMemoryDump(_, _)).Times(2);
569 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(2); 573 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(2);
570 574
571 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 575 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
572 576
573 task_runner1->set_enabled(false); 577 task_runner1->set_enabled(false);
574 last_callback_success_ = false; 578 last_callback_success_ = false;
575 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 579 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
576 MemoryDumpLevelOfDetail::DETAILED); 580 MemoryDumpLevelOfDetail::DETAILED);
577 // Tasks should be individually posted even if |mdps[1]| and |mdps[2]| belong 581 // Tasks should be individually posted even if |mdps[1]| and |mdps[2]| belong
578 // to same task runner. 582 // to same task runner.
579 EXPECT_EQ(1u, task_runner1->no_of_post_tasks()); 583 EXPECT_EQ(1u, task_runner1->no_of_post_tasks());
(...skipping 15 matching lines...) Expand all
595 TEST_F(MemoryDumpManagerTest, DisableFailingDumpers) { 599 TEST_F(MemoryDumpManagerTest, DisableFailingDumpers) {
596 InitializeMemoryDumpManager(false /* is_coordinator */); 600 InitializeMemoryDumpManager(false /* is_coordinator */);
597 MockMemoryDumpProvider mdp1; 601 MockMemoryDumpProvider mdp1;
598 MockMemoryDumpProvider mdp2; 602 MockMemoryDumpProvider mdp2;
599 603
600 RegisterDumpProvider(&mdp1, nullptr); 604 RegisterDumpProvider(&mdp1, nullptr);
601 RegisterDumpProvider(&mdp2, nullptr); 605 RegisterDumpProvider(&mdp2, nullptr);
602 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 606 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
603 607
604 const int kNumDumps = 2 * GetMaxConsecutiveFailuresCount(); 608 const int kNumDumps = 2 * GetMaxConsecutiveFailuresCount();
605 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(kNumDumps); 609 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(kNumDumps);
606 610
607 EXPECT_CALL(mdp1, OnMemoryDump(_, _)) 611 EXPECT_CALL(mdp1, OnMemoryDump(_, _))
608 .Times(GetMaxConsecutiveFailuresCount()) 612 .Times(GetMaxConsecutiveFailuresCount())
609 .WillRepeatedly(Return(false)); 613 .WillRepeatedly(Return(false));
610 614
611 EXPECT_CALL(mdp2, OnMemoryDump(_, _)) 615 EXPECT_CALL(mdp2, OnMemoryDump(_, _))
612 .WillOnce(Return(false)) 616 .WillOnce(Return(false))
613 .WillOnce(Return(true)) 617 .WillOnce(Return(true))
614 .WillOnce(Return(false)) 618 .WillOnce(Return(false))
615 .WillOnce(Return(false)) 619 .WillOnce(Return(false))
(...skipping 11 matching lines...) Expand all
627 // Sneakily registers an extra memory dump provider while an existing one is 631 // Sneakily registers an extra memory dump provider while an existing one is
628 // dumping and expect it to take part in the already active tracing session. 632 // dumping and expect it to take part in the already active tracing session.
629 TEST_F(MemoryDumpManagerTest, RegisterDumperWhileDumping) { 633 TEST_F(MemoryDumpManagerTest, RegisterDumperWhileDumping) {
630 InitializeMemoryDumpManager(false /* is_coordinator */); 634 InitializeMemoryDumpManager(false /* is_coordinator */);
631 MockMemoryDumpProvider mdp1; 635 MockMemoryDumpProvider mdp1;
632 MockMemoryDumpProvider mdp2; 636 MockMemoryDumpProvider mdp2;
633 637
634 RegisterDumpProvider(&mdp1, nullptr); 638 RegisterDumpProvider(&mdp1, nullptr);
635 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 639 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
636 640
637 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(4); 641 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(4);
638 642
639 EXPECT_CALL(mdp1, OnMemoryDump(_, _)) 643 EXPECT_CALL(mdp1, OnMemoryDump(_, _))
640 .Times(4) 644 .Times(4)
641 .WillOnce(Return(true)) 645 .WillOnce(Return(true))
642 .WillOnce( 646 .WillOnce(
643 Invoke([&mdp2](const MemoryDumpArgs&, ProcessMemoryDump*) -> bool { 647 Invoke([&mdp2](const MemoryDumpArgs&, ProcessMemoryDump*) -> bool {
644 RegisterDumpProvider(&mdp2, nullptr); 648 RegisterDumpProvider(&mdp2, nullptr);
645 return true; 649 return true;
646 })) 650 }))
647 .WillRepeatedly(Return(true)); 651 .WillRepeatedly(Return(true));
(...skipping 15 matching lines...) Expand all
663 // Like RegisterDumperWhileDumping, but unregister the dump provider instead. 667 // Like RegisterDumperWhileDumping, but unregister the dump provider instead.
664 TEST_F(MemoryDumpManagerTest, UnregisterDumperWhileDumping) { 668 TEST_F(MemoryDumpManagerTest, UnregisterDumperWhileDumping) {
665 InitializeMemoryDumpManager(false /* is_coordinator */); 669 InitializeMemoryDumpManager(false /* is_coordinator */);
666 MockMemoryDumpProvider mdp1; 670 MockMemoryDumpProvider mdp1;
667 MockMemoryDumpProvider mdp2; 671 MockMemoryDumpProvider mdp2;
668 672
669 RegisterDumpProvider(&mdp1, ThreadTaskRunnerHandle::Get(), kDefaultOptions); 673 RegisterDumpProvider(&mdp1, ThreadTaskRunnerHandle::Get(), kDefaultOptions);
670 RegisterDumpProvider(&mdp2, ThreadTaskRunnerHandle::Get(), kDefaultOptions); 674 RegisterDumpProvider(&mdp2, ThreadTaskRunnerHandle::Get(), kDefaultOptions);
671 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 675 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
672 676
673 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(4); 677 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(4);
674 678
675 EXPECT_CALL(mdp1, OnMemoryDump(_, _)) 679 EXPECT_CALL(mdp1, OnMemoryDump(_, _))
676 .Times(4) 680 .Times(4)
677 .WillOnce(Return(true)) 681 .WillOnce(Return(true))
678 .WillOnce( 682 .WillOnce(
679 Invoke([&mdp2](const MemoryDumpArgs&, ProcessMemoryDump*) -> bool { 683 Invoke([&mdp2](const MemoryDumpArgs&, ProcessMemoryDump*) -> bool {
680 MemoryDumpManager::GetInstance()->UnregisterDumpProvider(&mdp2); 684 MemoryDumpManager::GetInstance()->UnregisterDumpProvider(&mdp2);
681 return true; 685 return true;
682 })) 686 }))
683 .WillRepeatedly(Return(true)); 687 .WillRepeatedly(Return(true));
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 737
734 // OnMemoryDump is called once for the provider that dumps first, and zero 738 // OnMemoryDump is called once for the provider that dumps first, and zero
735 // times for the other provider. 739 // times for the other provider.
736 EXPECT_CALL(*mdp, OnMemoryDump(_, _)) 740 EXPECT_CALL(*mdp, OnMemoryDump(_, _))
737 .Times(AtMost(1)) 741 .Times(AtMost(1))
738 .WillOnce(Invoke(on_dump)); 742 .WillOnce(Invoke(on_dump));
739 } 743 }
740 744
741 last_callback_success_ = false; 745 last_callback_success_ = false;
742 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 746 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
743 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); 747 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(1);
744 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 748 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
745 MemoryDumpLevelOfDetail::DETAILED); 749 MemoryDumpLevelOfDetail::DETAILED);
746 ASSERT_EQ(1, on_memory_dump_call_count); 750 ASSERT_EQ(1, on_memory_dump_call_count);
747 ASSERT_TRUE(last_callback_success_); 751 ASSERT_TRUE(last_callback_success_);
748 752
749 DisableTracing(); 753 DisableTracing();
750 } 754 }
751 755
752 TEST_F(MemoryDumpManagerTest, TestPollingOnDumpThread) { 756 TEST_F(MemoryDumpManagerTest, TestPollingOnDumpThread) {
753 InitializeMemoryDumpManager(false /* is_coordinator */); 757 InitializeMemoryDumpManager(false /* is_coordinator */);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 // all polls or in between polls. 799 // all polls or in between polls.
796 EXPECT_CALL(*mdp2, PollFastMemoryTotal(_)) 800 EXPECT_CALL(*mdp2, PollFastMemoryTotal(_))
797 .Times(Between(0, kPollsToQuit - 1)) 801 .Times(Between(0, kPollsToQuit - 1))
798 .WillRepeatedly(Return()); 802 .WillRepeatedly(Return());
799 803
800 MemoryDumpScheduler::SetPollingIntervalForTesting(1); 804 MemoryDumpScheduler::SetPollingIntervalForTesting(1);
801 EnableTracingWithTraceConfig( 805 EnableTracingWithTraceConfig(
802 TraceConfigMemoryTestUtil::GetTraceConfig_PeakDetectionTrigger(3)); 806 TraceConfigMemoryTestUtil::GetTraceConfig_PeakDetectionTrigger(3));
803 807
804 int last_poll_to_request_dump = -2; 808 int last_poll_to_request_dump = -2;
805 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)) 809 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _))
806 .Times(testing::AtLeast(2)) 810 .Times(testing::AtLeast(2))
807 .WillRepeatedly(Invoke([&last_poll_to_request_dump, &call_count]( 811 .WillRepeatedly(Invoke([&last_poll_to_request_dump, &call_count](
808 const MemoryDumpRequestArgs& args, 812 const MemoryDumpRequestArgs& args,
809 const MemoryDumpCallback& callback) -> void { 813 const MemoryDumpCallback& callback) -> void {
810 // Minimum number of polls between dumps must be 3 (polling interval is 814 // Minimum number of polls between dumps must be 3 (polling interval is
811 // 1ms). 815 // 1ms).
812 EXPECT_GE(call_count - last_poll_to_request_dump, 3); 816 EXPECT_GE(call_count - last_poll_to_request_dump, 3);
813 last_poll_to_request_dump = call_count; 817 last_poll_to_request_dump = call_count;
814 })); 818 }));
815 819
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 858
855 // OnMemoryDump is called once for the provider that dumps first, and zero 859 // OnMemoryDump is called once for the provider that dumps first, and zero
856 // times for the other provider. 860 // times for the other provider.
857 EXPECT_CALL(*mdp, OnMemoryDump(_, _)) 861 EXPECT_CALL(*mdp, OnMemoryDump(_, _))
858 .Times(AtMost(1)) 862 .Times(AtMost(1))
859 .WillOnce(Invoke(on_dump)); 863 .WillOnce(Invoke(on_dump));
860 } 864 }
861 865
862 last_callback_success_ = false; 866 last_callback_success_ = false;
863 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 867 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
864 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); 868 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(1);
865 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 869 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
866 MemoryDumpLevelOfDetail::DETAILED); 870 MemoryDumpLevelOfDetail::DETAILED);
867 ASSERT_EQ(1, on_memory_dump_call_count); 871 ASSERT_EQ(1, on_memory_dump_call_count);
868 ASSERT_TRUE(last_callback_success_); 872 ASSERT_TRUE(last_callback_success_);
869 873
870 DisableTracing(); 874 DisableTracing();
871 } 875 }
872 876
873 // Checks that a NACK callback is invoked if RequestGlobalDump() is called when 877 // Checks that a NACK callback is invoked if RequestGlobalDump() is called when
874 // tracing is not enabled. 878 // tracing is not enabled.
875 TEST_F(MemoryDumpManagerTest, CallbackCalledOnFailure) { 879 TEST_F(MemoryDumpManagerTest, CallbackCalledOnFailure) {
876 InitializeMemoryDumpManager(false /* is_coordinator */); 880 InitializeMemoryDumpManager(false /* is_coordinator */);
877 MockMemoryDumpProvider mdp1; 881 MockMemoryDumpProvider mdp1;
878 RegisterDumpProvider(&mdp1, nullptr); 882 RegisterDumpProvider(&mdp1, nullptr);
879 883
880 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(0); 884 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(0);
881 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).Times(0); 885 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).Times(0);
882 886
883 last_callback_success_ = true; 887 last_callback_success_ = true;
884 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 888 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
885 MemoryDumpLevelOfDetail::DETAILED); 889 MemoryDumpLevelOfDetail::DETAILED);
886 EXPECT_FALSE(last_callback_success_); 890 EXPECT_FALSE(last_callback_success_);
887 } 891 }
888 892
889 // Checks that is the MemoryDumpManager is initialized after tracing already 893 // Checks that is the MemoryDumpManager is initialized after tracing already
890 // began, it will still late-join the party (real use case: startup tracing). 894 // began, it will still late-join the party (real use case: startup tracing).
891 TEST_F(MemoryDumpManagerTest, InitializedAfterStartOfTracing) { 895 TEST_F(MemoryDumpManagerTest, InitializedAfterStartOfTracing) {
892 MockMemoryDumpProvider mdp; 896 MockMemoryDumpProvider mdp;
893 RegisterDumpProvider(&mdp, nullptr); 897 RegisterDumpProvider(&mdp, nullptr);
894 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 898 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
895 899
896 // First check that a RequestGlobalDump() issued before the MemoryDumpManager 900 // First check that a RequestGlobalDump() issued before the MemoryDumpManager
897 // initialization gets NACK-ed cleanly. 901 // initialization gets NACK-ed cleanly.
898 { 902 {
899 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0); 903 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0);
900 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(0);
901 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 904 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
902 MemoryDumpLevelOfDetail::DETAILED); 905 MemoryDumpLevelOfDetail::DETAILED);
903 EXPECT_FALSE(last_callback_success_); 906 EXPECT_FALSE(last_callback_success_);
904 } 907 }
905 908
906 // Now late-initialize the MemoryDumpManager and check that the 909 // Now late-initialize the MemoryDumpManager and check that the
907 // RequestGlobalDump completes successfully. 910 // RequestGlobalDump completes successfully.
908 { 911 {
912 InitializeMemoryDumpManager(false /* is_coordinator */);
909 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(1); 913 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(1);
910 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); 914 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(1);
911 InitializeMemoryDumpManager(false /* is_coordinator */);
912 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 915 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
913 MemoryDumpLevelOfDetail::DETAILED); 916 MemoryDumpLevelOfDetail::DETAILED);
914 EXPECT_TRUE(last_callback_success_); 917 EXPECT_TRUE(last_callback_success_);
915 } 918 }
916 DisableTracing(); 919 DisableTracing();
917 } 920 }
918 921
919 // This test (and the MemoryDumpManagerTestCoordinator below) crystallizes the 922 // This test (and the MemoryDumpManagerTestCoordinator below) crystallizes the
920 // expectations of the chrome://tracing UI and chrome telemetry w.r.t. periodic 923 // expectations of the chrome://tracing UI and chrome telemetry w.r.t. periodic
921 // dumps in memory-infra, handling gracefully the transition between the legacy 924 // dumps in memory-infra, handling gracefully the transition between the legacy
922 // and the new-style (JSON-based) TraceConfig. 925 // and the new-style (JSON-based) TraceConfig.
923 TEST_F(MemoryDumpManagerTest, TraceConfigExpectations) { 926 TEST_F(MemoryDumpManagerTest, TraceConfigExpectations) {
924 InitializeMemoryDumpManager(false /* is_coordinator */); 927 InitializeMemoryDumpManager(false /* is_coordinator */);
925 MemoryDumpManagerDelegateForTesting& delegate = *delegate_; 928 MemoryDumpManagerDelegateForTesting& delegate = *delegate_ptr_;
926 929
927 // Don't trigger the default behavior of the mock delegate in this test, 930 // Don't trigger the default behavior of the mock delegate in this test,
928 // which would short-circuit the dump request to the actual 931 // which would short-circuit the dump request to the actual
929 // CreateProcessDump(). 932 // CreateProcessDump().
930 // We don't want to create any dump in this test, only check whether the dumps 933 // We don't want to create any dump in this test, only check whether the dumps
931 // are requested or not. 934 // are requested or not.
932 ON_CALL(delegate, RequestGlobalMemoryDump(_, _)).WillByDefault(Return()); 935 ON_CALL(delegate, RequestGlobalMemoryDump(_, _)).WillByDefault(Return());
933 936
934 // Enabling memory-infra in a non-coordinator process should not trigger any 937 // Enabling memory-infra in a non-coordinator process should not trigger any
935 // periodic dumps. 938 // periodic dumps.
936 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 939 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
937 EXPECT_FALSE(IsPeriodicDumpingEnabled()); 940 EXPECT_FALSE(IsPeriodicDumpingEnabled());
938 DisableTracing(); 941 DisableTracing();
939 942
940 // Enabling memory-infra with the new (JSON) TraceConfig in a non-coordinator 943 // Enabling memory-infra with the new (JSON) TraceConfig in a non-coordinator
941 // process with a fully defined trigger config should NOT enable any periodic 944 // process with a fully defined trigger config should NOT enable any periodic
942 // dumps. 945 // dumps.
943 EnableTracingWithTraceConfig( 946 EnableTracingWithTraceConfig(
944 TraceConfigMemoryTestUtil::GetTraceConfig_PeriodicTriggers(1, 5)); 947 TraceConfigMemoryTestUtil::GetTraceConfig_PeriodicTriggers(1, 5));
945 EXPECT_FALSE(IsPeriodicDumpingEnabled()); 948 EXPECT_FALSE(IsPeriodicDumpingEnabled());
946 DisableTracing(); 949 DisableTracing();
947 } 950 }
948 951
949 TEST_F(MemoryDumpManagerTest, TraceConfigExpectationsWhenIsCoordinator) { 952 TEST_F(MemoryDumpManagerTest, TraceConfigExpectationsWhenIsCoordinator) {
950 InitializeMemoryDumpManager(true /* is_coordinator */); 953 InitializeMemoryDumpManager(true /* is_coordinator */);
951 MemoryDumpManagerDelegateForTesting& delegate = *delegate_; 954 MemoryDumpManagerDelegateForTesting& delegate = *delegate_ptr_;
952 ON_CALL(delegate, RequestGlobalMemoryDump(_, _)).WillByDefault(Return()); 955 ON_CALL(delegate, RequestGlobalMemoryDump(_, _)).WillByDefault(Return());
953 956
954 // Enabling memory-infra with the legacy TraceConfig (category filter) in 957 // Enabling memory-infra with the legacy TraceConfig (category filter) in
955 // a coordinator process should enable periodic dumps. 958 // a coordinator process should enable periodic dumps.
956 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 959 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
957 EXPECT_TRUE(IsPeriodicDumpingEnabled()); 960 EXPECT_TRUE(IsPeriodicDumpingEnabled());
958 DisableTracing(); 961 DisableTracing();
959 962
960 // Enabling memory-infra with the new (JSON) TraceConfig in a coordinator 963 // Enabling memory-infra with the new (JSON) TraceConfig in a coordinator
961 // process without specifying any "memory_dump_config" section should enable 964 // process without specifying any "memory_dump_config" section should enable
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 MockMemoryDumpProvider mdp_with_affinity; 1025 MockMemoryDumpProvider mdp_with_affinity;
1023 RegisterDumpProvider(&mdp_with_affinity, mdp_thread->task_runner(), 1026 RegisterDumpProvider(&mdp_with_affinity, mdp_thread->task_runner(),
1024 kDefaultOptions); 1027 kDefaultOptions);
1025 1028
1026 // Register also an unbound dump provider. Unbound dump providers are always 1029 // Register also an unbound dump provider. Unbound dump providers are always
1027 // invoked after bound ones. 1030 // invoked after bound ones.
1028 MockMemoryDumpProvider unbound_mdp; 1031 MockMemoryDumpProvider unbound_mdp;
1029 RegisterDumpProvider(&unbound_mdp, nullptr, kDefaultOptions); 1032 RegisterDumpProvider(&unbound_mdp, nullptr, kDefaultOptions);
1030 1033
1031 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 1034 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
1032 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); 1035 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(1);
1033 EXPECT_CALL(mdp_with_affinity, OnMemoryDump(_, _)) 1036 EXPECT_CALL(mdp_with_affinity, OnMemoryDump(_, _))
1034 .Times(1) 1037 .Times(1)
1035 .WillOnce( 1038 .WillOnce(
1036 Invoke([&tracing_disabled_event](const MemoryDumpArgs&, 1039 Invoke([&tracing_disabled_event](const MemoryDumpArgs&,
1037 ProcessMemoryDump* pmd) -> bool { 1040 ProcessMemoryDump* pmd) -> bool {
1038 tracing_disabled_event.Wait(); 1041 tracing_disabled_event.Wait();
1039 1042
1040 // At this point tracing has been disabled and the 1043 // At this point tracing has been disabled and the
1041 // MemoryDumpManager.dump_thread_ has been shut down. 1044 // MemoryDumpManager.dump_thread_ has been shut down.
1042 return true; 1045 return true;
(...skipping 28 matching lines...) Expand all
1071 std::unique_ptr<Thread> mdp_thread(new Thread("test thread")); 1074 std::unique_ptr<Thread> mdp_thread(new Thread("test thread"));
1072 mdp_thread->Start(); 1075 mdp_thread->Start();
1073 1076
1074 // Create both same-thread MDP and another MDP with dedicated thread 1077 // Create both same-thread MDP and another MDP with dedicated thread
1075 MockMemoryDumpProvider mdp1; 1078 MockMemoryDumpProvider mdp1;
1076 RegisterDumpProvider(&mdp1, nullptr); 1079 RegisterDumpProvider(&mdp1, nullptr);
1077 MockMemoryDumpProvider mdp2; 1080 MockMemoryDumpProvider mdp2;
1078 RegisterDumpProvider(&mdp2, mdp_thread->task_runner(), kDefaultOptions); 1081 RegisterDumpProvider(&mdp2, mdp_thread->task_runner(), kDefaultOptions);
1079 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 1082 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
1080 1083
1081 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)) 1084 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _))
1082 .WillOnce(Invoke([this](const MemoryDumpRequestArgs& args, 1085 .WillOnce(Invoke([this](const MemoryDumpRequestArgs& args,
1083 const MemoryDumpCallback& callback) { 1086 const MemoryDumpCallback& callback) {
1084 DisableTracing(); 1087 DisableTracing();
1085 delegate_->CreateProcessDump(args, callback); 1088 delegate_ptr_->CreateProcessDump(args, callback);
1086 })); 1089 }));
1087 1090
1088 // If tracing is disabled for current session CreateProcessDump() should NOT 1091 // If tracing is disabled for current session CreateProcessDump() should NOT
1089 // request dumps from providers. Real-world regression: crbug.com/600570 . 1092 // request dumps from providers. Real-world regression: crbug.com/600570 .
1090 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).Times(0); 1093 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).Times(0);
1091 EXPECT_CALL(mdp2, OnMemoryDump(_, _)).Times(0); 1094 EXPECT_CALL(mdp2, OnMemoryDump(_, _)).Times(0);
1092 1095
1093 last_callback_success_ = true; 1096 last_callback_success_ = true;
1094 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 1097 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
1095 MemoryDumpLevelOfDetail::DETAILED); 1098 MemoryDumpLevelOfDetail::DETAILED);
(...skipping 14 matching lines...) Expand all
1110 MockMemoryDumpProvider mdp2; 1113 MockMemoryDumpProvider mdp2;
1111 options.target_pid = 123; 1114 options.target_pid = 123;
1112 RegisterDumpProvider(&mdp2, nullptr, options); 1115 RegisterDumpProvider(&mdp2, nullptr, options);
1113 1116
1114 // Another provider with out-of-process dumping. 1117 // Another provider with out-of-process dumping.
1115 MockMemoryDumpProvider mdp3; 1118 MockMemoryDumpProvider mdp3;
1116 options.target_pid = 456; 1119 options.target_pid = 456;
1117 RegisterDumpProvider(&mdp3, nullptr, options); 1120 RegisterDumpProvider(&mdp3, nullptr, options);
1118 1121
1119 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 1122 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
1120 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); 1123 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(1);
1121 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).Times(1).WillRepeatedly(Return(true)); 1124 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).Times(1).WillRepeatedly(Return(true));
1122 EXPECT_CALL(mdp2, OnMemoryDump(_, _)).Times(1).WillRepeatedly(Return(true)); 1125 EXPECT_CALL(mdp2, OnMemoryDump(_, _)).Times(1).WillRepeatedly(Return(true));
1123 EXPECT_CALL(mdp3, OnMemoryDump(_, _)).Times(1).WillRepeatedly(Return(true)); 1126 EXPECT_CALL(mdp3, OnMemoryDump(_, _)).Times(1).WillRepeatedly(Return(true));
1124 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 1127 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
1125 MemoryDumpLevelOfDetail::DETAILED); 1128 MemoryDumpLevelOfDetail::DETAILED);
1126 DisableTracing(); 1129 DisableTracing();
1127 1130
1128 // Flush the trace into JSON. 1131 // Flush the trace into JSON.
1129 trace_event::TraceResultBuffer buffer; 1132 trace_event::TraceResultBuffer buffer;
1130 TraceResultBuffer::SimpleOutput trace_output; 1133 TraceResultBuffer::SimpleOutput trace_output;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 EXPECT_CALL(*mdp, OnMemoryDump(_, _)) 1207 EXPECT_CALL(*mdp, OnMemoryDump(_, _))
1205 .Times(1) 1208 .Times(1)
1206 .WillOnce(Invoke(self_unregister_from_another_thread)); 1209 .WillOnce(Invoke(self_unregister_from_another_thread));
1207 EXPECT_CALL(*mdp, Destructor()) 1210 EXPECT_CALL(*mdp, Destructor())
1208 .Times(1) 1211 .Times(1)
1209 .WillOnce(Invoke([&thread_ref]() { 1212 .WillOnce(Invoke([&thread_ref]() {
1210 EXPECT_EQ(thread_ref, PlatformThread::CurrentRef()); 1213 EXPECT_EQ(thread_ref, PlatformThread::CurrentRef());
1211 })); 1214 }));
1212 1215
1213 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 1216 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
1214 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(2); 1217 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(2);
1215 for (int i = 0; i < 2; ++i) { 1218 for (int i = 0; i < 2; ++i) {
1216 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 1219 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
1217 MemoryDumpLevelOfDetail::DETAILED); 1220 MemoryDumpLevelOfDetail::DETAILED);
1218 } 1221 }
1219 DisableTracing(); 1222 DisableTracing();
1220 } 1223 }
1221 1224
1222 TEST_F(MemoryDumpManagerTest, TestWhitelistingMDP) { 1225 TEST_F(MemoryDumpManagerTest, TestWhitelistingMDP) {
1223 InitializeMemoryDumpManager(false /* is_coordinator */); 1226 InitializeMemoryDumpManager(false /* is_coordinator */);
1224 SetDumpProviderWhitelistForTesting(kTestMDPWhitelist); 1227 SetDumpProviderWhitelistForTesting(kTestMDPWhitelist);
1225 std::unique_ptr<MockMemoryDumpProvider> mdp1(new MockMemoryDumpProvider); 1228 std::unique_ptr<MockMemoryDumpProvider> mdp1(new MockMemoryDumpProvider);
1226 RegisterDumpProvider(mdp1.get(), nullptr); 1229 RegisterDumpProvider(mdp1.get(), nullptr);
1227 std::unique_ptr<MockMemoryDumpProvider> mdp2(new MockMemoryDumpProvider); 1230 std::unique_ptr<MockMemoryDumpProvider> mdp2(new MockMemoryDumpProvider);
1228 RegisterDumpProvider(mdp2.get(), nullptr, kDefaultOptions, 1231 RegisterDumpProvider(mdp2.get(), nullptr, kDefaultOptions,
1229 kWhitelistedMDPName); 1232 kWhitelistedMDPName);
1230 1233
1231 EXPECT_CALL(*mdp1, OnMemoryDump(_, _)).Times(0); 1234 EXPECT_CALL(*mdp1, OnMemoryDump(_, _)).Times(0);
1232 EXPECT_CALL(*mdp2, OnMemoryDump(_, _)).Times(1).WillOnce(Return(true)); 1235 EXPECT_CALL(*mdp2, OnMemoryDump(_, _)).Times(1).WillOnce(Return(true));
1233 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); 1236 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(1);
1234 1237
1235 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); 1238 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
1236 EXPECT_FALSE(IsPeriodicDumpingEnabled()); 1239 EXPECT_FALSE(IsPeriodicDumpingEnabled());
1237 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 1240 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
1238 MemoryDumpLevelOfDetail::BACKGROUND); 1241 MemoryDumpLevelOfDetail::BACKGROUND);
1239 DisableTracing(); 1242 DisableTracing();
1240 } 1243 }
1241 1244
1242 TEST_F(MemoryDumpManagerTest, TestBackgroundTracingSetup) { 1245 TEST_F(MemoryDumpManagerTest, TestBackgroundTracingSetup) {
1243 InitializeMemoryDumpManager(true /* is_coordinator */); 1246 InitializeMemoryDumpManager(true /* is_coordinator */);
1244 1247
1245 RunLoop run_loop; 1248 RunLoop run_loop;
1246 auto quit_closure = run_loop.QuitClosure(); 1249 auto quit_closure = run_loop.QuitClosure();
1247 1250
1248 testing::InSequence sequence; 1251 testing::InSequence sequence;
1249 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(IsBackgroundDump(), _)) 1252 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(IsBackgroundDump(), _))
1250 .Times(5); 1253 .Times(5);
1251 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(IsBackgroundDump(), _)) 1254 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(IsBackgroundDump(), _))
1252 .WillOnce(Invoke([quit_closure](const MemoryDumpRequestArgs& args, 1255 .WillOnce(Invoke([quit_closure](const MemoryDumpRequestArgs& args,
1253 const MemoryDumpCallback& callback) { 1256 const MemoryDumpCallback& callback) {
1254 ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure); 1257 ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure);
1255 })); 1258 }));
1256 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(AnyNumber()); 1259 EXPECT_CALL(*delegate_ptr_, RequestGlobalMemoryDump(_, _)).Times(AnyNumber());
1257 1260
1258 EnableTracingWithTraceConfig( 1261 EnableTracingWithTraceConfig(
1259 TraceConfigMemoryTestUtil::GetTraceConfig_BackgroundTrigger( 1262 TraceConfigMemoryTestUtil::GetTraceConfig_BackgroundTrigger(
1260 1 /* period_ms */)); 1263 1 /* period_ms */));
1261 1264
1262 // Only background mode dumps should be allowed with the trace config. 1265 // Only background mode dumps should be allowed with the trace config.
1263 last_callback_success_ = false; 1266 last_callback_success_ = false;
1264 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, 1267 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
1265 MemoryDumpLevelOfDetail::LIGHT); 1268 MemoryDumpLevelOfDetail::LIGHT);
1266 EXPECT_FALSE(last_callback_success_); 1269 EXPECT_FALSE(last_callback_success_);
(...skipping 19 matching lines...) Expand all
1286 thread.Start(); 1289 thread.Start();
1287 RegisterDumpProvider(&mdp1, thread.task_runner(), kDefaultOptions, 1290 RegisterDumpProvider(&mdp1, thread.task_runner(), kDefaultOptions,
1288 "BlacklistTestDumpProvider"); 1291 "BlacklistTestDumpProvider");
1289 // Unregistering on wrong thread should not crash. 1292 // Unregistering on wrong thread should not crash.
1290 mdm_->UnregisterDumpProvider(&mdp1); 1293 mdm_->UnregisterDumpProvider(&mdp1);
1291 thread.Stop(); 1294 thread.Stop();
1292 } 1295 }
1293 1296
1294 } // namespace trace_event 1297 } // namespace trace_event
1295 } // namespace base 1298 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698