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 <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 typedef base::Callback<void(const std::string& token, | 50 typedef base::Callback<void(const std::string& token, |
| 51 Result result)> GetTokenCallback; | 51 Result result)> GetTokenCallback; |
| 52 typedef base::Callback<void(Result result)> DeleteTokenCallback; | 52 typedef base::Callback<void(Result result)> DeleteTokenCallback; |
| 53 typedef base::Callback<void(Result result)> DeleteIDCallback; | 53 typedef base::Callback<void(Result result)> DeleteIDCallback; |
| 54 | 54 |
| 55 static const int kInstanceIDByteLength = 8; | 55 static const int kInstanceIDByteLength = 8; |
| 56 | 56 |
| 57 // Creator. | 57 // Creator. |
| 58 // |app_id|: identifies the application that uses the Instance ID. | 58 // |app_id|: identifies the application that uses the Instance ID. |
| 59 // |handler|: provides the GCM functionality needed to support Instance ID. | 59 // |handler|: provides the GCM functionality needed to support Instance ID. |
| 60 // Must outlive this class. | 60 // Must outlive this class. On Android, this can be null instead. |
|
jianli
2016/04/08 23:20:00
Probably it is better to refactor this in order to
johnme
2016/04/13 11:42:12
Hmm, Peter suggested we pass in only the InstanceI
| |
| 61 static scoped_ptr<InstanceID> Create(const std::string& app_id, | 61 static scoped_ptr<InstanceID> Create(const std::string& app_id, |
| 62 gcm::InstanceIDHandler* handler); | 62 gcm::InstanceIDHandler* handler); |
| 63 | 63 |
| 64 virtual ~InstanceID(); | 64 virtual ~InstanceID(); |
| 65 | 65 |
| 66 // Sets the callback that will be invoked when the token refresh event needs | 66 // Sets the callback that will be invoked when the token refresh event needs |
| 67 // to be triggered. | 67 // to be triggered. |
| 68 void SetTokenRefreshCallback(const TokenRefreshCallback& callback); | 68 void SetTokenRefreshCallback(const TokenRefreshCallback& callback); |
| 69 | 69 |
| 70 // Returns the Instance ID. | 70 // Returns the Instance ID. |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 99 const DeleteTokenCallback& callback) = 0; | 99 const DeleteTokenCallback& callback) = 0; |
| 100 | 100 |
| 101 // Resets the app instance identifier and revokes all tokens associated with | 101 // Resets the app instance identifier and revokes all tokens associated with |
| 102 // it. | 102 // it. |
| 103 // |callback|: to be called once the asynchronous operation is done. | 103 // |callback|: to be called once the asynchronous operation is done. |
| 104 virtual void DeleteID(const DeleteIDCallback& callback) = 0; | 104 virtual void DeleteID(const DeleteIDCallback& callback) = 0; |
| 105 | 105 |
| 106 std::string app_id() const { return app_id_; } | 106 std::string app_id() const { return app_id_; } |
| 107 | 107 |
| 108 protected: | 108 protected: |
| 109 InstanceID(const std::string& app_id, gcm::InstanceIDHandler* handler); | 109 InstanceID(const std::string& app_id); |
| 110 | 110 |
| 111 void NotifyTokenRefresh(bool update_id); | 111 void NotifyTokenRefresh(bool update_id); |
| 112 | 112 |
| 113 gcm::InstanceIDHandler* handler() const { return handler_; } | |
| 114 | |
| 115 private: | 113 private: |
| 116 // Owned by GCMProfileServiceFactory, which is a dependency of | |
| 117 // InstanceIDProfileServiceFactory, which owns this. | |
| 118 gcm::InstanceIDHandler* handler_; | |
| 119 | |
| 120 std::string app_id_; | 114 std::string app_id_; |
| 121 TokenRefreshCallback token_refresh_callback_; | 115 TokenRefreshCallback token_refresh_callback_; |
| 122 | 116 |
| 123 DISALLOW_COPY_AND_ASSIGN(InstanceID); | 117 DISALLOW_COPY_AND_ASSIGN(InstanceID); |
| 124 }; | 118 }; |
| 125 | 119 |
| 126 } // namespace instance_id | 120 } // namespace instance_id |
| 127 | 121 |
| 128 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_H_ | 122 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_H_ |
| OLD | NEW |