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 #include <stdint.h> | |
9 | 10 |
11 #include <queue> | |
10 #include <string> | 12 #include <string> |
11 | 13 |
12 #include "base/callback_forward.h" | 14 #include "base/callback_forward.h" |
13 #include "base/command_line.h" | 15 #include "base/command_line.h" |
14 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
15 #include "base/version.h" | 17 #include "base/version.h" |
16 | 18 |
17 namespace base { | 19 namespace base { |
18 class FilePath; | 20 class FilePath; |
19 class TaskRunner; | 21 class TaskRunner; |
(...skipping 23 matching lines...) Expand all Loading... | |
43 | 45 |
44 // Parameters used to invoke the sw_reporter component. | 46 // Parameters used to invoke the sw_reporter component. |
45 struct SwReporterInvocation { | 47 struct SwReporterInvocation { |
46 base::CommandLine command_line; | 48 base::CommandLine command_line; |
47 | 49 |
48 // Experimental versions of the reporter will write metrics to registry keys | 50 // Experimental versions of the reporter will write metrics to registry keys |
49 // ending in |suffix|. Those metrics should be copied to UMA histograms also | 51 // ending in |suffix|. Those metrics should be copied to UMA histograms also |
50 // ending in |suffix|. For the canonical version, |suffix| will be empty. | 52 // ending in |suffix|. For the canonical version, |suffix| will be empty. |
51 std::string suffix; | 53 std::string suffix; |
52 | 54 |
53 // The experimental sw_reporter never triggers the prompt, just reports | 55 // Flags to control optional behaviours. By default all are enabled; |
csharp
2016/09/13 17:09:03
What about disabling this all by default, to ensur
Joe Mason
2016/09/13 19:24:55
I think it's better to enable them by default beca
Joe Mason
2016/09/13 21:34:42
csharp convinced me offline that we should set the
| |
54 // results through UMA. | 56 // experimental versions of the reporter will turn off the behaviours that |
55 bool is_experimental = false; | 57 // are not yet supported. |
58 using Flags = uint32_t; | |
59 enum : Flags { | |
60 FLAG_LOG_TO_RAPPOR = 0x1, | |
61 FLAG_LOG_TO_PREFS = 0x2, | |
62 FLAG_TRIGGER_PROMPT = 0x4, | |
63 }; | |
64 Flags flags = FLAG_LOG_TO_RAPPOR | FLAG_LOG_TO_PREFS | FLAG_TRIGGER_PROMPT; | |
56 | 65 |
57 SwReporterInvocation(); | 66 SwReporterInvocation(); |
58 | 67 |
59 static SwReporterInvocation FromFilePath(const base::FilePath& exe_path); | 68 static SwReporterInvocation FromFilePath(const base::FilePath& exe_path); |
60 static SwReporterInvocation FromCommandLine( | 69 static SwReporterInvocation FromCommandLine( |
61 const base::CommandLine& command_line); | 70 const base::CommandLine& command_line); |
62 | 71 |
63 bool operator==(const SwReporterInvocation& other) const; | 72 bool operator==(const SwReporterInvocation& other) const; |
64 }; | 73 }; |
65 | 74 |
75 using SwReporterQueue = std::queue<SwReporterInvocation>; | |
76 | |
66 // Tries to run the sw_reporter component, and then schedule the next try. If | 77 // Tries to run the sw_reporter component, and then schedule the next try. If |
67 // called multiple times, then multiple sequences of trying to run will happen, | 78 // called multiple times, then multiple sequences of trying to run will happen, |
68 // yet only one reporter will run per specified period (either | 79 // yet only one SwReporterQueue will actually run per specified period (either |
69 // |kDaysBetweenSuccessfulSwReporterRuns| or | 80 // |kDaysBetweenSuccessfulSwReporterRuns| or |
70 // |kDaysBetweenSwReporterRunsForPendingPrompt|) will actually happen. | 81 // |kDaysBetweenSwReporterRunsForPendingPrompt|). |
71 // |invocation| is the details of the SwReporter to execute, and |version| is | 82 // |
72 // its version. The task runners are provided to allow tests to provide their | 83 // Each "run" of the sw_reporter component may aggregate the results of several |
73 // own. | 84 // executions of the tool with different command lines. |invocations| is the |
74 void RunSwReporter(const SwReporterInvocation& invocation, | 85 // queue of SwReporters to execute as a single "run". When a new try is |
75 const base::Version& version, | 86 // scheduled the entire queue is executed. |
76 scoped_refptr<base::TaskRunner> main_thread_task_runner, | 87 // |
77 scoped_refptr<base::TaskRunner> blocking_task_runner); | 88 // |version| is the version of the tool that will run. The task runners are |
89 // provided to allow tests to provide their own. | |
90 void RunSwReporters(const SwReporterQueue& invocations, | |
91 const base::Version& version, | |
92 scoped_refptr<base::TaskRunner> main_thread_task_runner, | |
93 scoped_refptr<base::TaskRunner> blocking_task_runner); | |
78 | 94 |
79 // Returns true iff Local State is successfully accessed and indicates the most | 95 // Returns true iff Local State is successfully accessed and indicates the most |
80 // recent Reporter run terminated with an exit code indicating the presence of | 96 // recent Reporter run terminated with an exit code indicating the presence of |
81 // UwS. | 97 // UwS. |
82 bool ReporterFoundUws(); | 98 bool ReporterFoundUws(); |
83 | 99 |
84 // Returns true iff a valid registry key for the SRT Cleaner exists, and that | 100 // Returns true iff a valid registry key for the SRT Cleaner exists, and that |
85 // key is nonempty. | 101 // key is nonempty. |
86 // TODO(tmartino): Consider changing to check whether the user has recently | 102 // TODO(tmartino): Consider changing to check whether the user has recently |
87 // run the cleaner, rather than checking if they've run it at all. | 103 // run the cleaner, rather than checking if they've run it at all. |
(...skipping 20 matching lines...) Expand all Loading... | |
108 | 124 |
109 // Set a delegate for testing. The implementation will not take ownership of | 125 // Set a delegate for testing. The implementation will not take ownership of |
110 // |delegate| - it must remain valid until this function is called again to | 126 // |delegate| - it must remain valid until this function is called again to |
111 // reset the delegate. If |delegate| is nullptr, any previous delegate is | 127 // reset the delegate. If |delegate| is nullptr, any previous delegate is |
112 // cleared. | 128 // cleared. |
113 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate); | 129 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate); |
114 | 130 |
115 } // namespace safe_browsing | 131 } // namespace safe_browsing |
116 | 132 |
117 #endif // CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_ | 133 #endif // CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_ |
OLD | NEW |