Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / safe_browsing / srt_fetcher_win.h
blob27333e4fc5a45e3e35f8218265ce8aacfb728c94
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_
8 #include <string>
10 #include "base/callback_forward.h"
11 #include "base/memory/ref_counted.h"
13 namespace base {
14 class FilePath;
15 class TaskRunner;
18 class Browser;
20 namespace safe_browsing {
22 // Reporter exit codes.
23 const int kSwReporterCleanupNeeded = 0;
24 const int kSwReporterNothingFound = 2;
25 const int kSwReporterPostRebootCleanupNeeded = 4;
26 const int kSwReporterDelayedPostRebootCleanupNeeded = 15;
28 // A special exit code identifying a failure to run the reporter.
29 const int kReporterFailureExitCode = INT_MAX;
31 // The number of days to wait before triggering another reporter run.
32 const int kDaysBetweenSuccessfulSwReporterRuns = 7;
33 const int kDaysBetweenSwReporterRunsForPendingPrompt = 1;
35 // To test SRT Fetches.
36 const int kSRTFetcherID = 47;
38 // Tries to run the sw_reporter component, and then schedule the next try. If
39 // called multiple times, then multiple sequences of trying to run will happen,
40 // yet only one reporter will run per specified period (either
41 // |kDaysBetweenSuccessfulSwReporterRuns| or
42 // |kDaysBetweenSwReporterRunsForPendingPrompt|) will actually happen.
43 // |exe_path| is the full path to the SwReporter to execute and |version| is its
44 // version. The task runners are provided to allow tests to provide their own.
45 void RunSwReporter(
46 const base::FilePath& exe_path,
47 const std::string& version,
48 const scoped_refptr<base::TaskRunner>& main_thread_task_runner,
49 const scoped_refptr<base::TaskRunner>& blocking_task_runner);
51 // Test mocks for launching the reporter and showing the prompt
52 typedef base::Callback<int(const base::FilePath& exe_path,
53 const std::string& version)> ReporterLauncher;
54 typedef base::Callback<void(Browser*, const std::string&)> PromptTrigger;
55 void SetReporterLauncherForTesting(const ReporterLauncher& reporter_launcher);
56 void SetPromptTriggerForTesting(const PromptTrigger& prompt_trigger);
58 } // namespace safe_browsing
60 #endif // CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_