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

Unified Diff: remoting/host/setup/host_starter.cc

Issue 1064863004: Use base::ResetAndReturn() in remoting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « remoting/host/setup/daemon_controller_delegate_mac.mm ('k') | remoting/host/setup/oauth_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/setup/host_starter.cc
diff --git a/remoting/host/setup/host_starter.cc b/remoting/host/setup/host_starter.cc
index 127c4a98706fe1c42b0ccc1a621adb3be2383b9a..5eda05c52a6f1b285d2f06faaf22be1156227d1d 100644
--- a/remoting/host/setup/host_starter.cc
+++ b/remoting/host/setup/host_starter.cc
@@ -5,6 +5,7 @@
#include "remoting/host/setup/host_starter.h"
#include "base/bind.h"
+#include "base/callback_helpers.h"
#include "base/guid.h"
#include "base/location.h"
#include "base/thread_task_runner_handle.h"
@@ -184,9 +185,7 @@ void HostStarter::OnHostStarted(DaemonController::AsyncResult result) {
service_client_->UnregisterHost(host_id_, access_token_, this);
return;
}
- CompletionCallback cb = on_done_;
- on_done_.Reset();
- cb.Run(START_COMPLETE);
+ base::ResetAndReturn(&on_done_).Run(START_COMPLETE);
}
void HostStarter::OnOAuthError() {
@@ -195,14 +194,12 @@ void HostStarter::OnOAuthError() {
&HostStarter::OnOAuthError, weak_ptr_));
return;
}
- CompletionCallback cb = on_done_;
- on_done_.Reset();
if (unregistering_host_) {
LOG(ERROR) << "OAuth error occurred when unregistering host.";
- cb.Run(START_ERROR);
- } else {
- cb.Run(OAUTH_ERROR);
}
+
+ base::ResetAndReturn(&on_done_)
+ .Run(unregistering_host_ ? START_ERROR : OAUTH_ERROR);
}
void HostStarter::OnNetworkError(int response_code) {
@@ -211,14 +208,12 @@ void HostStarter::OnNetworkError(int response_code) {
&HostStarter::OnNetworkError, weak_ptr_, response_code));
return;
}
- CompletionCallback cb = on_done_;
- on_done_.Reset();
if (unregistering_host_) {
LOG(ERROR) << "Network error occurred when unregistering host.";
- cb.Run(START_ERROR);
- } else {
- cb.Run(NETWORK_ERROR);
}
+
+ base::ResetAndReturn(&on_done_)
+ .Run(unregistering_host_ ? START_ERROR : NETWORK_ERROR);
}
void HostStarter::OnHostUnregistered() {
@@ -227,9 +222,7 @@ void HostStarter::OnHostUnregistered() {
&HostStarter::OnHostUnregistered, weak_ptr_));
return;
}
- CompletionCallback cb = on_done_;
- on_done_.Reset();
- cb.Run(START_ERROR);
+ base::ResetAndReturn(&on_done_).Run(START_ERROR);
}
} // namespace remoting
« no previous file with comments | « remoting/host/setup/daemon_controller_delegate_mac.mm ('k') | remoting/host/setup/oauth_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698