| OLD | NEW |
| 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 "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 run_loop.Run(); | 243 run_loop.Run(); |
| 244 } | 244 } |
| 245 mdps.pop_back(); | 245 mdps.pop_back(); |
| 246 threads.back()->Stop(); | 246 threads.back()->Stop(); |
| 247 threads.pop_back(); | 247 threads.pop_back(); |
| 248 } | 248 } |
| 249 | 249 |
| 250 DisableTracing(); | 250 DisableTracing(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 // Enable both dump providers, make mdp1 fail and assert that only mdp2 is | 253 // Enable both dump providers, make sure that mdp gets disabled after 3 failures |
| 254 // invoked the 2nd time. | 254 // and not disabled after 1. |
| 255 // FIXME(primiano): remove once crbug.com/461788 gets fixed. | |
| 256 TEST_F(MemoryDumpManagerTest, DisableFailingDumpers) { | 255 TEST_F(MemoryDumpManagerTest, DisableFailingDumpers) { |
| 257 MockDumpProvider mdp1; | 256 MockDumpProvider mdp1; |
| 258 MockDumpProvider mdp2; | 257 MockDumpProvider mdp2; |
| 259 | 258 |
| 260 mdm_->RegisterDumpProvider(&mdp1); | 259 mdm_->RegisterDumpProvider(&mdp1); |
| 261 mdm_->RegisterDumpProvider(&mdp2); | 260 mdm_->RegisterDumpProvider(&mdp2); |
| 262 EnableTracing(kTraceCategory); | 261 EnableTracing(kTraceCategory); |
| 263 | 262 |
| 264 EXPECT_CALL(mdp1, OnMemoryDump(_)).Times(1).WillRepeatedly(Return(false)); | 263 EXPECT_CALL(mdp1, OnMemoryDump(_)) |
| 265 EXPECT_CALL(mdp2, OnMemoryDump(_)).Times(1).WillRepeatedly(Return(true)); | 264 .Times(MemoryDumpManager::kMaxConsecutiveFailuresCount) |
| 266 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED); | 265 .WillRepeatedly(Return(false)); |
| 267 | 266 EXPECT_CALL(mdp2, OnMemoryDump(_)) |
| 268 EXPECT_CALL(mdp1, OnMemoryDump(_)).Times(0); | 267 .Times(1 + MemoryDumpManager::kMaxConsecutiveFailuresCount) |
| 269 EXPECT_CALL(mdp2, OnMemoryDump(_)).Times(1).WillRepeatedly(Return(false)); | 268 .WillOnce(Return(false)) |
| 270 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED); | 269 .WillRepeatedly(Return(true)); |
| 270 for (int i = 0; i < 1 + MemoryDumpManager::kMaxConsecutiveFailuresCount; |
| 271 i++) { |
| 272 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED); |
| 273 } |
| 271 | 274 |
| 272 DisableTracing(); | 275 DisableTracing(); |
| 273 } | 276 } |
| 274 | 277 |
| 275 } // namespace trace_event | 278 } // namespace trace_event |
| 276 } // namespace base | 279 } // namespace base |
| OLD | NEW |