Commit 8b31eb21 authored by Greg Thompson's avatar Greg Thompson

Fix needless environment scan in safe browsing incident reporting service.

BUG=413233
R=robertshield@chromium.org

Review URL: https://codereview.chromium.org/564833002

Cr-Commit-Position: refs/heads/master@{#294398}
parent 56075d70
......@@ -398,8 +398,10 @@ void IncidentReportingService::OnProfileAdded(Profile* profile) {
// Start a new report if this profile participates in safe browsing and there
// are process-wide incidents.
if (safe_browsing_enabled && GetProfileContext(NULL))
if (safe_browsing_enabled && GetProfileContext(NULL) &&
GetProfileContext(NULL)->incidents.size()) {
BeginReportProcessing();
}
// TODO(grt): register for pref change notifications to start delayed analysis
// and/or report processing if sb is currently disabled but subsequently
......
......@@ -794,6 +794,33 @@ TEST_F(IncidentReportingServiceTest, ProcessWideOneUploadAfterProfile) {
ExpectTestIncidentUploaded(1);
}
TEST_F(IncidentReportingServiceTest, NoCollectionWithoutIncident) {
// Register a callback.
RegisterAnalysis(ON_DELAYED_ANALYSIS_NO_ACTION);
// Let all tasks run.
task_runner_->RunUntilIdle();
// Confirm that the callback was not run.
ASSERT_FALSE(DelayedAnalysisRan());
// No collection should have taken place.
ASSERT_FALSE(HasCollectedEnvironmentData());
// Add a profile that participates in safe browsing.
CreateProfile(
"profile1", SAFE_BROWSING_OPT_IN, ON_PROFILE_ADDITION_NO_ACTION);
// Let all tasks run.
task_runner_->RunUntilIdle();
// Confirm that the callback was run.
ASSERT_TRUE(DelayedAnalysisRan());
// Still no collection should have taken place.
ASSERT_FALSE(HasCollectedEnvironmentData());
}
// Tests that delayed analysis callbacks are called following the addition of a
// profile that participates in safe browsing.
TEST_F(IncidentReportingServiceTest, AnalysisAfterProfile) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment