summaryrefslogtreecommitdiffstats
path: root/components/copresence
diff options
context:
space:
mode:
authorckehoe <ckehoe@chromium.org>2014-12-02 15:56:42 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-02 23:57:05 +0000
commitf955f261c291d9a2b05c43c8f3475eb87d0e9a58 (patch)
tree01d2cf916337660589b46c32e1f5238de698c1e6 /components/copresence
parent4afe36b8c8d469dd7a76b0db8d26522ae5f01619 (diff)
downloadchromium_src-f955f261c291d9a2b05c43c8f3475eb87d0e9a58.zip
chromium_src-f955f261c291d9a2b05c43c8f3475eb87d0e9a58.tar.gz
chromium_src-f955f261c291d9a2b05c43c8f3475eb87d0e9a58.tar.bz2
Using a CancelableCallback in GcmHandler
Review URL: https://codereview.chromium.org/754223002 Cr-Commit-Position: refs/heads/master@{#306497}
Diffstat (limited to 'components/copresence')
-rw-r--r--components/copresence/handlers/gcm_handler_impl.cc4
-rw-r--r--components/copresence/handlers/gcm_handler_impl.h14
2 files changed, 8 insertions, 10 deletions
diff --git a/components/copresence/handlers/gcm_handler_impl.cc b/components/copresence/handlers/gcm_handler_impl.cc
index 24b9d8c..ccf7203 100644
--- a/components/copresence/handlers/gcm_handler_impl.cc
+++ b/components/copresence/handlers/gcm_handler_impl.cc
@@ -47,14 +47,14 @@ GCMHandlerImpl::GCMHandlerImpl(gcm::GCMDriver* gcm_driver,
: driver_(gcm_driver),
directive_handler_(directive_handler),
registration_callback_(base::Bind(&GCMHandlerImpl::RegistrationComplete,
- AsWeakPtr())) {
+ base::Unretained(this))) {
DCHECK(driver_);
DCHECK(directive_handler_);
driver_->AddAppHandler(kCopresenceAppId, this);
driver_->Register(kCopresenceAppId,
std::vector<std::string>(1, kCopresenceSenderId),
- registration_callback_);
+ registration_callback_.callback());
}
GCMHandlerImpl::~GCMHandlerImpl() {
diff --git a/components/copresence/handlers/gcm_handler_impl.h b/components/copresence/handlers/gcm_handler_impl.h
index 3160d3e..6ce12b8 100644
--- a/components/copresence/handlers/gcm_handler_impl.h
+++ b/components/copresence/handlers/gcm_handler_impl.h
@@ -8,8 +8,8 @@
#include <string>
#include <vector>
-#include "base/callback.h"
-#include "base/memory/weak_ptr.h"
+#include "base/callback_forward.h"
+#include "base/cancelable_callback.h"
#include "components/copresence/handlers/gcm_handler.h"
#include "components/gcm_driver/gcm_app_handler.h"
#include "components/gcm_driver/gcm_client.h"
@@ -24,8 +24,7 @@ class DirectiveHandler;
// This class handles GCM messages from the Copresence server.
class GCMHandlerImpl final : public GCMHandler,
- public gcm::GCMAppHandler,
- public base::SupportsWeakPtr<GCMHandlerImpl> {
+ public gcm::GCMAppHandler {
public:
// Callback to report that registration has completed.
// Returns an empty ID if registration failed.
@@ -67,13 +66,12 @@ class GCMHandlerImpl final : public GCMHandler,
gcm::GCMDriver* driver_;
DirectiveHandler* const directive_handler_;
- // TODO(ckehoe): Change this to a CancelableCallback.
- base::Callback<void(const std::string&,
- gcm::GCMClient::Result)> registration_callback_;
-
std::string gcm_id_;
std::vector<RegistrationCallback> pending_id_requests_;
+ base::CancelableCallback<void(const std::string&,
+ gcm::GCMClient::Result)> registration_callback_;
+
DISALLOW_COPY_AND_ASSIGN(GCMHandlerImpl);
};