Chromium Code Reviews| 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. |
|
Nicolas Zea
2014/02/21 18:58:59
mention that this will not trigger a connection ye
jianli
2014/02/21 20:24:06
Done.
| |
| 136 // |chrome_build_proto|: chrome info, i.e., version, channel and etc. | 136 // |chrome_build_proto|: chrome info, i.e., version, channel and etc. |
| 137 // |store_path|: path to the GCM store. | 137 // |store_path|: path to the GCM store. |
| 138 // |blocking_task_runner|: for running blocking file tasks. | 138 // |blocking_task_runner|: for running blocking file tasks. |
| 139 // |url_request_context_getter|: for url requests. | 139 // |url_request_context_getter|: for url requests. |
| 140 // |delegate|: the delegate whose methods will be called asynchronously in | 140 // |delegate|: the delegate whose methods will be called asynchronously in |
| 141 // response to events and messages. | 141 // response to events and messages. |
| 142 virtual void Initialize( | 142 virtual void Initialize( |
| 143 const checkin_proto::ChromeBuildProto& chrome_build_proto, | 143 const checkin_proto::ChromeBuildProto& chrome_build_proto, |
| 144 const base::FilePath& store_path, | 144 const base::FilePath& store_path, |
| 145 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, | 145 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, |
| 146 const scoped_refptr<net::URLRequestContextGetter>& | 146 const scoped_refptr<net::URLRequestContextGetter>& |
| 147 url_request_context_getter, | 147 url_request_context_getter, |
| 148 Delegate* delegate) = 0; | 148 Delegate* delegate) = 0; |
| 149 | 149 |
| 150 // Loads the data from the persistent store and starts checking in with GCM. | |
| 151 virtual void CheckIn() = 0; | |
|
Nicolas Zea
2014/02/21 18:58:59
Does it make more sense to call this Load() now? A
jianli
2014/02/21 20:24:06
Renamed to Load() added comment.
| |
| 152 | |
| 150 // Checks out of the GCM service. This will erase all the cached and persisted | 153 // Checks out of the GCM service. This will erase all the cached and persisted |
| 151 // data. | 154 // data. |
| 152 virtual void CheckOut() = 0; | 155 virtual void CheckOut() = 0; |
| 153 | 156 |
| 154 // Registers the application for GCM. Delegate::OnRegisterFinished will be | 157 // Registers the application for GCM. Delegate::OnRegisterFinished will be |
| 155 // called asynchronously upon completion. | 158 // called asynchronously upon completion. |
| 156 // |app_id|: application ID. | 159 // |app_id|: application ID. |
| 157 // |cert|: SHA-1 of public key of the application, in base16 format. | 160 // |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 | 161 // |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 | 162 // messages to the application. These IDs are assigned by the |
| 160 // Google API Console. | 163 // Google API Console. |
| 161 virtual void Register(const std::string& app_id, | 164 virtual void Register(const std::string& app_id, |
| 162 const std::string& cert, | 165 const std::string& cert, |
| 163 const std::vector<std::string>& sender_ids) = 0; | 166 const std::vector<std::string>& sender_ids) = 0; |
| 164 | 167 |
| 165 // Unregisters the application from GCM when it is uninstalled. | 168 // Unregisters the application from GCM when it is uninstalled. |
| 166 // Delegate::OnUnregisterFinished will be called asynchronously upon | 169 // Delegate::OnUnregisterFinished will be called asynchronously upon |
| 167 // completion. | 170 // completion. |
| 168 // |app_id|: application ID. | 171 // |app_id|: application ID. |
| 169 virtual void Unregister(const std::string& app_id) = 0; | 172 virtual void Unregister(const std::string& app_id) = 0; |
| 170 | 173 |
| 171 // Sends a message to a given receiver. Delegate::OnSendFinished will be | 174 // Sends a message to a given receiver. Delegate::OnSendFinished will be |
| 172 // called asynchronously upon completion. | 175 // called asynchronously upon completion. |
| 173 // |app_id|: application ID. | 176 // |app_id|: application ID. |
| 174 // |receiver_id|: registration ID of the receiver party. | 177 // |receiver_id|: registration ID of the receiver party. |
| 175 // |message|: message to be sent. | 178 // |message|: message to be sent. |
| 176 virtual void Send(const std::string& app_id, | 179 virtual void Send(const std::string& app_id, |
| 177 const std::string& receiver_id, | 180 const std::string& receiver_id, |
| 178 const OutgoingMessage& message) = 0; | 181 const OutgoingMessage& message) = 0; |
| 179 | |
| 180 // Returns true if GCM becomes ready. | |
| 181 virtual bool IsReady() const = 0; | |
| 182 }; | 182 }; |
| 183 | 183 |
| 184 } // namespace gcm | 184 } // namespace gcm |
| 185 | 185 |
| 186 #endif // GOOGLE_APIS_GCM_GCM_CLIENT_H_ | 186 #endif // GOOGLE_APIS_GCM_GCM_CLIENT_H_ |
| OLD | NEW |