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

Unified Diff: components/gcm_driver/gcm_channel_status_request.h

Issue 530253002: Add GCMChannelStatusRequest to talk with server for all users (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix gn build Created 6 years, 3 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 | « components/gcm_driver/gcm_backoff_policy.cc ('k') | components/gcm_driver/gcm_channel_status_request.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/gcm_driver/gcm_channel_status_request.h
diff --git a/components/gcm_driver/gcm_channel_status_request.h b/components/gcm_driver/gcm_channel_status_request.h
new file mode 100644
index 0000000000000000000000000000000000000000..b27257596bc2022afed50c3d1e096ec2d59d2508
--- /dev/null
+++ b/components/gcm_driver/gcm_channel_status_request.h
@@ -0,0 +1,61 @@
+// 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 COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_REQUEST_H_
+#define COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_REQUEST_H_
+
+#include "base/callback.h"
+#include "base/compiler_specific.h"
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "net/base/backoff_entry.h"
+#include "net/url_request/url_fetcher_delegate.h"
+#include "net/url_request/url_request_context_getter.h"
+
+namespace net {
+class URLRequestContextGetter;
+}
+
+namespace gcm {
+
+// Defines the request to talk with the server to determine if the GCM support
+// should be enabled.
+class GCMChannelStatusRequest : public net::URLFetcherDelegate {
+ public:
+ // Callback completing the channel status request.
+ typedef base::Callback<void(bool enabled, int poll_interval_seconds)>
+ GCMChannelStatusRequestCallback;
+
+ GCMChannelStatusRequest(
+ const scoped_refptr<net::URLRequestContextGetter>& request_context_getter,
+ const GCMChannelStatusRequestCallback& callback);
+ virtual ~GCMChannelStatusRequest();
+
+ void Start();
+
+ // Exposed for testing purpose.
+ static int default_poll_interval_seconds_for_testing();
+ static int min_poll_interval_seconds_for_testing();
+
+ private:
+ // Overridden from URLFetcherDelegate:
+ virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
+
+ bool ParseResponse(const net::URLFetcher* source);
+ void RetryWithBackoff(bool update_backoff);
+
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
+ GCMChannelStatusRequestCallback callback_;
+ scoped_ptr<net::URLFetcher> url_fetcher_;
+ net::BackoffEntry backoff_entry_;
+ base::WeakPtrFactory<GCMChannelStatusRequest> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(GCMChannelStatusRequest);
+};
+
+} // namespace gcm
+
+#endif // COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_REQUEST_H_
« no previous file with comments | « components/gcm_driver/gcm_backoff_policy.cc ('k') | components/gcm_driver/gcm_channel_status_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698