OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_GCM_GCM_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_GCM_GCM_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_GCM_GCM_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_GCM_GCM_API_H_ |
7 | 7 |
8 #include "chrome/common/extensions/api/gcm.h" | 8 #include "chrome/common/extensions/api/gcm.h" |
9 #include "components/gcm_driver/gcm_client.h" | 9 #include "components/gcm_driver/gcm_client.h" |
10 #include "extensions/browser/extension_function.h" | 10 #include "extensions/browser/extension_function.h" |
11 | 11 |
12 namespace gcm { | 12 namespace gcm { |
13 class GCMDriver; | 13 class GCMDriver; |
14 class GCMProfileService; | 14 class GCMProfileService; |
15 } // namespace gcm | 15 } // namespace gcm |
16 | 16 |
17 class Profile; | 17 class Profile; |
18 | 18 |
19 namespace extensions { | 19 namespace extensions { |
20 | 20 |
21 class GcmApiFunction : public AsyncExtensionFunction { | 21 class GcmApiFunction : public AsyncExtensionFunction { |
22 public: | 22 public: |
23 GcmApiFunction() {} | 23 GcmApiFunction() {} |
24 | 24 |
25 protected: | 25 protected: |
26 virtual ~GcmApiFunction() {} | 26 virtual ~GcmApiFunction() {} |
27 | 27 |
28 // ExtensionFunction: | 28 // ExtensionFunction: |
29 virtual bool RunAsync() OVERRIDE FINAL; | 29 virtual bool RunAsync() override final; |
30 | 30 |
31 // Actual implementation of specific functions. | 31 // Actual implementation of specific functions. |
32 virtual bool DoWork() = 0; | 32 virtual bool DoWork() = 0; |
33 | 33 |
34 // Checks that the GCM API is enabled. | 34 // Checks that the GCM API is enabled. |
35 bool IsGcmApiEnabled() const; | 35 bool IsGcmApiEnabled() const; |
36 | 36 |
37 gcm::GCMDriver* GetGCMDriver() const; | 37 gcm::GCMDriver* GetGCMDriver() const; |
38 }; | 38 }; |
39 | 39 |
40 class GcmRegisterFunction : public GcmApiFunction { | 40 class GcmRegisterFunction : public GcmApiFunction { |
41 public: | 41 public: |
42 DECLARE_EXTENSION_FUNCTION("gcm.register", GCM_REGISTER); | 42 DECLARE_EXTENSION_FUNCTION("gcm.register", GCM_REGISTER); |
43 | 43 |
44 GcmRegisterFunction(); | 44 GcmRegisterFunction(); |
45 | 45 |
46 protected: | 46 protected: |
47 virtual ~GcmRegisterFunction(); | 47 virtual ~GcmRegisterFunction(); |
48 | 48 |
49 // Register function implementation. | 49 // Register function implementation. |
50 virtual bool DoWork() OVERRIDE FINAL; | 50 virtual bool DoWork() override final; |
51 | 51 |
52 private: | 52 private: |
53 void CompleteFunctionWithResult(const std::string& registration_id, | 53 void CompleteFunctionWithResult(const std::string& registration_id, |
54 gcm::GCMClient::Result result); | 54 gcm::GCMClient::Result result); |
55 }; | 55 }; |
56 | 56 |
57 class GcmUnregisterFunction : public GcmApiFunction { | 57 class GcmUnregisterFunction : public GcmApiFunction { |
58 public: | 58 public: |
59 DECLARE_EXTENSION_FUNCTION("gcm.unregister", GCM_UNREGISTER); | 59 DECLARE_EXTENSION_FUNCTION("gcm.unregister", GCM_UNREGISTER); |
60 | 60 |
61 GcmUnregisterFunction(); | 61 GcmUnregisterFunction(); |
62 | 62 |
63 protected: | 63 protected: |
64 virtual ~GcmUnregisterFunction(); | 64 virtual ~GcmUnregisterFunction(); |
65 | 65 |
66 // Register function implementation. | 66 // Register function implementation. |
67 virtual bool DoWork() OVERRIDE FINAL; | 67 virtual bool DoWork() override final; |
68 | 68 |
69 private: | 69 private: |
70 void CompleteFunctionWithResult(gcm::GCMClient::Result result); | 70 void CompleteFunctionWithResult(gcm::GCMClient::Result result); |
71 }; | 71 }; |
72 | 72 |
73 class GcmSendFunction : public GcmApiFunction { | 73 class GcmSendFunction : public GcmApiFunction { |
74 public: | 74 public: |
75 DECLARE_EXTENSION_FUNCTION("gcm.send", GCM_SEND); | 75 DECLARE_EXTENSION_FUNCTION("gcm.send", GCM_SEND); |
76 | 76 |
77 GcmSendFunction(); | 77 GcmSendFunction(); |
78 | 78 |
79 protected: | 79 protected: |
80 virtual ~GcmSendFunction(); | 80 virtual ~GcmSendFunction(); |
81 | 81 |
82 // Send function implementation. | 82 // Send function implementation. |
83 virtual bool DoWork() OVERRIDE FINAL; | 83 virtual bool DoWork() override final; |
84 | 84 |
85 private: | 85 private: |
86 void CompleteFunctionWithResult(const std::string& message_id, | 86 void CompleteFunctionWithResult(const std::string& message_id, |
87 gcm::GCMClient::Result result); | 87 gcm::GCMClient::Result result); |
88 | 88 |
89 // Validates that message data do not carry invalid keys and fit into | 89 // Validates that message data do not carry invalid keys and fit into |
90 // allowable size limits. | 90 // allowable size limits. |
91 bool ValidateMessageData(const gcm::GCMClient::MessageData& data) const; | 91 bool ValidateMessageData(const gcm::GCMClient::MessageData& data) const; |
92 }; | 92 }; |
93 | 93 |
(...skipping 11 matching lines...) Expand all Loading... |
105 | 105 |
106 private: | 106 private: |
107 // The application we route the event to is running in context of the | 107 // The application we route the event to is running in context of the |
108 // |profile_| and the latter outlives the event router. | 108 // |profile_| and the latter outlives the event router. |
109 Profile* profile_; | 109 Profile* profile_; |
110 }; | 110 }; |
111 | 111 |
112 } // namespace extensions | 112 } // namespace extensions |
113 | 113 |
114 #endif // CHROME_BROWSER_EXTENSIONS_API_GCM_GCM_API_H_ | 114 #endif // CHROME_BROWSER_EXTENSIONS_API_GCM_GCM_API_H_ |
OLD | NEW |