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 GOOGLE_APIS_GCM_GCM_CLIENT_H_ | 5 #ifndef GOOGLE_APIS_GCM_GCM_CLIENT_H_ |
6 #define GOOGLE_APIS_GCM_GCM_CLIENT_H_ | 6 #define GOOGLE_APIS_GCM_GCM_CLIENT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "google_apis/gcm/base/gcm_export.h" | 13 #include "google_apis/gcm/base/gcm_export.h" |
14 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 14 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
15 | 15 |
16 template <class T> class scoped_refptr; | 16 template <class T> class scoped_refptr; |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 class FilePath; | 19 class FilePath; |
20 class SequencedTaskRunner; | 20 class SequencedTaskRunner; |
21 } | 21 } |
22 | 22 |
23 namespace checkin_proto { | |
24 class ChromeBuildProto; | |
25 } | |
26 | |
27 namespace net { | 23 namespace net { |
28 class URLRequestContextGetter; | 24 class URLRequestContextGetter; |
29 } | 25 } |
30 | 26 |
31 namespace gcm { | 27 namespace gcm { |
32 | 28 |
33 class Encryptor; | 29 class Encryptor; |
34 | 30 |
35 // Interface that encapsulates the network communications with the Google Cloud | 31 // Interface that encapsulates the network communications with the Google Cloud |
36 // Messaging server. This interface is not supposed to be thread-safe. | 32 // Messaging server. This interface is not supposed to be thread-safe. |
(...skipping 14 matching lines...) Expand all Loading... |
51 // Network socket error. | 47 // Network socket error. |
52 NETWORK_ERROR, | 48 NETWORK_ERROR, |
53 // Problem at the server. | 49 // Problem at the server. |
54 SERVER_ERROR, | 50 SERVER_ERROR, |
55 // Exceeded the specified TTL during message sending. | 51 // Exceeded the specified TTL during message sending. |
56 TTL_EXCEEDED, | 52 TTL_EXCEEDED, |
57 // Other errors. | 53 // Other errors. |
58 UNKNOWN_ERROR | 54 UNKNOWN_ERROR |
59 }; | 55 }; |
60 | 56 |
| 57 enum ChromePlatform { |
| 58 PLATFORM_WIN, |
| 59 PLATFORM_MAC, |
| 60 PLATFORM_LINUX, |
| 61 PLATFORM_CROS, |
| 62 PLATFORM_IOS, |
| 63 PLATFORM_ANDROID, |
| 64 PLATFORM_UNKNOWN |
| 65 }; |
| 66 |
| 67 enum ChromeChannel { |
| 68 CHANNEL_STABLE, |
| 69 CHANNEL_BETA, |
| 70 CHANNEL_DEV, |
| 71 CHANNEL_CANARY, |
| 72 CHANNEL_UNKNOWN |
| 73 }; |
| 74 |
| 75 struct GCM_EXPORT ChromeBuildInfo { |
| 76 ChromeBuildInfo(); |
| 77 ~ChromeBuildInfo(); |
| 78 |
| 79 ChromePlatform platform; |
| 80 ChromeChannel channel; |
| 81 std::string version; |
| 82 }; |
| 83 |
61 // Message data consisting of key-value pairs. | 84 // Message data consisting of key-value pairs. |
62 typedef std::map<std::string, std::string> MessageData; | 85 typedef std::map<std::string, std::string> MessageData; |
63 | 86 |
64 // Message to be delivered to the other party. | 87 // Message to be delivered to the other party. |
65 struct GCM_EXPORT OutgoingMessage { | 88 struct GCM_EXPORT OutgoingMessage { |
66 OutgoingMessage(); | 89 OutgoingMessage(); |
67 ~OutgoingMessage(); | 90 ~OutgoingMessage(); |
68 | 91 |
69 // Message ID. | 92 // Message ID. |
70 std::string id; | 93 std::string id; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // Called when activities are being recorded and a new activity has just | 189 // Called when activities are being recorded and a new activity has just |
167 // been recorded. | 190 // been recorded. |
168 virtual void OnActivityRecorded() = 0; | 191 virtual void OnActivityRecorded() = 0; |
169 }; | 192 }; |
170 | 193 |
171 GCMClient(); | 194 GCMClient(); |
172 virtual ~GCMClient(); | 195 virtual ~GCMClient(); |
173 | 196 |
174 // Begins initialization of the GCM Client. This will not trigger a | 197 // Begins initialization of the GCM Client. This will not trigger a |
175 // connection. | 198 // connection. |
176 // |chrome_build_proto|: chrome info, i.e., version, channel and etc. | 199 // |chrome_build_info|: chrome info, i.e., version, channel and etc. |
177 // |store_path|: path to the GCM store. | 200 // |store_path|: path to the GCM store. |
178 // |account_ids|: account IDs to be related to the device when checking in. | 201 // |account_ids|: account IDs to be related to the device when checking in. |
179 // |blocking_task_runner|: for running blocking file tasks. | 202 // |blocking_task_runner|: for running blocking file tasks. |
180 // |url_request_context_getter|: for url requests. | 203 // |url_request_context_getter|: for url requests. |
181 // |delegate|: the delegate whose methods will be called asynchronously in | 204 // |delegate|: the delegate whose methods will be called asynchronously in |
182 // response to events and messages. | 205 // response to events and messages. |
183 virtual void Initialize( | 206 virtual void Initialize( |
184 const checkin_proto::ChromeBuildProto& chrome_build_proto, | 207 const ChromeBuildInfo& chrome_build_info, |
185 const base::FilePath& store_path, | 208 const base::FilePath& store_path, |
186 const std::vector<std::string>& account_ids, | 209 const std::vector<std::string>& account_ids, |
187 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, | 210 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, |
188 const scoped_refptr<net::URLRequestContextGetter>& | 211 const scoped_refptr<net::URLRequestContextGetter>& |
189 url_request_context_getter, | 212 url_request_context_getter, |
190 scoped_ptr<Encryptor> encryptor, | 213 scoped_ptr<Encryptor> encryptor, |
191 Delegate* delegate) = 0; | 214 Delegate* delegate) = 0; |
192 | 215 |
193 // Starts the GCM service by first loading the data from the persistent store. | 216 // Starts the GCM service by first loading the data from the persistent store. |
194 // This will then kick off the check-in if the check-in info is not found in | 217 // This will then kick off the check-in if the check-in info is not found in |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 // Clear all recorded GCM activity logs. | 255 // Clear all recorded GCM activity logs. |
233 virtual void ClearActivityLogs() = 0; | 256 virtual void ClearActivityLogs() = 0; |
234 | 257 |
235 // Gets internal states and statistics. | 258 // Gets internal states and statistics. |
236 virtual GCMStatistics GetStatistics() const = 0; | 259 virtual GCMStatistics GetStatistics() const = 0; |
237 }; | 260 }; |
238 | 261 |
239 } // namespace gcm | 262 } // namespace gcm |
240 | 263 |
241 #endif // GOOGLE_APIS_GCM_GCM_CLIENT_H_ | 264 #endif // GOOGLE_APIS_GCM_GCM_CLIENT_H_ |
OLD | NEW |