summaryrefslogtreecommitdiffstats
path: root/components/copresence
diff options
context:
space:
mode:
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);
};