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

Unified Diff: components/copresence/copresence_client.cc

Issue 433283002: Adding the Copresence RpcHandler and HttpPost helper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@directive-handler
Patch Set: Addressing nits Created 6 years, 4 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: 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();

Powered by Google App Engine
This is Rietveld 408576698