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" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "net/base/backoff_entry.h" | 14 #include "net/base/backoff_entry.h" |
15 #include "net/url_request/url_fetcher_delegate.h" | 15 #include "net/url_request/url_fetcher_delegate.h" |
16 #include "net/url_request/url_request_context_getter.h" | 16 #include "net/url_request/url_request_context_getter.h" |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 class URLRequestContextGetter; | 19 class URLRequestContextGetter; |
20 } | 20 } |
21 | 21 |
22 namespace gcm { | 22 namespace gcm { |
23 | 23 |
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 // |update_received|: use the existing values if it is false which means no |
| 30 // update is received. |
| 31 // |enabled|: indicates if GCM is enabled (allowed to run) or not. |
| 32 // |poll_interval_seconds|: the interval in seconds to start next poll |
| 33 // request. |
| 34 typedef base::Callback<void(bool update_received, |
| 35 bool enabled, |
| 36 int poll_interval_seconds)> |
30 GCMChannelStatusRequestCallback; | 37 GCMChannelStatusRequestCallback; |
31 | 38 |
32 GCMChannelStatusRequest( | 39 GCMChannelStatusRequest( |
33 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, | 40 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, |
34 const std::string& channel_status_request_url, | 41 const std::string& channel_status_request_url, |
35 const std::string& user_agent, | 42 const std::string& user_agent, |
36 const GCMChannelStatusRequestCallback& callback); | 43 const GCMChannelStatusRequestCallback& callback); |
37 virtual ~GCMChannelStatusRequest(); | 44 virtual ~GCMChannelStatusRequest(); |
38 | 45 |
39 void Start(); | 46 void Start(); |
(...skipping 15 matching lines...) Expand all Loading... |
55 scoped_ptr<net::URLFetcher> url_fetcher_; | 62 scoped_ptr<net::URLFetcher> url_fetcher_; |
56 net::BackoffEntry backoff_entry_; | 63 net::BackoffEntry backoff_entry_; |
57 base::WeakPtrFactory<GCMChannelStatusRequest> weak_ptr_factory_; | 64 base::WeakPtrFactory<GCMChannelStatusRequest> weak_ptr_factory_; |
58 | 65 |
59 DISALLOW_COPY_AND_ASSIGN(GCMChannelStatusRequest); | 66 DISALLOW_COPY_AND_ASSIGN(GCMChannelStatusRequest); |
60 }; | 67 }; |
61 | 68 |
62 } // namespace gcm | 69 } // namespace gcm |
63 | 70 |
64 #endif // COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_REQUEST_H_ | 71 #endif // COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_REQUEST_H_ |
OLD | NEW |