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 #ifndef CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_ |
6 #define CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_ |
7 | 7 |
8 #include <limits.h> | 8 #include <limits.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <vector> | |
11 | 12 |
12 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
14 #include "base/command_line.h" | |
13 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
14 #include "base/version.h" | 16 #include "base/version.h" |
15 | 17 |
16 namespace base { | 18 namespace base { |
17 class FilePath; | |
18 class TaskRunner; | 19 class TaskRunner; |
19 } | 20 } |
20 | 21 |
21 class Browser; | 22 class Browser; |
22 | 23 |
23 namespace safe_browsing { | 24 namespace safe_browsing { |
24 | 25 |
25 // SRT registry keys and value names. | 26 // SRT registry keys and value names. |
26 extern const wchar_t kSoftwareRemovalToolRegistryKey[]; | 27 extern const wchar_t kSoftwareRemovalToolRegistryKey[]; |
27 extern const wchar_t kEndTimeValueName[]; | 28 extern const wchar_t kEndTimeValueName[]; |
28 extern const wchar_t kStartTimeValueName[]; | 29 extern const wchar_t kStartTimeValueName[]; |
29 | 30 |
30 // Reporter exit codes. | 31 // Reporter exit codes. |
31 const int kSwReporterCleanupNeeded = 0; | 32 const int kSwReporterCleanupNeeded = 0; |
32 const int kSwReporterNothingFound = 2; | 33 const int kSwReporterNothingFound = 2; |
33 const int kSwReporterPostRebootCleanupNeeded = 4; | 34 const int kSwReporterPostRebootCleanupNeeded = 4; |
34 const int kSwReporterDelayedPostRebootCleanupNeeded = 15; | 35 const int kSwReporterDelayedPostRebootCleanupNeeded = 15; |
35 | 36 |
36 // A special exit code identifying a failure to run the reporter. | 37 // A special exit code identifying a failure to run the reporter. |
37 const int kReporterFailureExitCode = INT_MAX; | 38 const int kReporterFailureExitCode = INT_MAX; |
38 | 39 |
39 // The number of days to wait before triggering another reporter run. | 40 // The number of days to wait before triggering another reporter run. |
40 const int kDaysBetweenSuccessfulSwReporterRuns = 7; | 41 const int kDaysBetweenSuccessfulSwReporterRuns = 7; |
41 const int kDaysBetweenSwReporterRunsForPendingPrompt = 1; | 42 const int kDaysBetweenSwReporterRunsForPendingPrompt = 1; |
42 | 43 |
43 // To test SRT Fetches. | 44 // To test SRT Fetches. |
44 const int kSRTFetcherID = 47; | 45 const int kSRTFetcherID = 47; |
45 | 46 |
47 // Parameters used to invoke the sw_reporter component. | |
48 struct SwReporterInvocation { | |
49 base::CommandLine command_line; | |
50 | |
51 // Experimental versions of the reporter will write metrics to registry keys | |
52 // ending in |suffix|. Those metrics should be copid to UMA histograms also | |
csharp
2016/08/11 18:58:02
nit: copid -> copied
Joe Mason
2016/08/15 17:24:40
Done.
| |
53 // ending in |suffix|. For the canonical version, |suffix| will be empty. | |
54 std::string suffix; | |
55 | |
csharp
2016/08/11 18:58:02
I think this should always contain a bool to deter
Joe Mason
2016/08/15 17:24:40
Done.
| |
56 SwReporterInvocation(); | |
57 explicit SwReporterInvocation(const base::FilePath& exe_path); | |
58 SwReporterInvocation(const base::CommandLine& command_line, | |
59 const std::string& suffix); | |
60 | |
61 bool operator==(const SwReporterInvocation& other) const; | |
csharp
2016/08/11 18:58:02
Why do you need to compare SwReporterInvocations?
Joe Mason
2016/08/15 17:24:40
ReporterRunner::Run starts with a check to see if
| |
62 }; | |
63 | |
46 // Tries to run the sw_reporter component, and then schedule the next try. If | 64 // Tries to run the sw_reporter component, and then schedule the next try. If |
47 // called multiple times, then multiple sequences of trying to run will happen, | 65 // called multiple times, then multiple sequences of trying to run will happen, |
48 // yet only one reporter will run per specified period (either | 66 // yet only one reporter will run per specified period (either |
49 // |kDaysBetweenSuccessfulSwReporterRuns| or | 67 // |kDaysBetweenSuccessfulSwReporterRuns| or |
50 // |kDaysBetweenSwReporterRunsForPendingPrompt|) will actually happen. | 68 // |kDaysBetweenSwReporterRunsForPendingPrompt|) will actually happen. |
51 // |exe_path| is the full path to the SwReporter to execute and |version| is its | 69 // |command_line| is the command line to execute, including the full path to |
52 // version. The task runners are provided to allow tests to provide their own. | 70 // the SwReporter to execute, and |version| is its version. The task runners are |
71 // provided to allow tests to provide their own. | |
53 void RunSwReporter( | 72 void RunSwReporter( |
csharp
2016/08/11 18:58:02
Why not merge this and the next function and make
Joe Mason
2016/08/15 17:24:40
I removed Experimental from the function name but
| |
54 const base::FilePath& exe_path, | 73 const base::FilePath& exe_path, |
55 const base::Version& version, | 74 const base::Version& version, |
56 const scoped_refptr<base::TaskRunner>& main_thread_task_runner, | 75 const scoped_refptr<base::TaskRunner>& main_thread_task_runner, |
57 const scoped_refptr<base::TaskRunner>& blocking_task_runner); | 76 const scoped_refptr<base::TaskRunner>& blocking_task_runner); |
58 | 77 |
78 // Try to run multiple invocations of the experimental sw_reporter component, | |
79 // with different combinations of command line args. Each set of invocations is | |
80 // treated as a normal scheduled launch of the sw_reporter for the purposes of | |
81 // retries, as described in |RunSwReporter|. | |
82 // | |
83 // |invocation_queue| is a list of sw_reporter configurations which will be | |
84 // launched in order. Once one has been executed, the reporter is considered to | |
85 // have "run" - the remainder will also be executed as part of this run, but | |
86 // then the reporter will not be run again for the specified period. If none of | |
87 // the invocations in the queue execute, another queue can be tried by calling | |
88 // this function again. | |
89 // | |
90 // See |RunSwReporter| for the meaning of the remaining parameters. | |
91 // | |
92 // The experimental sw_reporter never triggers the prompt, just reports results. | |
93 void RunExperimentalSwReporters( | |
94 const std::vector<SwReporterInvocation>& invocation_queue, | |
95 const base::Version& version, | |
96 const scoped_refptr<base::TaskRunner>& main_thread_task_runner, | |
grt (UTC plus 2)
2016/08/10 06:47:02
since this function holds a reference to these two
Joe Mason
2016/08/15 17:24:40
Done.
| |
97 const scoped_refptr<base::TaskRunner>& blocking_task_runner); | |
98 | |
59 // Returns true iff Local State is successfully accessed and indicates the most | 99 // Returns true iff Local State is successfully accessed and indicates the most |
60 // recent Reporter run terminated with an exit code indicating the presence of | 100 // recent Reporter run terminated with an exit code indicating the presence of |
61 // UwS. | 101 // UwS. |
62 bool ReporterFoundUws(); | 102 bool ReporterFoundUws(); |
63 | 103 |
64 // Returns true iff a valid registry key for the SRT Cleaner exists, and that | 104 // Returns true iff a valid registry key for the SRT Cleaner exists, and that |
65 // key is nonempty. | 105 // key is nonempty. |
66 // TODO(tmartino): Consider changing to check whether the user has recently | 106 // TODO(tmartino): Consider changing to check whether the user has recently |
67 // run the cleaner, rather than checking if they've run it at all. | 107 // run the cleaner, rather than checking if they've run it at all. |
68 bool UserHasRunCleaner(); | 108 bool UserHasRunCleaner(); |
69 | 109 |
70 // Test mocks for launching the reporter and showing the prompt | 110 // Test mocks for launching the reporter and showing the prompt |
71 typedef base::Callback<int(const base::FilePath& exe_path)> ReporterLauncher; | 111 typedef base::Callback<int(const base::FilePath& exe_path)> ReporterLauncher; |
72 typedef base::Callback<void(Browser*, const std::string&)> PromptTrigger; | 112 typedef base::Callback<void(Browser*, const std::string&)> PromptTrigger; |
73 void SetReporterLauncherForTesting(const ReporterLauncher& reporter_launcher); | 113 void SetReporterLauncherForTesting(const ReporterLauncher& reporter_launcher); |
74 void SetPromptTriggerForTesting(const PromptTrigger& prompt_trigger); | 114 void SetPromptTriggerForTesting(const PromptTrigger& prompt_trigger); |
75 | 115 |
76 } // namespace safe_browsing | 116 } // namespace safe_browsing |
77 | 117 |
78 #endif // CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_ | 118 #endif // CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_ |
OLD | NEW |