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 <stddef.h> | 5 #include <stddef.h> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 class BackgroundTracingManagerUploadConfigWrapper { | 32 class BackgroundTracingManagerUploadConfigWrapper { |
33 public: | 33 public: |
34 BackgroundTracingManagerUploadConfigWrapper(const base::Closure& callback) | 34 BackgroundTracingManagerUploadConfigWrapper(const base::Closure& callback) |
35 : callback_(callback), receive_count_(0) { | 35 : callback_(callback), receive_count_(0) { |
36 receive_callback_ = | 36 receive_callback_ = |
37 base::Bind(&BackgroundTracingManagerUploadConfigWrapper::Upload, | 37 base::Bind(&BackgroundTracingManagerUploadConfigWrapper::Upload, |
38 base::Unretained(this)); | 38 base::Unretained(this)); |
39 } | 39 } |
40 | 40 |
41 void Upload(const scoped_refptr<base::RefCountedString>& file_contents, | 41 void Upload(const scoped_refptr<base::RefCountedString>& file_contents, |
42 scoped_ptr<const base::DictionaryValue> metadata, | 42 std::unique_ptr<const base::DictionaryValue> metadata, |
43 base::Callback<void()> done_callback) { | 43 base::Callback<void()> done_callback) { |
44 receive_count_ += 1; | 44 receive_count_ += 1; |
45 EXPECT_TRUE(file_contents); | 45 EXPECT_TRUE(file_contents); |
46 | 46 |
47 size_t compressed_length = file_contents->data().length(); | 47 size_t compressed_length = file_contents->data().length(); |
48 const size_t kOutputBufferLength = 10 * 1024 * 1024; | 48 const size_t kOutputBufferLength = 10 * 1024 * 1024; |
49 std::vector<char> output_str(kOutputBufferLength); | 49 std::vector<char> output_str(kOutputBufferLength); |
50 | 50 |
51 z_stream stream = {0}; | 51 z_stream stream = {0}; |
52 stream.avail_in = compressed_length; | 52 stream.avail_in = compressed_length; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 }; | 90 }; |
91 | 91 |
92 void StartedFinalizingCallback(base::Closure callback, | 92 void StartedFinalizingCallback(base::Closure callback, |
93 bool expected, | 93 bool expected, |
94 bool value) { | 94 bool value) { |
95 EXPECT_EQ(expected, value); | 95 EXPECT_EQ(expected, value); |
96 if (!callback.is_null()) | 96 if (!callback.is_null()) |
97 callback.Run(); | 97 callback.Run(); |
98 } | 98 } |
99 | 99 |
100 scoped_ptr<BackgroundTracingConfig> CreatePreemptiveConfig() { | 100 std::unique_ptr<BackgroundTracingConfig> CreatePreemptiveConfig() { |
101 base::DictionaryValue dict; | 101 base::DictionaryValue dict; |
102 | 102 |
103 dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); | 103 dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); |
104 dict.SetString("category", "BENCHMARK"); | 104 dict.SetString("category", "BENCHMARK"); |
105 | 105 |
106 scoped_ptr<base::ListValue> rules_list(new base::ListValue()); | 106 std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); |
107 { | 107 { |
108 scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); | 108 std::unique_ptr<base::DictionaryValue> rules_dict( |
| 109 new base::DictionaryValue()); |
109 rules_dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); | 110 rules_dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); |
110 rules_dict->SetString("trigger_name", "preemptive_test"); | 111 rules_dict->SetString("trigger_name", "preemptive_test"); |
111 rules_list->Append(std::move(rules_dict)); | 112 rules_list->Append(std::move(rules_dict)); |
112 } | 113 } |
113 dict.Set("configs", std::move(rules_list)); | 114 dict.Set("configs", std::move(rules_list)); |
114 | 115 |
115 scoped_ptr<BackgroundTracingConfig> config( | 116 std::unique_ptr<BackgroundTracingConfig> config( |
116 BackgroundTracingConfigImpl::FromDict(&dict)); | 117 BackgroundTracingConfigImpl::FromDict(&dict)); |
117 | 118 |
118 EXPECT_TRUE(config); | 119 EXPECT_TRUE(config); |
119 return config; | 120 return config; |
120 } | 121 } |
121 | 122 |
122 scoped_ptr<BackgroundTracingConfig> CreateReactiveConfig() { | 123 std::unique_ptr<BackgroundTracingConfig> CreateReactiveConfig() { |
123 base::DictionaryValue dict; | 124 base::DictionaryValue dict; |
124 | 125 |
125 dict.SetString("mode", "REACTIVE_TRACING_MODE"); | 126 dict.SetString("mode", "REACTIVE_TRACING_MODE"); |
126 | 127 |
127 scoped_ptr<base::ListValue> rules_list(new base::ListValue()); | 128 std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); |
128 { | 129 { |
129 scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); | 130 std::unique_ptr<base::DictionaryValue> rules_dict( |
| 131 new base::DictionaryValue()); |
130 rules_dict->SetString("rule", "TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL"); | 132 rules_dict->SetString("rule", "TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL"); |
131 rules_dict->SetString("trigger_name", "reactive_test"); | 133 rules_dict->SetString("trigger_name", "reactive_test"); |
132 rules_dict->SetString("category", "BENCHMARK"); | 134 rules_dict->SetString("category", "BENCHMARK"); |
133 rules_list->Append(std::move(rules_dict)); | 135 rules_list->Append(std::move(rules_dict)); |
134 } | 136 } |
135 dict.Set("configs", std::move(rules_list)); | 137 dict.Set("configs", std::move(rules_list)); |
136 | 138 |
137 scoped_ptr<BackgroundTracingConfig> config( | 139 std::unique_ptr<BackgroundTracingConfig> config( |
138 BackgroundTracingConfigImpl::FromDict(&dict)); | 140 BackgroundTracingConfigImpl::FromDict(&dict)); |
139 | 141 |
140 EXPECT_TRUE(config); | 142 EXPECT_TRUE(config); |
141 return config; | 143 return config; |
142 } | 144 } |
143 | 145 |
144 void SetupBackgroundTracingManager() { | 146 void SetupBackgroundTracingManager() { |
145 content::BackgroundTracingManager::GetInstance() | 147 content::BackgroundTracingManager::GetInstance() |
146 ->InvalidateTriggerHandlesForTesting(); | 148 ->InvalidateTriggerHandlesForTesting(); |
147 } | 149 } |
148 | 150 |
149 void DisableScenarioWhenIdle() { | 151 void DisableScenarioWhenIdle() { |
150 BackgroundTracingManager::GetInstance()->SetActiveScenario( | 152 BackgroundTracingManager::GetInstance()->SetActiveScenario( |
151 NULL, BackgroundTracingManager::ReceiveCallback(), | 153 NULL, BackgroundTracingManager::ReceiveCallback(), |
152 BackgroundTracingManager::NO_DATA_FILTERING); | 154 BackgroundTracingManager::NO_DATA_FILTERING); |
153 } | 155 } |
154 | 156 |
155 // This tests that the endpoint receives the final trace data. | 157 // This tests that the endpoint receives the final trace data. |
156 IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, | 158 IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, |
157 ReceiveTraceFinalContentsOnTrigger) { | 159 ReceiveTraceFinalContentsOnTrigger) { |
158 { | 160 { |
159 SetupBackgroundTracingManager(); | 161 SetupBackgroundTracingManager(); |
160 | 162 |
161 base::RunLoop run_loop; | 163 base::RunLoop run_loop; |
162 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 164 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
163 run_loop.QuitClosure()); | 165 run_loop.QuitClosure()); |
164 | 166 |
165 scoped_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); | 167 std::unique_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); |
166 | 168 |
167 BackgroundTracingManager::TriggerHandle handle = | 169 BackgroundTracingManager::TriggerHandle handle = |
168 BackgroundTracingManager:: | 170 BackgroundTracingManager:: |
169 GetInstance()->RegisterTriggerType("preemptive_test"); | 171 GetInstance()->RegisterTriggerType("preemptive_test"); |
170 | 172 |
171 BackgroundTracingManager::GetInstance()->SetActiveScenario( | 173 BackgroundTracingManager::GetInstance()->SetActiveScenario( |
172 std::move(config), upload_config_wrapper.get_receive_callback(), | 174 std::move(config), upload_config_wrapper.get_receive_callback(), |
173 BackgroundTracingManager::NO_DATA_FILTERING); | 175 BackgroundTracingManager::NO_DATA_FILTERING); |
174 | 176 |
175 BackgroundTracingManager::GetInstance()->WhenIdle( | 177 BackgroundTracingManager::GetInstance()->WhenIdle( |
(...skipping 11 matching lines...) Expand all Loading... |
187 // This tests triggering more than once still only gathers once. | 189 // This tests triggering more than once still only gathers once. |
188 IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, | 190 IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, |
189 CallTriggersMoreThanOnceOnlyGatherOnce) { | 191 CallTriggersMoreThanOnceOnlyGatherOnce) { |
190 { | 192 { |
191 SetupBackgroundTracingManager(); | 193 SetupBackgroundTracingManager(); |
192 | 194 |
193 base::RunLoop run_loop; | 195 base::RunLoop run_loop; |
194 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 196 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
195 run_loop.QuitClosure()); | 197 run_loop.QuitClosure()); |
196 | 198 |
197 scoped_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); | 199 std::unique_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); |
198 | 200 |
199 content::BackgroundTracingManager::TriggerHandle handle = | 201 content::BackgroundTracingManager::TriggerHandle handle = |
200 content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( | 202 content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( |
201 "preemptive_test"); | 203 "preemptive_test"); |
202 | 204 |
203 BackgroundTracingManager::GetInstance()->SetActiveScenario( | 205 BackgroundTracingManager::GetInstance()->SetActiveScenario( |
204 std::move(config), upload_config_wrapper.get_receive_callback(), | 206 std::move(config), upload_config_wrapper.get_receive_callback(), |
205 BackgroundTracingManager::NO_DATA_FILTERING); | 207 BackgroundTracingManager::NO_DATA_FILTERING); |
206 | 208 |
207 BackgroundTracingManager::GetInstance()->WhenIdle( | 209 BackgroundTracingManager::GetInstance()->WhenIdle( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 NoWhitelistedArgsStripped) { | 241 NoWhitelistedArgsStripped) { |
240 SetupBackgroundTracingManager(); | 242 SetupBackgroundTracingManager(); |
241 | 243 |
242 base::trace_event::TraceLog::GetInstance()->SetArgumentFilterPredicate( | 244 base::trace_event::TraceLog::GetInstance()->SetArgumentFilterPredicate( |
243 base::Bind(&IsTraceEventArgsWhitelisted)); | 245 base::Bind(&IsTraceEventArgsWhitelisted)); |
244 | 246 |
245 base::RunLoop wait_for_upload; | 247 base::RunLoop wait_for_upload; |
246 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 248 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
247 wait_for_upload.QuitClosure()); | 249 wait_for_upload.QuitClosure()); |
248 | 250 |
249 scoped_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); | 251 std::unique_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); |
250 | 252 |
251 content::BackgroundTracingManager::TriggerHandle handle = | 253 content::BackgroundTracingManager::TriggerHandle handle = |
252 content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( | 254 content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( |
253 "preemptive_test"); | 255 "preemptive_test"); |
254 | 256 |
255 base::RunLoop wait_for_activated; | 257 base::RunLoop wait_for_activated; |
256 BackgroundTracingManager::GetInstance()->SetTracingEnabledCallbackForTesting( | 258 BackgroundTracingManager::GetInstance()->SetTracingEnabledCallbackForTesting( |
257 wait_for_activated.QuitClosure()); | 259 wait_for_activated.QuitClosure()); |
258 EXPECT_TRUE(BackgroundTracingManager::GetInstance()->SetActiveScenario( | 260 EXPECT_TRUE(BackgroundTracingManager::GetInstance()->SetActiveScenario( |
259 std::move(config), upload_config_wrapper.get_receive_callback(), | 261 std::move(config), upload_config_wrapper.get_receive_callback(), |
(...skipping 23 matching lines...) Expand all Loading... |
283 TraceMetadataInTrace) { | 285 TraceMetadataInTrace) { |
284 SetupBackgroundTracingManager(); | 286 SetupBackgroundTracingManager(); |
285 | 287 |
286 base::trace_event::TraceLog::GetInstance()->SetArgumentFilterPredicate( | 288 base::trace_event::TraceLog::GetInstance()->SetArgumentFilterPredicate( |
287 base::Bind(&IsTraceEventArgsWhitelisted)); | 289 base::Bind(&IsTraceEventArgsWhitelisted)); |
288 | 290 |
289 base::RunLoop wait_for_upload; | 291 base::RunLoop wait_for_upload; |
290 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 292 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
291 wait_for_upload.QuitClosure()); | 293 wait_for_upload.QuitClosure()); |
292 | 294 |
293 scoped_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); | 295 std::unique_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); |
294 | 296 |
295 content::BackgroundTracingManager::TriggerHandle handle = | 297 content::BackgroundTracingManager::TriggerHandle handle = |
296 content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( | 298 content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( |
297 "preemptive_test"); | 299 "preemptive_test"); |
298 | 300 |
299 base::RunLoop wait_for_activated; | 301 base::RunLoop wait_for_activated; |
300 BackgroundTracingManager::GetInstance()->SetTracingEnabledCallbackForTesting( | 302 BackgroundTracingManager::GetInstance()->SetTracingEnabledCallbackForTesting( |
301 wait_for_activated.QuitClosure()); | 303 wait_for_activated.QuitClosure()); |
302 EXPECT_TRUE(BackgroundTracingManager::GetInstance()->SetActiveScenario( | 304 EXPECT_TRUE(BackgroundTracingManager::GetInstance()->SetActiveScenario( |
303 std::move(config), upload_config_wrapper.get_receive_callback(), | 305 std::move(config), upload_config_wrapper.get_receive_callback(), |
(...skipping 23 matching lines...) Expand all Loading... |
327 CrashWhenSubprocessWithoutArgumentFilter) { | 329 CrashWhenSubprocessWithoutArgumentFilter) { |
328 SetupBackgroundTracingManager(); | 330 SetupBackgroundTracingManager(); |
329 | 331 |
330 base::trace_event::TraceLog::GetInstance()->SetArgumentFilterPredicate( | 332 base::trace_event::TraceLog::GetInstance()->SetArgumentFilterPredicate( |
331 base::Bind(&IsTraceEventArgsWhitelisted)); | 333 base::Bind(&IsTraceEventArgsWhitelisted)); |
332 | 334 |
333 base::RunLoop wait_for_upload; | 335 base::RunLoop wait_for_upload; |
334 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 336 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
335 wait_for_upload.QuitClosure()); | 337 wait_for_upload.QuitClosure()); |
336 | 338 |
337 scoped_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); | 339 std::unique_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); |
338 | 340 |
339 content::BackgroundTracingManager::TriggerHandle handle = | 341 content::BackgroundTracingManager::TriggerHandle handle = |
340 content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( | 342 content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( |
341 "preemptive_test"); | 343 "preemptive_test"); |
342 | 344 |
343 base::RunLoop wait_for_activated; | 345 base::RunLoop wait_for_activated; |
344 BackgroundTracingManager::GetInstance()->SetTracingEnabledCallbackForTesting( | 346 BackgroundTracingManager::GetInstance()->SetTracingEnabledCallbackForTesting( |
345 wait_for_activated.QuitClosure()); | 347 wait_for_activated.QuitClosure()); |
346 EXPECT_TRUE(BackgroundTracingManager::GetInstance()->SetActiveScenario( | 348 EXPECT_TRUE(BackgroundTracingManager::GetInstance()->SetActiveScenario( |
347 std::move(config), upload_config_wrapper.get_receive_callback(), | 349 std::move(config), upload_config_wrapper.get_receive_callback(), |
(...skipping 24 matching lines...) Expand all Loading... |
372 SetupBackgroundTracingManager(); | 374 SetupBackgroundTracingManager(); |
373 | 375 |
374 base::RunLoop run_loop; | 376 base::RunLoop run_loop; |
375 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 377 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
376 run_loop.QuitClosure()); | 378 run_loop.QuitClosure()); |
377 | 379 |
378 base::DictionaryValue dict; | 380 base::DictionaryValue dict; |
379 dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); | 381 dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); |
380 dict.SetString("category", "BENCHMARK"); | 382 dict.SetString("category", "BENCHMARK"); |
381 | 383 |
382 scoped_ptr<base::ListValue> rules_list(new base::ListValue()); | 384 std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); |
383 { | 385 { |
384 scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); | 386 std::unique_ptr<base::DictionaryValue> rules_dict( |
| 387 new base::DictionaryValue()); |
385 rules_dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); | 388 rules_dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); |
386 rules_dict->SetString("trigger_name", "test1"); | 389 rules_dict->SetString("trigger_name", "test1"); |
387 rules_list->Append(std::move(rules_dict)); | 390 rules_list->Append(std::move(rules_dict)); |
388 } | 391 } |
389 { | 392 { |
390 scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); | 393 std::unique_ptr<base::DictionaryValue> rules_dict( |
| 394 new base::DictionaryValue()); |
391 rules_dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); | 395 rules_dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); |
392 rules_dict->SetString("trigger_name", "test2"); | 396 rules_dict->SetString("trigger_name", "test2"); |
393 rules_list->Append(std::move(rules_dict)); | 397 rules_list->Append(std::move(rules_dict)); |
394 } | 398 } |
395 | 399 |
396 dict.Set("configs", std::move(rules_list)); | 400 dict.Set("configs", std::move(rules_list)); |
397 | 401 |
398 scoped_ptr<BackgroundTracingConfig> config( | 402 std::unique_ptr<BackgroundTracingConfig> config( |
399 BackgroundTracingConfigImpl::FromDict(&dict)); | 403 BackgroundTracingConfigImpl::FromDict(&dict)); |
400 EXPECT_TRUE(config); | 404 EXPECT_TRUE(config); |
401 | 405 |
402 BackgroundTracingManager::TriggerHandle handle1 = | 406 BackgroundTracingManager::TriggerHandle handle1 = |
403 BackgroundTracingManager::GetInstance()->RegisterTriggerType("test1"); | 407 BackgroundTracingManager::GetInstance()->RegisterTriggerType("test1"); |
404 BackgroundTracingManager::TriggerHandle handle2 = | 408 BackgroundTracingManager::TriggerHandle handle2 = |
405 BackgroundTracingManager::GetInstance()->RegisterTriggerType("test2"); | 409 BackgroundTracingManager::GetInstance()->RegisterTriggerType("test2"); |
406 | 410 |
407 BackgroundTracingManager::GetInstance()->SetActiveScenario( | 411 BackgroundTracingManager::GetInstance()->SetActiveScenario( |
408 std::move(config), upload_config_wrapper.get_receive_callback(), | 412 std::move(config), upload_config_wrapper.get_receive_callback(), |
(...skipping 22 matching lines...) Expand all Loading... |
431 SetupBackgroundTracingManager(); | 435 SetupBackgroundTracingManager(); |
432 | 436 |
433 base::RunLoop run_loop; | 437 base::RunLoop run_loop; |
434 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 438 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
435 run_loop.QuitClosure()); | 439 run_loop.QuitClosure()); |
436 | 440 |
437 base::DictionaryValue dict; | 441 base::DictionaryValue dict; |
438 dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); | 442 dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); |
439 dict.SetString("category", "BENCHMARK"); | 443 dict.SetString("category", "BENCHMARK"); |
440 | 444 |
441 scoped_ptr<base::ListValue> rules_list(new base::ListValue()); | 445 std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); |
442 { | 446 { |
443 scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); | 447 std::unique_ptr<base::DictionaryValue> rules_dict( |
| 448 new base::DictionaryValue()); |
444 rules_dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); | 449 rules_dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); |
445 rules_dict->SetString("trigger_name", "test2"); | 450 rules_dict->SetString("trigger_name", "test2"); |
446 rules_list->Append(std::move(rules_dict)); | 451 rules_list->Append(std::move(rules_dict)); |
447 } | 452 } |
448 | 453 |
449 dict.Set("configs", std::move(rules_list)); | 454 dict.Set("configs", std::move(rules_list)); |
450 dict.SetString("enable_blink_features", "FasterWeb1,FasterWeb2"); | 455 dict.SetString("enable_blink_features", "FasterWeb1,FasterWeb2"); |
451 dict.SetString("disable_blink_features", "SlowerWeb1,SlowerWeb2"); | 456 dict.SetString("disable_blink_features", "SlowerWeb1,SlowerWeb2"); |
452 scoped_ptr<BackgroundTracingConfig> config( | 457 std::unique_ptr<BackgroundTracingConfig> config( |
453 BackgroundTracingConfigImpl::FromDict(&dict)); | 458 BackgroundTracingConfigImpl::FromDict(&dict)); |
454 EXPECT_TRUE(config); | 459 EXPECT_TRUE(config); |
455 | 460 |
456 bool scenario_activated = | 461 bool scenario_activated = |
457 BackgroundTracingManager::GetInstance()->SetActiveScenario( | 462 BackgroundTracingManager::GetInstance()->SetActiveScenario( |
458 std::move(config), upload_config_wrapper.get_receive_callback(), | 463 std::move(config), upload_config_wrapper.get_receive_callback(), |
459 BackgroundTracingManager::NO_DATA_FILTERING); | 464 BackgroundTracingManager::NO_DATA_FILTERING); |
460 | 465 |
461 EXPECT_TRUE(scenario_activated); | 466 EXPECT_TRUE(scenario_activated); |
462 | 467 |
(...skipping 15 matching lines...) Expand all Loading... |
478 SetupBackgroundTracingManager(); | 483 SetupBackgroundTracingManager(); |
479 | 484 |
480 base::RunLoop run_loop; | 485 base::RunLoop run_loop; |
481 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 486 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
482 run_loop.QuitClosure()); | 487 run_loop.QuitClosure()); |
483 | 488 |
484 base::DictionaryValue dict; | 489 base::DictionaryValue dict; |
485 dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); | 490 dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); |
486 dict.SetString("category", "BENCHMARK"); | 491 dict.SetString("category", "BENCHMARK"); |
487 | 492 |
488 scoped_ptr<base::ListValue> rules_list(new base::ListValue()); | 493 std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); |
489 { | 494 { |
490 scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); | 495 std::unique_ptr<base::DictionaryValue> rules_dict( |
| 496 new base::DictionaryValue()); |
491 rules_dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); | 497 rules_dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); |
492 rules_dict->SetString("trigger_name", "test2"); | 498 rules_dict->SetString("trigger_name", "test2"); |
493 rules_list->Append(std::move(rules_dict)); | 499 rules_list->Append(std::move(rules_dict)); |
494 } | 500 } |
495 | 501 |
496 dict.Set("configs", std::move(rules_list)); | 502 dict.Set("configs", std::move(rules_list)); |
497 dict.SetString("enable_blink_features", "FasterWeb1,FasterWeb2"); | 503 dict.SetString("enable_blink_features", "FasterWeb1,FasterWeb2"); |
498 dict.SetString("disable_blink_features", "SlowerWeb1,SlowerWeb2"); | 504 dict.SetString("disable_blink_features", "SlowerWeb1,SlowerWeb2"); |
499 scoped_ptr<BackgroundTracingConfig> config( | 505 std::unique_ptr<BackgroundTracingConfig> config( |
500 BackgroundTracingConfigImpl::FromDict(&dict)); | 506 BackgroundTracingConfigImpl::FromDict(&dict)); |
501 EXPECT_TRUE(config); | 507 EXPECT_TRUE(config); |
502 | 508 |
503 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 509 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
504 switches::kEnableBlinkFeatures, "FooFeature"); | 510 switches::kEnableBlinkFeatures, "FooFeature"); |
505 | 511 |
506 bool scenario_activated = | 512 bool scenario_activated = |
507 BackgroundTracingManager::GetInstance()->SetActiveScenario( | 513 BackgroundTracingManager::GetInstance()->SetActiveScenario( |
508 std::move(config), upload_config_wrapper.get_receive_callback(), | 514 std::move(config), upload_config_wrapper.get_receive_callback(), |
509 BackgroundTracingManager::NO_DATA_FILTERING); | 515 BackgroundTracingManager::NO_DATA_FILTERING); |
510 | 516 |
511 EXPECT_FALSE(scenario_activated); | 517 EXPECT_FALSE(scenario_activated); |
512 } | 518 } |
513 | 519 |
514 // This tests that delayed histogram triggers triggers work as expected | 520 // This tests that delayed histogram triggers triggers work as expected |
515 // with preemptive scenarios. | 521 // with preemptive scenarios. |
516 IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, | 522 IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, |
517 CallPreemptiveTriggerWithDelay) { | 523 CallPreemptiveTriggerWithDelay) { |
518 { | 524 { |
519 SetupBackgroundTracingManager(); | 525 SetupBackgroundTracingManager(); |
520 | 526 |
521 base::RunLoop run_loop; | 527 base::RunLoop run_loop; |
522 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 528 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
523 run_loop.QuitClosure()); | 529 run_loop.QuitClosure()); |
524 | 530 |
525 base::DictionaryValue dict; | 531 base::DictionaryValue dict; |
526 dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); | 532 dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); |
527 dict.SetString("category", "BENCHMARK"); | 533 dict.SetString("category", "BENCHMARK"); |
528 | 534 |
529 scoped_ptr<base::ListValue> rules_list(new base::ListValue()); | 535 std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); |
530 { | 536 { |
531 scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); | 537 std::unique_ptr<base::DictionaryValue> rules_dict( |
| 538 new base::DictionaryValue()); |
532 rules_dict->SetString( | 539 rules_dict->SetString( |
533 "rule", "MONITOR_AND_DUMP_WHEN_SPECIFIC_HISTOGRAM_AND_VALUE"); | 540 "rule", "MONITOR_AND_DUMP_WHEN_SPECIFIC_HISTOGRAM_AND_VALUE"); |
534 rules_dict->SetString("histogram_name", "fake"); | 541 rules_dict->SetString("histogram_name", "fake"); |
535 rules_dict->SetInteger("histogram_value", 1); | 542 rules_dict->SetInteger("histogram_value", 1); |
536 rules_dict->SetInteger("trigger_delay", 10); | 543 rules_dict->SetInteger("trigger_delay", 10); |
537 rules_list->Append(std::move(rules_dict)); | 544 rules_list->Append(std::move(rules_dict)); |
538 } | 545 } |
539 | 546 |
540 dict.Set("configs", std::move(rules_list)); | 547 dict.Set("configs", std::move(rules_list)); |
541 | 548 |
542 scoped_ptr<BackgroundTracingConfig> config( | 549 std::unique_ptr<BackgroundTracingConfig> config( |
543 BackgroundTracingConfigImpl::FromDict(&dict)); | 550 BackgroundTracingConfigImpl::FromDict(&dict)); |
544 EXPECT_TRUE(config); | 551 EXPECT_TRUE(config); |
545 | 552 |
546 BackgroundTracingManager::GetInstance()->SetActiveScenario( | 553 BackgroundTracingManager::GetInstance()->SetActiveScenario( |
547 std::move(config), upload_config_wrapper.get_receive_callback(), | 554 std::move(config), upload_config_wrapper.get_receive_callback(), |
548 BackgroundTracingManager::NO_DATA_FILTERING); | 555 BackgroundTracingManager::NO_DATA_FILTERING); |
549 | 556 |
550 BackgroundTracingManager::GetInstance()->WhenIdle( | 557 BackgroundTracingManager::GetInstance()->WhenIdle( |
551 base::Bind(&DisableScenarioWhenIdle)); | 558 base::Bind(&DisableScenarioWhenIdle)); |
552 | 559 |
(...skipping 26 matching lines...) Expand all Loading... |
579 // This tests that you can't trigger without a scenario set. | 586 // This tests that you can't trigger without a scenario set. |
580 IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, | 587 IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, |
581 CannotTriggerWithoutScenarioSet) { | 588 CannotTriggerWithoutScenarioSet) { |
582 { | 589 { |
583 SetupBackgroundTracingManager(); | 590 SetupBackgroundTracingManager(); |
584 | 591 |
585 base::RunLoop run_loop; | 592 base::RunLoop run_loop; |
586 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 593 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
587 (base::Closure())); | 594 (base::Closure())); |
588 | 595 |
589 scoped_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); | 596 std::unique_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); |
590 | 597 |
591 content::BackgroundTracingManager::TriggerHandle handle = | 598 content::BackgroundTracingManager::TriggerHandle handle = |
592 content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( | 599 content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( |
593 "preemptive_test"); | 600 "preemptive_test"); |
594 | 601 |
595 BackgroundTracingManager::GetInstance()->TriggerNamedEvent( | 602 BackgroundTracingManager::GetInstance()->TriggerNamedEvent( |
596 handle, | 603 handle, |
597 base::Bind(&StartedFinalizingCallback, run_loop.QuitClosure(), false)); | 604 base::Bind(&StartedFinalizingCallback, run_loop.QuitClosure(), false)); |
598 | 605 |
599 run_loop.Run(); | 606 run_loop.Run(); |
600 | 607 |
601 EXPECT_TRUE(upload_config_wrapper.get_receive_count() == 0); | 608 EXPECT_TRUE(upload_config_wrapper.get_receive_count() == 0); |
602 } | 609 } |
603 } | 610 } |
604 | 611 |
605 // This tests that no trace is triggered with a handle that isn't specified | 612 // This tests that no trace is triggered with a handle that isn't specified |
606 // in the config. | 613 // in the config. |
607 IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, | 614 IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, |
608 DoesNotTriggerWithWrongHandle) { | 615 DoesNotTriggerWithWrongHandle) { |
609 { | 616 { |
610 SetupBackgroundTracingManager(); | 617 SetupBackgroundTracingManager(); |
611 | 618 |
612 base::RunLoop run_loop; | 619 base::RunLoop run_loop; |
613 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 620 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
614 (base::Closure())); | 621 (base::Closure())); |
615 | 622 |
616 scoped_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); | 623 std::unique_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); |
617 | 624 |
618 content::BackgroundTracingManager::TriggerHandle handle = | 625 content::BackgroundTracingManager::TriggerHandle handle = |
619 content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( | 626 content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( |
620 "does_not_exist"); | 627 "does_not_exist"); |
621 | 628 |
622 BackgroundTracingManager::GetInstance()->SetActiveScenario( | 629 BackgroundTracingManager::GetInstance()->SetActiveScenario( |
623 std::move(config), upload_config_wrapper.get_receive_callback(), | 630 std::move(config), upload_config_wrapper.get_receive_callback(), |
624 BackgroundTracingManager::NO_DATA_FILTERING); | 631 BackgroundTracingManager::NO_DATA_FILTERING); |
625 | 632 |
626 BackgroundTracingManager::GetInstance()->WhenIdle( | 633 BackgroundTracingManager::GetInstance()->WhenIdle( |
(...skipping 12 matching lines...) Expand all Loading... |
639 // This tests that no trace is triggered with an invalid handle. | 646 // This tests that no trace is triggered with an invalid handle. |
640 IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, | 647 IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, |
641 DoesNotTriggerWithInvalidHandle) { | 648 DoesNotTriggerWithInvalidHandle) { |
642 { | 649 { |
643 SetupBackgroundTracingManager(); | 650 SetupBackgroundTracingManager(); |
644 | 651 |
645 base::RunLoop run_loop; | 652 base::RunLoop run_loop; |
646 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 653 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
647 (base::Closure())); | 654 (base::Closure())); |
648 | 655 |
649 scoped_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); | 656 std::unique_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); |
650 | 657 |
651 content::BackgroundTracingManager::TriggerHandle handle = | 658 content::BackgroundTracingManager::TriggerHandle handle = |
652 content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( | 659 content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( |
653 "preemptive_test"); | 660 "preemptive_test"); |
654 | 661 |
655 content::BackgroundTracingManager::GetInstance() | 662 content::BackgroundTracingManager::GetInstance() |
656 ->InvalidateTriggerHandlesForTesting(); | 663 ->InvalidateTriggerHandlesForTesting(); |
657 | 664 |
658 BackgroundTracingManager::GetInstance()->SetActiveScenario( | 665 BackgroundTracingManager::GetInstance()->SetActiveScenario( |
659 std::move(config), upload_config_wrapper.get_receive_callback(), | 666 std::move(config), upload_config_wrapper.get_receive_callback(), |
(...skipping 20 matching lines...) Expand all Loading... |
680 | 687 |
681 base::RunLoop run_loop; | 688 base::RunLoop run_loop; |
682 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 689 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
683 (base::Closure())); | 690 (base::Closure())); |
684 | 691 |
685 base::DictionaryValue dict; | 692 base::DictionaryValue dict; |
686 | 693 |
687 dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); | 694 dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); |
688 dict.SetString("category", "BENCHMARK"); | 695 dict.SetString("category", "BENCHMARK"); |
689 | 696 |
690 scoped_ptr<base::ListValue> rules_list(new base::ListValue()); | 697 std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); |
691 { | 698 { |
692 scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); | 699 std::unique_ptr<base::DictionaryValue> rules_dict( |
| 700 new base::DictionaryValue()); |
693 rules_dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); | 701 rules_dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); |
694 rules_dict->SetString("trigger_name", "preemptive_test"); | 702 rules_dict->SetString("trigger_name", "preemptive_test"); |
695 rules_dict->SetDouble("trigger_chance", 0.0); | 703 rules_dict->SetDouble("trigger_chance", 0.0); |
696 rules_list->Append(std::move(rules_dict)); | 704 rules_list->Append(std::move(rules_dict)); |
697 } | 705 } |
698 dict.Set("configs", std::move(rules_list)); | 706 dict.Set("configs", std::move(rules_list)); |
699 | 707 |
700 scoped_ptr<BackgroundTracingConfig> config( | 708 std::unique_ptr<BackgroundTracingConfig> config( |
701 BackgroundTracingConfigImpl::FromDict(&dict)); | 709 BackgroundTracingConfigImpl::FromDict(&dict)); |
702 | 710 |
703 EXPECT_TRUE(config); | 711 EXPECT_TRUE(config); |
704 | 712 |
705 content::BackgroundTracingManager::TriggerHandle handle = | 713 content::BackgroundTracingManager::TriggerHandle handle = |
706 content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( | 714 content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( |
707 "preemptive_test"); | 715 "preemptive_test"); |
708 | 716 |
709 BackgroundTracingManager::GetInstance()->SetActiveScenario( | 717 BackgroundTracingManager::GetInstance()->SetActiveScenario( |
710 std::move(config), upload_config_wrapper.get_receive_callback(), | 718 std::move(config), upload_config_wrapper.get_receive_callback(), |
(...skipping 19 matching lines...) Expand all Loading... |
730 SetupBackgroundTracingManager(); | 738 SetupBackgroundTracingManager(); |
731 | 739 |
732 base::RunLoop run_loop; | 740 base::RunLoop run_loop; |
733 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 741 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
734 (base::Closure())); | 742 (base::Closure())); |
735 | 743 |
736 base::DictionaryValue dict; | 744 base::DictionaryValue dict; |
737 | 745 |
738 dict.SetString("mode", "REACTIVE_TRACING_MODE"); | 746 dict.SetString("mode", "REACTIVE_TRACING_MODE"); |
739 | 747 |
740 scoped_ptr<base::ListValue> rules_list(new base::ListValue()); | 748 std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); |
741 { | 749 { |
742 scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); | 750 std::unique_ptr<base::DictionaryValue> rules_dict( |
| 751 new base::DictionaryValue()); |
743 rules_dict->SetString("rule", | 752 rules_dict->SetString("rule", |
744 "TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL"); | 753 "TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL"); |
745 rules_dict->SetString("trigger_name", "reactive_test1"); | 754 rules_dict->SetString("trigger_name", "reactive_test1"); |
746 rules_dict->SetString("category", "BENCHMARK"); | 755 rules_dict->SetString("category", "BENCHMARK"); |
747 rules_dict->SetDouble("trigger_chance", 0.0); | 756 rules_dict->SetDouble("trigger_chance", 0.0); |
748 | 757 |
749 rules_list->Append(std::move(rules_dict)); | 758 rules_list->Append(std::move(rules_dict)); |
750 } | 759 } |
751 dict.Set("configs", std::move(rules_list)); | 760 dict.Set("configs", std::move(rules_list)); |
752 | 761 |
753 scoped_ptr<BackgroundTracingConfig> config( | 762 std::unique_ptr<BackgroundTracingConfig> config( |
754 BackgroundTracingConfigImpl::FromDict(&dict)); | 763 BackgroundTracingConfigImpl::FromDict(&dict)); |
755 | 764 |
756 EXPECT_TRUE(config); | 765 EXPECT_TRUE(config); |
757 | 766 |
758 content::BackgroundTracingManager::TriggerHandle handle = | 767 content::BackgroundTracingManager::TriggerHandle handle = |
759 content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( | 768 content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( |
760 "preemptive_test"); | 769 "preemptive_test"); |
761 | 770 |
762 BackgroundTracingManager::GetInstance()->SetActiveScenario( | 771 BackgroundTracingManager::GetInstance()->SetActiveScenario( |
763 std::move(config), upload_config_wrapper.get_receive_callback(), | 772 std::move(config), upload_config_wrapper.get_receive_callback(), |
(...skipping 20 matching lines...) Expand all Loading... |
784 | 793 |
785 base::RunLoop run_loop; | 794 base::RunLoop run_loop; |
786 | 795 |
787 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 796 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
788 run_loop.QuitClosure()); | 797 run_loop.QuitClosure()); |
789 | 798 |
790 base::DictionaryValue dict; | 799 base::DictionaryValue dict; |
791 dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); | 800 dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); |
792 dict.SetString("category", "BENCHMARK"); | 801 dict.SetString("category", "BENCHMARK"); |
793 | 802 |
794 scoped_ptr<base::ListValue> rules_list(new base::ListValue()); | 803 std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); |
795 { | 804 { |
796 scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); | 805 std::unique_ptr<base::DictionaryValue> rules_dict( |
| 806 new base::DictionaryValue()); |
797 rules_dict->SetString( | 807 rules_dict->SetString( |
798 "rule", "MONITOR_AND_DUMP_WHEN_SPECIFIC_HISTOGRAM_AND_VALUE"); | 808 "rule", "MONITOR_AND_DUMP_WHEN_SPECIFIC_HISTOGRAM_AND_VALUE"); |
799 rules_dict->SetString("histogram_name", "fake"); | 809 rules_dict->SetString("histogram_name", "fake"); |
800 rules_dict->SetInteger("histogram_value", 1); | 810 rules_dict->SetInteger("histogram_value", 1); |
801 rules_list->Append(std::move(rules_dict)); | 811 rules_list->Append(std::move(rules_dict)); |
802 } | 812 } |
803 | 813 |
804 dict.Set("configs", std::move(rules_list)); | 814 dict.Set("configs", std::move(rules_list)); |
805 | 815 |
806 scoped_ptr<BackgroundTracingConfig> config( | 816 std::unique_ptr<BackgroundTracingConfig> config( |
807 BackgroundTracingConfigImpl::FromDict(&dict)); | 817 BackgroundTracingConfigImpl::FromDict(&dict)); |
808 EXPECT_TRUE(config); | 818 EXPECT_TRUE(config); |
809 | 819 |
810 BackgroundTracingManager::GetInstance()->SetActiveScenario( | 820 BackgroundTracingManager::GetInstance()->SetActiveScenario( |
811 std::move(config), upload_config_wrapper.get_receive_callback(), | 821 std::move(config), upload_config_wrapper.get_receive_callback(), |
812 BackgroundTracingManager::NO_DATA_FILTERING); | 822 BackgroundTracingManager::NO_DATA_FILTERING); |
813 | 823 |
814 // Our reference value is "1", so a value of "2" should trigger a trace. | 824 // Our reference value is "1", so a value of "2" should trigger a trace. |
815 LOCAL_HISTOGRAM_COUNTS("fake", 2); | 825 LOCAL_HISTOGRAM_COUNTS("fake", 2); |
816 | 826 |
(...skipping 11 matching lines...) Expand all Loading... |
828 | 838 |
829 base::RunLoop run_loop; | 839 base::RunLoop run_loop; |
830 | 840 |
831 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 841 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
832 run_loop.QuitClosure()); | 842 run_loop.QuitClosure()); |
833 | 843 |
834 base::DictionaryValue dict; | 844 base::DictionaryValue dict; |
835 dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); | 845 dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); |
836 dict.SetString("category", "BENCHMARK"); | 846 dict.SetString("category", "BENCHMARK"); |
837 | 847 |
838 scoped_ptr<base::ListValue> rules_list(new base::ListValue()); | 848 std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); |
839 { | 849 { |
840 scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); | 850 std::unique_ptr<base::DictionaryValue> rules_dict( |
| 851 new base::DictionaryValue()); |
841 rules_dict->SetString( | 852 rules_dict->SetString( |
842 "rule", "MONITOR_AND_DUMP_WHEN_SPECIFIC_HISTOGRAM_AND_VALUE"); | 853 "rule", "MONITOR_AND_DUMP_WHEN_SPECIFIC_HISTOGRAM_AND_VALUE"); |
843 rules_dict->SetString("histogram_name", "fake"); | 854 rules_dict->SetString("histogram_name", "fake"); |
844 rules_dict->SetInteger("histogram_value", 1); | 855 rules_dict->SetInteger("histogram_value", 1); |
845 rules_list->Append(std::move(rules_dict)); | 856 rules_list->Append(std::move(rules_dict)); |
846 } | 857 } |
847 | 858 |
848 dict.Set("configs", std::move(rules_list)); | 859 dict.Set("configs", std::move(rules_list)); |
849 | 860 |
850 scoped_ptr<BackgroundTracingConfig> config( | 861 std::unique_ptr<BackgroundTracingConfig> config( |
851 BackgroundTracingConfigImpl::FromDict(&dict)); | 862 BackgroundTracingConfigImpl::FromDict(&dict)); |
852 EXPECT_TRUE(config); | 863 EXPECT_TRUE(config); |
853 | 864 |
854 BackgroundTracingManager::GetInstance()->SetActiveScenario( | 865 BackgroundTracingManager::GetInstance()->SetActiveScenario( |
855 std::move(config), upload_config_wrapper.get_receive_callback(), | 866 std::move(config), upload_config_wrapper.get_receive_callback(), |
856 BackgroundTracingManager::NO_DATA_FILTERING); | 867 BackgroundTracingManager::NO_DATA_FILTERING); |
857 | 868 |
858 // This should fail to trigger a trace since the sample value < the | 869 // This should fail to trigger a trace since the sample value < the |
859 // the reference value above. | 870 // the reference value above. |
860 LOCAL_HISTOGRAM_COUNTS("fake", 0); | 871 LOCAL_HISTOGRAM_COUNTS("fake", 0); |
(...skipping 12 matching lines...) Expand all Loading... |
873 | 884 |
874 base::RunLoop run_loop; | 885 base::RunLoop run_loop; |
875 | 886 |
876 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 887 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
877 run_loop.QuitClosure()); | 888 run_loop.QuitClosure()); |
878 | 889 |
879 base::DictionaryValue dict; | 890 base::DictionaryValue dict; |
880 dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); | 891 dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); |
881 dict.SetString("category", "BENCHMARK"); | 892 dict.SetString("category", "BENCHMARK"); |
882 | 893 |
883 scoped_ptr<base::ListValue> rules_list(new base::ListValue()); | 894 std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); |
884 { | 895 { |
885 scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); | 896 std::unique_ptr<base::DictionaryValue> rules_dict( |
| 897 new base::DictionaryValue()); |
886 rules_dict->SetString( | 898 rules_dict->SetString( |
887 "rule", "MONITOR_AND_DUMP_WHEN_SPECIFIC_HISTOGRAM_AND_VALUE"); | 899 "rule", "MONITOR_AND_DUMP_WHEN_SPECIFIC_HISTOGRAM_AND_VALUE"); |
888 rules_dict->SetString("histogram_name", "fake"); | 900 rules_dict->SetString("histogram_name", "fake"); |
889 rules_dict->SetInteger("histogram_lower_value", 1); | 901 rules_dict->SetInteger("histogram_lower_value", 1); |
890 rules_dict->SetInteger("histogram_upper_value", 3); | 902 rules_dict->SetInteger("histogram_upper_value", 3); |
891 rules_list->Append(std::move(rules_dict)); | 903 rules_list->Append(std::move(rules_dict)); |
892 } | 904 } |
893 | 905 |
894 dict.Set("configs", std::move(rules_list)); | 906 dict.Set("configs", std::move(rules_list)); |
895 | 907 |
896 scoped_ptr<BackgroundTracingConfig> config( | 908 std::unique_ptr<BackgroundTracingConfig> config( |
897 BackgroundTracingConfigImpl::FromDict(&dict)); | 909 BackgroundTracingConfigImpl::FromDict(&dict)); |
898 EXPECT_TRUE(config); | 910 EXPECT_TRUE(config); |
899 | 911 |
900 BackgroundTracingManager::GetInstance()->SetActiveScenario( | 912 BackgroundTracingManager::GetInstance()->SetActiveScenario( |
901 std::move(config), upload_config_wrapper.get_receive_callback(), | 913 std::move(config), upload_config_wrapper.get_receive_callback(), |
902 BackgroundTracingManager::NO_DATA_FILTERING); | 914 BackgroundTracingManager::NO_DATA_FILTERING); |
903 | 915 |
904 // This should fail to trigger a trace since the sample value > the | 916 // This should fail to trigger a trace since the sample value > the |
905 // the upper reference value above. | 917 // the upper reference value above. |
906 LOCAL_HISTOGRAM_COUNTS("fake", 0); | 918 LOCAL_HISTOGRAM_COUNTS("fake", 0); |
(...skipping 10 matching lines...) Expand all Loading... |
917 { | 929 { |
918 SetupBackgroundTracingManager(); | 930 SetupBackgroundTracingManager(); |
919 | 931 |
920 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 932 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
921 (base::Closure())); | 933 (base::Closure())); |
922 | 934 |
923 base::DictionaryValue dict; | 935 base::DictionaryValue dict; |
924 dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); | 936 dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); |
925 dict.SetString("category", "BENCHMARK"); | 937 dict.SetString("category", "BENCHMARK"); |
926 | 938 |
927 scoped_ptr<base::ListValue> rules_list(new base::ListValue()); | 939 std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); |
928 { | 940 { |
929 scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); | 941 std::unique_ptr<base::DictionaryValue> rules_dict( |
| 942 new base::DictionaryValue()); |
930 rules_dict->SetString("rule", "INVALID_RULE"); | 943 rules_dict->SetString("rule", "INVALID_RULE"); |
931 rules_list->Append(std::move(rules_dict)); | 944 rules_list->Append(std::move(rules_dict)); |
932 } | 945 } |
933 | 946 |
934 dict.Set("configs", std::move(rules_list)); | 947 dict.Set("configs", std::move(rules_list)); |
935 | 948 |
936 scoped_ptr<BackgroundTracingConfig> config( | 949 std::unique_ptr<BackgroundTracingConfig> config( |
937 BackgroundTracingConfigImpl::FromDict(&dict)); | 950 BackgroundTracingConfigImpl::FromDict(&dict)); |
938 // An invalid config should always return a nullptr here. | 951 // An invalid config should always return a nullptr here. |
939 EXPECT_FALSE(config); | 952 EXPECT_FALSE(config); |
940 } | 953 } |
941 } | 954 } |
942 | 955 |
943 // This tests that reactive mode records and terminates with timeout. | 956 // This tests that reactive mode records and terminates with timeout. |
944 IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, | 957 IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, |
945 ReactiveTimeoutTermination) { | 958 ReactiveTimeoutTermination) { |
946 { | 959 { |
947 SetupBackgroundTracingManager(); | 960 SetupBackgroundTracingManager(); |
948 | 961 |
949 base::RunLoop run_loop; | 962 base::RunLoop run_loop; |
950 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 963 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
951 run_loop.QuitClosure()); | 964 run_loop.QuitClosure()); |
952 | 965 |
953 scoped_ptr<BackgroundTracingConfig> config = CreateReactiveConfig(); | 966 std::unique_ptr<BackgroundTracingConfig> config = CreateReactiveConfig(); |
954 | 967 |
955 BackgroundTracingManager::TriggerHandle handle = | 968 BackgroundTracingManager::TriggerHandle handle = |
956 BackgroundTracingManager:: | 969 BackgroundTracingManager:: |
957 GetInstance()->RegisterTriggerType("reactive_test"); | 970 GetInstance()->RegisterTriggerType("reactive_test"); |
958 | 971 |
959 BackgroundTracingManager::GetInstance()->SetActiveScenario( | 972 BackgroundTracingManager::GetInstance()->SetActiveScenario( |
960 std::move(config), upload_config_wrapper.get_receive_callback(), | 973 std::move(config), upload_config_wrapper.get_receive_callback(), |
961 BackgroundTracingManager::NO_DATA_FILTERING); | 974 BackgroundTracingManager::NO_DATA_FILTERING); |
962 | 975 |
963 BackgroundTracingManager::GetInstance()->WhenIdle( | 976 BackgroundTracingManager::GetInstance()->WhenIdle( |
(...skipping 13 matching lines...) Expand all Loading... |
977 // This tests that reactive mode records and terminates with a second trigger. | 990 // This tests that reactive mode records and terminates with a second trigger. |
978 IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, | 991 IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, |
979 ReactiveSecondTriggerTermination) { | 992 ReactiveSecondTriggerTermination) { |
980 { | 993 { |
981 SetupBackgroundTracingManager(); | 994 SetupBackgroundTracingManager(); |
982 | 995 |
983 base::RunLoop run_loop; | 996 base::RunLoop run_loop; |
984 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 997 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
985 run_loop.QuitClosure()); | 998 run_loop.QuitClosure()); |
986 | 999 |
987 scoped_ptr<BackgroundTracingConfig> config = CreateReactiveConfig(); | 1000 std::unique_ptr<BackgroundTracingConfig> config = CreateReactiveConfig(); |
988 | 1001 |
989 BackgroundTracingManager::TriggerHandle handle = | 1002 BackgroundTracingManager::TriggerHandle handle = |
990 BackgroundTracingManager:: | 1003 BackgroundTracingManager:: |
991 GetInstance()->RegisterTriggerType("reactive_test"); | 1004 GetInstance()->RegisterTriggerType("reactive_test"); |
992 | 1005 |
993 BackgroundTracingManager::GetInstance()->SetActiveScenario( | 1006 BackgroundTracingManager::GetInstance()->SetActiveScenario( |
994 std::move(config), upload_config_wrapper.get_receive_callback(), | 1007 std::move(config), upload_config_wrapper.get_receive_callback(), |
995 BackgroundTracingManager::NO_DATA_FILTERING); | 1008 BackgroundTracingManager::NO_DATA_FILTERING); |
996 | 1009 |
997 BackgroundTracingManager::GetInstance()->WhenIdle( | 1010 BackgroundTracingManager::GetInstance()->WhenIdle( |
(...skipping 17 matching lines...) Expand all Loading... |
1015 { | 1028 { |
1016 SetupBackgroundTracingManager(); | 1029 SetupBackgroundTracingManager(); |
1017 | 1030 |
1018 base::RunLoop run_loop; | 1031 base::RunLoop run_loop; |
1019 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 1032 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
1020 run_loop.QuitClosure()); | 1033 run_loop.QuitClosure()); |
1021 | 1034 |
1022 base::DictionaryValue dict; | 1035 base::DictionaryValue dict; |
1023 dict.SetString("mode", "REACTIVE_TRACING_MODE"); | 1036 dict.SetString("mode", "REACTIVE_TRACING_MODE"); |
1024 | 1037 |
1025 scoped_ptr<base::ListValue> rules_list(new base::ListValue()); | 1038 std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); |
1026 { | 1039 { |
1027 scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); | 1040 std::unique_ptr<base::DictionaryValue> rules_dict( |
| 1041 new base::DictionaryValue()); |
1028 rules_dict->SetString("rule", | 1042 rules_dict->SetString("rule", |
1029 "TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL"); | 1043 "TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL"); |
1030 rules_dict->SetString("trigger_name", "reactive_test1"); | 1044 rules_dict->SetString("trigger_name", "reactive_test1"); |
1031 rules_dict->SetString("category", "BENCHMARK"); | 1045 rules_dict->SetString("category", "BENCHMARK"); |
1032 rules_list->Append(std::move(rules_dict)); | 1046 rules_list->Append(std::move(rules_dict)); |
1033 } | 1047 } |
1034 { | 1048 { |
1035 scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); | 1049 std::unique_ptr<base::DictionaryValue> rules_dict( |
| 1050 new base::DictionaryValue()); |
1036 rules_dict->SetString("rule", | 1051 rules_dict->SetString("rule", |
1037 "TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL"); | 1052 "TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL"); |
1038 rules_dict->SetString("trigger_name", "reactive_test2"); | 1053 rules_dict->SetString("trigger_name", "reactive_test2"); |
1039 rules_dict->SetString("category", "BENCHMARK"); | 1054 rules_dict->SetString("category", "BENCHMARK"); |
1040 rules_list->Append(std::move(rules_dict)); | 1055 rules_list->Append(std::move(rules_dict)); |
1041 } | 1056 } |
1042 dict.Set("configs", std::move(rules_list)); | 1057 dict.Set("configs", std::move(rules_list)); |
1043 | 1058 |
1044 scoped_ptr<BackgroundTracingConfig> config( | 1059 std::unique_ptr<BackgroundTracingConfig> config( |
1045 BackgroundTracingConfigImpl::FromDict(&dict)); | 1060 BackgroundTracingConfigImpl::FromDict(&dict)); |
1046 | 1061 |
1047 BackgroundTracingManager::TriggerHandle handle1 = | 1062 BackgroundTracingManager::TriggerHandle handle1 = |
1048 BackgroundTracingManager::GetInstance()->RegisterTriggerType( | 1063 BackgroundTracingManager::GetInstance()->RegisterTriggerType( |
1049 "reactive_test1"); | 1064 "reactive_test1"); |
1050 BackgroundTracingManager::TriggerHandle handle2 = | 1065 BackgroundTracingManager::TriggerHandle handle2 = |
1051 BackgroundTracingManager::GetInstance()->RegisterTriggerType( | 1066 BackgroundTracingManager::GetInstance()->RegisterTriggerType( |
1052 "reactive_test2"); | 1067 "reactive_test2"); |
1053 | 1068 |
1054 BackgroundTracingManager::GetInstance()->SetActiveScenario( | 1069 BackgroundTracingManager::GetInstance()->SetActiveScenario( |
(...skipping 24 matching lines...) Expand all Loading... |
1079 // This tests a third trigger in reactive more does not start another trace. | 1094 // This tests a third trigger in reactive more does not start another trace. |
1080 IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, | 1095 IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, |
1081 ReactiveThirdTriggerTimeout) { | 1096 ReactiveThirdTriggerTimeout) { |
1082 { | 1097 { |
1083 SetupBackgroundTracingManager(); | 1098 SetupBackgroundTracingManager(); |
1084 | 1099 |
1085 base::RunLoop run_loop; | 1100 base::RunLoop run_loop; |
1086 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 1101 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( |
1087 run_loop.QuitClosure()); | 1102 run_loop.QuitClosure()); |
1088 | 1103 |
1089 scoped_ptr<BackgroundTracingConfig> config = CreateReactiveConfig(); | 1104 std::unique_ptr<BackgroundTracingConfig> config = CreateReactiveConfig(); |
1090 | 1105 |
1091 BackgroundTracingManager::TriggerHandle handle = | 1106 BackgroundTracingManager::TriggerHandle handle = |
1092 BackgroundTracingManager:: | 1107 BackgroundTracingManager:: |
1093 GetInstance()->RegisterTriggerType("reactive_test"); | 1108 GetInstance()->RegisterTriggerType("reactive_test"); |
1094 | 1109 |
1095 BackgroundTracingManager::GetInstance()->SetActiveScenario( | 1110 BackgroundTracingManager::GetInstance()->SetActiveScenario( |
1096 std::move(config), upload_config_wrapper.get_receive_callback(), | 1111 std::move(config), upload_config_wrapper.get_receive_callback(), |
1097 BackgroundTracingManager::NO_DATA_FILTERING); | 1112 BackgroundTracingManager::NO_DATA_FILTERING); |
1098 | 1113 |
1099 BackgroundTracingManager::GetInstance()->WhenIdle( | 1114 BackgroundTracingManager::GetInstance()->WhenIdle( |
1100 base::Bind(&DisableScenarioWhenIdle)); | 1115 base::Bind(&DisableScenarioWhenIdle)); |
1101 | 1116 |
1102 BackgroundTracingManager::GetInstance()->TriggerNamedEvent( | 1117 BackgroundTracingManager::GetInstance()->TriggerNamedEvent( |
1103 handle, base::Bind(&StartedFinalizingCallback, base::Closure(), true)); | 1118 handle, base::Bind(&StartedFinalizingCallback, base::Closure(), true)); |
1104 // second trigger to terminate. | 1119 // second trigger to terminate. |
1105 BackgroundTracingManager::GetInstance()->TriggerNamedEvent( | 1120 BackgroundTracingManager::GetInstance()->TriggerNamedEvent( |
1106 handle, base::Bind(&StartedFinalizingCallback, base::Closure(), true)); | 1121 handle, base::Bind(&StartedFinalizingCallback, base::Closure(), true)); |
1107 // third trigger to trigger again, fails as it is still gathering. | 1122 // third trigger to trigger again, fails as it is still gathering. |
1108 BackgroundTracingManager::GetInstance()->TriggerNamedEvent( | 1123 BackgroundTracingManager::GetInstance()->TriggerNamedEvent( |
1109 handle, base::Bind(&StartedFinalizingCallback, base::Closure(), false)); | 1124 handle, base::Bind(&StartedFinalizingCallback, base::Closure(), false)); |
1110 | 1125 |
1111 run_loop.Run(); | 1126 run_loop.Run(); |
1112 | 1127 |
1113 EXPECT_TRUE(upload_config_wrapper.get_receive_count() == 1); | 1128 EXPECT_TRUE(upload_config_wrapper.get_receive_count() == 1); |
1114 } | 1129 } |
1115 } | 1130 } |
1116 | 1131 |
1117 } // namespace content | 1132 } // namespace content |
OLD | NEW |