Index: remoting/host/setup/native_messaging_host.cc |
diff --git a/remoting/host/setup/native_messaging_host.cc b/remoting/host/setup/native_messaging_host.cc |
index a98de3a6a69c70db66bdb8ee718c02914669d009..275e9fed13628616c56becd6872bf2b3132d2420 100644 |
--- a/remoting/host/setup/native_messaging_host.cc |
+++ b/remoting/host/setup/native_messaging_host.cc |
@@ -62,7 +62,7 @@ scoped_ptr<base::DictionaryValue> ConfigDictionaryFromMessage( |
namespace remoting { |
NativeMessagingHost::NativeMessagingHost( |
- scoped_ptr<DaemonController> daemon_controller, |
+ scoped_refptr<DaemonController> daemon_controller, |
scoped_refptr<protocol::PairingRegistry> pairing_registry, |
scoped_ptr<OAuthClient> oauth_client, |
base::PlatformFile input, |
@@ -73,7 +73,7 @@ NativeMessagingHost::NativeMessagingHost( |
quit_closure_(quit_closure), |
native_messaging_reader_(input), |
native_messaging_writer_(output), |
- daemon_controller_(daemon_controller.Pass()), |
+ daemon_controller_(daemon_controller), |
pairing_registry_(pairing_registry), |
oauth_client_(oauth_client.Pass()), |
pending_requests_(0), |
@@ -270,11 +270,9 @@ bool NativeMessagingHost::ProcessUpdateDaemonConfig( |
if (!config_dict) |
return false; |
- // base::Unretained() is safe because this object owns |daemon_controller_| |
- // which owns the thread that will run the callback. |
daemon_controller_->UpdateConfig( |
config_dict.Pass(), |
- base::Bind(&NativeMessagingHost::SendAsyncResult, base::Unretained(this), |
+ base::Bind(&NativeMessagingHost::SendAsyncResult, weak_ptr_, |
base::Passed(&response))); |
return true; |
} |
@@ -283,8 +281,8 @@ bool NativeMessagingHost::ProcessGetDaemonConfig( |
const base::DictionaryValue& message, |
scoped_ptr<base::DictionaryValue> response) { |
daemon_controller_->GetConfig( |
- base::Bind(&NativeMessagingHost::SendConfigResponse, |
- base::Unretained(this), base::Passed(&response))); |
+ base::Bind(&NativeMessagingHost::SendConfigResponse, weak_ptr_, |
+ base::Passed(&response))); |
return true; |
} |
@@ -307,7 +305,7 @@ bool NativeMessagingHost::ProcessGetUsageStatsConsent( |
scoped_ptr<base::DictionaryValue> response) { |
daemon_controller_->GetUsageStatsConsent( |
base::Bind(&NativeMessagingHost::SendUsageStatsConsentResponse, |
- base::Unretained(this), base::Passed(&response))); |
+ weak_ptr_, base::Passed(&response))); |
return true; |
} |
@@ -327,7 +325,7 @@ bool NativeMessagingHost::ProcessStartDaemon( |
daemon_controller_->SetConfigAndStart( |
config_dict.Pass(), consent, |
- base::Bind(&NativeMessagingHost::SendAsyncResult, base::Unretained(this), |
+ base::Bind(&NativeMessagingHost::SendAsyncResult, weak_ptr_, |
base::Passed(&response))); |
return true; |
} |
@@ -336,7 +334,7 @@ bool NativeMessagingHost::ProcessStopDaemon( |
const base::DictionaryValue& message, |
scoped_ptr<base::DictionaryValue> response) { |
daemon_controller_->Stop( |
- base::Bind(&NativeMessagingHost::SendAsyncResult, base::Unretained(this), |
+ base::Bind(&NativeMessagingHost::SendAsyncResult, weak_ptr_, |
base::Passed(&response))); |
return true; |
} |
@@ -446,12 +444,10 @@ void NativeMessagingHost::SendPairedClientsResponse( |
void NativeMessagingHost::SendUsageStatsConsentResponse( |
scoped_ptr<base::DictionaryValue> response, |
- bool supported, |
- bool allowed, |
- bool set_by_policy) { |
- response->SetBoolean("supported", supported); |
- response->SetBoolean("allowed", allowed); |
- response->SetBoolean("setByPolicy", set_by_policy); |
+ const DaemonController::UsageStatsConsent& consent) { |
+ response->SetBoolean("supported", consent.supported); |
+ response->SetBoolean("allowed", consent.allowed); |
+ response->SetBoolean("setByPolicy", consent.set_by_policy); |
SendResponse(response.Pass()); |
} |