| Index: content/browser/tracing/background_tracing_manager_browsertest.cc
|
| diff --git a/content/browser/tracing/background_tracing_manager_browsertest.cc b/content/browser/tracing/background_tracing_manager_browsertest.cc
|
| index af69655408084b00e4ff5b0363bac593185af3d9..daef12d619af118bf91fe77555641d2996e48df2 100644
|
| --- a/content/browser/tracing/background_tracing_manager_browsertest.cc
|
| +++ b/content/browser/tracing/background_tracing_manager_browsertest.cc
|
| @@ -131,6 +131,7 @@ std::unique_ptr<BackgroundTracingConfig> CreateReactiveConfig() {
|
| new base::DictionaryValue());
|
| rules_dict->SetString("rule", "TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL");
|
| rules_dict->SetString("trigger_name", "reactive_test");
|
| + rules_dict->SetBoolean("stop_tracing_on_repeated_reactive", true);
|
| rules_dict->SetString("category", "BENCHMARK");
|
| rules_list->Append(std::move(rules_dict));
|
| }
|
| @@ -1099,6 +1100,8 @@ IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest,
|
| rules_dict->SetString("rule",
|
| "TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL");
|
| rules_dict->SetString("trigger_name", "reactive_test1");
|
| + rules_dict->SetBoolean("stop_tracing_on_repeated_reactive", true);
|
| + rules_dict->SetInteger("trigger_delay", 10);
|
| rules_dict->SetString("category", "BENCHMARK");
|
| rules_list->Append(std::move(rules_dict));
|
| }
|
| @@ -1108,6 +1111,8 @@ IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest,
|
| rules_dict->SetString("rule",
|
| "TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL");
|
| rules_dict->SetString("trigger_name", "reactive_test2");
|
| + rules_dict->SetBoolean("stop_tracing_on_repeated_reactive", true);
|
| + rules_dict->SetInteger("trigger_delay", 10);
|
| rules_dict->SetString("category", "BENCHMARK");
|
| rules_list->Append(std::move(rules_dict));
|
| }
|
| @@ -1148,6 +1153,73 @@ IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest,
|
| }
|
| }
|
|
|
| +// This tests that reactive mode only terminates with a repeated trigger
|
| +// if the config specifies that it should.
|
| +IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest,
|
| + ReactiveSecondTriggerIgnored) {
|
| + {
|
| + SetupBackgroundTracingManager();
|
| +
|
| + base::RunLoop run_loop;
|
| + BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper(
|
| + run_loop.QuitClosure());
|
| +
|
| + base::DictionaryValue dict;
|
| + dict.SetString("mode", "REACTIVE_TRACING_MODE");
|
| +
|
| + std::unique_ptr<base::ListValue> rules_list(new base::ListValue());
|
| + {
|
| + std::unique_ptr<base::DictionaryValue> rules_dict(
|
| + new base::DictionaryValue());
|
| + rules_dict->SetString("rule",
|
| + "TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL");
|
| + rules_dict->SetString("trigger_name", "reactive_test");
|
| + rules_dict->SetBoolean("stop_tracing_on_repeated_reactive", false);
|
| + rules_dict->SetInteger("trigger_delay", 10);
|
| + rules_dict->SetString("category", "BENCHMARK");
|
| + rules_list->Append(std::move(rules_dict));
|
| + }
|
| + dict.Set("configs", std::move(rules_list));
|
| +
|
| + std::unique_ptr<BackgroundTracingConfig> config(
|
| + BackgroundTracingConfigImpl::FromDict(&dict));
|
| +
|
| + BackgroundTracingManager::TriggerHandle trigger_handle =
|
| + BackgroundTracingManager::GetInstance()->RegisterTriggerType(
|
| + "reactive_test");
|
| +
|
| + EXPECT_TRUE(BackgroundTracingManager::GetInstance()->SetActiveScenario(
|
| + std::move(config), upload_config_wrapper.get_receive_callback(),
|
| + BackgroundTracingManager::NO_DATA_FILTERING));
|
| +
|
| + BackgroundTracingManager::GetInstance()->WhenIdle(
|
| + base::Bind(&DisableScenarioWhenIdle));
|
| +
|
| + BackgroundTracingManager::GetInstance()->TriggerNamedEvent(
|
| + trigger_handle,
|
| + base::Bind(&StartedFinalizingCallback, base::Closure(), true));
|
| +
|
| + // This is expected to fail since we already triggered.
|
| + BackgroundTracingManager::GetInstance()->TriggerNamedEvent(
|
| + trigger_handle,
|
| + base::Bind(&StartedFinalizingCallback, base::Closure(), false));
|
| +
|
| + // Since we specified a delay in the scenario, we should still be tracing
|
| + // at this point.
|
| + EXPECT_TRUE(
|
| + BackgroundTracingManagerImpl::GetInstance()->IsTracingForTesting());
|
| +
|
| + BackgroundTracingManager::GetInstance()->FireTimerForTesting();
|
| +
|
| + EXPECT_FALSE(
|
| + BackgroundTracingManagerImpl::GetInstance()->IsTracingForTesting());
|
| +
|
| + run_loop.Run();
|
| +
|
| + EXPECT_TRUE(upload_config_wrapper.get_receive_count() == 1);
|
| + }
|
| +}
|
| +
|
| // This tests a third trigger in reactive more does not start another trace.
|
| IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest,
|
| ReactiveThirdTriggerTimeout) {
|
|
|