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

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: Final updates based on CR 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
« no previous file with comments | « no previous file | google_apis/gcm/engine/unregistration_request.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/basictypes.h"
9 #include "base/callback.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "google_apis/gcm/base/gcm_export.h"
14 #include "net/base/backoff_entry.h"
15 #include "net/url_request/url_fetcher_delegate.h"
16
17 namespace net {
18 class URLRequestContextGetter;
19 }
20
21 namespace gcm {
22
23 // Unregistration request is used to revoke registration IDs for applications
24 // that were uninstalled and should no longer receive GCM messages. In case an
25 // attempt to unregister fails, it will retry using the backoff policy.
26 // TODO(fgorski): Consider sharing code with RegistrationRequest if possible.
27 class GCM_EXPORT UnregistrationRequest : public net::URLFetcherDelegate {
28 public:
29 // Callback completing the unregistration request.
30 typedef base::Callback<void(bool success)> UnregistrationCallback;
31
32 // Details of the of the Unregistration Request. All parameters are mandatory.
33 struct GCM_EXPORT RequestInfo {
34 RequestInfo(uint64 android_id,
35 uint64 security_token,
36 const std::string& app_id);
37 ~RequestInfo();
38
39 // Android ID of the device.
40 uint64 android_id;
41 // Security token of the device.
42 uint64 security_token;
43 // Application ID.
44 std::string app_id;
45 };
46
47 // Creates an instance of UnregistrationRequest. |callback| will be called
48 // once registration has been revoked or there has been an error that makes
49 // further retries pointless.
50 UnregistrationRequest(
51 const RequestInfo& request_info,
52 const net::BackoffEntry::Policy& backoff_policy,
53 const UnregistrationCallback& callback,
54 scoped_refptr<net::URLRequestContextGetter> request_context_getter);
55 virtual ~UnregistrationRequest();
56
57 // Starts an unregistration request.
58 void Start();
59
60 // URLFetcherDelegate implementation.
61 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
62
63 private:
64 // Schedules a retry attempt and informs the backoff of previous request's
65 // failure, when |update_backoff| is true.
66 void RetryWithBackoff(bool update_backoff);
67
68 UnregistrationCallback callback_;
69 RequestInfo request_info_;
70
71 net::BackoffEntry backoff_entry_;
72 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
73 scoped_ptr<net::URLFetcher> url_fetcher_;
74
75 base::WeakPtrFactory<UnregistrationRequest> weak_ptr_factory_;
76
77 DISALLOW_COPY_AND_ASSIGN(UnregistrationRequest);
78 };
79
80 } // namespace gcm
81
82 #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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698