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

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 android 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
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..54fe0ed36ca38294e4f33f488e4faaa3ca20ca55
--- /dev/null
+++ b/components/gcm_driver/gcm_channel_status_request.h
@@ -0,0 +1,63 @@
+// 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 "base/time/time.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 {
+
+class GCMChannelStatusRequest : public net::URLFetcherDelegate {
fgorski 2014/09/03 20:42:16 document
jianli 2014/09/03 21:17:55 Done.
+ public:
+ // Callback completing the unregistration request.
fgorski 2014/09/03 20:42:16 fix doc
jianli 2014/09/03 21:17:55 Done.
+ typedef base::Callback<void(bool enabled,
+ const base::TimeDelta& poll_interval)>
+ GCMChannelStatusRequestCallback;
+
+ GCMChannelStatusRequest(
+ const std::string& client_id,
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter,
+ const GCMChannelStatusRequestCallback& callback);
+ virtual ~GCMChannelStatusRequest();
+
+ void Start();
+
+ // Exposed for testing purpose.
+ static base::TimeDelta default_poll_interval_for_testing();
+ static base::TimeDelta min_poll_interval_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);
+
+ std::string client_id_;
fgorski 2014/09/03 20:42:16 comment on the client id
jianli 2014/09/03 21:17:55 Done.
+ 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_

Powered by Google App Engine
This is Rietveld 408576698