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

Side by Side Diff: chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_runner_win.h

Issue 2890023005: Chrome Cleaner UI: reporter no longer uses mojo. (Closed)
Patch Set: Move main run function to inside the ChromeCleanerRunner class. Created 3 years, 7 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
(Empty)
1 // Copyright 2017 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.
4
5 #ifndef CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_CHROME_CLEANER_RUNNER_WIN_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_CHROME_CLEANER_RUNNER_WIN_H_
7
8 #include <limits>
9 #include <memory>
10 #include <set>
11 #include <string>
12
13 #include "base/callback.h"
14 #include "base/command_line.h"
15 #include "base/files/file_path.h"
16 #include "base/memory/ref_counted.h"
17 #include "chrome/browser/safe_browsing/chrome_cleaner/reporter_runner_win.h"
18 #include "chrome/browser/safe_browsing/chrome_cleaner/srt_chrome_prompt_impl.h"
19 #include "components/chrome_cleaner/public/interfaces/chrome_prompt.mojom.h"
20
21 namespace safe_browsing {
22
23 // Class responsible for launching the cleaner process and waiting for its
24 // completion when the InBrowserCleanerUI feature is enabled. This object is
25 // also responsible for starting the ChromePromptImpl object on the IO thread
26 // and controlling its lifetime.
27 //
28 // Expected lifecycle of a ChromeCleanerRunner:
29 // - Created on the UI thread.
Joe Mason 2017/05/19 22:02:25 Can you rephrase this as something like "created o
alito 2017/05/22 23:26:31 I made another pass over the comments in this file
30 // - Launches the Chrome Cleaner process when the
31 // LaunchAndWaitForExitOnBackgroundThread() function is called, creates a
32 // ChromePromptImpl object on the IO thread and waits for the process to
33 // terminate. That function must be called on a sequence with the correct set
34 // of traits. See the implementation of
35 // RunChromeCleanerAndReplyWithExitCode() for details.
36 // - deleted on the UI thread when the Chrome Cleaner process exits, at which
Joe Mason 2017/05/19 22:02:25 Which would make this "deleted on the CleanerRunne
alito 2017/05/22 23:26:31 Reformulated.
37 // point the ChromePromptImpl object will also be scheduled for deletion on
38 // the IO thread.
39 class ChromeCleanerRunner
40 : public base::RefCountedThreadSafe<ChromeCleanerRunner> {
41 public:
42 using ProcessDoneCallback = base::OnceCallback<void(int /*exit_code*/)>;
43
44 static constexpr int kNotLaunchedExitCode = std::numeric_limits<int>::max();
45
46 // Executes the Chrome Cleaner in the background and passes information back
47 // to the caller by calling the given callbacks on the UI thread.
Joe Mason 2017/05/19 22:02:25 I would phrase this as something like "...by calli
alito 2017/05/22 23:26:31 Reformulated the comments. PTAnL.
48 //
49 // This function will pass command line flags to the Chrome Cleaner executable
50 // as appropriate based on the flags in |reporter_invocation| and the
51 // |matrics_enabled| and |cleaner_logs_enabled| parameters. The Cleaner
Joe Mason 2017/05/19 22:02:25 Typo: metrics_enabled.
alito 2017/05/22 23:26:31 Done.
52 // process will communicate with Chrome via a mojo IPC interface and any IPC
53 // requests or notifications are passed to the caller on the UI thread via the
54 // |on_prompt_user|, |on_connection_closed|, and |on_connection_error|
55 // callbacks. The details of the mojo interface are documented in
56 // "components/chrome_cleaner/public/interfaces/chrome_prompt.mojom.h".
57 //
58 // Finally, when the Chrome Cleaner process terminates, the exit code is
59 // passed along to |done_callback|, also on the UI thread.
60 static void RunChromeCleanerAndReplyWithExitCode(
61 const base::FilePath& executable_path,
62 const SwReporterInvocation& reporter_invocation,
63 bool metrics_enabled,
Joe Mason 2017/05/19 22:02:25 How about enums for metrics_enabled and cleaner_lo
alito 2017/05/22 23:26:31 Done.
64 bool cleaner_logs_enabled,
65 ChromePromptImpl::OnPromptUser on_prompt_user,
66 base::OnceClosure on_connection_closed,
67 base::OnceClosure on_connection_error,
68 ChromeCleanerRunner::ProcessDoneCallback on_process_done);
69
70 private:
71 friend class base::RefCountedThreadSafe<ChromeCleanerRunner>;
72 ~ChromeCleanerRunner();
73
74 ChromeCleanerRunner(const base::FilePath& executable_path,
75 const SwReporterInvocation& reporter_invocation,
76 bool metrics_enabled,
77 bool cleaner_logs_enabled,
78 ChromePromptImpl::OnPromptUser on_prompt_user,
79 base::OnceClosure on_connection_closed,
80 base::OnceClosure on_connection_error,
81 ProcessDoneCallback on_process_done);
82
83 int LaunchAndWaitForExitOnBackgroundThread();
84
85 void CreateChromePromptImpl(
86 chrome_cleaner::mojom::ChromePromptRequest chrome_prompt_request);
87 void ReleaseChromePromptImpl();
88
89 void OnPromptUser(std::unique_ptr<std::set<base::FilePath>> files_to_delete,
90 chrome_cleaner::mojom::ChromePrompt::PromptUserCallback
91 prompt_user_callback);
92 void OnConnectionClosed();
93 void OnConnectionError(const std::string& error);
94 void OnProcessDone(int exit_code);
95
96 base::CommandLine command_line_;
97 ChromePromptImpl::OnPromptUser on_prompt_user_;
98 base::OnceClosure on_connection_closed_;
99 base::OnceClosure on_connection_error_;
100 ProcessDoneCallback on_process_done_;
101
102 std::unique_ptr<ChromePromptImpl> chrome_prompt_impl_;
Joe Mason 2017/05/19 22:02:25 Can you add a base::SequenceChecker and check CALL
alito 2017/05/22 23:26:31 I decided to use a SingleThreadTaskRunner instead
103 };
104
105 } // namespace safe_browsing
106
107 #endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_CHROME_CLEANER_RUNNER_WIN _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698