Chromium Code Reviews| 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_REGISTRATION_REQUEST_H_ | 5 #ifndef GOOGLE_APIS_GCM_ENGINE_REGISTRATION_REQUEST_H_ |
| 6 #define GOOGLE_APIS_GCM_ENGINE_REGISTRATION_REQUEST_H_ | 6 #define GOOGLE_APIS_GCM_ENGINE_REGISTRATION_REQUEST_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 // immediately above this line. Make sure to update the corresponding | 52 // immediately above this line. Make sure to update the corresponding |
| 53 // histogram enum accordingly. | 53 // histogram enum accordingly. |
| 54 STATUS_COUNT | 54 STATUS_COUNT |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 // Callback completing the registration request. | 57 // Callback completing the registration request. |
| 58 typedef base::Callback<void(Status status, | 58 typedef base::Callback<void(Status status, |
| 59 const std::string& registration_id)> | 59 const std::string& registration_id)> |
| 60 RegistrationCallback; | 60 RegistrationCallback; |
| 61 | 61 |
| 62 // Details of the of the Registration Request. Only user's android ID and | 62 // Encapsulates the common info about a registration/token request. |
|
Nicolas Zea
2015/05/21 21:07:51
Are all parameters mandatory?
jianli
2015/05/21 23:11:24
Yes. Added to comment.
| |
| 63 // its serial number are optional and can be set to 0. All other parameters | |
| 64 // have to be specified to successfully complete the call. | |
| 65 struct GCM_EXPORT RequestInfo { | 63 struct GCM_EXPORT RequestInfo { |
| 64 public: | |
| 66 RequestInfo(uint64 android_id, | 65 RequestInfo(uint64 android_id, |
| 67 uint64 security_token, | 66 uint64 security_token, |
| 68 const std::string& app_id, | 67 const std::string& app_id); |
| 69 const std::vector<std::string>& sender_ids); | |
| 70 ~RequestInfo(); | 68 ~RequestInfo(); |
| 71 | 69 |
| 72 // Android ID of the device. | 70 // Android ID of the device. |
| 73 uint64 android_id; | 71 uint64 android_id; |
| 74 // Security token of the device. | 72 // Security token of the device. |
| 75 uint64 security_token; | 73 uint64 security_token; |
| 76 // Application ID. | 74 // Application ID. |
| 77 std::string app_id; | 75 std::string app_id; |
| 78 // Certificate of the application. | |
| 79 std::string cert; | |
| 80 // List of IDs of senders. Allowed up to 100. | |
| 81 std::vector<std::string> sender_ids; | |
| 82 }; | 76 }; |
| 83 | 77 |
| 84 RegistrationRequest( | 78 RegistrationRequest( |
| 85 const GURL& registration_url, | 79 const GURL& registration_url, |
| 86 const RequestInfo& request_info, | 80 const RequestInfo& request_info, |
| 87 const net::BackoffEntry::Policy& backoff_policy, | 81 const net::BackoffEntry::Policy& backoff_policy, |
| 88 const RegistrationCallback& callback, | 82 const RegistrationCallback& callback, |
| 89 int max_retry_count, | 83 int max_retry_count, |
| 90 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | 84 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
| 91 GCMStatsRecorder* recorder); | 85 GCMStatsRecorder* recorder); |
| 92 ~RegistrationRequest() override; | 86 ~RegistrationRequest() override; |
| 93 | 87 |
| 94 void Start(); | 88 void Start(); |
| 95 | 89 |
| 96 // URLFetcherDelegate implementation. | 90 // URLFetcherDelegate implementation. |
| 97 void OnURLFetchComplete(const net::URLFetcher* source) override; | 91 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 98 | 92 |
| 93 virtual void BuildRequestHeaders(std::string* extra_headers); | |
|
Nicolas Zea
2015/05/21 21:07:51
Although I like the approach of injecting extra re
jianli
2015/05/21 23:11:24
I don't fully understand the callback proposal. Co
Nicolas Zea
2015/05/22 14:53:13
So there's be three new constructor parameters, tw
| |
| 94 virtual void BuildRequestBody(std::string* body); | |
| 95 // Returns the source string to print by the stats recorder. | |
| 96 virtual std::string GetSourceForRecorder() const = 0; | |
| 97 | |
| 99 private: | 98 private: |
| 100 // Schedules a retry attempt, informs the backoff of a previous request's | 99 // Schedules a retry attempt, informs the backoff of a previous request's |
| 101 // failure, when |update_backoff| is true. | 100 // failure, when |update_backoff| is true. |
| 102 void RetryWithBackoff(bool update_backoff); | 101 void RetryWithBackoff(bool update_backoff); |
| 103 | 102 |
| 104 // Parse the response returned by the URL fetcher into token, and returns the | 103 // Parse the response returned by the URL fetcher into token, and returns the |
| 105 // status. | 104 // status. |
| 106 Status ParseResponse(const net::URLFetcher* source, std::string* token); | 105 Status ParseResponse(const net::URLFetcher* source, std::string* token); |
| 107 | 106 |
| 108 RegistrationCallback callback_; | 107 RegistrationCallback callback_; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 119 GCMStatsRecorder* recorder_; | 118 GCMStatsRecorder* recorder_; |
| 120 | 119 |
| 121 base::WeakPtrFactory<RegistrationRequest> weak_ptr_factory_; | 120 base::WeakPtrFactory<RegistrationRequest> weak_ptr_factory_; |
| 122 | 121 |
| 123 DISALLOW_COPY_AND_ASSIGN(RegistrationRequest); | 122 DISALLOW_COPY_AND_ASSIGN(RegistrationRequest); |
| 124 }; | 123 }; |
| 125 | 124 |
| 126 } // namespace gcm | 125 } // namespace gcm |
| 127 | 126 |
| 128 #endif // GOOGLE_APIS_GCM_ENGINE_REGISTRATION_REQUEST_H_ | 127 #endif // GOOGLE_APIS_GCM_ENGINE_REGISTRATION_REQUEST_H_ |
| OLD | NEW |