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> |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 125 |
126 // Called when the GCM becomes ready. To get to this state, GCMClient | 126 // Called when the GCM becomes ready. To get to this state, GCMClient |
127 // finished loading from the GCM store and retrieved the device check-in | 127 // finished loading from the GCM store and retrieved the device check-in |
128 // from the server if it hadn't yet. | 128 // from the server if it hadn't yet. |
129 virtual void OnGCMReady() = 0; | 129 virtual void OnGCMReady() = 0; |
130 }; | 130 }; |
131 | 131 |
132 GCMClient(); | 132 GCMClient(); |
133 virtual ~GCMClient(); | 133 virtual ~GCMClient(); |
134 | 134 |
135 // Begins initialization of the GCM Client. | 135 // Begins initialization of the GCM Client. This will not trigger a |
| 136 // connection. |
136 // |chrome_build_proto|: chrome info, i.e., version, channel and etc. | 137 // |chrome_build_proto|: chrome info, i.e., version, channel and etc. |
137 // |store_path|: path to the GCM store. | 138 // |store_path|: path to the GCM store. |
138 // |blocking_task_runner|: for running blocking file tasks. | 139 // |blocking_task_runner|: for running blocking file tasks. |
139 // |url_request_context_getter|: for url requests. | 140 // |url_request_context_getter|: for url requests. |
140 // |delegate|: the delegate whose methods will be called asynchronously in | 141 // |delegate|: the delegate whose methods will be called asynchronously in |
141 // response to events and messages. | 142 // response to events and messages. |
142 virtual void Initialize( | 143 virtual void Initialize( |
143 const checkin_proto::ChromeBuildProto& chrome_build_proto, | 144 const checkin_proto::ChromeBuildProto& chrome_build_proto, |
144 const base::FilePath& store_path, | 145 const base::FilePath& store_path, |
145 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, | 146 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, |
146 const scoped_refptr<net::URLRequestContextGetter>& | 147 const scoped_refptr<net::URLRequestContextGetter>& |
147 url_request_context_getter, | 148 url_request_context_getter, |
148 Delegate* delegate) = 0; | 149 Delegate* delegate) = 0; |
149 | 150 |
| 151 // Loads the data from the persistent store. This will automatically kick off |
| 152 // the check-in if the check-in info is not found in the store. |
| 153 virtual void Load() = 0; |
| 154 |
150 // Checks out of the GCM service. This will erase all the cached and persisted | 155 // Checks out of the GCM service. This will erase all the cached and persisted |
151 // data. | 156 // data. |
152 virtual void CheckOut() = 0; | 157 virtual void CheckOut() = 0; |
153 | 158 |
154 // Registers the application for GCM. Delegate::OnRegisterFinished will be | 159 // Registers the application for GCM. Delegate::OnRegisterFinished will be |
155 // called asynchronously upon completion. | 160 // called asynchronously upon completion. |
156 // |app_id|: application ID. | 161 // |app_id|: application ID. |
157 // |cert|: SHA-1 of public key of the application, in base16 format. | 162 // |cert|: SHA-1 of public key of the application, in base16 format. |
158 // |sender_ids|: list of IDs of the servers that are allowed to send the | 163 // |sender_ids|: list of IDs of the servers that are allowed to send the |
159 // messages to the application. These IDs are assigned by the | 164 // messages to the application. These IDs are assigned by the |
160 // Google API Console. | 165 // Google API Console. |
161 virtual void Register(const std::string& app_id, | 166 virtual void Register(const std::string& app_id, |
162 const std::string& cert, | 167 const std::string& cert, |
163 const std::vector<std::string>& sender_ids) = 0; | 168 const std::vector<std::string>& sender_ids) = 0; |
164 | 169 |
165 // Unregisters the application from GCM when it is uninstalled. | 170 // Unregisters the application from GCM when it is uninstalled. |
166 // Delegate::OnUnregisterFinished will be called asynchronously upon | 171 // Delegate::OnUnregisterFinished will be called asynchronously upon |
167 // completion. | 172 // completion. |
168 // |app_id|: application ID. | 173 // |app_id|: application ID. |
169 virtual void Unregister(const std::string& app_id) = 0; | 174 virtual void Unregister(const std::string& app_id) = 0; |
170 | 175 |
171 // Sends a message to a given receiver. Delegate::OnSendFinished will be | 176 // Sends a message to a given receiver. Delegate::OnSendFinished will be |
172 // called asynchronously upon completion. | 177 // called asynchronously upon completion. |
173 // |app_id|: application ID. | 178 // |app_id|: application ID. |
174 // |receiver_id|: registration ID of the receiver party. | 179 // |receiver_id|: registration ID of the receiver party. |
175 // |message|: message to be sent. | 180 // |message|: message to be sent. |
176 virtual void Send(const std::string& app_id, | 181 virtual void Send(const std::string& app_id, |
177 const std::string& receiver_id, | 182 const std::string& receiver_id, |
178 const OutgoingMessage& message) = 0; | 183 const OutgoingMessage& message) = 0; |
179 | |
180 // Returns true if GCM becomes ready. | |
181 virtual bool IsReady() const = 0; | |
182 }; | 184 }; |
183 | 185 |
184 } // namespace gcm | 186 } // namespace gcm |
185 | 187 |
186 #endif // GOOGLE_APIS_GCM_GCM_CLIENT_H_ | 188 #endif // GOOGLE_APIS_GCM_GCM_CLIENT_H_ |
OLD | NEW |