| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_REQUEST_H_ | 5 #ifndef COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_REQUEST_H_ |
| 6 #define COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_REQUEST_H_ | 6 #define COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_REQUEST_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // Defines the request to talk with the server to determine if the GCM support | 24 // Defines the request to talk with the server to determine if the GCM support |
| 25 // should be enabled. | 25 // should be enabled. |
| 26 class GCMChannelStatusRequest : public net::URLFetcherDelegate { | 26 class GCMChannelStatusRequest : public net::URLFetcherDelegate { |
| 27 public: | 27 public: |
| 28 // Callback completing the channel status request. | 28 // Callback completing the channel status request. |
| 29 typedef base::Callback<void(bool enabled, int poll_interval_seconds)> | 29 typedef base::Callback<void(bool enabled, int poll_interval_seconds)> |
| 30 GCMChannelStatusRequestCallback; | 30 GCMChannelStatusRequestCallback; |
| 31 | 31 |
| 32 GCMChannelStatusRequest( | 32 GCMChannelStatusRequest( |
| 33 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, | 33 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, |
| 34 const std::string& channel_status_request_url, |
| 35 const std::string& user_agent, |
| 34 const GCMChannelStatusRequestCallback& callback); | 36 const GCMChannelStatusRequestCallback& callback); |
| 35 virtual ~GCMChannelStatusRequest(); | 37 virtual ~GCMChannelStatusRequest(); |
| 36 | 38 |
| 37 void Start(); | 39 void Start(); |
| 38 | 40 |
| 39 static int default_poll_interval_seconds(); | 41 static int default_poll_interval_seconds(); |
| 40 static int min_poll_interval_seconds(); | 42 static int min_poll_interval_seconds(); |
| 41 | 43 |
| 42 private: | 44 private: |
| 43 // Overridden from URLFetcherDelegate: | 45 // Overridden from URLFetcherDelegate: |
| 44 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; | 46 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 45 | 47 |
| 46 bool ParseResponse(const net::URLFetcher* source); | 48 bool ParseResponse(const net::URLFetcher* source); |
| 47 void RetryWithBackoff(bool update_backoff); | 49 void RetryWithBackoff(bool update_backoff); |
| 48 | 50 |
| 49 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 51 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
| 52 std::string channel_status_request_url_; |
| 53 std::string user_agent_; |
| 50 GCMChannelStatusRequestCallback callback_; | 54 GCMChannelStatusRequestCallback callback_; |
| 51 scoped_ptr<net::URLFetcher> url_fetcher_; | 55 scoped_ptr<net::URLFetcher> url_fetcher_; |
| 52 net::BackoffEntry backoff_entry_; | 56 net::BackoffEntry backoff_entry_; |
| 53 base::WeakPtrFactory<GCMChannelStatusRequest> weak_ptr_factory_; | 57 base::WeakPtrFactory<GCMChannelStatusRequest> weak_ptr_factory_; |
| 54 | 58 |
| 55 DISALLOW_COPY_AND_ASSIGN(GCMChannelStatusRequest); | 59 DISALLOW_COPY_AND_ASSIGN(GCMChannelStatusRequest); |
| 56 }; | 60 }; |
| 57 | 61 |
| 58 } // namespace gcm | 62 } // namespace gcm |
| 59 | 63 |
| 60 #endif // COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_REQUEST_H_ | 64 #endif // COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_REQUEST_H_ |
| OLD | NEW |