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

Side by Side Diff: chrome/browser/safe_browsing/srt_fetcher_win.h

Issue 2226133005: Add support for the ExperimentalSwReporterEngine field trial. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor, split some prep work into a different patch Created 4 years, 4 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 unified diff | Download patch
OLDNEW
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 <queue>
10 #include <string> 11 #include <string>
11 12
12 #include "base/callback_forward.h" 13 #include "base/callback_forward.h"
13 #include "base/command_line.h" 14 #include "base/command_line.h"
14 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
15 #include "base/version.h" 16 #include "base/version.h"
16 17
17 namespace base { 18 namespace base {
18 class FilePath; 19 class FilePath;
19 class TaskRunner; 20 class TaskRunner;
(...skipping 21 matching lines...) Expand all
41 const int kDaysBetweenSuccessfulSwReporterRuns = 7; 42 const int kDaysBetweenSuccessfulSwReporterRuns = 7;
42 const int kDaysBetweenSwReporterRunsForPendingPrompt = 1; 43 const int kDaysBetweenSwReporterRunsForPendingPrompt = 1;
43 44
44 // To test SRT Fetches. 45 // To test SRT Fetches.
45 const int kSRTFetcherID = 47; 46 const int kSRTFetcherID = 47;
46 47
47 // Parameters used to invoke the sw_reporter component. 48 // Parameters used to invoke the sw_reporter component.
48 struct SwReporterInvocation { 49 struct SwReporterInvocation {
49 base::CommandLine command_line; 50 base::CommandLine command_line;
50 51
52 // Experimental versions of the reporter will write metrics to registry keys
53 // ending in |suffix|. Those metrics should be copied to UMA histograms also
54 // ending in |suffix|. For the canonical version, |suffix| will be empty.
55 std::string suffix;
56
57 // The experimental sw_reporter never triggers the prompt, just reports
58 // results through UMA.
59 bool is_experimental;
60
51 SwReporterInvocation(); 61 SwReporterInvocation();
52 explicit SwReporterInvocation(const base::FilePath& exe_path); 62 explicit SwReporterInvocation(const base::FilePath& exe_path);
53 explicit SwReporterInvocation(const base::CommandLine& command_line); 63 explicit SwReporterInvocation(const base::CommandLine& command_line);
54 64
55 bool operator==(const SwReporterInvocation& other) const; 65 bool operator==(const SwReporterInvocation& other) const;
56 }; 66 };
57 67
58 // Tries to run the sw_reporter component, and then schedule the next try. If 68 // Tries to run the sw_reporter component, and then schedule the next try. If
59 // called multiple times, then multiple sequences of trying to run will happen, 69 // called multiple times, then multiple sequences of trying to run will happen,
60 // yet only one reporter will run per specified period (either 70 // yet only one reporter will run per specified period (either
61 // |kDaysBetweenSuccessfulSwReporterRuns| or 71 // |kDaysBetweenSuccessfulSwReporterRuns| or
62 // |kDaysBetweenSwReporterRunsForPendingPrompt|) will actually happen. 72 // |kDaysBetweenSwReporterRunsForPendingPrompt|) will actually happen.
63 // |invocation| is the details of the SwReporter to execute, and |version| is 73 // |invocation| is the details of the SwReporter to execute, and |version| is
64 // its version. The task runners are provided to allow tests to provide their 74 // its version. The task runners are provided to allow tests to provide their
65 // own. 75 // own.
66 void RunSwReporter(const SwReporterInvocation& invocation, 76 void RunSwReporter(const SwReporterInvocation& invocation,
67 const base::Version& version, 77 const base::Version& version,
68 scoped_refptr<base::TaskRunner> main_thread_task_runner, 78 scoped_refptr<base::TaskRunner> main_thread_task_runner,
69 scoped_refptr<base::TaskRunner> blocking_task_runner); 79 scoped_refptr<base::TaskRunner> blocking_task_runner);
70 80
81 // Try to run multiple invocations of the sw_reporter component, with different
82 // combinations of command line args. Each set of invocations is treated as a
83 // normal scheduled launch of the sw_reporter for the purposes of retries, as
84 // described in |RunSwReporter|.
85 //
86 // |invocations| is a list of sw_reporter configurations which will be launched
87 // in order. Once one has been executed, the reporter is considered to have
88 // "run" - the remainder will also be executed as part of this run, but then
89 // the reporter will not be run again for the specified period. If none of the
90 // invocations in the queue execute, another queue can be tried by calling this
91 // function again.
92 //
93 // See |RunSwReporter| for the meaning of the remaining parameters.
94 void RunSwReporters(const std::queue<SwReporterInvocation>& invocations,
95 const base::Version& version,
96 scoped_refptr<base::TaskRunner> main_thread_task_runner,
97 scoped_refptr<base::TaskRunner> blocking_task_runner);
98
71 // 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
72 // 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
73 // UwS. 101 // UwS.
74 bool ReporterFoundUws(); 102 bool ReporterFoundUws();
75 103
76 // 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
77 // key is nonempty. 105 // key is nonempty.
78 // TODO(tmartino): Consider changing to check whether the user has recently 106 // TODO(tmartino): Consider changing to check whether the user has recently
79 // 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.
80 bool UserHasRunCleaner(); 108 bool UserHasRunCleaner();
81 109
82 // Test mocks for launching the reporter and showing the prompt 110 // Test mocks for launching the reporter and showing the prompt
83 typedef base::Callback<int(const SwReporterInvocation& invocation)> 111 typedef base::Callback<int(const SwReporterInvocation& invocation)>
84 ReporterLauncher; 112 ReporterLauncher;
85 typedef base::Callback<void(Browser*, const std::string&)> PromptTrigger; 113 typedef base::Callback<void(Browser*, const std::string&)> PromptTrigger;
86 void SetReporterLauncherForTesting(const ReporterLauncher& reporter_launcher); 114 void SetReporterLauncherForTesting(const ReporterLauncher& reporter_launcher);
87 void SetPromptTriggerForTesting(const PromptTrigger& prompt_trigger); 115 void SetPromptTriggerForTesting(const PromptTrigger& prompt_trigger);
88 116
89 // Callbacks to let the tests know when the reporter is ready to launch. 117 // Callbacks to let the tests know when the reporter is ready to launch.
90 typedef base::Callback<void(void)> LaunchReadyNotifier; 118 typedef base::Callback<void(void)> LaunchReadyNotifier;
91 void SetLaunchReadyNotifierForTesting(const LaunchReadyNotifier& notifier); 119 void SetLaunchReadyNotifierForTesting(const LaunchReadyNotifier& notifier);
92 typedef base::Callback<void(void)> ReporterDoneNotifier; 120 typedef base::Callback<void(void)> ReporterDoneNotifier;
93 void SetReporterDoneNotifierForTesting(const ReporterDoneNotifier& notifier); 121 void SetReporterDoneNotifierForTesting(const ReporterDoneNotifier& notifier);
94 122
95 } // namespace safe_browsing 123 } // namespace safe_browsing
96 124
97 #endif // CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_ 125 #endif // CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698