Chromium Code Reviews| Index: chrome/browser/safe_browsing/certificate_reporting_service_test_utils.h |
| diff --git a/chrome/browser/safe_browsing/certificate_reporting_service_test_utils.h b/chrome/browser/safe_browsing/certificate_reporting_service_test_utils.h |
| index 33da0bd1d75fd796f192fb27298d1e0b010e710c..2d0ee265851a46331ac291241e8eb37599267373 100644 |
| --- a/chrome/browser/safe_browsing/certificate_reporting_service_test_utils.h |
| +++ b/chrome/browser/safe_browsing/certificate_reporting_service_test_utils.h |
| @@ -5,7 +5,7 @@ |
| #ifndef CHROME_BROWSER_SAFE_BROWSING_CERTIFICATE_REPORTING_SERVICE_TEST_UTILS_H_ |
| #define CHROME_BROWSER_SAFE_BROWSING_CERTIFICATE_REPORTING_SERVICE_TEST_UTILS_H_ |
| -#include <set> |
| +#include <unordered_set> |
|
estark
2017/01/13 23:26:22
looks like you're using normal <set> below; did yo
meacer
2017/01/17 22:24:27
Changed to unordered_map.
|
| #include "base/macros.h" |
| #include "base/run_loop.h" |
| @@ -23,6 +23,21 @@ class NetworkDelegate; |
| namespace certificate_reporting_test_utils { |
| +// Struct that wraps information about observed reports. |
| +struct ObservedReport { |
| + std::string hostname; |
| + bool is_retried; |
| + |
| + ObservedReport(const std::string& hostname, bool is_retried); |
| + |
| + // For std::set: |
| + bool operator<(const ObservedReport& other) const; |
| + bool operator==(const ObservedReport& other) const; |
| + |
| + static ObservedReport Retried(const std::string& hostname); |
| + static ObservedReport NotRetried(const std::string& hostname); |
| +}; |
| + |
| // Syntactic sugar for wrapping report expectations in a more readable way. |
| // Passed to WaitForRequestDeletions() as input. |
| // Example: |
| @@ -35,16 +50,16 @@ struct ReportExpectation { |
| ReportExpectation(const ReportExpectation& other); |
| ~ReportExpectation(); |
| // Returns an expectation where all reports in |reports| succeed. |
| - static ReportExpectation Successful(const std::set<std::string>& reports); |
| + static ReportExpectation Successful(const std::set<ObservedReport>& reports); |
| // Returns an expectation where all reports in |reports| fail. |
| - static ReportExpectation Failed(const std::set<std::string>& reports); |
| + static ReportExpectation Failed(const std::set<ObservedReport>& reports); |
| // Returns an expectation where all reports in |reports| are delayed. |
| - static ReportExpectation Delayed(const std::set<std::string>& reports); |
| + static ReportExpectation Delayed(const std::set<ObservedReport>& reports); |
| // Total number of reports expected. |
| int num_reports() const; |
| - std::set<std::string> successful_reports; |
| - std::set<std::string> failed_reports; |
| - std::set<std::string> delayed_reports; |
| + std::set<ObservedReport> successful_reports; |
| + std::set<ObservedReport> failed_reports; |
| + std::set<ObservedReport> delayed_reports; |
| }; |
| // Failure mode of the report sending attempts. |
| @@ -70,13 +85,13 @@ class RequestObserver { |
| // Called when a request created or destroyed, depending on whichever one this |
| // class observes. |
| - void OnRequest(const std::string& serialized_report, |
| + void OnRequest(const ObservedReport& observed_report, |
| ReportSendingResult report_type); |
| // These must be called on the UI thread. |
| - const std::set<std::string>& successful_reports() const; |
| - const std::set<std::string>& failed_reports() const; |
| - const std::set<std::string>& delayed_reports() const; |
| + const std::set<ObservedReport>& successful_reports() const; |
| + const std::set<ObservedReport>& failed_reports() const; |
| + const std::set<ObservedReport>& delayed_reports() const; |
| void ClearObservedReports(); |
| private: |
| @@ -84,9 +99,9 @@ class RequestObserver { |
| unsigned int num_received_events_; |
| std::unique_ptr<base::RunLoop> run_loop_; |
| - std::set<std::string> successful_reports_; |
| - std::set<std::string> failed_reports_; |
| - std::set<std::string> delayed_reports_; |
| + std::set<ObservedReport> successful_reports_; |
| + std::set<ObservedReport> failed_reports_; |
| + std::set<ObservedReport> delayed_reports_; |
| }; |
| // A URLRequestJob that can be delayed until Resume() is called. Returns an |
| @@ -152,9 +167,9 @@ class CertReportJobInterceptor : public net::URLRequestInterceptor { |
| private: |
| void SetFailureModeOnIOThread(ReportSendingResult expected_report_result); |
| void ResumeOnIOThread(); |
| - void RequestCreated(const std::string& uploaded_report, |
| + void RequestCreated(const std::string& serialized_report, |
| ReportSendingResult expected_report_result) const; |
| - void RequestDestructed(const std::string& uploaded_report, |
| + void RequestDestructed(const std::string& serialized_report, |
| ReportSendingResult expected_report_result) const; |
| mutable std::set<std::string> successful_reports_; |