Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2623)

Unified Diff: chrome/browser/safe_browsing/srt_fetcher_win.h

Issue 2849433002: Adds error handling support for the SwReporter launcher (reland) (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« no previous file with comments | « chrome/browser/safe_browsing/srt_fetcher_browsertest_win.cc ('k') | chrome/browser/safe_browsing/srt_fetcher_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698