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 class GCMChannelStatusRequest : public net::URLFetcherDelegate { | |
fgorski
2014/09/03 20:42:16
document
jianli
2014/09/03 21:17:55
Done.
| |
26 public: | |
27 // Callback completing the unregistration request. | |
fgorski
2014/09/03 20:42:16
fix doc
jianli
2014/09/03 21:17:55
Done.
| |
28 typedef base::Callback<void(bool enabled, | |
29 const base::TimeDelta& poll_interval)> | |
30 GCMChannelStatusRequestCallback; | |
31 | |
32 GCMChannelStatusRequest( | |
33 const std::string& client_id, | |
34 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | |
35 const GCMChannelStatusRequestCallback& callback); | |
36 virtual ~GCMChannelStatusRequest(); | |
37 | |
38 void Start(); | |
39 | |
40 // Exposed for testing purpose. | |
41 static base::TimeDelta default_poll_interval_for_testing(); | |
42 static base::TimeDelta min_poll_interval_for_testing(); | |
43 | |
44 private: | |
45 // Overridden from URLFetcherDelegate: | |
46 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | |
47 | |
48 bool ParseResponse(const net::URLFetcher* source); | |
49 void RetryWithBackoff(bool update_backoff); | |
50 | |
51 std::string client_id_; | |
fgorski
2014/09/03 20:42:16
comment on the client id
jianli
2014/09/03 21:17:55
Done.
| |
52 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | |
53 GCMChannelStatusRequestCallback callback_; | |
54 scoped_ptr<net::URLFetcher> url_fetcher_; | |
55 net::BackoffEntry backoff_entry_; | |
56 base::WeakPtrFactory<GCMChannelStatusRequest> weak_ptr_factory_; | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(GCMChannelStatusRequest); | |
59 }; | |
60 | |
61 } // namespace gcm | |
62 | |
63 #endif // COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_REQUEST_H_ | |
OLD | NEW |