Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_INSTANCE_ID_INSTANCE_ID_H_ | 5 #ifndef COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_H_ |
| 6 #define COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_H_ | 6 #define COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 | 15 |
| 16 namespace gcm { | 16 namespace gcm { |
| 17 class InstanceIDHandler; | 17 class InstanceIDHandler; |
| 18 } // namespace gcm | 18 } // namespace gcm |
| 19 | 19 |
| 20 namespace instance_id { | 20 namespace instance_id { |
| 21 | 21 |
| 22 // Encapsulates Instance ID functionalities that need to be implemented for | 22 // Encapsulates Instance ID functionalities that need to be implemented for |
| 23 // different platform. One instance is created per application. Life of | 23 // different platforms. One instance is created per application. Life of |
| 24 // Instance ID is managed by the InstanceIdDriver. | 24 // Instance ID is managed by the InstanceIDDriver. |
| 25 class InstanceID { | 25 class InstanceID { |
| 26 public: | 26 public: |
| 27 enum Result { | 27 enum Result { |
| 28 // Successful operation. | 28 // Successful operation. |
| 29 SUCCESS, | 29 SUCCESS, |
| 30 // Invalid parameter. | 30 // Invalid parameter. |
| 31 INVALID_PARAMETER, | 31 INVALID_PARAMETER, |
| 32 // Instance ID is disabled. | 32 // Instance ID is disabled. |
| 33 DISABLED, | 33 DISABLED, |
| 34 // Previous asynchronous operation is still pending to finish. | 34 // Previous asynchronous operation is still pending to finish. |
| 35 ASYNC_OPERATION_PENDING, | 35 ASYNC_OPERATION_PENDING, |
| 36 // Network socket error. | 36 // Network socket error. |
| 37 NETWORK_ERROR, | 37 NETWORK_ERROR, |
| 38 // Problem at the server. | 38 // Problem at the server. |
| 39 SERVER_ERROR, | 39 SERVER_ERROR, |
| 40 // Other errors. | 40 // Other errors. |
| 41 UNKNOWN_ERROR | 41 UNKNOWN_ERROR |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 // Asynchronous callbacks. | 44 // Asynchronous callbacks. Must not synchronously delete this (using |
|
Peter Beverloo
2016/04/27 10:56:37
nit: reads slightly easier if you'd use |this| (ze
johnme
2016/04/27 18:03:57
Done.
| |
| 45 // InstanceIDDriver::RemoveInstanceID). | |
| 45 typedef base::Callback<void(const std::string& app_id, | 46 typedef base::Callback<void(const std::string& app_id, |
| 46 bool update_id)> TokenRefreshCallback; | 47 bool update_id)> TokenRefreshCallback; |
| 47 typedef base::Callback<void(const std::string& id)> GetIDCallback; | 48 typedef base::Callback<void(const std::string& id)> GetIDCallback; |
| 48 typedef base::Callback<void(const base::Time& creation_time)> | 49 typedef base::Callback<void(const base::Time& creation_time)> |
| 49 GetCreationTimeCallback; | 50 GetCreationTimeCallback; |
| 50 typedef base::Callback<void(const std::string& token, | 51 typedef base::Callback<void(const std::string& token, |
| 51 Result result)> GetTokenCallback; | 52 Result result)> GetTokenCallback; |
| 52 typedef base::Callback<void(Result result)> DeleteTokenCallback; | 53 typedef base::Callback<void(Result result)> DeleteTokenCallback; |
| 53 typedef base::Callback<void(Result result)> DeleteIDCallback; | 54 typedef base::Callback<void(Result result)> DeleteIDCallback; |
| 54 | 55 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 private: | 114 private: |
| 114 std::string app_id_; | 115 std::string app_id_; |
| 115 TokenRefreshCallback token_refresh_callback_; | 116 TokenRefreshCallback token_refresh_callback_; |
| 116 | 117 |
| 117 DISALLOW_COPY_AND_ASSIGN(InstanceID); | 118 DISALLOW_COPY_AND_ASSIGN(InstanceID); |
| 118 }; | 119 }; |
| 119 | 120 |
| 120 } // namespace instance_id | 121 } // namespace instance_id |
| 121 | 122 |
| 122 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_H_ | 123 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_H_ |
| OLD | NEW |