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

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

Issue 2844113002: Revert of Adds error handling support for the SwReporter launcher. (Closed)
Patch Set: 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 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 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <queue> 11 #include <queue>
12 #include <string> 12 #include <string>
13 13
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/feature_list.h" 15 #include "base/feature_list.h"
16 #include "base/process/launch.h" 16 #include "base/process/launch.h"
17 #include "base/process/process.h" 17 #include "base/process/process.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "components/chrome_cleaner/public/interfaces/chrome_prompt.mojom.h"
20 19
21 namespace base { 20 namespace base {
22 class FilePath; 21 class FilePath;
23 class TaskRunner; 22 class TaskRunner;
24 class Version; 23 class Version;
25 } 24 }
26 25
27 class Browser; 26 class Browser;
28 27
29 namespace safe_browsing { 28 namespace safe_browsing {
30 29
31 class ChromePromptImpl;
32
33 // A special exit code identifying a failure to run the reporter. 30 // A special exit code identifying a failure to run the reporter.
34 const int kReporterNotLaunchedExitCode = INT_MAX; 31 const int kReporterFailureExitCode = INT_MAX;
35 32
36 // The number of days to wait before triggering another reporter run. 33 // The number of days to wait before triggering another reporter run.
37 const int kDaysBetweenSuccessfulSwReporterRuns = 7; 34 const int kDaysBetweenSuccessfulSwReporterRuns = 7;
38 const int kDaysBetweenSwReporterRunsForPendingPrompt = 1; 35 const int kDaysBetweenSwReporterRunsForPendingPrompt = 1;
39 // The number of days to wait before sending out reporter logs. 36 // The number of days to wait before sending out reporter logs.
40 const int kDaysBetweenReporterLogsSent = 7; 37 const int kDaysBetweenReporterLogsSent = 7;
41 38
42 // When enabled, moves all user interaction with the Software Reporter and the 39 // When enabled, moves all user interaction with the Software Reporter and the
43 // Chrome Cleanup tool to Chrome. 40 // Chrome Cleanup tool to Chrome.
44 extern const base::Feature kInBrowserCleanerUIFeature; 41 extern const base::Feature kInBrowserCleanerUIFeature;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // 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
100 // UwS. 97 // UwS.
101 bool ReporterFoundUws(); 98 bool ReporterFoundUws();
102 99
103 // 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
104 // key is nonempty. 101 // key is nonempty.
105 // TODO(tmartino): Consider changing to check whether the user has recently 102 // TODO(tmartino): Consider changing to check whether the user has recently
106 // 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.
107 bool UserHasRunCleaner(); 104 bool UserHasRunCleaner();
108 105
109 // A delegate used by tests to implement test doubles (e.g., stubs, fakes, or 106 // Mocks and callbacks for the unit tests.
110 // mocks).
111 class SwReporterTestingDelegate { 107 class SwReporterTestingDelegate {
112 public: 108 public:
113 virtual ~SwReporterTestingDelegate() {} 109 virtual ~SwReporterTestingDelegate() {}
114 110
115 // Invoked by tests in places of base::LaunchProcess. 111 // Test mock for launching the reporter.
116 // See chrome_cleaner::mojom::ChromePromptRequest().
117 virtual base::Process LaunchReporter( 112 virtual base::Process LaunchReporter(
118 const SwReporterInvocation& invocation, 113 const SwReporterInvocation& invocation,
119 const base::LaunchOptions& launch_options) = 0; 114 const base::LaunchOptions& launch_options) = 0;
120 115
121 // Invoked by tests in place of the actual prompting logic. 116 // Test mock for showing the prompt.
122 // See MaybeFetchSRT().
123 virtual void TriggerPrompt(Browser* browser, 117 virtual void TriggerPrompt(Browser* browser,
124 const std::string& reporter_version) = 0; 118 const std::string& reporter_version) = 0;
125 119
126 // Invoked by tests to override the current time. 120 // Returns the test's idea of the current time.
127 // See Now() in srt_fetcher_win.cc.
128 virtual base::Time Now() const = 0; 121 virtual base::Time Now() const = 0;
129 122
130 // A task runner used to spawn the reporter process (which blocks). 123 // A task runner used to spawn the reporter process (which blocks).
131 // See ReporterRunner::ScheduleNextInvocation().
132 virtual base::TaskRunner* BlockingTaskRunner() const = 0; 124 virtual base::TaskRunner* BlockingTaskRunner() const = 0;
133
134 // Returns a ChromePromptImpl object that keeps track of specific
135 // actions during tests. Replaces the object returned by
136 // SwReporterProcess::CreateChromePromptImpl().
137 // See SwReporterProcess::LaunchConnectedReporterProcess().
138 virtual std::unique_ptr<ChromePromptImpl> CreateChromePromptImpl(
139 chrome_cleaner::mojom::ChromePromptRequest request) = 0;
140
141 // Connection closed callback defined by tests in place of the default
142 // error handler. See SRTFetcherTest::CreateChromePromptImpl().
143 virtual void OnConnectionClosed() = 0;
144
145 // Bad message handler callback defined by tests in place of the default
146 // error handler. See SwReporterProcess::LaunchConnectedReporterProcess().
147 virtual void OnConnectionError(const std::string& message) = 0;
148 }; 125 };
149 126
150 // Set a delegate for testing. The implementation will not take ownership of 127 // Set a delegate for testing. The implementation will not take ownership of
151 // |delegate| - it must remain valid until this function is called again to 128 // |delegate| - it must remain valid until this function is called again to
152 // reset the delegate. If |delegate| is nullptr, any previous delegate is 129 // reset the delegate. If |delegate| is nullptr, any previous delegate is
153 // cleared. 130 // cleared.
154 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate); 131 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate);
155 132
156 void DisplaySRTPromptForTesting(const base::FilePath& download_path); 133 void DisplaySRTPromptForTesting(const base::FilePath& download_path);
157 134
158 } // namespace safe_browsing 135 } // namespace safe_browsing
159 136
160 #endif // CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_ 137 #endif // CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_
OLDNEW
« 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