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

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: Sync 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..9e471e5e3ad14f9b5830fe185ae7e067684e1dda
--- /dev/null
+++ b/components/gcm_driver/gcm_channel_status_request.h
@@ -0,0 +1,65 @@
+// 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 {
+
+// 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,
+ const base::TimeDelta& poll_interval)>
+ GCMChannelStatusRequestCallback;
+
+ GCMChannelStatusRequest(
+ const std::string& client_id,
Nicolas Zea 2014/09/04 23:57:50 What is client id going to be?
jianli 2014/09/05 18:41:55 This is similar to GenerateCacheGUID or GenerateIn
Nicolas Zea 2014/09/05 18:53:03 Do we need a client id at all? If this is a kill s
jianli 2014/09/05 21:26:17 After talking w/ Kevin, we don't need this.
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter,
Nicolas Zea 2014/09/04 23:57:50 nit: scoped_refptrs should be passed by const ref
jianli 2014/09/05 18:41:55 Done.
+ 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_; // Our unique ID.
Nicolas Zea 2014/09/04 23:57:50 nit: make const (and any other of these members th
jianli 2014/09/05 18:41: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