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

Side by Side Diff: google_apis/gcm/engine/unregistration_request.h

Issue 147763008: [GCM] Unregistration request (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing feedback form Jian Li Created 6 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef GOOGLE_APIS_GCM_ENGINE_UNREGISTRATION_REQUEST_H_
6 #define GOOGLE_APIS_GCM_ENGINE_UNREGISTRATION_REQUEST_H_
7
8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "google_apis/gcm/base/gcm_export.h"
13 #include "net/base/backoff_entry.h"
14 #include "net/url_request/url_fetcher_delegate.h"
15
16 namespace net {
17 class URLRequestContextGetter;
18 }
19
20 namespace gcm {
21
22 // Unregistration request is used to revoke registration IDs for applications
23 // that were uninstalled and should no longer receive GCM messages. In case an
24 // attempt to unregister fails, it will retry using the backoff policy.
25 // TODO(fgorski): Consider sharing code with RegistrationRequest if possible.
26 class GCM_EXPORT UnregistrationRequest : public net::URLFetcherDelegate {
27 public:
28 // Callback completing the unregistration request.
29 typedef base::Callback<void(bool success)> UnregistrationCallback;
30
31 // Details of the of the Unregistration Request. All parameters are mandatory.
32 struct GCM_EXPORT RequestInfo {
33 RequestInfo(uint64 android_id,
34 uint64 security_token,
35 const std::string& app_id);
36 ~RequestInfo();
37
38 // Android ID of the device.
39 uint64 android_id;
40 // Security token of the device.
41 uint64 security_token;
42 // Application ID.
43 std::string app_id;
44 };
45
46 // Creates an instance of UnregistrationRequest. |callback| will be called
47 // once registration has been revoked or there has been an error that makes
48 // further retries pointless.
49 UnregistrationRequest(
50 const RequestInfo& request_info,
51 const net::BackoffEntry::Policy& backoff_policy,
52 const UnregistrationCallback& callback,
53 scoped_refptr<net::URLRequestContextGetter> request_context_getter);
54 virtual ~UnregistrationRequest();
55
56 // Starts an unregistration request.
57 void Start();
58
59 // URLFetcherDelegate implementation.
60 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
61
62 private:
63 // Schedules a retry attempt and informs the backoff of previous request's
64 // failure, when |update_backoff| is true.
65 void RetryWithBackoff(bool update_backoff);
66
67 UnregistrationCallback callback_;
68 RequestInfo request_info_;
69
70 net::BackoffEntry backoff_entry_;
71 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
72 scoped_ptr<net::URLFetcher> url_fetcher_;
73
74 base::WeakPtrFactory<UnregistrationRequest> weak_ptr_factory_;
75
76 DISALLOW_COPY_AND_ASSIGN(UnregistrationRequest);
77 };
78
79 } // namespace gcm
80
81 #endif // GOOGLE_APIS_GCM_ENGINE_UNREGISTRATION_REQUEST_H_
OLDNEW
« no previous file with comments | « no previous file | google_apis/gcm/engine/unregistration_request.cc » ('j') | google_apis/gcm/engine/unregistration_request.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698