Chromium Code Reviews| 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..6a5ddf8c52cfe57dd6ce4836444f08c87b5d3073 100644 |
| --- a/google_apis/gcm/engine/unregistration_request.h |
| +++ b/google_apis/gcm/engine/unregistration_request.h |
| @@ -24,9 +24,9 @@ namespace gcm { |
| class GCMStatsRecorder; |
| -// Unregistration request is used to revoke registration IDs for applications |
| -// that were uninstalled and should no longer receive GCM messages. In case an |
| -// attempt to unregister fails, it will retry using the backoff policy. |
| +// Encapsulates the common logic applying to both GCM unregistration requests |
| +// and InstanceID delete-token requests. In case an attempt fails, it will retry |
| +// using the backoff policy. |
| // TODO(fgorski): Consider sharing code with RegistrationRequest if possible. |
| class GCM_EXPORT UnregistrationRequest : public net::URLFetcherDelegate { |
| public: |
| @@ -55,7 +55,8 @@ 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. |
| + // Defines the common info about an unregistration/token-deletion request. |
| + // All parameters are mandatory. |
| struct GCM_EXPORT RequestInfo { |
| RequestInfo(uint64 android_id, |
| uint64 security_token, |
| @@ -70,12 +71,24 @@ class GCM_EXPORT UnregistrationRequest : public net::URLFetcherDelegate { |
| std::string app_id; |
| }; |
| + // Encapsulates the custom logic that is needed to build and process the |
| + // unregistration request. |
| + class GCM_EXPORT CustomRequestHandler { |
| + public: |
| + CustomRequestHandler(); |
| + virtual ~CustomRequestHandler(); |
| + |
| + virtual void BuildRequestBody(std::string* body) = 0; |
|
Nicolas Zea
2015/05/26 16:39:15
Comment when these are called? (i.e. this is calle
jianli
2015/05/26 20:49:39
Done.
|
| + virtual Status ParseResponse(const net::URLFetcher* source) = 0; |
| + }; |
| + |
| // Creates an instance of UnregistrationRequest. |callback| will be called |
| // once registration has been revoked or there has been an error that makes |
| // further retries pointless. |
| UnregistrationRequest( |
| const GURL& registration_url, |
| const RequestInfo& request_info, |
| + scoped_ptr<CustomRequestHandler> custom_request_handler, |
| const net::BackoffEntry::Policy& backoff_policy, |
| const UnregistrationCallback& callback, |
| scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
| @@ -85,16 +98,21 @@ class GCM_EXPORT UnregistrationRequest : public net::URLFetcherDelegate { |
| // Starts an unregistration request. |
| void Start(); |
| + private: |
| // URLFetcherDelegate implementation. |
| void OnURLFetchComplete(const net::URLFetcher* source) override; |
| - private: |
| + void BuildRequestHeaders(std::string* extra_headers); |
| + void BuildRequestBody(std::string* body); |
| + Status ParseResponse(const net::URLFetcher* source); |
| + |
| // Schedules a retry attempt and informs the backoff of previous request's |
| // failure, when |update_backoff| is true. |
| void RetryWithBackoff(bool update_backoff); |
| UnregistrationCallback callback_; |
| RequestInfo request_info_; |
| + scoped_ptr<CustomRequestHandler> custom_request_handler_; |
| GURL registration_url_; |
| net::BackoffEntry backoff_entry_; |