Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(519)

Side by Side Diff: components/gcm_driver/instance_id/instance_id.h

Issue 2675293003: Push API: Don't wait for network when unsubscribing (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.
Peter Beverloo 2017/02/07 18:11:08 :)
johnme 2017/02/08 14:14:36 Acknowledged.
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
Peter Beverloo 2017/02/07 18:11:08 micro nit^2: no newline
johnme 2017/02/08 14:14:36 Done.
50 LAST_RESULT = UNKNOWN_ERROR
45 }; 51 };
46 52
47 // Asynchronous callbacks. Must not synchronously delete |this| (using 53 // Asynchronous callbacks. Must not synchronously delete |this| (using
48 // InstanceIDDriver::RemoveInstanceID). 54 // InstanceIDDriver::RemoveInstanceID).
49 typedef base::Callback<void(const std::string& app_id, 55 typedef base::Callback<void(const std::string& app_id,
50 bool update_id)> TokenRefreshCallback; 56 bool update_id)> TokenRefreshCallback;
51 typedef base::Callback<void(const std::string& id)> GetIDCallback; 57 typedef base::Callback<void(const std::string& id)> GetIDCallback;
52 typedef base::Callback<void(const base::Time& creation_time)> 58 typedef base::Callback<void(const base::Time& creation_time)>
53 GetCreationTimeCallback; 59 GetCreationTimeCallback;
54 typedef base::Callback<void(const std::string& token, 60 typedef base::Callback<void(const std::string& token,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 TokenRefreshCallback token_refresh_callback_; 150 TokenRefreshCallback token_refresh_callback_;
145 151
146 base::WeakPtrFactory<InstanceID> weak_ptr_factory_; 152 base::WeakPtrFactory<InstanceID> weak_ptr_factory_;
147 153
148 DISALLOW_COPY_AND_ASSIGN(InstanceID); 154 DISALLOW_COPY_AND_ASSIGN(InstanceID);
149 }; 155 };
150 156
151 } // namespace instance_id 157 } // namespace instance_id
152 158
153 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_H_ 159 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698