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 // |update_received|: use the existing values if it is false which means no | 29 typedef base::Callback<void(bool enabled, int poll_interval_seconds)> |
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)> | |
37 GCMChannelStatusRequestCallback; | 30 GCMChannelStatusRequestCallback; |
38 | 31 |
39 GCMChannelStatusRequest( | 32 GCMChannelStatusRequest( |
40 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, | 33 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, |
41 const std::string& channel_status_request_url, | 34 const std::string& channel_status_request_url, |
42 const std::string& user_agent, | 35 const std::string& user_agent, |
43 const GCMChannelStatusRequestCallback& callback); | 36 const GCMChannelStatusRequestCallback& callback); |
44 virtual ~GCMChannelStatusRequest(); | 37 virtual ~GCMChannelStatusRequest(); |
45 | 38 |
46 void Start(); | 39 void Start(); |
(...skipping 15 matching lines...) Expand all Loading... |
62 scoped_ptr<net::URLFetcher> url_fetcher_; | 55 scoped_ptr<net::URLFetcher> url_fetcher_; |
63 net::BackoffEntry backoff_entry_; | 56 net::BackoffEntry backoff_entry_; |
64 base::WeakPtrFactory<GCMChannelStatusRequest> weak_ptr_factory_; | 57 base::WeakPtrFactory<GCMChannelStatusRequest> weak_ptr_factory_; |
65 | 58 |
66 DISALLOW_COPY_AND_ASSIGN(GCMChannelStatusRequest); | 59 DISALLOW_COPY_AND_ASSIGN(GCMChannelStatusRequest); |
67 }; | 60 }; |
68 | 61 |
69 } // namespace gcm | 62 } // namespace gcm |
70 | 63 |
71 #endif // COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_REQUEST_H_ | 64 #endif // COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_REQUEST_H_ |
OLD | NEW |