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

Unified Diff: google_apis/gcm/engine/unregistration_request.h

Issue 1137463003: Support getting and deleting token for Instance ID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync 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 side-by-side diff with in-line comments
Download patch
Index: google_apis/gcm/engine/unregistration_request.h
diff --git a/google_apis/gcm/engine/unregistration_request.h b/google_apis/gcm/engine/unregistration_request.h
index c5c0eb5919b915e2672e0c3a4e8bfffe690130b9..92541935cef2f4d8910bd31940a8a14cfa61be1e 100644
--- a/google_apis/gcm/engine/unregistration_request.h
+++ b/google_apis/gcm/engine/unregistration_request.h
@@ -55,19 +55,83 @@ class GCM_EXPORT UnregistrationRequest : public net::URLFetcherDelegate {
// Callback completing the unregistration request.
typedef base::Callback<void(Status success)> UnregistrationCallback;
- // Details of the of the Unregistration Request. All parameters are mandatory.
- struct GCM_EXPORT RequestInfo {
- RequestInfo(uint64 android_id,
- uint64 security_token,
- const std::string& app_id);
- ~RequestInfo();
-
+ // Encapsulates the common info about an unregistration/token-deletion
+ // request.
+ class GCM_EXPORT RequestInfo {
+ public:
+ RequestInfo();
+ virtual ~RequestInfo();
+
+ virtual void BuildRequestHeaders(std::string* extra_headers);
+ virtual void BuildRequestBody(std::string* body);
+
+ std::string app_id() const { return app_id_; }
+
+ void set_chrome_version(const std::string& chrome_version) {
+ chrome_version_ = chrome_version;
+ }
+ void set_android_id(uint64 android_id) {
+ android_id_ = android_id;
+ }
+ void set_security_token(uint64 security_token) {
+ security_token_ = security_token;
+ }
+ void set_app_id(const std::string& app_id) {
+ app_id_ = app_id;
+ }
+
+ protected:
+ // Version to pass.
+ std::string chrome_version_;
// Android ID of the device.
- uint64 android_id;
+ uint64 android_id_;
// Security token of the device.
- uint64 security_token;
+ uint64 security_token_;
// Application ID.
- std::string app_id;
+ std::string app_id_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(RequestInfo);
+ };
+
+ // GCM unregistration request.
+ class GCM_EXPORT GCMRequestInfo : public RequestInfo {
+ public:
+ GCMRequestInfo();
+ ~GCMRequestInfo() override;
+
+ // RequestInfo overrides:
+ void BuildRequestBody(std::string* body) override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(GCMRequestInfo);
+ };
+
+ // Instance ID token deletion request.
+ class GCM_EXPORT InstanceIDRequestInfo : public RequestInfo {
+ public:
+ InstanceIDRequestInfo();
+ ~InstanceIDRequestInfo() override;
+
+ // RequestInfo overrides:
+ void BuildRequestBody(std::string* body) override;
+
+ void set_instance_id(const std::string& instance_id) {
+ instance_id_ = instance_id;
+ }
+ void set_authorized_entity(const std::string& authorized_entity) {
+ authorized_entity_ = authorized_entity;
+ }
+ void set_scope(const std::string& scope) {
+ scope_ = scope;
+ }
+
+ private:
+ std::string instance_id_;
+ std::string authorized_entity_;
+ std::string scope_;
+
+ DISALLOW_COPY_AND_ASSIGN(InstanceIDRequestInfo);
};
// Creates an instance of UnregistrationRequest. |callback| will be called
@@ -75,7 +139,7 @@ class GCM_EXPORT UnregistrationRequest : public net::URLFetcherDelegate {
// further retries pointless.
UnregistrationRequest(
const GURL& registration_url,
- const RequestInfo& request_info,
+ scoped_ptr<RequestInfo> request_info,
const net::BackoffEntry::Policy& backoff_policy,
const UnregistrationCallback& callback,
scoped_refptr<net::URLRequestContextGetter> request_context_getter,
@@ -94,7 +158,7 @@ class GCM_EXPORT UnregistrationRequest : public net::URLFetcherDelegate {
void RetryWithBackoff(bool update_backoff);
UnregistrationCallback callback_;
- RequestInfo request_info_;
+ scoped_ptr<RequestInfo> request_info_;
GURL registration_url_;
net::BackoffEntry backoff_entry_;

Powered by Google App Engine
This is Rietveld 408576698