Index: chrome/browser/safe_browsing/srt_fetcher_win.h |
diff --git a/chrome/browser/safe_browsing/srt_fetcher_win.h b/chrome/browser/safe_browsing/srt_fetcher_win.h |
index 2d1ca858de6bbcbdeb014a1d7f3507f3e7f74af9..26400ce1b6a8279779727ca995994b10e03974ef 100644 |
--- a/chrome/browser/safe_browsing/srt_fetcher_win.h |
+++ b/chrome/browser/safe_browsing/srt_fetcher_win.h |
@@ -16,6 +16,7 @@ |
#include "base/process/launch.h" |
#include "base/process/process.h" |
#include "base/time/time.h" |
+#include "components/chrome_cleaner/public/interfaces/chrome_prompt.mojom.h" |
namespace base { |
class FilePath; |
@@ -27,8 +28,10 @@ class Browser; |
namespace safe_browsing { |
+class ChromePromptImpl; |
+ |
// A special exit code identifying a failure to run the reporter. |
-const int kReporterFailureExitCode = INT_MAX; |
+const int kReporterNotLaunchedExitCode = INT_MAX; |
// The number of days to wait before triggering another reporter run. |
const int kDaysBetweenSuccessfulSwReporterRuns = 7; |
@@ -103,25 +106,45 @@ bool ReporterFoundUws(); |
// run the cleaner, rather than checking if they've run it at all. |
bool UserHasRunCleaner(); |
-// Mocks and callbacks for the unit tests. |
+// A delegate used by tests to implement test doubles (e.g., stubs, fakes, or |
+// mocks). |
class SwReporterTestingDelegate { |
public: |
virtual ~SwReporterTestingDelegate() {} |
- // Test mock for launching the reporter. |
+ // Invoked by tests in places of base::LaunchProcess. |
+ // See chrome_cleaner::mojom::ChromePromptRequest(). |
virtual base::Process LaunchReporter( |
const SwReporterInvocation& invocation, |
const base::LaunchOptions& launch_options) = 0; |
- // Test mock for showing the prompt. |
+ // Invoked by tests in place of the actual prompting logic. |
+ // See MaybeFetchSRT(). |
virtual void TriggerPrompt(Browser* browser, |
const std::string& reporter_version) = 0; |
- // Returns the test's idea of the current time. |
+ // Invoked by tests to override the current time. |
+ // See Now() in srt_fetcher_win.cc. |
virtual base::Time Now() const = 0; |
// A task runner used to spawn the reporter process (which blocks). |
+ // See ReporterRunner::ScheduleNextInvocation(). |
virtual base::TaskRunner* BlockingTaskRunner() const = 0; |
+ |
+ // Returns a ChromePromptImpl object that keeps track of specific |
+ // actions during tests. Replaces the object returned by |
+ // SwReporterProcess::CreateChromePromptImpl(). |
+ // See SwReporterProcess::LaunchConnectedReporterProcess(). |
+ virtual std::unique_ptr<ChromePromptImpl> CreateChromePromptImpl( |
+ chrome_cleaner::mojom::ChromePromptRequest request) = 0; |
+ |
+ // Connection closed callback defined by tests in place of the default |
+ // error handler. See SRTFetcherTest::CreateChromePromptImpl(). |
+ virtual void OnConnectionClosed() = 0; |
+ |
+ // Bad message handler callback defined by tests in place of the default |
+ // error handler. See SwReporterProcess::LaunchConnectedReporterProcess(). |
+ virtual void OnConnectionError(const std::string& message) = 0; |
}; |
// Set a delegate for testing. The implementation will not take ownership of |