OLD | NEW |
1 // Copyright 2014 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 COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ | 5 #ifndef COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ |
6 #define COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ | 6 #define COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 const std::string& sender_id); | 253 const std::string& sender_id); |
254 | 254 |
255 // Platform-specific implementation of Send. | 255 // Platform-specific implementation of Send. |
256 virtual void SendImpl(const std::string& app_id, | 256 virtual void SendImpl(const std::string& app_id, |
257 const std::string& receiver_id, | 257 const std::string& receiver_id, |
258 const OutgoingMessage& message) = 0; | 258 const OutgoingMessage& message) = 0; |
259 | 259 |
260 // Platform-specific implementation of recording message decryption failures. | 260 // Platform-specific implementation of recording message decryption failures. |
261 virtual void RecordDecryptionFailure( | 261 virtual void RecordDecryptionFailure( |
262 const std::string& app_id, | 262 const std::string& app_id, |
263 GCMEncryptionProvider::DecryptionFailure reason) = 0; | 263 GCMEncryptionProvider::DecryptionResult result) = 0; |
264 | 264 |
265 // Runs the Register callback. | 265 // Runs the Register callback. |
266 void RegisterFinished(const std::string& app_id, | 266 void RegisterFinished(const std::string& app_id, |
267 const std::string& registration_id, | 267 const std::string& registration_id, |
268 GCMClient::Result result); | 268 GCMClient::Result result); |
269 | 269 |
270 // To be called when a registration for |app_id| has been unregistered, having | 270 // To be called when a registration for |app_id| has been unregistered, having |
271 // |result| as the result of the unregistration. Will remove any encryption | 271 // |result| as the result of the unregistration. Will remove any encryption |
272 // information associated with the |app_id| and then calls UnregisterFinished. | 272 // information associated with the |app_id| and then calls UnregisterFinished. |
273 void RemoveEncryptionInfoAfterUnregister(const std::string& app_id, | 273 void RemoveEncryptionInfoAfterUnregister(const std::string& app_id, |
(...skipping 17 matching lines...) Expand all Loading... |
291 // |message| will be dispatched immediately to the handler for |app_id|. | 291 // |message| will be dispatched immediately to the handler for |app_id|. |
292 void DispatchMessage(const std::string& app_id, | 292 void DispatchMessage(const std::string& app_id, |
293 const IncomingMessage& message); | 293 const IncomingMessage& message); |
294 | 294 |
295 private: | 295 private: |
296 // Common code shared by Unregister and UnregisterWithSenderId. | 296 // Common code shared by Unregister and UnregisterWithSenderId. |
297 void UnregisterInternal(const std::string& app_id, | 297 void UnregisterInternal(const std::string& app_id, |
298 const std::string* sender_id, | 298 const std::string* sender_id, |
299 const UnregisterCallback& callback); | 299 const UnregisterCallback& callback); |
300 | 300 |
| 301 // Dispatches the OnMessage event to the app handler associated with |app_id| |
| 302 // if |result| indicates that it is safe to do so, or will report a decryption |
| 303 // failure for the |app_id| otherwise. |
| 304 void DispatchMessageInternal(const std::string& app_id, |
| 305 GCMEncryptionProvider::DecryptionResult result, |
| 306 const IncomingMessage& message); |
| 307 |
301 // Called after unregistration completes in order to trigger the pending | 308 // Called after unregistration completes in order to trigger the pending |
302 // registration. | 309 // registration. |
303 void RegisterAfterUnregister( | 310 void RegisterAfterUnregister( |
304 const std::string& app_id, | 311 const std::string& app_id, |
305 const std::vector<std::string>& normalized_sender_ids, | 312 const std::vector<std::string>& normalized_sender_ids, |
306 const UnregisterCallback& unregister_callback, | 313 const UnregisterCallback& unregister_callback, |
307 GCMClient::Result result); | 314 GCMClient::Result result); |
308 | 315 |
309 // Callback map (from app_id to callback) for Register. | 316 // Callback map (from app_id to callback) for Register. |
310 std::map<std::string, RegisterCallback> register_callbacks_; | 317 std::map<std::string, RegisterCallback> register_callbacks_; |
(...skipping 16 matching lines...) Expand all Loading... |
327 DefaultGCMAppHandler default_app_handler_; | 334 DefaultGCMAppHandler default_app_handler_; |
328 | 335 |
329 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; | 336 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; |
330 | 337 |
331 DISALLOW_COPY_AND_ASSIGN(GCMDriver); | 338 DISALLOW_COPY_AND_ASSIGN(GCMDriver); |
332 }; | 339 }; |
333 | 340 |
334 } // namespace gcm | 341 } // namespace gcm |
335 | 342 |
336 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ | 343 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ |
OLD | NEW |