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> |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 using GetTokenCallback = | 59 using GetTokenCallback = |
60 base::Callback<void(const std::string& token, Result result)>; | 60 base::Callback<void(const std::string& token, Result result)>; |
61 using ValidateTokenCallback = base::Callback<void(bool is_valid)>; | 61 using ValidateTokenCallback = base::Callback<void(bool is_valid)>; |
62 using GetEncryptionInfoCallback = | 62 using GetEncryptionInfoCallback = |
63 base::Callback<void(const std::string&, const std::string&)>; | 63 base::Callback<void(const std::string&, const std::string&)>; |
64 using DeleteTokenCallback = base::Callback<void(Result result)>; | 64 using DeleteTokenCallback = base::Callback<void(Result result)>; |
65 using DeleteIDCallback = base::Callback<void(Result result)>; | 65 using DeleteIDCallback = base::Callback<void(Result result)>; |
66 | 66 |
67 static const int kInstanceIDByteLength = 8; | 67 static const int kInstanceIDByteLength = 8; |
68 | 68 |
69 // Creator. Should only be used by InstanceIDDriver::GetInstanceID. | |
70 // |app_id|: identifies the application that uses the Instance ID. | |
71 // |handler|: provides the GCM functionality needed to support Instance ID. | |
72 // Must outlive this class. On Android, this can be null instead. | |
73 static std::unique_ptr<InstanceID> CreateInternal(const std::string& app_id, | |
74 gcm::GCMDriver* gcm_driver); | |
75 | |
76 virtual ~InstanceID(); | 69 virtual ~InstanceID(); |
77 | 70 |
78 // Sets the callback that will be invoked when the token refresh event needs | 71 // Sets the callback that will be invoked when the token refresh event needs |
79 // to be triggered. | 72 // to be triggered. |
80 void SetTokenRefreshCallback(const TokenRefreshCallback& callback); | 73 void SetTokenRefreshCallback(const TokenRefreshCallback& callback); |
81 | 74 |
82 // Returns the Instance ID. | 75 // Returns the Instance ID. |
83 virtual void GetID(const GetIDCallback& callback) = 0; | 76 virtual void GetID(const GetIDCallback& callback) = 0; |
84 | 77 |
85 // Returns the time when the InstanceID has been generated. | 78 // Returns the time when the InstanceID has been generated. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 TokenRefreshCallback token_refresh_callback_; | 150 TokenRefreshCallback token_refresh_callback_; |
158 | 151 |
159 base::WeakPtrFactory<InstanceID> weak_ptr_factory_; | 152 base::WeakPtrFactory<InstanceID> weak_ptr_factory_; |
160 | 153 |
161 DISALLOW_COPY_AND_ASSIGN(InstanceID); | 154 DISALLOW_COPY_AND_ASSIGN(InstanceID); |
162 }; | 155 }; |
163 | 156 |
164 } // namespace instance_id | 157 } // namespace instance_id |
165 | 158 |
166 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_H_ | 159 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_H_ |
OLD | NEW |