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/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 | 16 |
17 namespace gcm { | 17 namespace gcm { |
18 class GCMDriver; | 18 class GCMDriver; |
19 } // namespace gcm | 19 } // namespace gcm |
20 | 20 |
21 namespace instance_id { | 21 namespace instance_id { |
22 | 22 |
23 extern const char kGCMScope[]; | 23 extern const char kGCMScope[]; |
24 | 24 |
25 // Encapsulates Instance ID functionalities that need to be implemented for | 25 // Encapsulates Instance ID functionalities that need to be implemented for |
26 // different platforms. One instance is created per application. Life of | 26 // different platforms. One instance is created per application. Life of |
27 // Instance ID is managed by the InstanceIDDriver. | 27 // Instance ID is managed by the InstanceIDDriver. |
28 class InstanceID { | 28 class InstanceID { |
29 public: | 29 public: |
| 30 // Used in UMA. Can add enum values, but never renumber or delete and reuse. |
30 enum Result { | 31 enum Result { |
31 // Successful operation. | 32 // Successful operation. |
32 SUCCESS, | 33 SUCCESS = 0, |
33 // Invalid parameter. | 34 // Invalid parameter. |
34 INVALID_PARAMETER, | 35 INVALID_PARAMETER = 1, |
35 // Instance ID is disabled. | 36 // Instance ID is disabled. |
36 DISABLED, | 37 DISABLED = 2, |
37 // Previous asynchronous operation is still pending to finish. | 38 // Previous asynchronous operation is still pending to finish. |
38 ASYNC_OPERATION_PENDING, | 39 ASYNC_OPERATION_PENDING = 3, |
39 // Network socket error. | 40 // Network socket error. |
40 NETWORK_ERROR, | 41 NETWORK_ERROR = 4, |
41 // Problem at the server. | 42 // Problem at the server. |
42 SERVER_ERROR, | 43 SERVER_ERROR = 5, |
| 44 // 6 is omitted, in case we ever merge this enum with GCMClient::Result. |
43 // Other errors. | 45 // Other errors. |
44 UNKNOWN_ERROR | 46 UNKNOWN_ERROR = 7, |
| 47 |
| 48 // Used for UMA. Keep LAST_RESULT up to date and sync with histograms.xml. |
| 49 LAST_RESULT = UNKNOWN_ERROR |
45 }; | 50 }; |
46 | 51 |
47 // Asynchronous callbacks. Must not synchronously delete |this| (using | 52 // Asynchronous callbacks. Must not synchronously delete |this| (using |
48 // InstanceIDDriver::RemoveInstanceID). | 53 // InstanceIDDriver::RemoveInstanceID). |
49 typedef base::Callback<void(const std::string& app_id, | 54 typedef base::Callback<void(const std::string& app_id, |
50 bool update_id)> TokenRefreshCallback; | 55 bool update_id)> TokenRefreshCallback; |
51 typedef base::Callback<void(const std::string& id)> GetIDCallback; | 56 typedef base::Callback<void(const std::string& id)> GetIDCallback; |
52 typedef base::Callback<void(const base::Time& creation_time)> | 57 typedef base::Callback<void(const base::Time& creation_time)> |
53 GetCreationTimeCallback; | 58 GetCreationTimeCallback; |
54 typedef base::Callback<void(const std::string& token, | 59 typedef base::Callback<void(const std::string& token, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 TokenRefreshCallback token_refresh_callback_; | 149 TokenRefreshCallback token_refresh_callback_; |
145 | 150 |
146 base::WeakPtrFactory<InstanceID> weak_ptr_factory_; | 151 base::WeakPtrFactory<InstanceID> weak_ptr_factory_; |
147 | 152 |
148 DISALLOW_COPY_AND_ASSIGN(InstanceID); | 153 DISALLOW_COPY_AND_ASSIGN(InstanceID); |
149 }; | 154 }; |
150 | 155 |
151 } // namespace instance_id | 156 } // namespace instance_id |
152 | 157 |
153 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_H_ | 158 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_H_ |
OLD | NEW |