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 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" |
13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
14 | 15 |
15 namespace gcm { | 16 namespace gcm { |
16 class GCMDriver; | 17 class GCMDriver; |
17 } // namespace gcm | 18 } // namespace gcm |
18 | 19 |
19 namespace instance_id { | 20 namespace instance_id { |
20 | 21 |
21 // Encapsulates Instance ID functionalities that need to be implemented for | 22 // Encapsulates Instance ID functionalities that need to be implemented for |
22 // different platform. One instance is created per application. Life of | 23 // different platform. One instance is created per application. Life of |
(...skipping 27 matching lines...) Expand all Loading... |
50 Result result)> GetTokenCallback; | 51 Result result)> GetTokenCallback; |
51 typedef base::Callback<void(Result result)> DeleteTokenCallback; | 52 typedef base::Callback<void(Result result)> DeleteTokenCallback; |
52 typedef base::Callback<void(Result result)> DeleteIDCallback; | 53 typedef base::Callback<void(Result result)> DeleteIDCallback; |
53 | 54 |
54 static const int kInstanceIDByteLength = 8; | 55 static const int kInstanceIDByteLength = 8; |
55 | 56 |
56 // Creator. | 57 // Creator. |
57 // |app_id|: identifies the application that uses the Instance ID. | 58 // |app_id|: identifies the application that uses the Instance ID. |
58 // |gcm_driver|: driver to access the GCM functionalities needed to support | 59 // |gcm_driver|: driver to access the GCM functionalities needed to support |
59 // Instance ID. | 60 // Instance ID. |
60 static InstanceID* Create(const std::string& app_id, | 61 static scoped_ptr<InstanceID> Create(const std::string& app_id, |
61 gcm::GCMDriver* gcm_driver); | 62 gcm::GCMDriver* gcm_driver); |
62 | 63 |
63 virtual ~InstanceID(); | 64 virtual ~InstanceID(); |
64 | 65 |
65 // 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 |
66 // to be triggered. | 67 // to be triggered. |
67 void SetTokenRefreshCallback(const TokenRefreshCallback& callback); | 68 void SetTokenRefreshCallback(const TokenRefreshCallback& callback); |
68 | 69 |
69 // Returns the Instance ID. | 70 // Returns the Instance ID. |
70 virtual void GetID(const GetIDCallback& callback) = 0; | 71 virtual void GetID(const GetIDCallback& callback) = 0; |
71 | 72 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 private: | 113 private: |
113 std::string app_id_; | 114 std::string app_id_; |
114 TokenRefreshCallback token_refresh_callback_; | 115 TokenRefreshCallback token_refresh_callback_; |
115 | 116 |
116 DISALLOW_COPY_AND_ASSIGN(InstanceID); | 117 DISALLOW_COPY_AND_ASSIGN(InstanceID); |
117 }; | 118 }; |
118 | 119 |
119 } // namespace instance_id | 120 } // namespace instance_id |
120 | 121 |
121 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_H_ | 122 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_H_ |
OLD | NEW |