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 GOOGLE_APIS_GCM_ENGINE_CHECKIN_REQUEST_H_ | 5 #ifndef GOOGLE_APIS_GCM_ENGINE_CHECKIN_REQUEST_H_ |
6 #define GOOGLE_APIS_GCM_ENGINE_CHECKIN_REQUEST_H_ | 6 #define GOOGLE_APIS_GCM_ENGINE_CHECKIN_REQUEST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "google_apis/gcm/base/gcm_export.h" | 14 #include "google_apis/gcm/base/gcm_export.h" |
15 #include "google_apis/gcm/protocol/android_checkin.pb.h" | 15 #include "google_apis/gcm/protocol/android_checkin.pb.h" |
16 #include "google_apis/gcm/protocol/checkin.pb.h" | 16 #include "google_apis/gcm/protocol/checkin.pb.h" |
17 #include "net/base/backoff_entry.h" | 17 #include "net/base/backoff_entry.h" |
18 #include "net/url_request/url_fetcher_delegate.h" | 18 #include "net/url_request/url_fetcher_delegate.h" |
19 | 19 |
20 namespace net { | 20 namespace net { |
21 class URLRequestContextGetter; | 21 class URLRequestContextGetter; |
22 } | 22 } |
23 | 23 |
24 namespace gcm { | 24 namespace gcm { |
25 | 25 |
| 26 class GCMStatsRecorder; |
| 27 |
26 // Enables making check-in requests with the GCM infrastructure. When called | 28 // Enables making check-in requests with the GCM infrastructure. When called |
27 // with android_id and security_token both set to 0 it is an initial check-in | 29 // with android_id and security_token both set to 0 it is an initial check-in |
28 // used to obtain credentials. These should be persisted and used for subsequent | 30 // used to obtain credentials. These should be persisted and used for subsequent |
29 // check-ins. | 31 // check-ins. |
30 class GCM_EXPORT CheckinRequest : public net::URLFetcherDelegate { | 32 class GCM_EXPORT CheckinRequest : public net::URLFetcherDelegate { |
31 public: | 33 public: |
32 // A callback function for the checkin request, accepting |checkin_response| | 34 // A callback function for the checkin request, accepting |checkin_response| |
33 // protobuf. | 35 // protobuf. |
34 typedef base::Callback<void(const checkin_proto::AndroidCheckinResponse& | 36 typedef base::Callback<void(const checkin_proto::AndroidCheckinResponse& |
35 checkin_response)> CheckinRequestCallback; | 37 checkin_response)> CheckinRequestCallback; |
(...skipping 15 matching lines...) Expand all Loading... |
51 std::string settings_digest; | 53 std::string settings_digest; |
52 // Account IDs of GAIA accounts related to this device. | 54 // Account IDs of GAIA accounts related to this device. |
53 std::vector<std::string> account_ids; | 55 std::vector<std::string> account_ids; |
54 // Information of the Chrome build of this device. | 56 // Information of the Chrome build of this device. |
55 checkin_proto::ChromeBuildProto chrome_build_proto; | 57 checkin_proto::ChromeBuildProto chrome_build_proto; |
56 }; | 58 }; |
57 | 59 |
58 CheckinRequest(const RequestInfo& request_info, | 60 CheckinRequest(const RequestInfo& request_info, |
59 const net::BackoffEntry::Policy& backoff_policy, | 61 const net::BackoffEntry::Policy& backoff_policy, |
60 const CheckinRequestCallback& callback, | 62 const CheckinRequestCallback& callback, |
61 net::URLRequestContextGetter* request_context_getter); | 63 net::URLRequestContextGetter* request_context_getter, |
| 64 GCMStatsRecorder* recorder); |
62 virtual ~CheckinRequest(); | 65 virtual ~CheckinRequest(); |
63 | 66 |
64 void Start(); | 67 void Start(); |
65 | 68 |
66 // URLFetcherDelegate implementation. | 69 // URLFetcherDelegate implementation. |
67 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 70 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
68 | 71 |
69 private: | 72 private: |
70 // Schedules a retry attempt, informs the backoff of a previous request's | 73 // Schedules a retry attempt, informs the backoff of a previous request's |
71 // failure when |update_backoff| is true. | 74 // failure when |update_backoff| is true. |
72 void RetryWithBackoff(bool update_backoff); | 75 void RetryWithBackoff(bool update_backoff); |
73 | 76 |
74 net::URLRequestContextGetter* request_context_getter_; | 77 net::URLRequestContextGetter* request_context_getter_; |
75 CheckinRequestCallback callback_; | 78 CheckinRequestCallback callback_; |
76 | 79 |
77 net::BackoffEntry backoff_entry_; | 80 net::BackoffEntry backoff_entry_; |
78 scoped_ptr<net::URLFetcher> url_fetcher_; | 81 scoped_ptr<net::URLFetcher> url_fetcher_; |
79 const RequestInfo request_info_; | 82 const RequestInfo request_info_; |
80 | 83 |
| 84 // Recorder that records GCM activities for debugging purpose. Not owned. |
| 85 GCMStatsRecorder* recorder_; |
| 86 |
81 base::WeakPtrFactory<CheckinRequest> weak_ptr_factory_; | 87 base::WeakPtrFactory<CheckinRequest> weak_ptr_factory_; |
82 | 88 |
83 DISALLOW_COPY_AND_ASSIGN(CheckinRequest); | 89 DISALLOW_COPY_AND_ASSIGN(CheckinRequest); |
84 }; | 90 }; |
85 | 91 |
86 } // namespace gcm | 92 } // namespace gcm |
87 | 93 |
88 #endif // GOOGLE_APIS_GCM_ENGINE_CHECKIN_REQUEST_H_ | 94 #endif // GOOGLE_APIS_GCM_ENGINE_CHECKIN_REQUEST_H_ |
OLD | NEW |