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 11 matching lines...) Expand all Loading... |
22 using testing::AtMost; | 22 using testing::AtMost; |
23 using testing::Between; | 23 using testing::Between; |
24 using testing::Invoke; | 24 using testing::Invoke; |
25 using testing::Return; | 25 using testing::Return; |
26 | 26 |
27 namespace base { | 27 namespace base { |
28 namespace trace_event { | 28 namespace trace_event { |
29 namespace { | 29 namespace { |
30 MemoryDumpArgs g_high_detail_args = {MemoryDumpArgs::LevelOfDetail::HIGH}; | 30 MemoryDumpArgs g_high_detail_args = {MemoryDumpArgs::LevelOfDetail::HIGH}; |
31 MemoryDumpArgs g_low_detail_args = {MemoryDumpArgs::LevelOfDetail::LOW}; | 31 MemoryDumpArgs g_low_detail_args = {MemoryDumpArgs::LevelOfDetail::LOW}; |
| 32 const char kTraceConfigWithTriggersFmt[] = |
| 33 "{\"included_categories\":[\"%s\"],\"memory_dump_config\":{\"triggers\":[" |
| 34 "{\"mode\":\"light\", \"periodic_interval_ms\":1}," |
| 35 "{\"mode\":\"detailed\", \"periodic_interval_ms\":5}]}}"; |
32 } // namespace | 36 } // namespace |
33 | 37 |
34 // GTest matchers for MemoryDumpRequestArgs arguments. | 38 // GTest matchers for MemoryDumpRequestArgs arguments. |
35 MATCHER(IsHighDetail, "") { | 39 MATCHER(IsHighDetail, "") { |
36 return arg.level_of_detail == MemoryDumpArgs::LevelOfDetail::HIGH; | 40 return arg.level_of_detail == MemoryDumpArgs::LevelOfDetail::HIGH; |
37 } | 41 } |
38 | 42 |
39 MATCHER(IsLowDetail, "") { | 43 MATCHER(IsLowDetail, "") { |
40 return arg.level_of_detail == MemoryDumpArgs::LevelOfDetail::LOW; | 44 return arg.level_of_detail == MemoryDumpArgs::LevelOfDetail::LOW; |
41 } | 45 } |
42 | 46 |
43 // GTest matchers for MemoryDumpArgs arguments. | 47 // GTest matchers for MemoryDumpArgs arguments. |
44 MATCHER(IsHighDetailArgs, "") { | 48 MATCHER(IsHighDetailArgs, "") { |
45 return arg.dump_args.level_of_detail == MemoryDumpArgs::LevelOfDetail::HIGH; | 49 return arg.dump_args.level_of_detail == MemoryDumpArgs::LevelOfDetail::HIGH; |
46 } | 50 } |
47 | 51 |
48 MATCHER(IsLowDetailArgs, "") { | 52 MATCHER(IsLowDetailArgs, "") { |
49 return arg.dump_args.level_of_detail == MemoryDumpArgs::LevelOfDetail::LOW; | 53 return arg.dump_args.level_of_detail == MemoryDumpArgs::LevelOfDetail::LOW; |
50 } | 54 } |
51 | 55 |
52 // Testing MemoryDumpManagerDelegate which, by default, short-circuits dump | 56 // Testing MemoryDumpManagerDelegate which, by default, short-circuits dump |
53 // requests locally to the MemoryDumpManager instead of performing IPC dances. | 57 // requests locally to the MemoryDumpManager instead of performing IPC dances. |
54 class MemoryDumpManagerDelegateForTesting : public MemoryDumpManagerDelegate { | 58 class MemoryDumpManagerDelegateForTesting : public MemoryDumpManagerDelegate { |
55 public: | 59 public: |
56 MemoryDumpManagerDelegateForTesting() { | 60 MemoryDumpManagerDelegateForTesting() { |
57 EXPECT_CALL(*this, IsCoordinatorProcess()).WillRepeatedly(Return(false)); | |
58 ON_CALL(*this, RequestGlobalMemoryDump(_, _)) | 61 ON_CALL(*this, RequestGlobalMemoryDump(_, _)) |
59 .WillByDefault(Invoke( | 62 .WillByDefault(Invoke( |
60 this, &MemoryDumpManagerDelegateForTesting::CreateProcessDump)); | 63 this, &MemoryDumpManagerDelegateForTesting::CreateProcessDump)); |
61 } | 64 } |
62 | 65 |
63 MOCK_METHOD2(RequestGlobalMemoryDump, | 66 MOCK_METHOD2(RequestGlobalMemoryDump, |
64 void(const MemoryDumpRequestArgs& args, | 67 void(const MemoryDumpRequestArgs& args, |
65 const MemoryDumpCallback& callback)); | 68 const MemoryDumpCallback& callback)); |
66 | 69 |
67 MOCK_CONST_METHOD0(IsCoordinatorProcess, bool()); | |
68 | |
69 uint64 GetTracingProcessId() const override { | 70 uint64 GetTracingProcessId() const override { |
70 NOTREACHED(); | 71 NOTREACHED(); |
71 return MemoryDumpManager::kInvalidTracingProcessId; | 72 return MemoryDumpManager::kInvalidTracingProcessId; |
72 } | 73 } |
73 }; | 74 }; |
74 | 75 |
75 class MockMemoryDumpProvider : public MemoryDumpProvider { | 76 class MockMemoryDumpProvider : public MemoryDumpProvider { |
76 public: | 77 public: |
77 MOCK_METHOD2(OnMemoryDump, | 78 MOCK_METHOD2(OnMemoryDump, |
78 bool(const MemoryDumpArgs& args, ProcessMemoryDump* pmd)); | 79 bool(const MemoryDumpArgs& args, ProcessMemoryDump* pmd)); |
79 }; | 80 }; |
80 | 81 |
81 class MemoryDumpManagerTest : public testing::Test { | 82 class MemoryDumpManagerTest : public testing::Test { |
82 public: | 83 public: |
83 void SetUp() override { | 84 void SetUp() override { |
84 last_callback_success_ = false; | 85 last_callback_success_ = false; |
85 message_loop_.reset(new MessageLoop()); | 86 message_loop_.reset(new MessageLoop()); |
86 mdm_.reset(new MemoryDumpManager()); | 87 mdm_.reset(new MemoryDumpManager()); |
87 MemoryDumpManager::SetInstanceForTesting(mdm_.get()); | 88 MemoryDumpManager::SetInstanceForTesting(mdm_.get()); |
88 ASSERT_EQ(mdm_, MemoryDumpManager::GetInstance()); | 89 ASSERT_EQ(mdm_, MemoryDumpManager::GetInstance()); |
89 mdm_->Initialize(); | |
90 delegate_.reset(new MemoryDumpManagerDelegateForTesting); | 90 delegate_.reset(new MemoryDumpManagerDelegateForTesting); |
91 mdm_->SetDelegate(delegate_.get()); | |
92 } | 91 } |
93 | 92 |
94 void TearDown() override { | 93 void TearDown() override { |
95 MemoryDumpManager::SetInstanceForTesting(nullptr); | 94 MemoryDumpManager::SetInstanceForTesting(nullptr); |
96 mdm_.reset(); | 95 mdm_.reset(); |
97 delegate_.reset(); | 96 delegate_.reset(); |
98 message_loop_.reset(); | 97 message_loop_.reset(); |
99 TraceLog::DeleteForTesting(); | 98 TraceLog::DeleteForTesting(); |
100 } | 99 } |
101 | 100 |
102 void DumpCallbackAdapter(scoped_refptr<SingleThreadTaskRunner> task_runner, | 101 void DumpCallbackAdapter(scoped_refptr<SingleThreadTaskRunner> task_runner, |
103 Closure closure, | 102 Closure closure, |
104 uint64 dump_guid, | 103 uint64 dump_guid, |
105 bool success) { | 104 bool success) { |
106 last_callback_success_ = success; | 105 last_callback_success_ = success; |
107 task_runner->PostTask(FROM_HERE, closure); | 106 task_runner->PostTask(FROM_HERE, closure); |
108 } | 107 } |
109 | 108 |
110 protected: | 109 protected: |
111 // This enables tracing using the legacy category filter string. | 110 void InitializeMemoryDumpManager(bool is_coordinator) { |
| 111 mdm_->Initialize(delegate_.get(), is_coordinator); |
| 112 } |
| 113 |
112 void EnableTracingWithLegacyCategories(const char* category) { | 114 void EnableTracingWithLegacyCategories(const char* category) { |
113 TraceLog::GetInstance()->SetEnabled(TraceConfig(category, ""), | 115 TraceLog::GetInstance()->SetEnabled(TraceConfig(category, ""), |
114 TraceLog::RECORDING_MODE); | 116 TraceLog::RECORDING_MODE); |
115 } | 117 } |
116 | 118 |
117 void EnableTracingWithTraceConfig(const char* trace_config) { | 119 void EnableTracingWithTraceConfig(const char* trace_config) { |
118 TraceLog::GetInstance()->SetEnabled(TraceConfig(trace_config), | 120 TraceLog::GetInstance()->SetEnabled(TraceConfig(trace_config), |
119 TraceLog::RECORDING_MODE); | 121 TraceLog::RECORDING_MODE); |
120 } | 122 } |
121 | 123 |
122 void DisableTracing() { TraceLog::GetInstance()->SetDisabled(); } | 124 void DisableTracing() { TraceLog::GetInstance()->SetDisabled(); } |
123 | 125 |
124 bool IsPeriodicDumpingEnabled() const { | 126 bool IsPeriodicDumpingEnabled() const { |
125 return mdm_->periodic_dump_timer_.IsRunning(); | 127 return mdm_->periodic_dump_timer_.IsRunning(); |
126 } | 128 } |
127 | 129 |
| 130 int GetMaxConsecutiveFailuresCount() const { |
| 131 return MemoryDumpManager::kMaxConsecutiveFailuresCount; |
| 132 } |
| 133 |
128 scoped_ptr<MemoryDumpManager> mdm_; | 134 scoped_ptr<MemoryDumpManager> mdm_; |
129 scoped_ptr<MemoryDumpManagerDelegateForTesting> delegate_; | 135 scoped_ptr<MemoryDumpManagerDelegateForTesting> delegate_; |
130 bool last_callback_success_; | 136 bool last_callback_success_; |
131 | 137 |
132 private: | 138 private: |
133 scoped_ptr<MessageLoop> message_loop_; | 139 scoped_ptr<MessageLoop> message_loop_; |
134 | 140 |
135 // We want our singleton torn down after each test. | 141 // We want our singleton torn down after each test. |
136 ShadowingAtExitManager at_exit_manager_; | 142 ShadowingAtExitManager at_exit_manager_; |
137 }; | 143 }; |
138 | 144 |
139 // Basic sanity checks. Registers a memory dump provider and checks that it is | 145 // Basic sanity checks. Registers a memory dump provider and checks that it is |
140 // called, but only when memory-infra is enabled. | 146 // called, but only when memory-infra is enabled. |
141 TEST_F(MemoryDumpManagerTest, SingleDumper) { | 147 TEST_F(MemoryDumpManagerTest, SingleDumper) { |
| 148 InitializeMemoryDumpManager(false /* is_coordinator */); |
142 MockMemoryDumpProvider mdp; | 149 MockMemoryDumpProvider mdp; |
143 mdm_->RegisterDumpProvider(&mdp); | 150 mdm_->RegisterDumpProvider(&mdp); |
144 | 151 |
145 // Check that the dumper is not called if the memory category is not enabled. | 152 // Check that the dumper is not called if the memory category is not enabled. |
146 EnableTracingWithLegacyCategories("foobar-but-not-memory"); | 153 EnableTracingWithLegacyCategories("foobar-but-not-memory"); |
147 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(0); | 154 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(0); |
148 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0); | 155 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0); |
149 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, | 156 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, |
150 g_high_detail_args); | 157 g_high_detail_args); |
151 DisableTracing(); | 158 DisableTracing(); |
(...skipping 16 matching lines...) Expand all Loading... |
168 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); | 175 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); |
169 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0); | 176 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0); |
170 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, | 177 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, |
171 g_high_detail_args); | 178 g_high_detail_args); |
172 TraceLog::GetInstance()->SetDisabled(); | 179 TraceLog::GetInstance()->SetDisabled(); |
173 } | 180 } |
174 | 181 |
175 // Checks that requesting dumps with high level of detail actually propagates | 182 // Checks that requesting dumps with high level of detail actually propagates |
176 // the level of the detail properly to OnMemoryDump() call on dump providers. | 183 // the level of the detail properly to OnMemoryDump() call on dump providers. |
177 TEST_F(MemoryDumpManagerTest, CheckMemoryDumpArgs) { | 184 TEST_F(MemoryDumpManagerTest, CheckMemoryDumpArgs) { |
| 185 InitializeMemoryDumpManager(false /* is_coordinator */); |
178 MockMemoryDumpProvider mdp; | 186 MockMemoryDumpProvider mdp; |
179 | 187 |
180 mdm_->RegisterDumpProvider(&mdp); | 188 mdm_->RegisterDumpProvider(&mdp); |
181 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); | 189 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); |
182 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); | 190 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); |
183 EXPECT_CALL(mdp, OnMemoryDump(IsHighDetail(), _)).WillOnce(Return(true)); | 191 EXPECT_CALL(mdp, OnMemoryDump(IsHighDetail(), _)).WillOnce(Return(true)); |
184 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, | 192 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, |
185 g_high_detail_args); | 193 g_high_detail_args); |
186 DisableTracing(); | 194 DisableTracing(); |
187 mdm_->UnregisterDumpProvider(&mdp); | 195 mdm_->UnregisterDumpProvider(&mdp); |
188 | 196 |
189 // Check that requesting dumps with low level of detail actually propagates to | 197 // Check that requesting dumps with low level of detail actually propagates to |
190 // OnMemoryDump() call on dump providers. | 198 // OnMemoryDump() call on dump providers. |
191 mdm_->RegisterDumpProvider(&mdp); | 199 mdm_->RegisterDumpProvider(&mdp); |
192 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); | 200 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); |
193 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); | 201 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); |
194 EXPECT_CALL(mdp, OnMemoryDump(IsLowDetail(), _)).WillOnce(Return(true)); | 202 EXPECT_CALL(mdp, OnMemoryDump(IsLowDetail(), _)).WillOnce(Return(true)); |
195 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, | 203 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, |
196 g_low_detail_args); | 204 g_low_detail_args); |
197 DisableTracing(); | 205 DisableTracing(); |
198 mdm_->UnregisterDumpProvider(&mdp); | 206 mdm_->UnregisterDumpProvider(&mdp); |
199 } | 207 } |
200 | 208 |
201 // Checks that the SharedSessionState object is acqually shared over time. | 209 // Checks that the SharedSessionState object is acqually shared over time. |
202 TEST_F(MemoryDumpManagerTest, SharedSessionState) { | 210 TEST_F(MemoryDumpManagerTest, SharedSessionState) { |
| 211 InitializeMemoryDumpManager(false /* is_coordinator */); |
203 MockMemoryDumpProvider mdp1; | 212 MockMemoryDumpProvider mdp1; |
204 MockMemoryDumpProvider mdp2; | 213 MockMemoryDumpProvider mdp2; |
205 mdm_->RegisterDumpProvider(&mdp1); | 214 mdm_->RegisterDumpProvider(&mdp1); |
206 mdm_->RegisterDumpProvider(&mdp2); | 215 mdm_->RegisterDumpProvider(&mdp2); |
207 | 216 |
208 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); | 217 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); |
209 const MemoryDumpSessionState* session_state = mdm_->session_state().get(); | 218 const MemoryDumpSessionState* session_state = mdm_->session_state().get(); |
210 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(2); | 219 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(2); |
211 EXPECT_CALL(mdp1, OnMemoryDump(_, _)) | 220 EXPECT_CALL(mdp1, OnMemoryDump(_, _)) |
212 .Times(2) | 221 .Times(2) |
(...skipping 12 matching lines...) Expand all Loading... |
225 | 234 |
226 for (int i = 0; i < 2; ++i) | 235 for (int i = 0; i < 2; ++i) |
227 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, | 236 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, |
228 g_high_detail_args); | 237 g_high_detail_args); |
229 | 238 |
230 DisableTracing(); | 239 DisableTracing(); |
231 } | 240 } |
232 | 241 |
233 // Checks that the (Un)RegisterDumpProvider logic behaves sanely. | 242 // Checks that the (Un)RegisterDumpProvider logic behaves sanely. |
234 TEST_F(MemoryDumpManagerTest, MultipleDumpers) { | 243 TEST_F(MemoryDumpManagerTest, MultipleDumpers) { |
| 244 InitializeMemoryDumpManager(false /* is_coordinator */); |
235 MockMemoryDumpProvider mdp1; | 245 MockMemoryDumpProvider mdp1; |
236 MockMemoryDumpProvider mdp2; | 246 MockMemoryDumpProvider mdp2; |
237 | 247 |
238 // Enable only mdp1. | 248 // Enable only mdp1. |
239 mdm_->RegisterDumpProvider(&mdp1); | 249 mdm_->RegisterDumpProvider(&mdp1); |
240 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); | 250 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); |
241 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); | 251 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); |
242 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).WillOnce(Return(true)); | 252 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).WillOnce(Return(true)); |
243 EXPECT_CALL(mdp2, OnMemoryDump(_, _)).Times(0); | 253 EXPECT_CALL(mdp2, OnMemoryDump(_, _)).Times(0); |
244 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, | 254 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, |
(...skipping 18 matching lines...) Expand all Loading... |
263 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).WillOnce(Return(true)); | 273 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).WillOnce(Return(true)); |
264 EXPECT_CALL(mdp2, OnMemoryDump(_, _)).WillOnce(Return(true)); | 274 EXPECT_CALL(mdp2, OnMemoryDump(_, _)).WillOnce(Return(true)); |
265 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, | 275 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, |
266 g_high_detail_args); | 276 g_high_detail_args); |
267 DisableTracing(); | 277 DisableTracing(); |
268 } | 278 } |
269 | 279 |
270 // Checks that the dump provider invocations depend only on the current | 280 // Checks that the dump provider invocations depend only on the current |
271 // registration state and not on previous registrations and dumps. | 281 // registration state and not on previous registrations and dumps. |
272 TEST_F(MemoryDumpManagerTest, RegistrationConsistency) { | 282 TEST_F(MemoryDumpManagerTest, RegistrationConsistency) { |
| 283 InitializeMemoryDumpManager(false /* is_coordinator */); |
273 MockMemoryDumpProvider mdp; | 284 MockMemoryDumpProvider mdp; |
274 | 285 |
275 mdm_->RegisterDumpProvider(&mdp); | 286 mdm_->RegisterDumpProvider(&mdp); |
276 | 287 |
277 { | 288 { |
278 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); | 289 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); |
279 EXPECT_CALL(mdp, OnMemoryDump(_, _)).WillOnce(Return(true)); | 290 EXPECT_CALL(mdp, OnMemoryDump(_, _)).WillOnce(Return(true)); |
280 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); | 291 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); |
281 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, | 292 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, |
282 g_high_detail_args); | 293 g_high_detail_args); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 g_high_detail_args); | 329 g_high_detail_args); |
319 DisableTracing(); | 330 DisableTracing(); |
320 } | 331 } |
321 } | 332 } |
322 | 333 |
323 // Checks that the MemoryDumpManager respects the thread affinity when a | 334 // Checks that the MemoryDumpManager respects the thread affinity when a |
324 // MemoryDumpProvider specifies a task_runner(). The test starts creating 8 | 335 // MemoryDumpProvider specifies a task_runner(). The test starts creating 8 |
325 // threads and registering a MemoryDumpProvider on each of them. At each | 336 // threads and registering a MemoryDumpProvider on each of them. At each |
326 // iteration, one thread is removed, to check the live unregistration logic. | 337 // iteration, one thread is removed, to check the live unregistration logic. |
327 TEST_F(MemoryDumpManagerTest, RespectTaskRunnerAffinity) { | 338 TEST_F(MemoryDumpManagerTest, RespectTaskRunnerAffinity) { |
| 339 InitializeMemoryDumpManager(false /* is_coordinator */); |
328 const uint32 kNumInitialThreads = 8; | 340 const uint32 kNumInitialThreads = 8; |
329 | 341 |
330 ScopedVector<Thread> threads; | 342 ScopedVector<Thread> threads; |
331 ScopedVector<MockMemoryDumpProvider> mdps; | 343 ScopedVector<MockMemoryDumpProvider> mdps; |
332 | 344 |
333 // Create the threads and setup the expectations. Given that at each iteration | 345 // Create the threads and setup the expectations. Given that at each iteration |
334 // we will pop out one thread/MemoryDumpProvider, each MDP is supposed to be | 346 // we will pop out one thread/MemoryDumpProvider, each MDP is supposed to be |
335 // invoked a number of times equal to its index. | 347 // invoked a number of times equal to its index. |
336 for (uint32 i = kNumInitialThreads; i > 0; --i) { | 348 for (uint32 i = kNumInitialThreads; i > 0; --i) { |
337 Thread* thread = new Thread("test thread"); | 349 Thread* thread = new Thread("test thread"); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 threads.back()->Stop(); | 396 threads.back()->Stop(); |
385 threads.pop_back(); | 397 threads.pop_back(); |
386 } | 398 } |
387 | 399 |
388 DisableTracing(); | 400 DisableTracing(); |
389 } | 401 } |
390 | 402 |
391 // Checks that providers get disabled after 3 consecutive failures, but not | 403 // Checks that providers get disabled after 3 consecutive failures, but not |
392 // otherwise (e.g., if interleaved). | 404 // otherwise (e.g., if interleaved). |
393 TEST_F(MemoryDumpManagerTest, DisableFailingDumpers) { | 405 TEST_F(MemoryDumpManagerTest, DisableFailingDumpers) { |
| 406 InitializeMemoryDumpManager(false /* is_coordinator */); |
394 MockMemoryDumpProvider mdp1; | 407 MockMemoryDumpProvider mdp1; |
395 MockMemoryDumpProvider mdp2; | 408 MockMemoryDumpProvider mdp2; |
396 | 409 |
397 mdm_->RegisterDumpProvider(&mdp1); | 410 mdm_->RegisterDumpProvider(&mdp1); |
398 mdm_->RegisterDumpProvider(&mdp2); | 411 mdm_->RegisterDumpProvider(&mdp2); |
399 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); | 412 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); |
400 | 413 |
401 const int kNumDumps = 2 * MemoryDumpManager::kMaxConsecutiveFailuresCount; | 414 const int kNumDumps = 2 * GetMaxConsecutiveFailuresCount(); |
402 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(kNumDumps); | 415 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(kNumDumps); |
403 | 416 |
404 EXPECT_CALL(mdp1, OnMemoryDump(_, _)) | 417 EXPECT_CALL(mdp1, OnMemoryDump(_, _)) |
405 .Times(MemoryDumpManager::kMaxConsecutiveFailuresCount) | 418 .Times(GetMaxConsecutiveFailuresCount()) |
406 .WillRepeatedly(Return(false)); | 419 .WillRepeatedly(Return(false)); |
407 | 420 |
408 EXPECT_CALL(mdp2, OnMemoryDump(_, _)) | 421 EXPECT_CALL(mdp2, OnMemoryDump(_, _)) |
409 .WillOnce(Return(false)) | 422 .WillOnce(Return(false)) |
410 .WillOnce(Return(true)) | 423 .WillOnce(Return(true)) |
411 .WillOnce(Return(false)) | 424 .WillOnce(Return(false)) |
412 .WillOnce(Return(false)) | 425 .WillOnce(Return(false)) |
413 .WillOnce(Return(true)) | 426 .WillOnce(Return(true)) |
414 .WillOnce(Return(false)); | 427 .WillOnce(Return(false)); |
415 | 428 |
416 for (int i = 0; i < kNumDumps; i++) { | 429 for (int i = 0; i < kNumDumps; i++) { |
417 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, | 430 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, |
418 g_high_detail_args); | 431 g_high_detail_args); |
419 } | 432 } |
420 | 433 |
421 DisableTracing(); | 434 DisableTracing(); |
422 } | 435 } |
423 | 436 |
424 // Sneakily registers an extra memory dump provider while an existing one is | 437 // Sneakily registers an extra memory dump provider while an existing one is |
425 // dumping and expect it to take part in the already active tracing session. | 438 // dumping and expect it to take part in the already active tracing session. |
426 TEST_F(MemoryDumpManagerTest, RegisterDumperWhileDumping) { | 439 TEST_F(MemoryDumpManagerTest, RegisterDumperWhileDumping) { |
| 440 InitializeMemoryDumpManager(false /* is_coordinator */); |
427 MockMemoryDumpProvider mdp1; | 441 MockMemoryDumpProvider mdp1; |
428 MockMemoryDumpProvider mdp2; | 442 MockMemoryDumpProvider mdp2; |
429 | 443 |
430 mdm_->RegisterDumpProvider(&mdp1); | 444 mdm_->RegisterDumpProvider(&mdp1); |
431 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); | 445 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); |
432 | 446 |
433 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(4); | 447 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(4); |
434 | 448 |
435 EXPECT_CALL(mdp1, OnMemoryDump(_, _)) | 449 EXPECT_CALL(mdp1, OnMemoryDump(_, _)) |
436 .Times(4) | 450 .Times(4) |
(...skipping 14 matching lines...) Expand all Loading... |
451 for (int i = 0; i < 4; i++) { | 465 for (int i = 0; i < 4; i++) { |
452 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, | 466 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, |
453 g_high_detail_args); | 467 g_high_detail_args); |
454 } | 468 } |
455 | 469 |
456 DisableTracing(); | 470 DisableTracing(); |
457 } | 471 } |
458 | 472 |
459 // Like RegisterDumperWhileDumping, but unregister the dump provider instead. | 473 // Like RegisterDumperWhileDumping, but unregister the dump provider instead. |
460 TEST_F(MemoryDumpManagerTest, UnregisterDumperWhileDumping) { | 474 TEST_F(MemoryDumpManagerTest, UnregisterDumperWhileDumping) { |
| 475 InitializeMemoryDumpManager(false /* is_coordinator */); |
461 MockMemoryDumpProvider mdp1; | 476 MockMemoryDumpProvider mdp1; |
462 MockMemoryDumpProvider mdp2; | 477 MockMemoryDumpProvider mdp2; |
463 | 478 |
464 mdm_->RegisterDumpProvider(&mdp1, ThreadTaskRunnerHandle::Get()); | 479 mdm_->RegisterDumpProvider(&mdp1, ThreadTaskRunnerHandle::Get()); |
465 mdm_->RegisterDumpProvider(&mdp2, ThreadTaskRunnerHandle::Get()); | 480 mdm_->RegisterDumpProvider(&mdp2, ThreadTaskRunnerHandle::Get()); |
466 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); | 481 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); |
467 | 482 |
468 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(4); | 483 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(4); |
469 | 484 |
470 EXPECT_CALL(mdp1, OnMemoryDump(_, _)) | 485 EXPECT_CALL(mdp1, OnMemoryDump(_, _)) |
(...skipping 16 matching lines...) Expand all Loading... |
487 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, | 502 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, |
488 g_high_detail_args); | 503 g_high_detail_args); |
489 } | 504 } |
490 | 505 |
491 DisableTracing(); | 506 DisableTracing(); |
492 } | 507 } |
493 | 508 |
494 // Checks that the dump does not abort when unregistering a provider while | 509 // Checks that the dump does not abort when unregistering a provider while |
495 // dumping from a different thread than the dumping thread. | 510 // dumping from a different thread than the dumping thread. |
496 TEST_F(MemoryDumpManagerTest, UnregisterDumperFromThreadWhileDumping) { | 511 TEST_F(MemoryDumpManagerTest, UnregisterDumperFromThreadWhileDumping) { |
| 512 InitializeMemoryDumpManager(false /* is_coordinator */); |
497 ScopedVector<TestIOThread> threads; | 513 ScopedVector<TestIOThread> threads; |
498 ScopedVector<MockMemoryDumpProvider> mdps; | 514 ScopedVector<MockMemoryDumpProvider> mdps; |
499 | 515 |
500 for (int i = 0; i < 2; i++) { | 516 for (int i = 0; i < 2; i++) { |
501 threads.push_back(new TestIOThread(TestIOThread::kAutoStart)); | 517 threads.push_back(new TestIOThread(TestIOThread::kAutoStart)); |
502 mdps.push_back(new MockMemoryDumpProvider()); | 518 mdps.push_back(new MockMemoryDumpProvider()); |
503 mdm_->RegisterDumpProvider(mdps.back(), threads.back()->task_runner()); | 519 mdm_->RegisterDumpProvider(mdps.back(), threads.back()->task_runner()); |
504 } | 520 } |
505 | 521 |
506 int on_memory_dump_call_count = 0; | 522 int on_memory_dump_call_count = 0; |
(...skipping 20 matching lines...) Expand all Loading... |
527 .Times(AtMost(1)) | 543 .Times(AtMost(1)) |
528 .WillOnce(Invoke(on_dump)); | 544 .WillOnce(Invoke(on_dump)); |
529 } | 545 } |
530 | 546 |
531 last_callback_success_ = false; | 547 last_callback_success_ = false; |
532 MemoryDumpCallback callback = | 548 MemoryDumpCallback callback = |
533 Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this), | 549 Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this), |
534 MessageLoop::current()->task_runner(), run_loop.QuitClosure()); | 550 MessageLoop::current()->task_runner(), run_loop.QuitClosure()); |
535 | 551 |
536 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); | 552 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); |
537 MemoryDumpRequestArgs request_args = {0, MemoryDumpType::EXPLICITLY_TRIGGERED, | 553 |
538 g_high_detail_args}; | 554 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1); |
539 mdm_->CreateProcessDump(request_args, callback); | 555 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, |
| 556 g_high_detail_args, callback); |
540 | 557 |
541 run_loop.Run(); | 558 run_loop.Run(); |
542 | 559 |
543 ASSERT_EQ(1, on_memory_dump_call_count); | 560 ASSERT_EQ(1, on_memory_dump_call_count); |
544 ASSERT_EQ(true, last_callback_success_); | 561 ASSERT_EQ(true, last_callback_success_); |
545 | 562 |
546 DisableTracing(); | 563 DisableTracing(); |
547 } | 564 } |
548 | 565 |
549 // Checks that a NACK callback is invoked if RequestGlobalDump() is called when | 566 // Checks that a NACK callback is invoked if RequestGlobalDump() is called when |
550 // tracing is not enabled. | 567 // tracing is not enabled. |
551 TEST_F(MemoryDumpManagerTest, CallbackCalledOnFailure) { | 568 TEST_F(MemoryDumpManagerTest, CallbackCalledOnFailure) { |
| 569 InitializeMemoryDumpManager(false /* is_coordinator */); |
552 MockMemoryDumpProvider mdp1; | 570 MockMemoryDumpProvider mdp1; |
553 mdm_->RegisterDumpProvider(&mdp1); | 571 mdm_->RegisterDumpProvider(&mdp1); |
554 | 572 |
555 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(0); | 573 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(0); |
556 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).Times(0); | 574 EXPECT_CALL(mdp1, OnMemoryDump(_, _)).Times(0); |
557 | 575 |
558 last_callback_success_ = true; | 576 last_callback_success_ = true; |
559 { | 577 { |
560 RunLoop run_loop; | 578 RunLoop run_loop; |
561 MemoryDumpCallback callback = | 579 MemoryDumpCallback callback = |
562 Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this), | 580 Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this), |
563 MessageLoop::current()->task_runner(), run_loop.QuitClosure()); | 581 MessageLoop::current()->task_runner(), run_loop.QuitClosure()); |
564 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, | 582 mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED, |
565 g_high_detail_args, callback); | 583 g_high_detail_args, callback); |
566 run_loop.Run(); | 584 run_loop.Run(); |
567 } | 585 } |
568 EXPECT_FALSE(last_callback_success_); | 586 EXPECT_FALSE(last_callback_success_); |
569 } | 587 } |
570 | 588 |
571 // This test crystallizes the expectations of the chrome://tracing UI and | 589 // This test (and the MemoryDumpManagerTestCoordinator below) crystallizes the |
572 // chrome telemetry w.r.t. periodic dumps in memory-infra, handling gracefully | 590 // expectations of the chrome://tracing UI and chrome telemetry w.r.t. periodic |
573 // the transition between the legacy and the new-style (JSON-based) TraceConfig. | 591 // dumps in memory-infra, handling gracefully the transition between the legacy |
| 592 // and the new-style (JSON-based) TraceConfig. |
574 TEST_F(MemoryDumpManagerTest, TraceConfigExpectations) { | 593 TEST_F(MemoryDumpManagerTest, TraceConfigExpectations) { |
| 594 InitializeMemoryDumpManager(false /* is_coordinator */); |
575 MemoryDumpManagerDelegateForTesting& delegate = *delegate_; | 595 MemoryDumpManagerDelegateForTesting& delegate = *delegate_; |
576 | 596 |
577 // Don't trigger the default behavior of the mock delegate in this test, | 597 // Don't trigger the default behavior of the mock delegate in this test, |
578 // which would short-circuit the dump request to the actual | 598 // which would short-circuit the dump request to the actual |
579 // CreateProcessDump(). | 599 // CreateProcessDump(). |
580 // We don't want to create any dump in this test, only check whether the dumps | 600 // We don't want to create any dump in this test, only check whether the dumps |
581 // are requested or not. | 601 // are requested or not. |
582 ON_CALL(delegate, RequestGlobalMemoryDump(_, _)).WillByDefault(Return()); | 602 ON_CALL(delegate, RequestGlobalMemoryDump(_, _)).WillByDefault(Return()); |
583 | 603 |
584 // Enabling memory-infra in a non-coordinator process should not trigger any | 604 // Enabling memory-infra in a non-coordinator process should not trigger any |
585 // periodic dumps. | 605 // periodic dumps. |
586 EXPECT_CALL(delegate, IsCoordinatorProcess()).WillRepeatedly(Return(false)); | |
587 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); | 606 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); |
588 EXPECT_FALSE(IsPeriodicDumpingEnabled()); | 607 EXPECT_FALSE(IsPeriodicDumpingEnabled()); |
589 DisableTracing(); | 608 DisableTracing(); |
590 | 609 |
| 610 // Enabling memory-infra with the new (JSON) TraceConfig in a non-coordinator |
| 611 // process with a fully defined trigger config should NOT enable any periodic |
| 612 // dumps. |
| 613 const std::string kTraceConfigWithTriggers = StringPrintf( |
| 614 kTraceConfigWithTriggersFmt, MemoryDumpManager::kTraceCategory); |
| 615 EnableTracingWithTraceConfig(kTraceConfigWithTriggers.c_str()); |
| 616 EXPECT_FALSE(IsPeriodicDumpingEnabled()); |
| 617 DisableTracing(); |
| 618 } |
| 619 |
| 620 TEST_F(MemoryDumpManagerTest, TraceConfigExpectationsWhenIsCoordinator) { |
| 621 InitializeMemoryDumpManager(true /* is_coordinator */); |
| 622 MemoryDumpManagerDelegateForTesting& delegate = *delegate_; |
| 623 ON_CALL(delegate, RequestGlobalMemoryDump(_, _)).WillByDefault(Return()); |
| 624 |
591 // Enabling memory-infra with the legacy TraceConfig (category filter) in | 625 // Enabling memory-infra with the legacy TraceConfig (category filter) in |
592 // a coordinator process should enable periodic dumps. | 626 // a coordinator process should enable periodic dumps. |
593 EXPECT_CALL(delegate, IsCoordinatorProcess()).WillRepeatedly(Return(true)); | |
594 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); | 627 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); |
595 EXPECT_TRUE(IsPeriodicDumpingEnabled()); | 628 EXPECT_TRUE(IsPeriodicDumpingEnabled()); |
596 DisableTracing(); | 629 DisableTracing(); |
597 | 630 |
598 // Enabling memory-infra with the new (JSON) TraceConfig in a coordinator | 631 // Enabling memory-infra with the new (JSON) TraceConfig in a coordinator |
599 // process without specifying any "memory_dump_config" section should enable | 632 // process without specifying any "memory_dump_config" section should enable |
600 // periodic dumps. This is to preserve the behavior chrome://tracing UI, that | 633 // periodic dumps. This is to preserve the behavior chrome://tracing UI, that |
601 // is: ticking memory-infra should dump periodically with the default config. | 634 // is: ticking memory-infra should dump periodically with the default config. |
602 EXPECT_CALL(delegate, IsCoordinatorProcess()).WillRepeatedly(Return(true)); | |
603 const std::string kTraceConfigWithNoMemorDumpConfig = StringPrintf( | 635 const std::string kTraceConfigWithNoMemorDumpConfig = StringPrintf( |
604 "{\"included_categories\":[\"%s\"]}", MemoryDumpManager::kTraceCategory); | 636 "{\"included_categories\":[\"%s\"]}", MemoryDumpManager::kTraceCategory); |
605 EnableTracingWithTraceConfig(kTraceConfigWithNoMemorDumpConfig.c_str()); | 637 EnableTracingWithTraceConfig(kTraceConfigWithNoMemorDumpConfig.c_str()); |
606 EXPECT_TRUE(IsPeriodicDumpingEnabled()); | 638 EXPECT_TRUE(IsPeriodicDumpingEnabled()); |
607 DisableTracing(); | 639 DisableTracing(); |
608 | 640 |
609 // Enabling memory-infra with the new (JSON) TraceConfig in a coordinator | 641 // Enabling memory-infra with the new (JSON) TraceConfig in a coordinator |
610 // process with an empty "memory_dump_config" should NOT enable periodic | 642 // process with an empty "memory_dump_config" should NOT enable periodic |
611 // dumps. This is the way telemetry is supposed to use memory-infra with | 643 // dumps. This is the way telemetry is supposed to use memory-infra with |
612 // only explicitly triggered dumps. | 644 // only explicitly triggered dumps. |
613 EXPECT_CALL(delegate, IsCoordinatorProcess()).WillRepeatedly(Return(true)); | |
614 const std::string kTraceConfigWithNoTriggers = StringPrintf( | 645 const std::string kTraceConfigWithNoTriggers = StringPrintf( |
615 "{\"included_categories\":[\"%s\"], \"memory_dump_config\":{}", | 646 "{\"included_categories\":[\"%s\"], \"memory_dump_config\":{}", |
616 MemoryDumpManager::kTraceCategory); | 647 MemoryDumpManager::kTraceCategory); |
617 EnableTracingWithTraceConfig(kTraceConfigWithNoTriggers.c_str()); | 648 EnableTracingWithTraceConfig(kTraceConfigWithNoTriggers.c_str()); |
618 EXPECT_FALSE(IsPeriodicDumpingEnabled()); | 649 EXPECT_FALSE(IsPeriodicDumpingEnabled()); |
619 DisableTracing(); | 650 DisableTracing(); |
620 | 651 |
621 // Enabling memory-infra with the new (JSON) TraceConfig in a non-coordinator | |
622 // process with a fully defined trigger config should NOT enable any periodic | |
623 // dumps. | |
624 EXPECT_CALL(delegate, IsCoordinatorProcess()).WillRepeatedly(Return(false)); | |
625 const std::string kTraceConfigWithTriggers = StringPrintf( | |
626 "{\"included_categories\":[\"%s\"]," | |
627 "\"memory_dump_config\":{" | |
628 "\"triggers\":[" | |
629 "{\"mode\":\"light\", \"periodic_interval_ms\":1}," | |
630 "{\"mode\":\"detailed\", \"periodic_interval_ms\":5}" | |
631 "]" | |
632 "}" | |
633 "}", MemoryDumpManager::kTraceCategory); | |
634 EnableTracingWithTraceConfig(kTraceConfigWithTriggers.c_str()); | |
635 EXPECT_FALSE(IsPeriodicDumpingEnabled()); | |
636 DisableTracing(); | |
637 | |
638 // Enabling memory-infra with the new (JSON) TraceConfig in a coordinator | 652 // Enabling memory-infra with the new (JSON) TraceConfig in a coordinator |
639 // process with a fully defined trigger config should cause periodic dumps to | 653 // process with a fully defined trigger config should cause periodic dumps to |
640 // be performed in the correct order. | 654 // be performed in the correct order. |
641 EXPECT_CALL(delegate, IsCoordinatorProcess()).WillRepeatedly(Return(true)); | |
642 | |
643 RunLoop run_loop; | 655 RunLoop run_loop; |
644 auto quit_closure = run_loop.QuitClosure(); | 656 auto quit_closure = run_loop.QuitClosure(); |
645 | 657 |
646 // The expected sequence with config of light=1ms, heavy=5ms is H,L,L,L,H,... | 658 // The expected sequence with config of light=1ms, heavy=5ms is H,L,L,L,H,... |
647 testing::InSequence sequence; | 659 testing::InSequence sequence; |
648 EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsHighDetailArgs(), _)); | 660 EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsHighDetailArgs(), _)); |
649 EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLowDetailArgs(), _)).Times(3); | 661 EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLowDetailArgs(), _)).Times(3); |
650 EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsHighDetailArgs(), _)); | 662 EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsHighDetailArgs(), _)); |
651 EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLowDetailArgs(), _)).Times(2); | 663 EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLowDetailArgs(), _)).Times(2); |
652 EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLowDetailArgs(), _)) | 664 EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLowDetailArgs(), _)) |
653 .WillOnce(Invoke([quit_closure](const MemoryDumpRequestArgs& args, | 665 .WillOnce(Invoke([quit_closure](const MemoryDumpRequestArgs& args, |
654 const MemoryDumpCallback& callback) { | 666 const MemoryDumpCallback& callback) { |
655 ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure); | 667 ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure); |
656 })); | 668 })); |
657 | 669 |
658 // Swallow all the final spurious calls until tracing gets disabled. | 670 // Swallow all the final spurious calls until tracing gets disabled. |
659 EXPECT_CALL(delegate, RequestGlobalMemoryDump(_, _)).Times(AnyNumber()); | 671 EXPECT_CALL(delegate, RequestGlobalMemoryDump(_, _)).Times(AnyNumber()); |
660 | 672 |
| 673 const std::string kTraceConfigWithTriggers = StringPrintf( |
| 674 kTraceConfigWithTriggersFmt, MemoryDumpManager::kTraceCategory); |
661 EnableTracingWithTraceConfig(kTraceConfigWithTriggers.c_str()); | 675 EnableTracingWithTraceConfig(kTraceConfigWithTriggers.c_str()); |
662 run_loop.Run(); | 676 run_loop.Run(); |
663 DisableTracing(); | 677 DisableTracing(); |
664 } | 678 } |
665 | 679 |
666 } // namespace trace_event | 680 } // namespace trace_event |
667 } // namespace base | 681 } // namespace base |
OLD | NEW |