OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_COPRESENCE_HANDLERS_GCM_HANDLER_H_ | |
6 #define COMPONENTS_COPRESENCE_HANDLERS_GCM_HANDLER_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/callback_forward.h" | |
12 #include "components/gcm_driver/gcm_app_handler.h" | |
13 #include "components/gcm_driver/gcm_client.h" | |
14 | |
15 namespace gcm { | |
16 class GCMDriver; | |
17 } | |
18 | |
19 namespace copresence { | |
20 | |
21 class DirectiveHandler; | |
22 | |
23 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.
| |
24 public: | |
25 // Callback to report that registration has completed. | |
26 // Returns an empty ID if registration failed. | |
27 typedef base::Callback<void(const std::string&)> RegistrationCallback; | |
28 | |
29 static const char kCopresenceAppId[]; | |
30 static const char kCopresenceSenderId[]; | |
31 static const char kGcmMessageKey[]; | |
32 | |
33 // |gcm_driver| is required, but may disappear if we get a ShutdownHandler() | |
34 // call first. |directive_handler| must outlive us. The caller owns both. | |
35 GCMHandler(gcm::GCMDriver* gcm_driver, | |
36 DirectiveHandler* directive_handler); | |
37 ~GCMHandler() override; | |
38 | |
39 void RegistrationComplete(const std::string& registration_id, | |
40 gcm::GCMClient::Result result); | |
41 void GetGcmId(const RegistrationCallback& callback); | |
42 | |
43 // GCMAppHandler implementation | |
44 | |
45 void ShutdownHandler() override; | |
46 | |
47 void OnMessage(const std::string& app_id, | |
48 const gcm::GCMClient::IncomingMessage& message) override; | |
49 void OnMessagesDeleted(const std::string& app_id) override; | |
50 | |
51 void OnSendError( | |
52 const std::string& app_id, | |
53 const gcm::GCMClient::SendErrorDetails& send_error_details) override; | |
54 void OnSendAcknowledged(const std::string& app_id, | |
55 const std::string& message_id) override; | |
56 | |
57 bool CanHandle(const std::string& app_id) const override; | |
58 | |
59 private: | |
60 gcm::GCMDriver* driver_; | |
61 DirectiveHandler* const directive_handler_; | |
62 | |
63 std::string gcm_id_; | |
64 std::vector<RegistrationCallback> pending_id_requests_; | |
65 | |
66 DISALLOW_COPY_AND_ASSIGN(GCMHandler); | |
67 }; | |
68 | |
69 } // namespace copresence | |
70 | |
71 #endif // COMPONENTS_COPRESENCE_HANDLERS_GCM_HANDLER_H_ | |
OLD | NEW |