Index: components/copresence/copresence_client.cc |
diff --git a/components/copresence/copresence_client.cc b/components/copresence/copresence_client.cc |
index 60e45e15d2156368eddf0e575f1812e6339e9dc6..17f906b59f3516e8cddd2bd9cf328cf7c77e5477 100644 |
--- a/components/copresence/copresence_client.cc |
+++ b/components/copresence/copresence_client.cc |
@@ -26,26 +26,22 @@ CopresenceClient::CopresenceClient(CopresenceClientDelegate* delegate) |
: delegate_(delegate), init_failed_(false), pending_init_operations_(0) { |
DVLOG(3) << "Initializing client."; |
pending_init_operations_++; |
- rpc_handler_.reset( |
- new RpcHandler(delegate, |
- base::Bind(&CopresenceClient::InitStepComplete, |
- AsWeakPtr(), |
- "Copresence device registration"))); |
+ rpc_handler_.reset(new RpcHandler(delegate)); |
+ // We own the RpcHandler, so it won't outlive us. |
+ rpc_handler_->Initialize(base::Bind(&CopresenceClient::InitStepComplete, |
+ base::Unretained(this), |
+ "Copresence device registration")); |
pending_init_operations_++; |
delegate_->GetWhispernetClient()->Initialize( |
base::Bind(&CopresenceClient::InitStepComplete, |
- AsWeakPtr(), |
+ // The WhispernetClient must discard this on Shutdown. |
willchan no longer on Chromium
2014/08/08 01:05:58
I like that you got rid of the AsWeakPtr(). It's i
rkc
2014/08/08 01:29:07
So this is actually a bug. If the whispernet clien
willchan no longer on Chromium
2014/08/08 18:01:20
I chatted with rkc@ offline about this, but I can'
Charlie
2014/08/08 21:57:52
Putting just this one back to AsWeakPtr(), and get
willchan no longer on Chromium
2014/08/08 22:53:33
Please don't use SupportsWeakPtr(), there's reason
Charlie
2014/08/08 23:38:30
Noted. Will fix after this is in.
|
+ base::Unretained(this), |
"Whispernet proxy initialization")); |
} |
CopresenceClient::~CopresenceClient() { |
-} |
- |
-void CopresenceClient::Shutdown() { |
- DVLOG(3) << "Shutting down client."; |
delegate_->GetWhispernetClient()->Shutdown(); |
- rpc_handler_->DisconnectFromWhispernet(); |
} |
// Returns false if any operations were malformed. |
@@ -76,7 +72,7 @@ void CopresenceClient::CompleteInitialization() { |
return; |
if (!init_failed_) |
- rpc_handler_->ConnectToWhispernet(delegate_->GetWhispernetClient()); |
+ rpc_handler_->ConnectToWhispernet(); |
for (std::vector<PendingRequest>::iterator request = |
pending_requests_queue_.begin(); |