| 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 <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 NETWORK_ERROR, | 34 NETWORK_ERROR, |
| 35 // Problem at the server. | 35 // Problem at the server. |
| 36 SERVER_ERROR, | 36 SERVER_ERROR, |
| 37 // Other errors. | 37 // Other errors. |
| 38 UNKNOWN_ERROR | 38 UNKNOWN_ERROR |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 // Asynchronous callbacks. | 41 // Asynchronous callbacks. |
| 42 typedef base::Callback<void(const std::string& app_id, | 42 typedef base::Callback<void(const std::string& app_id, |
| 43 bool update_id)> TokenRefreshCallback; | 43 bool update_id)> TokenRefreshCallback; |
| 44 typedef base::Callback<void(const std::string& id)> GetIDCallback; |
| 45 typedef base::Callback<void(const base::Time& creation_time)> |
| 46 GetCreationTimeCallback; |
| 44 typedef base::Callback<void(const std::string& token, | 47 typedef base::Callback<void(const std::string& token, |
| 45 Result result)> GetTokenCallback; | 48 Result result)> GetTokenCallback; |
| 46 typedef base::Callback<void(Result result)> DeleteTokenCallback; | 49 typedef base::Callback<void(Result result)> DeleteTokenCallback; |
| 47 typedef base::Callback<void(Result result)> DeleteIDCallback; | 50 typedef base::Callback<void(Result result)> DeleteIDCallback; |
| 48 | 51 |
| 49 static const int kInstanceIDByteLength = 8; | 52 static const int kInstanceIDByteLength = 8; |
| 50 | 53 |
| 51 // Creator. | 54 // Creator. |
| 52 // |app_id|: identifies the application that uses the Instance ID. | 55 // |app_id|: identifies the application that uses the Instance ID. |
| 53 // |gcm_driver|: driver to access the GCM functionalities needed to support | 56 // |gcm_driver|: driver to access the GCM functionalities needed to support |
| 54 // Instance ID. | 57 // Instance ID. |
| 55 static InstanceID* Create(const std::string& app_id, | 58 static InstanceID* Create(const std::string& app_id, |
| 56 gcm::GCMDriver* gcm_driver); | 59 gcm::GCMDriver* gcm_driver); |
| 57 | 60 |
| 58 virtual ~InstanceID(); | 61 virtual ~InstanceID(); |
| 59 | 62 |
| 60 // Sets the callback that will be invoked when the token refresh event needs | 63 // Sets the callback that will be invoked when the token refresh event needs |
| 61 // to be triggered. | 64 // to be triggered. |
| 62 void SetTokenRefreshCallback(const TokenRefreshCallback& callback); | 65 void SetTokenRefreshCallback(const TokenRefreshCallback& callback); |
| 63 | 66 |
| 64 // Returns the Instance ID. | 67 // Returns the Instance ID. |
| 65 virtual std::string GetID() = 0; | 68 virtual void GetID(const GetIDCallback& callback) = 0; |
| 66 | 69 |
| 67 // Returns the time when the InstanceID has been generated. | 70 // Returns the time when the InstanceID has been generated. |
| 68 virtual base::Time GetCreationTime() = 0; | 71 virtual void GetCreationTime(const GetCreationTimeCallback& callback) = 0; |
| 69 | 72 |
| 70 // Retrieves a token that allows the authorized entity to access the service | 73 // Retrieves a token that allows the authorized entity to access the service |
| 71 // defined as "scope". | 74 // defined as "scope". |
| 72 // |authorized_entity|: identifies the entity that is authorized to access | 75 // |authorized_entity|: identifies the entity that is authorized to access |
| 73 // resources associated with this Instance ID. It can be | 76 // resources associated with this Instance ID. It can be |
| 74 // another Instance ID or a project ID. | 77 // another Instance ID or a project ID. |
| 75 // |scope|: identifies authorized actions that the authorized entity can take. | 78 // |scope|: identifies authorized actions that the authorized entity can take. |
| 76 // E.g. for sending GCM messages, "GCM" scope should be used. | 79 // E.g. for sending GCM messages, "GCM" scope should be used. |
| 77 // |options|: allows including a small number of string key/value pairs that | 80 // |options|: allows including a small number of string key/value pairs that |
| 78 // will be associated with the token and may be used in processing | 81 // will be associated with the token and may be used in processing |
| (...skipping 28 matching lines...) Expand all Loading... |
| 107 private: | 110 private: |
| 108 std::string app_id_; | 111 std::string app_id_; |
| 109 TokenRefreshCallback token_refresh_callback_; | 112 TokenRefreshCallback token_refresh_callback_; |
| 110 | 113 |
| 111 DISALLOW_COPY_AND_ASSIGN(InstanceID); | 114 DISALLOW_COPY_AND_ASSIGN(InstanceID); |
| 112 }; | 115 }; |
| 113 | 116 |
| 114 } // namespace instance_id | 117 } // namespace instance_id |
| 115 | 118 |
| 116 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_H_ | 119 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_H_ |
| OLD | NEW |