| 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 // |account_ids|: account IDs to be related to the device when checking in. | 139 // |account_ids|: account IDs to be related to the device when checking in. |
| 139 // |blocking_task_runner|: for running blocking file tasks. | 140 // |blocking_task_runner|: for running blocking file tasks. |
| 140 // |url_request_context_getter|: for url requests. | 141 // |url_request_context_getter|: for url requests. |
| 141 // |delegate|: the delegate whose methods will be called asynchronously in | 142 // |delegate|: the delegate whose methods will be called asynchronously in |
| 142 // response to events and messages. | 143 // response to events and messages. |
| 143 virtual void Initialize( | 144 virtual void Initialize( |
| 144 const checkin_proto::ChromeBuildProto& chrome_build_proto, | 145 const checkin_proto::ChromeBuildProto& chrome_build_proto, |
| 145 const base::FilePath& store_path, | 146 const base::FilePath& store_path, |
| 146 const std::vector<std::string>& account_ids, | 147 const std::vector<std::string>& account_ids, |
| 147 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, | 148 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, |
| 148 const scoped_refptr<net::URLRequestContextGetter>& | 149 const scoped_refptr<net::URLRequestContextGetter>& |
| 149 url_request_context_getter, | 150 url_request_context_getter, |
| 150 Delegate* delegate) = 0; | 151 Delegate* delegate) = 0; |
| 151 | 152 |
| 153 // Loads the data from the persistent store. This will automatically kick off |
| 154 // the check-in if the check-in info is not found in the store. |
| 155 virtual void Load() = 0; |
| 156 |
| 152 // Checks out of the GCM service. This will erase all the cached and persisted | 157 // Checks out of the GCM service. This will erase all the cached and persisted |
| 153 // data. | 158 // data. |
| 154 virtual void CheckOut() = 0; | 159 virtual void CheckOut() = 0; |
| 155 | 160 |
| 156 // Registers the application for GCM. Delegate::OnRegisterFinished will be | 161 // Registers the application for GCM. Delegate::OnRegisterFinished will be |
| 157 // called asynchronously upon completion. | 162 // called asynchronously upon completion. |
| 158 // |app_id|: application ID. | 163 // |app_id|: application ID. |
| 159 // |cert|: SHA-1 of public key of the application, in base16 format. | 164 // |cert|: SHA-1 of public key of the application, in base16 format. |
| 160 // |sender_ids|: list of IDs of the servers that are allowed to send the | 165 // |sender_ids|: list of IDs of the servers that are allowed to send the |
| 161 // messages to the application. These IDs are assigned by the | 166 // messages to the application. These IDs are assigned by the |
| 162 // Google API Console. | 167 // Google API Console. |
| 163 virtual void Register(const std::string& app_id, | 168 virtual void Register(const std::string& app_id, |
| 164 const std::string& cert, | 169 const std::string& cert, |
| 165 const std::vector<std::string>& sender_ids) = 0; | 170 const std::vector<std::string>& sender_ids) = 0; |
| 166 | 171 |
| 167 // Unregisters the application from GCM when it is uninstalled. | 172 // Unregisters the application from GCM when it is uninstalled. |
| 168 // Delegate::OnUnregisterFinished will be called asynchronously upon | 173 // Delegate::OnUnregisterFinished will be called asynchronously upon |
| 169 // completion. | 174 // completion. |
| 170 // |app_id|: application ID. | 175 // |app_id|: application ID. |
| 171 virtual void Unregister(const std::string& app_id) = 0; | 176 virtual void Unregister(const std::string& app_id) = 0; |
| 172 | 177 |
| 173 // Sends a message to a given receiver. Delegate::OnSendFinished will be | 178 // Sends a message to a given receiver. Delegate::OnSendFinished will be |
| 174 // called asynchronously upon completion. | 179 // called asynchronously upon completion. |
| 175 // |app_id|: application ID. | 180 // |app_id|: application ID. |
| 176 // |receiver_id|: registration ID of the receiver party. | 181 // |receiver_id|: registration ID of the receiver party. |
| 177 // |message|: message to be sent. | 182 // |message|: message to be sent. |
| 178 virtual void Send(const std::string& app_id, | 183 virtual void Send(const std::string& app_id, |
| 179 const std::string& receiver_id, | 184 const std::string& receiver_id, |
| 180 const OutgoingMessage& message) = 0; | 185 const OutgoingMessage& message) = 0; |
| 181 | |
| 182 // Returns true if GCM becomes ready. | |
| 183 virtual bool IsReady() const = 0; | |
| 184 }; | 186 }; |
| 185 | 187 |
| 186 } // namespace gcm | 188 } // namespace gcm |
| 187 | 189 |
| 188 #endif // GOOGLE_APIS_GCM_GCM_CLIENT_H_ | 190 #endif // GOOGLE_APIS_GCM_GCM_CLIENT_H_ |
| OLD | NEW |