| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 184 |
| 185 // Enable both mdp1 and mdp2. | 185 // Enable both mdp1 and mdp2. |
| 186 mdm_->RegisterDumpProvider(&mdp1); | 186 mdm_->RegisterDumpProvider(&mdp1); |
| 187 EnableTracing(kTraceCategory); | 187 EnableTracing(kTraceCategory); |
| 188 EXPECT_CALL(mdp1, OnMemoryDump(_)).Times(1).WillRepeatedly(Return(true)); | 188 EXPECT_CALL(mdp1, OnMemoryDump(_)).Times(1).WillRepeatedly(Return(true)); |
| 189 EXPECT_CALL(mdp2, OnMemoryDump(_)).Times(1).WillRepeatedly(Return(true)); | 189 EXPECT_CALL(mdp2, OnMemoryDump(_)).Times(1).WillRepeatedly(Return(true)); |
| 190 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED); | 190 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED); |
| 191 DisableTracing(); | 191 DisableTracing(); |
| 192 } | 192 } |
| 193 | 193 |
| 194 // Fails on Linux TSan. http://crbug.com/499983 | |
| 195 #if defined(OS_LINUX) | |
| 196 #define MAYBE_RespectTaskRunnerAffinity DISABLED_RespectTaskRunnerAffinity | |
| 197 #else | |
| 198 #define MAYBE_RespectTaskRunnerAffinity RespectTaskRunnerAffinity | |
| 199 #endif | |
| 200 | |
| 201 // Checks that the MemoryDumpManager respects the thread affinity when a | 194 // Checks that the MemoryDumpManager respects the thread affinity when a |
| 202 // MemoryDumpProvider specifies a task_runner(). The test starts creating 8 | 195 // MemoryDumpProvider specifies a task_runner(). The test starts creating 8 |
| 203 // threads and registering a MemoryDumpProvider on each of them. At each | 196 // threads and registering a MemoryDumpProvider on each of them. At each |
| 204 // iteration, one thread is removed, to check the live unregistration logic. | 197 // iteration, one thread is removed, to check the live unregistration logic. |
| 205 TEST_F(MemoryDumpManagerTest, MAYBE_RespectTaskRunnerAffinity) { | 198 TEST_F(MemoryDumpManagerTest, RespectTaskRunnerAffinity) { |
| 206 const uint32 kNumInitialThreads = 8; | 199 const uint32 kNumInitialThreads = 8; |
| 207 | 200 |
| 208 ScopedVector<Thread> threads; | 201 ScopedVector<Thread> threads; |
| 209 ScopedVector<MockDumpProvider> mdps; | 202 ScopedVector<MockDumpProvider> mdps; |
| 210 | 203 |
| 211 // Create the threads and setup the expectations. Given that at each iteration | 204 // Create the threads and setup the expectations. Given that at each iteration |
| 212 // we will pop out one thread/MemoryDumpProvider, each MDP is supposed to be | 205 // we will pop out one thread/MemoryDumpProvider, each MDP is supposed to be |
| 213 // invoked a number of times equal to its index. | 206 // invoked a number of times equal to its index. |
| 214 for (uint32 i = kNumInitialThreads; i > 0; --i) { | 207 for (uint32 i = kNumInitialThreads; i > 0; --i) { |
| 215 threads.push_back(new Thread("test thread")); | 208 threads.push_back(new Thread("test thread")); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 | 267 |
| 275 EXPECT_CALL(mdp1, OnMemoryDump(_)).Times(0); | 268 EXPECT_CALL(mdp1, OnMemoryDump(_)).Times(0); |
| 276 EXPECT_CALL(mdp2, OnMemoryDump(_)).Times(1).WillRepeatedly(Return(false)); | 269 EXPECT_CALL(mdp2, OnMemoryDump(_)).Times(1).WillRepeatedly(Return(false)); |
| 277 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED); | 270 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED); |
| 278 | 271 |
| 279 DisableTracing(); | 272 DisableTracing(); |
| 280 } | 273 } |
| 281 | 274 |
| 282 } // namespace trace_event | 275 } // namespace trace_event |
| 283 } // namespace base | 276 } // namespace base |
| OLD | NEW |