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

Unified Diff: components/copresence/handlers/gcm_handler.h

Issue 710513004: Adding GCM support to the copresence component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding a unit test Created 6 years, 1 month 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/handlers/gcm_handler.h
diff --git a/components/copresence/handlers/gcm_handler.h b/components/copresence/handlers/gcm_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..cc1460ac7c4bd6930825f14813ca7cdb74bbae49
--- /dev/null
+++ b/components/copresence/handlers/gcm_handler.h
@@ -0,0 +1,71 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_COPRESENCE_HANDLERS_GCM_HANDLER_H_
+#define COMPONENTS_COPRESENCE_HANDLERS_GCM_HANDLER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/callback_forward.h"
+#include "components/gcm_driver/gcm_app_handler.h"
+#include "components/gcm_driver/gcm_client.h"
+
+namespace gcm {
+class GCMDriver;
+}
+
+namespace copresence {
+
+class DirectiveHandler;
+
+class GCMHandler final : public gcm::GCMAppHandler {
fgorski 2014/11/07 17:40:44 Document the class and methods that are not overri
Charlie 2014/11/07 19:42:30 Done.
+ public:
+ // Callback to report that registration has completed.
+ // Returns an empty ID if registration failed.
+ typedef base::Callback<void(const std::string&)> RegistrationCallback;
+
+ static const char kCopresenceAppId[];
+ static const char kCopresenceSenderId[];
+ static const char kGcmMessageKey[];
+
+ // |gcm_driver| is required, but may disappear if we get a ShutdownHandler()
+ // call first. |directive_handler| must outlive us. The caller owns both.
+ GCMHandler(gcm::GCMDriver* gcm_driver,
+ DirectiveHandler* directive_handler);
+ ~GCMHandler() override;
+
+ void RegistrationComplete(const std::string& registration_id,
+ gcm::GCMClient::Result result);
+ void GetGcmId(const RegistrationCallback& callback);
+
+ // GCMAppHandler implementation
+
+ void ShutdownHandler() override;
+
+ void OnMessage(const std::string& app_id,
+ const gcm::GCMClient::IncomingMessage& message) override;
+ void OnMessagesDeleted(const std::string& app_id) override;
+
+ void OnSendError(
+ const std::string& app_id,
+ const gcm::GCMClient::SendErrorDetails& send_error_details) override;
+ void OnSendAcknowledged(const std::string& app_id,
+ const std::string& message_id) override;
+
+ bool CanHandle(const std::string& app_id) const override;
+
+ private:
+ gcm::GCMDriver* driver_;
+ DirectiveHandler* const directive_handler_;
+
+ std::string gcm_id_;
+ std::vector<RegistrationCallback> pending_id_requests_;
+
+ DISALLOW_COPY_AND_ASSIGN(GCMHandler);
+};
+
+} // namespace copresence
+
+#endif // COMPONENTS_COPRESENCE_HANDLERS_GCM_HANDLER_H_

Powered by Google App Engine
This is Rietveld 408576698