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

Side by Side Diff: chrome/browser/extensions/api/instance_id/instance_id_api.h

Issue 1128123003: Implement InstanceID API functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android build Created 5 years, 7 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 CHROME_BROWSER_EXTENSIONS_API_INSTANCE_ID_INSTANCE_ID_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_INSTANCE_ID_INSTANCE_ID_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_INSTANCE_ID_INSTANCE_ID_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_INSTANCE_ID_INSTANCE_ID_API_H_
7 7
8 #include "base/macros.h"
9 #include "components/gcm_driver/instance_id/instance_id.h"
8 #include "extensions/browser/extension_function.h" 10 #include "extensions/browser/extension_function.h"
9 11
10 class Profile; 12 class Profile;
13 namespace instance_id{
14 class InstanceID;
fgorski 2015/05/07 19:59:53 either this or the include above is not necessary.
jianli 2015/05/07 20:47:01 Removed the forward declaration since now we reall
15 } // instance_id
11 16
12 namespace extensions { 17 namespace extensions {
13 18
14 class InstanceIDGetIDFunction : public UIThreadExtensionFunction { 19 class InstanceIDApiFunction : public UIThreadExtensionFunction {
20 public:
21 InstanceIDApiFunction();
22
23 protected:
24 ~InstanceIDApiFunction() override;
25
26 // ExtensionFunction:
27 ResponseAction Run() override;
28
29 // Actual implementation of specific functions.
30 virtual ResponseAction DoWork() = 0;
31
32 // Checks whether the InstanceID API is enabled.
33 bool IsEnabled() const;
34
35 instance_id::InstanceID* GetInstanceID() const;
36
37 DISALLOW_COPY_AND_ASSIGN(InstanceIDApiFunction);
38 };
39
40 class InstanceIDGetIDFunction : public InstanceIDApiFunction {
15 public: 41 public:
16 DECLARE_EXTENSION_FUNCTION("instanceID.getID", INSTANCEID_GETID); 42 DECLARE_EXTENSION_FUNCTION("instanceID.getID", INSTANCEID_GETID);
17 43
18 InstanceIDGetIDFunction(); 44 InstanceIDGetIDFunction();
19 45
20 protected: 46 protected:
21 ~InstanceIDGetIDFunction() override; 47 ~InstanceIDGetIDFunction() override;
22 48
23 // ExtensionFunction: 49 // InstanceIDApiFunction:
24 ResponseAction Run() override; 50 ResponseAction DoWork() override;
51
52 private:
53 DISALLOW_COPY_AND_ASSIGN(InstanceIDGetIDFunction);
25 }; 54 };
26 55
27 class InstanceIDGetCreationTimeFunction : public UIThreadExtensionFunction { 56 class InstanceIDGetCreationTimeFunction : public InstanceIDApiFunction {
28 public: 57 public:
29 DECLARE_EXTENSION_FUNCTION("instanceID.getCreationTime", 58 DECLARE_EXTENSION_FUNCTION("instanceID.getCreationTime",
30 INSTANCEID_GETCREATIONTIME); 59 INSTANCEID_GETCREATIONTIME);
31 60
32 InstanceIDGetCreationTimeFunction(); 61 InstanceIDGetCreationTimeFunction();
33 62
34 protected: 63 protected:
35 ~InstanceIDGetCreationTimeFunction() override; 64 ~InstanceIDGetCreationTimeFunction() override;
36 65
37 // ExtensionFunction: 66 // InstanceIDApiFunction:
38 ResponseAction Run() override; 67 ResponseAction DoWork() override;
68
69 private:
70 DISALLOW_COPY_AND_ASSIGN(InstanceIDGetCreationTimeFunction);
39 }; 71 };
40 72
41 class InstanceIDGetTokenFunction : public UIThreadExtensionFunction { 73 class InstanceIDGetTokenFunction : public InstanceIDApiFunction {
42 public: 74 public:
43 DECLARE_EXTENSION_FUNCTION("instanceID.getToken", INSTANCEID_GETTOKEN); 75 DECLARE_EXTENSION_FUNCTION("instanceID.getToken", INSTANCEID_GETTOKEN);
44 76
45 InstanceIDGetTokenFunction(); 77 InstanceIDGetTokenFunction();
46 78
47 protected: 79 protected:
48 ~InstanceIDGetTokenFunction() override; 80 ~InstanceIDGetTokenFunction() override;
49 81
50 // ExtensionFunction: 82 // InstanceIDApiFunction:
51 ResponseAction Run() override; 83 ResponseAction DoWork() override;
84
85 private:
86 void GetTokenCompleted(instance_id::InstanceID* instance_id,
87 const std::string& token,
88 instance_id::InstanceID::Result result);
89
90 DISALLOW_COPY_AND_ASSIGN(InstanceIDGetTokenFunction);
52 }; 91 };
53 92
54 class InstanceIDDeleteTokenFunction : public UIThreadExtensionFunction { 93 class InstanceIDDeleteTokenFunction : public InstanceIDApiFunction {
55 public: 94 public:
56 DECLARE_EXTENSION_FUNCTION("instanceID.DeleteToken", INSTANCEID_DELETETOKEN); 95 DECLARE_EXTENSION_FUNCTION("instanceID.DeleteToken", INSTANCEID_DELETETOKEN);
57 96
58 InstanceIDDeleteTokenFunction(); 97 InstanceIDDeleteTokenFunction();
59 98
60 protected: 99 protected:
61 ~InstanceIDDeleteTokenFunction() override; 100 ~InstanceIDDeleteTokenFunction() override;
62 101
63 // ExtensionFunction: 102 // InstanceIDApiFunction:
64 ResponseAction Run() override; 103 ResponseAction DoWork() override;
104
105 private:
106 void DeleteTokenCompleted(instance_id::InstanceID* instance_id,
107 instance_id::InstanceID::Result result);
108
109 DISALLOW_COPY_AND_ASSIGN(InstanceIDDeleteTokenFunction);
65 }; 110 };
66 111
67 class InstanceIDDeleteIDFunction : public UIThreadExtensionFunction { 112 class InstanceIDDeleteIDFunction : public InstanceIDApiFunction {
68 public: 113 public:
69 DECLARE_EXTENSION_FUNCTION("instanceID.deleteID", 114 DECLARE_EXTENSION_FUNCTION("instanceID.deleteID",
70 INSTANCEID_DELETEID); 115 INSTANCEID_DELETEID);
71 116
72 InstanceIDDeleteIDFunction(); 117 InstanceIDDeleteIDFunction();
73 118
74 protected: 119 protected:
75 ~InstanceIDDeleteIDFunction() override; 120 ~InstanceIDDeleteIDFunction() override;
76 121
77 // ExtensionFunction: 122 // InstanceIDApiFunction:
78 ResponseAction Run() override; 123 ResponseAction DoWork() override;
124
125 private:
126 void DeleteIDCompleted(instance_id::InstanceID* instance_id,
127 instance_id::InstanceID::Result result);
128
129 DISALLOW_COPY_AND_ASSIGN(InstanceIDDeleteIDFunction);
79 }; 130 };
80 131
81 } // namespace extensions 132 } // namespace extensions
82 133
83 #endif // CHROME_BROWSER_EXTENSIONS_API_INSTANCE_ID_INSTANCE_ID_API_H_ 134 #endif // CHROME_BROWSER_EXTENSIONS_API_INSTANCE_ID_INSTANCE_ID_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698