summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorsergeyu <sergeyu@chromium.org>2015-04-24 17:18:08 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-25 00:18:25 +0000
commitd9bdcb6c95619e6cb3a4281156573c58f7626a26 (patch)
tree84cf1bd7964177589cc1f1e024655dbb0ef50042 /remoting
parentf79a51f871181b0da7653cfa17d351745bd12994 (diff)
downloadchromium_src-d9bdcb6c95619e6cb3a4281156573c58f7626a26.zip
chromium_src-d9bdcb6c95619e6cb3a4281156573c58f7626a26.tar.gz
chromium_src-d9bdcb6c95619e6cb3a4281156573c58f7626a26.tar.bz2
Use base::ResetAndReturn() in remoting.
base::ResetAndReturn() makes code shorter and simpler. Also in several places callbacks were Reset() after Run(), which is dangerous for callback that are allowed to delete the caller. base::ResetAndReturn() helps to avoid this issue. Review URL: https://codereview.chromium.org/1064863004 Cr-Commit-Position: refs/heads/master@{#326940}
Diffstat (limited to 'remoting')
-rw-r--r--remoting/client/plugin/chromoting_instance.cc4
-rw-r--r--remoting/client/token_fetcher_proxy.cc5
-rw-r--r--remoting/host/daemon_process.cc5
-rw-r--r--remoting/host/dns_blackhole_checker.cc4
-rw-r--r--remoting/host/heartbeat_sender.cc14
-rw-r--r--remoting/host/it2me/it2me_host.cc4
-rw-r--r--remoting/host/register_support_host_request.cc5
-rw-r--r--remoting/host/setup/daemon_controller_delegate_mac.mm9
-rw-r--r--remoting/host/setup/host_starter.cc25
-rw-r--r--remoting/host/setup/oauth_client.cc5
-rw-r--r--remoting/protocol/fake_authenticator.cc5
-rw-r--r--remoting/protocol/fake_datagram_socket.cc5
-rw-r--r--remoting/protocol/ssl_hmac_channel_authenticator.cc13
-rw-r--r--remoting/protocol/ssl_hmac_channel_authenticator.h1
-rw-r--r--remoting/protocol/third_party_authenticator_unittest.cc9
-rw-r--r--remoting/signaling/iq_sender.cc8
-rw-r--r--remoting/test/access_token_fetcher.cc13
-rw-r--r--remoting/test/remote_host_info_fetcher.cc16
18 files changed, 60 insertions, 90 deletions
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
index 9572bc4..3faab96 100644
--- a/remoting/client/plugin/chromoting_instance.cc
+++ b/remoting/client/plugin/chromoting_instance.cc
@@ -14,6 +14,7 @@
#include "base/bind.h"
#include "base/callback.h"
+#include "base/callback_helpers.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/lazy_instance.h"
@@ -905,8 +906,7 @@ void ChromotingInstance::HandleOnPinFetched(const base::DictionaryValue& data) {
return;
}
if (!secret_fetched_callback_.is_null()) {
- secret_fetched_callback_.Run(pin);
- secret_fetched_callback_.Reset();
+ base::ResetAndReturn(&secret_fetched_callback_).Run(pin);
} else {
LOG(WARNING) << "Ignored OnPinFetched received without a pending fetch.";
}
diff --git a/remoting/client/token_fetcher_proxy.cc b/remoting/client/token_fetcher_proxy.cc
index c1082b2..1079290 100644
--- a/remoting/client/token_fetcher_proxy.cc
+++ b/remoting/client/token_fetcher_proxy.cc
@@ -4,6 +4,8 @@
#include "remoting/client/token_fetcher_proxy.h"
+#include "base/callback_helpers.h"
+
namespace remoting {
TokenFetcherProxy::TokenFetcherProxy(
@@ -29,8 +31,7 @@ void TokenFetcherProxy::FetchThirdPartyToken(
void TokenFetcherProxy::OnTokenFetched(
const std::string& token, const std::string& shared_secret) {
if (!token_fetched_callback_.is_null()) {
- token_fetched_callback_.Run(token, shared_secret);
- token_fetched_callback_.Reset();
+ base::ResetAndReturn(&token_fetched_callback_).Run(token, shared_secret);
}
}
diff --git a/remoting/host/daemon_process.cc b/remoting/host/daemon_process.cc
index 8c9ebbb..e08677a 100644
--- a/remoting/host/daemon_process.cc
+++ b/remoting/host/daemon_process.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/callback_helpers.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
@@ -285,9 +286,7 @@ void DaemonProcess::Stop() {
DCHECK(caller_task_runner()->BelongsToCurrentThread());
if (!stopped_callback_.is_null()) {
- base::Closure stopped_callback = stopped_callback_;
- stopped_callback_.Reset();
- stopped_callback.Run();
+ base::ResetAndReturn(&stopped_callback_).Run();
}
}
diff --git a/remoting/host/dns_blackhole_checker.cc b/remoting/host/dns_blackhole_checker.cc
index 745481e..b92eb12 100644
--- a/remoting/host/dns_blackhole_checker.cc
+++ b/remoting/host/dns_blackhole_checker.cc
@@ -4,6 +4,7 @@
#include "remoting/host/dns_blackhole_checker.h"
+#include "base/callback_helpers.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_request_context_getter.h"
#include "remoting/base/logging.h"
@@ -40,8 +41,7 @@ void DnsBlackholeChecker::OnURLFetchComplete(const net::URLFetcher* source) {
HOST_LOG << "Unable to connect to host talkgadget (" << response << ")";
}
url_fetcher_.reset(nullptr);
- callback_.Run(allow);
- callback_.Reset();
+ base::ResetAndReturn(&callback_).Run(allow);
}
void DnsBlackholeChecker::CheckForDnsBlackhole(
diff --git a/remoting/host/heartbeat_sender.cc b/remoting/host/heartbeat_sender.cc
index ae10955..1d1a77d 100644
--- a/remoting/host/heartbeat_sender.cc
+++ b/remoting/host/heartbeat_sender.cc
@@ -7,6 +7,7 @@
#include <math.h>
#include "base/bind.h"
+#include "base/callback_helpers.h"
#include "base/rand_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringize_macros.h"
@@ -105,9 +106,7 @@ bool HeartbeatSender::OnSignalStrategyIncomingStanza(
void HeartbeatSender::OnHostOfflineReasonTimeout() {
DCHECK(!host_offline_reason_ack_callback_.is_null());
- base::Callback<void(bool)> local_callback = host_offline_reason_ack_callback_;
- host_offline_reason_ack_callback_.Reset();
- local_callback.Run(false);
+ base::ResetAndReturn(&host_offline_reason_ack_callback_).Run(false);
}
void HeartbeatSender::OnHostOfflineReasonAck() {
@@ -122,11 +121,10 @@ void HeartbeatSender::OnHostOfflineReasonAck() {
// Run the ACK callback under a clean stack via PostTask() (because the
// callback can end up deleting |this| HeartbeatSender [i.e. when used from
// HostSignalingManager]).
- base::Closure fully_bound_ack_callback =
- base::Bind(host_offline_reason_ack_callback_, true);
- host_offline_reason_ack_callback_.Reset();
- base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
- fully_bound_ack_callback);
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::Bind(base::ResetAndReturn(&host_offline_reason_ack_callback_),
+ true));
}
void HeartbeatSender::SetHostOfflineReason(
diff --git a/remoting/host/it2me/it2me_host.cc b/remoting/host/it2me/it2me_host.cc
index 0ea715f..a67511cb 100644
--- a/remoting/host/it2me/it2me_host.cc
+++ b/remoting/host/it2me/it2me_host.cc
@@ -5,6 +5,7 @@
#include "remoting/host/it2me/it2me_host.h"
#include "base/bind.h"
+#include "base/callback_helpers.h"
#include "base/strings/string_util.h"
#include "base/threading/platform_thread.h"
#include "net/socket/client_socket_factory.h"
@@ -371,8 +372,7 @@ void It2MeHost::OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) {
policy_received_ = true;
if (!pending_connect_.is_null()) {
- pending_connect_.Run();
- pending_connect_.Reset();
+ base::ResetAndReturn(&pending_connect_).Run();
}
}
diff --git a/remoting/host/register_support_host_request.cc b/remoting/host/register_support_host_request.cc
index c0a80d1..b1bdd41 100644
--- a/remoting/host/register_support_host_request.cc
+++ b/remoting/host/register_support_host_request.cc
@@ -5,6 +5,7 @@
#include "remoting/host/register_support_host_request.h"
#include "base/bind.h"
+#include "base/callback_helpers.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
@@ -178,9 +179,7 @@ void RegisterSupportHostRequest::CallCallback(
signal_strategy_->RemoveListener(this);
signal_strategy_ = nullptr;
- RegisterCallback callback = callback_;
- callback_.Reset();
- callback.Run(success, support_id, lifetime);
+ base::ResetAndReturn(&callback_).Run(success, support_id, lifetime);
}
} // namespace remoting
diff --git a/remoting/host/setup/daemon_controller_delegate_mac.mm b/remoting/host/setup/daemon_controller_delegate_mac.mm
index 2fd7daa..9821f86 100644
--- a/remoting/host/setup/daemon_controller_delegate_mac.mm
+++ b/remoting/host/setup/daemon_controller_delegate_mac.mm
@@ -12,6 +12,7 @@
#include "base/basictypes.h"
#include "base/bind.h"
+#include "base/callback_helpers.h"
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
@@ -175,12 +176,10 @@ void DaemonControllerDelegateMac::PreferencePaneCallbackDelegate(
return;
}
- DCHECK(!current_callback_.is_null());
- DaemonController::CompletionCallback done = current_callback_;
- current_callback_.Reset();
- done.Run(result);
-
DeregisterForPreferencePaneNotifications();
+
+ DCHECK(!current_callback_.is_null());
+ base::ResetAndReturn(&current_callback_).Run(result);
}
// static
diff --git a/remoting/host/setup/host_starter.cc b/remoting/host/setup/host_starter.cc
index 127c4a9..5eda05c 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
diff --git a/remoting/host/setup/oauth_client.cc b/remoting/host/setup/oauth_client.cc
index d96d360..fae8021 100644
--- a/remoting/host/setup/oauth_client.cc
+++ b/remoting/host/setup/oauth_client.cc
@@ -4,6 +4,7 @@
#include "remoting/host/setup/oauth_client.h"
+#include "base/callback_helpers.h"
#include "base/logging.h"
namespace {
@@ -61,9 +62,7 @@ void OAuthClient::OnRefreshTokenResponse(
void OAuthClient::SendResponse(const std::string& user_email,
const std::string& refresh_token) {
- CompletionCallback on_done = on_done_;
- on_done_.Reset();
- on_done.Run(user_email, refresh_token);
+ base::ResetAndReturn(&on_done_).Run(user_email, refresh_token);
// Process the next request in the queue.
if (pending_requests_.size()) {
diff --git a/remoting/protocol/fake_authenticator.cc b/remoting/protocol/fake_authenticator.cc
index c816cfa..d597568 100644
--- a/remoting/protocol/fake_authenticator.cc
+++ b/remoting/protocol/fake_authenticator.cc
@@ -4,6 +4,7 @@
#include "remoting/protocol/fake_authenticator.h"
+#include "base/callback_helpers.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
#include "net/base/io_buffer.h"
@@ -82,11 +83,9 @@ void FakeChannelAuthenticator::OnAuthBytesRead(int result) {
}
void FakeChannelAuthenticator::CallDoneCallback() {
- DoneCallback callback = done_callback_;
- done_callback_.Reset();
if (result_ != net::OK)
socket_.reset();
- callback.Run(result_, socket_.Pass());
+ base::ResetAndReturn(&done_callback_).Run(result_, socket_.Pass());
}
FakeAuthenticator::FakeAuthenticator(
diff --git a/remoting/protocol/fake_datagram_socket.cc b/remoting/protocol/fake_datagram_socket.cc
index 75a50b3..9bd4ede 100644
--- a/remoting/protocol/fake_datagram_socket.cc
+++ b/remoting/protocol/fake_datagram_socket.cc
@@ -5,6 +5,7 @@
#include "remoting/protocol/fake_datagram_socket.h"
#include "base/bind.h"
+#include "base/callback_helpers.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "net/base/address_list.h"
@@ -36,9 +37,7 @@ void FakeDatagramSocket::AppendInputPacket(const std::string& data) {
int result = CopyReadData(read_buffer_.get(), read_buffer_size_);
read_buffer_ = nullptr;
- net::CompletionCallback callback = read_callback_;
- read_callback_.Reset();
- callback.Run(result);
+ base::ResetAndReturn(&read_callback_).Run(result);
}
}
diff --git a/remoting/protocol/ssl_hmac_channel_authenticator.cc b/remoting/protocol/ssl_hmac_channel_authenticator.cc
index 464aa1d..23158d2 100644
--- a/remoting/protocol/ssl_hmac_channel_authenticator.cc
+++ b/remoting/protocol/ssl_hmac_channel_authenticator.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/callback_helpers.h"
#include "base/logging.h"
#include "crypto/secure_util.h"
#include "net/base/host_port_pair.h"
@@ -313,20 +314,12 @@ void SslHmacChannelAuthenticator::CheckDone(bool* callback_called) {
if (callback_called)
*callback_called = true;
- CallDoneCallback(net::OK, socket_.Pass());
+ base::ResetAndReturn(&done_callback_).Run(net::OK, socket_.Pass());
}
}
void SslHmacChannelAuthenticator::NotifyError(int error) {
- CallDoneCallback(error, nullptr);
-}
-
-void SslHmacChannelAuthenticator::CallDoneCallback(
- int error,
- scoped_ptr<net::StreamSocket> socket) {
- DoneCallback callback = done_callback_;
- done_callback_.Reset();
- callback.Run(error, socket.Pass());
+ base::ResetAndReturn(&done_callback_).Run(error, nullptr);
}
} // namespace protocol
diff --git a/remoting/protocol/ssl_hmac_channel_authenticator.h b/remoting/protocol/ssl_hmac_channel_authenticator.h
index 7bb6fb9..6bd9006 100644
--- a/remoting/protocol/ssl_hmac_channel_authenticator.h
+++ b/remoting/protocol/ssl_hmac_channel_authenticator.h
@@ -78,7 +78,6 @@ class SslHmacChannelAuthenticator : public ChannelAuthenticator,
void CheckDone(bool* callback_called);
void NotifyError(int error);
- void CallDoneCallback(int error, scoped_ptr<net::StreamSocket> socket);
// The mutual secret used for authentication.
std::string auth_key_;
diff --git a/remoting/protocol/third_party_authenticator_unittest.cc b/remoting/protocol/third_party_authenticator_unittest.cc
index 770907d..9f6dde1 100644
--- a/remoting/protocol/third_party_authenticator_unittest.cc
+++ b/remoting/protocol/third_party_authenticator_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/bind.h"
+#include "base/callback_helpers.h"
#include "net/base/net_errors.h"
#include "remoting/base/rsa_key_pair.h"
#include "remoting/protocol/authenticator_test_base.h"
@@ -53,9 +54,7 @@ class ThirdPartyAuthenticatorTest : public AuthenticatorTestBase {
void OnTokenFetched(const std::string& token,
const std::string& shared_secret) {
ASSERT_FALSE(on_token_fetched_.is_null());
- TokenFetchedCallback on_token_fetched = on_token_fetched_;
- on_token_fetched_.Reset();
- on_token_fetched.Run(token, shared_secret);
+ base::ResetAndReturn(&on_token_fetched_).Run(token, shared_secret);
}
private:
@@ -79,9 +78,7 @@ class ThirdPartyAuthenticatorTest : public AuthenticatorTestBase {
void OnTokenValidated(const std::string& shared_secret) {
ASSERT_FALSE(on_token_validated_.is_null());
- TokenValidatedCallback on_token_validated = on_token_validated_;
- on_token_validated_.Reset();
- on_token_validated.Run(shared_secret);
+ base::ResetAndReturn(&on_token_validated_).Run(shared_secret);
}
const GURL& token_url() const override { return token_url_; }
diff --git a/remoting/signaling/iq_sender.cc b/remoting/signaling/iq_sender.cc
index d3e7432..7fefc71 100644
--- a/remoting/signaling/iq_sender.cc
+++ b/remoting/signaling/iq_sender.cc
@@ -5,6 +5,7 @@
#include "remoting/signaling/iq_sender.h"
#include "base/bind.h"
+#include "base/callback_helpers.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -138,11 +139,8 @@ void IqRequest::SetTimeout(base::TimeDelta timeout) {
}
void IqRequest::CallCallback(const buzz::XmlElement* stanza) {
- if (!callback_.is_null()) {
- IqSender::ReplyCallback callback(callback_);
- callback_.Reset();
- callback.Run(this, stanza);
- }
+ if (!callback_.is_null())
+ base::ResetAndReturn(&callback_).Run(this, stanza);
}
void IqRequest::OnTimeout() {
diff --git a/remoting/test/access_token_fetcher.cc b/remoting/test/access_token_fetcher.cc
index 4fa690e..a7f0dcb 100644
--- a/remoting/test/access_token_fetcher.cc
+++ b/remoting/test/access_token_fetcher.cc
@@ -8,6 +8,7 @@
#include <vector>
#include "base/bind.h"
+#include "base/callback_helpers.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/thread_task_runner_handle.h"
@@ -149,8 +150,8 @@ void AccessTokenFetcher::OnGetTokenInfoResponse(
DVLOG(1) << "Access Token has been validated";
}
- access_token_callback_.Run(access_token_, refresh_token_);
- access_token_callback_.Reset();
+ base::ResetAndReturn(&access_token_callback_)
+ .Run(access_token_, refresh_token_);
}
void AccessTokenFetcher::OnOAuthError() {
@@ -159,8 +160,8 @@ void AccessTokenFetcher::OnOAuthError() {
access_token_.clear();
refresh_token_.clear();
- access_token_callback_.Run(access_token_, refresh_token_);
- access_token_callback_.Reset();
+ base::ResetAndReturn(&access_token_callback_)
+ .Run(access_token_, refresh_token_);
}
void AccessTokenFetcher::OnNetworkError(int response_code) {
@@ -170,8 +171,8 @@ void AccessTokenFetcher::OnNetworkError(int response_code) {
access_token_.clear();
refresh_token_.clear();
- access_token_callback_.Run(access_token_, refresh_token_);
- access_token_callback_.Reset();
+ base::ResetAndReturn(&access_token_callback_)
+ .Run(access_token_, refresh_token_);
}
void AccessTokenFetcher::ValidateAccessToken() {
diff --git a/remoting/test/remote_host_info_fetcher.cc b/remoting/test/remote_host_info_fetcher.cc
index f2b0e8f..e386bf8 100644
--- a/remoting/test/remote_host_info_fetcher.cc
+++ b/remoting/test/remote_host_info_fetcher.cc
@@ -5,6 +5,7 @@
#include "remoting/test/remote_host_info_fetcher.h"
#include "base/bind.h"
+#include "base/callback_helpers.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/logging.h"
@@ -88,16 +89,14 @@ void RemoteHostInfoFetcher::OnURLFetchComplete(const net::URLFetcher* source) {
if (response_code != net::HTTP_OK) {
LOG(ERROR) << "RemoteHostInfo request failed with error code: "
<< response_code;
- remote_host_info_callback_.Run(remote_host_info);
- remote_host_info_callback_.Reset();
+ base::ResetAndReturn(&remote_host_info_callback_).Run(remote_host_info);
return;
}
std::string response_string;
if (!request_->GetResponseAsString(&response_string)) {
LOG(ERROR) << "Failed to retrieve RemoteHostInfo response data";
- remote_host_info_callback_.Run(remote_host_info);
- remote_host_info_callback_.Reset();
+ base::ResetAndReturn(&remote_host_info_callback_).Run(remote_host_info);
return;
}
@@ -106,8 +105,7 @@ void RemoteHostInfoFetcher::OnURLFetchComplete(const net::URLFetcher* source) {
if (!response_value ||
!response_value->IsType(base::Value::TYPE_DICTIONARY)) {
LOG(ERROR) << "Failed to parse response string to JSON";
- remote_host_info_callback_.Run(remote_host_info);
- remote_host_info_callback_.Reset();
+ base::ResetAndReturn(&remote_host_info_callback_).Run(remote_host_info);
return;
}
@@ -117,8 +115,7 @@ void RemoteHostInfoFetcher::OnURLFetchComplete(const net::URLFetcher* source) {
response->GetString("status", &remote_host_status);
} else {
LOG(ERROR) << "Failed to convert parsed JSON to a dictionary object";
- remote_host_info_callback_.Run(remote_host_info);
- remote_host_info_callback_.Reset();
+ base::ResetAndReturn(&remote_host_info_callback_).Run(remote_host_info);
return;
}
@@ -133,8 +130,7 @@ void RemoteHostInfoFetcher::OnURLFetchComplete(const net::URLFetcher* source) {
response->GetString("sharedSecret", &remote_host_info.shared_secret);
}
- remote_host_info_callback_.Run(remote_host_info);
- remote_host_info_callback_.Reset();
+ base::ResetAndReturn(&remote_host_info_callback_).Run(remote_host_info);
}
} // namespace test