Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_REQUEST_H_ | |
| 6 #define COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_REQUEST_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/compiler_specific.h" | |
| 10 #include "base/macros.h" | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/memory/weak_ptr.h" | |
| 14 #include "base/time/time.h" | |
| 15 #include "net/base/backoff_entry.h" | |
| 16 #include "net/url_request/url_fetcher_delegate.h" | |
| 17 #include "net/url_request/url_request_context_getter.h" | |
| 18 | |
| 19 namespace net { | |
| 20 class URLRequestContextGetter; | |
| 21 } | |
| 22 | |
| 23 namespace gcm { | |
| 24 | |
| 25 // Defines the request to talk with the server to determine if the GCM support | |
| 26 // should be enabled. | |
| 27 class GCMChannelStatusRequest : public net::URLFetcherDelegate { | |
| 28 public: | |
| 29 // Callback completing the channel status request. | |
| 30 typedef base::Callback<void(bool enabled, | |
| 31 const base::TimeDelta& poll_interval)> | |
| 32 GCMChannelStatusRequestCallback; | |
| 33 | |
| 34 GCMChannelStatusRequest( | |
| 35 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.
| |
| 36 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.
| |
| 37 const GCMChannelStatusRequestCallback& callback); | |
| 38 virtual ~GCMChannelStatusRequest(); | |
| 39 | |
| 40 void Start(); | |
| 41 | |
| 42 // Exposed for testing purpose. | |
| 43 static base::TimeDelta default_poll_interval_for_testing(); | |
| 44 static base::TimeDelta min_poll_interval_for_testing(); | |
| 45 | |
| 46 private: | |
| 47 // Overridden from URLFetcherDelegate: | |
| 48 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | |
| 49 | |
| 50 bool ParseResponse(const net::URLFetcher* source); | |
| 51 void RetryWithBackoff(bool update_backoff); | |
| 52 | |
| 53 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.
| |
| 54 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | |
| 55 GCMChannelStatusRequestCallback callback_; | |
| 56 scoped_ptr<net::URLFetcher> url_fetcher_; | |
| 57 net::BackoffEntry backoff_entry_; | |
| 58 base::WeakPtrFactory<GCMChannelStatusRequest> weak_ptr_factory_; | |
| 59 | |
| 60 DISALLOW_COPY_AND_ASSIGN(GCMChannelStatusRequest); | |
| 61 }; | |
| 62 | |
| 63 } // namespace gcm | |
| 64 | |
| 65 #endif // COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_REQUEST_H_ | |
| OLD | NEW |