Index: chrome/browser/extensions/api/instance_id/instance_id_api.h |
diff --git a/chrome/browser/extensions/api/instance_id/instance_id_api.h b/chrome/browser/extensions/api/instance_id/instance_id_api.h |
index c7530ebbcaa711c7b1f492310dd36c358c17beec..fa66e21ef9af73720934129e0bb126d4149cec0c 100644 |
--- a/chrome/browser/extensions/api/instance_id/instance_id_api.h |
+++ b/chrome/browser/extensions/api/instance_id/instance_id_api.h |
@@ -5,13 +5,39 @@ |
#ifndef CHROME_BROWSER_EXTENSIONS_API_INSTANCE_ID_INSTANCE_ID_API_H_ |
#define CHROME_BROWSER_EXTENSIONS_API_INSTANCE_ID_INSTANCE_ID_API_H_ |
+#include "base/macros.h" |
+#include "components/gcm_driver/instance_id/instance_id.h" |
#include "extensions/browser/extension_function.h" |
class Profile; |
+namespace instance_id{ |
+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
|
+} // instance_id |
namespace extensions { |
-class InstanceIDGetIDFunction : public UIThreadExtensionFunction { |
+class InstanceIDApiFunction : public UIThreadExtensionFunction { |
+ public: |
+ InstanceIDApiFunction(); |
+ |
+ protected: |
+ ~InstanceIDApiFunction() override; |
+ |
+ // ExtensionFunction: |
+ ResponseAction Run() override; |
+ |
+ // Actual implementation of specific functions. |
+ virtual ResponseAction DoWork() = 0; |
+ |
+ // Checks whether the InstanceID API is enabled. |
+ bool IsEnabled() const; |
+ |
+ instance_id::InstanceID* GetInstanceID() const; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(InstanceIDApiFunction); |
+}; |
+ |
+class InstanceIDGetIDFunction : public InstanceIDApiFunction { |
public: |
DECLARE_EXTENSION_FUNCTION("instanceID.getID", INSTANCEID_GETID); |
@@ -20,11 +46,14 @@ class InstanceIDGetIDFunction : public UIThreadExtensionFunction { |
protected: |
~InstanceIDGetIDFunction() override; |
- // ExtensionFunction: |
- ResponseAction Run() override; |
+ // InstanceIDApiFunction: |
+ ResponseAction DoWork() override; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(InstanceIDGetIDFunction); |
}; |
-class InstanceIDGetCreationTimeFunction : public UIThreadExtensionFunction { |
+class InstanceIDGetCreationTimeFunction : public InstanceIDApiFunction { |
public: |
DECLARE_EXTENSION_FUNCTION("instanceID.getCreationTime", |
INSTANCEID_GETCREATIONTIME); |
@@ -34,11 +63,14 @@ class InstanceIDGetCreationTimeFunction : public UIThreadExtensionFunction { |
protected: |
~InstanceIDGetCreationTimeFunction() override; |
- // ExtensionFunction: |
- ResponseAction Run() override; |
+ // InstanceIDApiFunction: |
+ ResponseAction DoWork() override; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(InstanceIDGetCreationTimeFunction); |
}; |
-class InstanceIDGetTokenFunction : public UIThreadExtensionFunction { |
+class InstanceIDGetTokenFunction : public InstanceIDApiFunction { |
public: |
DECLARE_EXTENSION_FUNCTION("instanceID.getToken", INSTANCEID_GETTOKEN); |
@@ -47,11 +79,18 @@ class InstanceIDGetTokenFunction : public UIThreadExtensionFunction { |
protected: |
~InstanceIDGetTokenFunction() override; |
- // ExtensionFunction: |
- ResponseAction Run() override; |
+ // InstanceIDApiFunction: |
+ ResponseAction DoWork() override; |
+ |
+ private: |
+ void GetTokenCompleted(instance_id::InstanceID* instance_id, |
+ const std::string& token, |
+ instance_id::InstanceID::Result result); |
+ |
+ DISALLOW_COPY_AND_ASSIGN(InstanceIDGetTokenFunction); |
}; |
-class InstanceIDDeleteTokenFunction : public UIThreadExtensionFunction { |
+class InstanceIDDeleteTokenFunction : public InstanceIDApiFunction { |
public: |
DECLARE_EXTENSION_FUNCTION("instanceID.DeleteToken", INSTANCEID_DELETETOKEN); |
@@ -60,11 +99,17 @@ class InstanceIDDeleteTokenFunction : public UIThreadExtensionFunction { |
protected: |
~InstanceIDDeleteTokenFunction() override; |
- // ExtensionFunction: |
- ResponseAction Run() override; |
+ // InstanceIDApiFunction: |
+ ResponseAction DoWork() override; |
+ |
+ private: |
+ void DeleteTokenCompleted(instance_id::InstanceID* instance_id, |
+ instance_id::InstanceID::Result result); |
+ |
+ DISALLOW_COPY_AND_ASSIGN(InstanceIDDeleteTokenFunction); |
}; |
-class InstanceIDDeleteIDFunction : public UIThreadExtensionFunction { |
+class InstanceIDDeleteIDFunction : public InstanceIDApiFunction { |
public: |
DECLARE_EXTENSION_FUNCTION("instanceID.deleteID", |
INSTANCEID_DELETEID); |
@@ -74,8 +119,14 @@ class InstanceIDDeleteIDFunction : public UIThreadExtensionFunction { |
protected: |
~InstanceIDDeleteIDFunction() override; |
- // ExtensionFunction: |
- ResponseAction Run() override; |
+ // InstanceIDApiFunction: |
+ ResponseAction DoWork() override; |
+ |
+ private: |
+ void DeleteIDCompleted(instance_id::InstanceID* instance_id, |
+ instance_id::InstanceID::Result result); |
+ |
+ DISALLOW_COPY_AND_ASSIGN(InstanceIDDeleteIDFunction); |
}; |
} // namespace extensions |