OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 COMPONENTS_GCM_DRIVER_GCM_CLIENT_H_ |
6 #define GOOGLE_APIS_GCM_GCM_CLIENT_H_ | 6 #define COMPONENTS_GCM_DRIVER_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 "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "google_apis/gcm/base/gcm_export.h" | 14 #include "components/gcm_driver/gcm_activity.h" |
15 #include "google_apis/gcm/gcm_activity.h" | |
16 | 15 |
17 template <class T> class scoped_refptr; | 16 template <class T> class scoped_refptr; |
18 | 17 |
19 namespace base { | 18 namespace base { |
20 class FilePath; | 19 class FilePath; |
21 class SequencedTaskRunner; | 20 class SequencedTaskRunner; |
22 } | 21 } |
23 | 22 |
24 namespace net { | 23 namespace net { |
25 class URLRequestContextGetter; | 24 class URLRequestContextGetter; |
26 } | 25 } |
27 | 26 |
28 namespace gcm { | 27 namespace gcm { |
29 | 28 |
30 class Encryptor; | 29 class Encryptor; |
31 | 30 |
32 // Interface that encapsulates the network communications with the Google Cloud | 31 // Interface that encapsulates the network communications with the Google Cloud |
33 // Messaging server. This interface is not supposed to be thread-safe. | 32 // Messaging server. This interface is not supposed to be thread-safe. |
34 class GCM_EXPORT GCMClient { | 33 class GCMClient { |
35 public: | 34 public: |
36 enum Result { | 35 enum Result { |
37 // Successful operation. | 36 // Successful operation. |
38 SUCCESS, | 37 SUCCESS, |
39 // Invalid parameter. | 38 // Invalid parameter. |
40 INVALID_PARAMETER, | 39 INVALID_PARAMETER, |
41 // GCM is disabled. | 40 // GCM is disabled. |
42 GCM_DISABLED, | 41 GCM_DISABLED, |
43 // Profile not signed in. | 42 // Profile not signed in. |
44 NOT_SIGNED_IN, | 43 NOT_SIGNED_IN, |
(...skipping 21 matching lines...) Expand all Loading... |
66 }; | 65 }; |
67 | 66 |
68 enum ChromeChannel { | 67 enum ChromeChannel { |
69 CHANNEL_STABLE, | 68 CHANNEL_STABLE, |
70 CHANNEL_BETA, | 69 CHANNEL_BETA, |
71 CHANNEL_DEV, | 70 CHANNEL_DEV, |
72 CHANNEL_CANARY, | 71 CHANNEL_CANARY, |
73 CHANNEL_UNKNOWN | 72 CHANNEL_UNKNOWN |
74 }; | 73 }; |
75 | 74 |
76 struct GCM_EXPORT ChromeBuildInfo { | 75 struct ChromeBuildInfo { |
77 ChromeBuildInfo(); | 76 ChromeBuildInfo(); |
78 ~ChromeBuildInfo(); | 77 ~ChromeBuildInfo(); |
79 | 78 |
80 ChromePlatform platform; | 79 ChromePlatform platform; |
81 ChromeChannel channel; | 80 ChromeChannel channel; |
82 std::string version; | 81 std::string version; |
83 }; | 82 }; |
84 | 83 |
85 // Message data consisting of key-value pairs. | 84 // Message data consisting of key-value pairs. |
86 typedef std::map<std::string, std::string> MessageData; | 85 typedef std::map<std::string, std::string> MessageData; |
87 | 86 |
88 // Message to be delivered to the other party. | 87 // Message to be delivered to the other party. |
89 struct GCM_EXPORT OutgoingMessage { | 88 struct OutgoingMessage { |
90 OutgoingMessage(); | 89 OutgoingMessage(); |
91 ~OutgoingMessage(); | 90 ~OutgoingMessage(); |
92 | 91 |
93 // Message ID. | 92 // Message ID. |
94 std::string id; | 93 std::string id; |
95 // In seconds. | 94 // In seconds. |
96 int time_to_live; | 95 int time_to_live; |
97 MessageData data; | 96 MessageData data; |
98 | 97 |
99 static const int kMaximumTTL = 4 * 7 * 24 * 60 * 60; // 4 weeks. | 98 static const int kMaximumTTL = 4 * 7 * 24 * 60 * 60; // 4 weeks. |
100 }; | 99 }; |
101 | 100 |
102 // Message being received from the other party. | 101 // Message being received from the other party. |
103 struct GCM_EXPORT IncomingMessage { | 102 struct IncomingMessage { |
104 IncomingMessage(); | 103 IncomingMessage(); |
105 ~IncomingMessage(); | 104 ~IncomingMessage(); |
106 | 105 |
107 MessageData data; | 106 MessageData data; |
108 std::string collapse_key; | 107 std::string collapse_key; |
109 std::string sender_id; | 108 std::string sender_id; |
110 }; | 109 }; |
111 | 110 |
112 // Detailed information of the Send Error event. | 111 // Detailed information of the Send Error event. |
113 struct GCM_EXPORT SendErrorDetails { | 112 struct SendErrorDetails { |
114 SendErrorDetails(); | 113 SendErrorDetails(); |
115 ~SendErrorDetails(); | 114 ~SendErrorDetails(); |
116 | 115 |
117 std::string message_id; | 116 std::string message_id; |
118 MessageData additional_data; | 117 MessageData additional_data; |
119 Result result; | 118 Result result; |
120 }; | 119 }; |
121 | 120 |
122 // Internal states and activity statistics of a GCM client. | 121 // Internal states and activity statistics of a GCM client. |
123 struct GCM_EXPORT GCMStatistics { | 122 struct GCMStatistics { |
124 public: | 123 public: |
125 GCMStatistics(); | 124 GCMStatistics(); |
126 ~GCMStatistics(); | 125 ~GCMStatistics(); |
127 | 126 |
128 bool is_recording; | 127 bool is_recording; |
129 bool gcm_client_created; | 128 bool gcm_client_created; |
130 std::string gcm_client_state; | 129 std::string gcm_client_state; |
131 bool connection_client_created; | 130 bool connection_client_created; |
132 std::string connection_state; | 131 std::string connection_state; |
133 uint64 android_id; | 132 uint64 android_id; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 | 254 |
256 // Clear all recorded GCM activity logs. | 255 // Clear all recorded GCM activity logs. |
257 virtual void ClearActivityLogs() = 0; | 256 virtual void ClearActivityLogs() = 0; |
258 | 257 |
259 // Gets internal states and statistics. | 258 // Gets internal states and statistics. |
260 virtual GCMStatistics GetStatistics() const = 0; | 259 virtual GCMStatistics GetStatistics() const = 0; |
261 }; | 260 }; |
262 | 261 |
263 } // namespace gcm | 262 } // namespace gcm |
264 | 263 |
265 #endif // GOOGLE_APIS_GCM_GCM_CLIENT_H_ | 264 #endif // COMPONENTS_GCM_DRIVER_GCM_CLIENT_H_ |
OLD | NEW |