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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | google_apis/gcm/engine/unregistration_request.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..c52879dc0515a42776655352dca0f7d6729dceed
--- /dev/null
+++ b/google_apis/gcm/engine/unregistration_request.h
@@ -0,0 +1,82 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GOOGLE_APIS_GCM_ENGINE_UNREGISTRATION_REQUEST_H_
+#define GOOGLE_APIS_GCM_ENGINE_UNREGISTRATION_REQUEST_H_
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "google_apis/gcm/base/gcm_export.h"
+#include "net/base/backoff_entry.h"
+#include "net/url_request/url_fetcher_delegate.h"
+
+namespace net {
+class URLRequestContextGetter;
+}
+
+namespace gcm {
+
+// 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.
+// TODO(fgorski): Consider sharing code with RegistrationRequest if possible.
+class GCM_EXPORT UnregistrationRequest : public net::URLFetcherDelegate {
+ public:
+ // Callback completing the unregistration request.
+ typedef base::Callback<void(bool 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();
+
+ // Android ID of the device.
+ uint64 android_id;
+ // Security token of the device.
+ uint64 security_token;
+ // Application ID.
+ std::string app_id;
+ };
+
+ // 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 RequestInfo& request_info,
+ const net::BackoffEntry::Policy& backoff_policy,
+ const UnregistrationCallback& callback,
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter);
+ virtual ~UnregistrationRequest();
+
+ // Starts an unregistration request.
+ void Start();
+
+ // URLFetcherDelegate implementation.
+ virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
+
+ private:
+ // 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_;
+
+ net::BackoffEntry backoff_entry_;
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
+ scoped_ptr<net::URLFetcher> url_fetcher_;
+
+ base::WeakPtrFactory<UnregistrationRequest> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(UnregistrationRequest);
+};
+
+} // namespace gcm
+
+#endif // GOOGLE_APIS_GCM_ENGINE_UNREGISTRATION_REQUEST_H_
« 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