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

Unified Diff: chrome/browser/safe_browsing/srt_fetcher_win.cc

Issue 2834613003: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/srt_fetcher_win.cc
diff --git a/chrome/browser/safe_browsing/srt_fetcher_win.cc b/chrome/browser/safe_browsing/srt_fetcher_win.cc
index 6f2ee0f88e9f5b90d245d708ba646f5d6e69535e..45cb63e3b8ddf75472e436a6e1886e8fc73bed04 100644
--- a/chrome/browser/safe_browsing/srt_fetcher_win.cc
+++ b/chrome/browser/safe_browsing/srt_fetcher_win.cc
@@ -593,6 +593,10 @@ class SwReporterProcess : public base::RefCountedThreadSafe<SwReporterProcess> {
// Starts a new instance of ChromePromptImpl to receive requests from the
// reporter. Must be run on the IO thread.
grt (UTC plus 2) 2017/04/21 11:10:58 "...reporter and establishes the mojo connection t
ftirelo 2017/04/24 15:47:46 Done.
void CreateChromePromptImpl(
+ base::ProcessHandle process,
+ mojo::edk::ConnectionParams connection_params,
+ std::unique_ptr<mojo::edk::PendingProcessConnection>
+ pending_process_connection,
chrome_cleaner::mojom::ChromePromptRequest chrome_prompt_request);
// Releases the instance of ChromePromptImpl. Must be run on the IO thread.
@@ -620,7 +624,7 @@ int SwReporterProcess::LaunchAndWaitForExitOnBackgroundThread() {
// This exit code is used to identify that a reporter run didn't happen, so
// the result should be ignored and a rerun scheduled for the usual delay.
- int exit_code = kReporterFailureExitCode;
+ int exit_code = kReporterNotLaunchedExitCode;
UMAHistogramReporter uma(invocation_.suffix);
if (reporter_process.IsValid()) {
uma.RecordReporterStep(SW_REPORTER_START_EXECUTION);
@@ -644,10 +648,12 @@ void SwReporterProcess::OnReporterDone() {
base::Process SwReporterProcess::LaunchConnectedReporterProcess() {
DCHECK(base::FeatureList::IsEnabled(kInBrowserCleanerUIFeature));
- mojo::edk::PendingProcessConnection pending_process_connection;
+ std::unique_ptr<mojo::edk::PendingProcessConnection>
+ pending_process_connection =
+ base::MakeUnique<mojo::edk::PendingProcessConnection>();
std::string mojo_pipe_token;
mojo::ScopedMessagePipeHandle mojo_pipe =
- pending_process_connection.CreateMessagePipe(&mojo_pipe_token);
+ pending_process_connection->CreateMessagePipe(&mojo_pipe_token);
invocation_.command_line.AppendSwitchASCII(
chrome_cleaner::kChromeMojoPipeTokenSwitch, mojo_pipe_token);
invocation_.command_line.AppendSwitchASCII(
@@ -668,21 +674,19 @@ base::Process SwReporterProcess::LaunchConnectedReporterProcess() {
if (!reporter_process.IsValid())
return reporter_process;
- pending_process_connection.Connect(
- reporter_process.Handle(),
- mojo::edk::ConnectionParams(channel.PassServerHandle()));
-
chrome_cleaner::mojom::ChromePromptRequest chrome_prompt_request;
chrome_prompt_request.Bind(std::move(mojo_pipe));
// ChromePromptImpl tasks will need to run on the IO thread. There is no
// need to synchronize its creation, since the client end will wait for this
// initialization to be done before sending requests.
+ base::OnceClosure f = base::BindOnce(
grt (UTC plus 2) 2017/04/21 11:10:59 why introduce a local for this? if you really thin
ftirelo 2017/04/24 15:47:46 Left-over from a previous test; after it passed, I
+ &SwReporterProcess::CreateChromePromptImpl, base::RetainedRef(this),
+ reporter_process.Handle(),
grt (UTC plus 2) 2017/04/21 11:10:58 please document why it's safe to pass the naked ha
ftirelo 2017/04/24 15:47:46 Obsolete.
+ mojo::edk::ConnectionParams(channel.PassServerHandle()),
+ std::move(pending_process_connection), std::move(chrome_prompt_request));
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)
- ->PostTask(FROM_HERE,
- base::BindOnce(&SwReporterProcess::CreateChromePromptImpl,
- base::RetainedRef(this),
- std::move(chrome_prompt_request)));
+ ->PostTask(FROM_HERE, std::move(f));
return reporter_process;
}
@@ -696,12 +700,21 @@ base::Process SwReporterProcess::LaunchReporterProcess(
}
void SwReporterProcess::CreateChromePromptImpl(
+ base::ProcessHandle process,
+ mojo::edk::ConnectionParams connection_params,
+ std::unique_ptr<mojo::edk::PendingProcessConnection>
+ pending_process_connection,
chrome_cleaner::mojom::ChromePromptRequest chrome_prompt_request) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(base::FeatureList::IsEnabled(kInBrowserCleanerUIFeature));
chrome_prompt_impl_ =
base::MakeUnique<ChromePromptImpl>(std::move(chrome_prompt_request));
grt (UTC plus 2) 2017/04/21 11:10:58 perhaps this could call a function on the testing
ftirelo 2017/04/24 15:47:46 Done.
+
+ pending_process_connection->Connect(
+ process, std::move(connection_params),
+ base::Bind(&ChromePromptImpl::OnConnectionError,
+ base::Unretained(chrome_prompt_impl_.get())));
grt (UTC plus 2) 2017/04/21 11:10:58 please document why this Unretained is safe. is it
ftirelo 2017/04/24 15:47:46 Obsolete.
}
void SwReporterProcess::ReleaseChromePromptImpl() {
@@ -934,7 +947,7 @@ class ReporterRunner : public chrome::BrowserListObserver {
base::TimeDelta reporter_running_time = now - reporter_start_time;
// Don't continue the current queue of reporters if one failed to launch.
- if (exit_code == kReporterFailureExitCode)
+ if (exit_code == kReporterNotLaunchedExitCode)
current_invocations_ = SwReporterQueue();
// As soon as we're not running this queue, schedule the next overall queue
@@ -954,7 +967,7 @@ class ReporterRunner : public chrome::BrowserListObserver {
// code itself doesn't need to be logged in this case because
// SW_REPORTER_FAILED_TO_START is logged in
// |LaunchAndWaitForExitOnBackgroundThread|.)
- if (exit_code == kReporterFailureExitCode)
+ if (exit_code == kReporterNotLaunchedExitCode)
return;
const auto& finished_invocation = sw_reporter_process->invocation();

Powered by Google App Engine
This is Rietveld 408576698