Chromium Code Reviews| 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 "chrome/browser/safe_browsing/srt_fetcher_win.h" | 5 #include "chrome/browser/safe_browsing/srt_fetcher_win.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 590 // this run. | 590 // this run. |
| 591 EnableSBExtendedReporting(); | 591 EnableSBExtendedReporting(); |
| 592 SetLastTimeSentReport(kDaysBetweenReporterLogsSent - 1); | 592 SetLastTimeSentReport(kDaysBetweenReporterLogsSent - 1); |
| 593 int64_t last_time_sent_logs = GetLastTimeSentReport(); | 593 int64_t last_time_sent_logs = GetLastTimeSentReport(); |
| 594 RunReporter(); | 594 RunReporter(); |
| 595 TestReporterLaunchCycle({base::FilePath()}); | 595 TestReporterLaunchCycle({base::FilePath()}); |
| 596 ExpectLoggingSwitches(std::set<std::string>{/*expect no switches*/}); | 596 ExpectLoggingSwitches(std::set<std::string>{/*expect no switches*/}); |
| 597 EXPECT_EQ(last_time_sent_logs, GetLastTimeSentReport()); | 597 EXPECT_EQ(last_time_sent_logs, GetLastTimeSentReport()); |
| 598 } | 598 } |
| 599 | 599 |
| 600 IN_PROC_BROWSER_TEST_F(SRTFetcherTest, ReporterLogging_MultipleLaunches) { | |
| 601 exit_code_to_report_ = kSwReporterNothingFound; | |
| 602 base::test::ScopedFeatureList scoped_feature_list; | |
| 603 EnableSBExtendedReporting(); | |
| 604 SetLastTimeSentReport(kDaysBetweenReporterLogsSent + 3); | |
| 605 | |
| 606 const base::FilePath path1(L"path1"); | |
| 607 const base::FilePath path2(L"path2"); | |
| 608 SwReporterQueue invocations; | |
| 609 for (auto path : {path1, path2}) { | |
|
Sorin Jianu
2017/02/06 18:31:44
do we want to use auto& to avoid a copy here?
Joe Mason
2017/02/06 18:50:52
Good idea. Done.
| |
| 610 auto invocation = SwReporterInvocation::FromFilePath(path); | |
| 611 invocation.supported_behaviours = | |
| 612 SwReporterInvocation::BEHAVIOUR_ALLOW_SEND_REPORTER_LOGS; | |
| 613 invocations.push(invocation); | |
| 614 } | |
| 615 RunReporterQueue(invocations); | |
| 616 | |
| 617 // SBER is enabled and last time logs were sent was more than | |
| 618 // |kDaysBetweenReporterLogsSent| day ago, so we should send logs in this run. | |
| 619 { | |
| 620 SCOPED_TRACE("first launch"); | |
| 621 TestPartialLaunchCycle({path1}); | |
| 622 ExpectLoggingSwitches(std::set<std::string>(std::begin(kExpectedSwitches), | |
| 623 std::end(kExpectedSwitches))); | |
| 624 ExpectLastReportSentInTheLastHour(); | |
| 625 } | |
| 626 | |
| 627 // Logs should also be sent for the next run, even though LastTimeSentReport | |
| 628 // is now recent, because the run is part of the same set of invocations. | |
| 629 { | |
| 630 SCOPED_TRACE("second launch"); | |
| 631 TestReporterLaunchCycle({path2}); | |
| 632 ExpectLoggingSwitches(std::set<std::string>(std::begin(kExpectedSwitches), | |
| 633 std::end(kExpectedSwitches))); | |
| 634 ExpectLastReportSentInTheLastHour(); | |
| 635 } | |
| 636 } | |
| 637 | |
| 600 } // namespace safe_browsing | 638 } // namespace safe_browsing |
| OLD | NEW |