| 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 CHROMEOS_GEOLOCATION_SIMPLE_GEOLOCATION_REQUEST_H_ | 5 #ifndef CHROMEOS_GEOLOCATION_SIMPLE_GEOLOCATION_REQUEST_H_ |
| 6 #define CHROMEOS_GEOLOCATION_SIMPLE_GEOLOCATION_REQUEST_H_ | 6 #define CHROMEOS_GEOLOCATION_SIMPLE_GEOLOCATION_REQUEST_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // The second argument indicates whether there was a server error or not. | 46 // The second argument indicates whether there was a server error or not. |
| 47 // It is true when there was a server or network error - either no response | 47 // It is true when there was a server or network error - either no response |
| 48 // or a 500 error code. | 48 // or a 500 error code. |
| 49 typedef base::Callback<void(const Geoposition& /* position*/, | 49 typedef base::Callback<void(const Geoposition& /* position*/, |
| 50 bool /* server_error */, | 50 bool /* server_error */, |
| 51 const base::TimeDelta elapsed)> ResponseCallback; | 51 const base::TimeDelta elapsed)> ResponseCallback; |
| 52 | 52 |
| 53 // |url| is the server address to which the request wil be sent. | 53 // |url| is the server address to which the request wil be sent. |
| 54 // |timeout| retry request on error until timeout. | 54 // |timeout| retry request on error until timeout. |
| 55 // If wifi_data is not null, it will be sent to the geolocation server. | 55 // If wifi_data is not null, it will be sent to the geolocation server. |
| 56 // If cell_tower_data is not null, it will be sent to the geolocation server. |
| 56 SimpleGeolocationRequest(net::URLRequestContextGetter* url_context_getter, | 57 SimpleGeolocationRequest(net::URLRequestContextGetter* url_context_getter, |
| 57 const GURL& service_url, | 58 const GURL& service_url, |
| 58 base::TimeDelta timeout, | 59 base::TimeDelta timeout, |
| 59 std::unique_ptr<WifiAccessPointVector> wifi_data); | 60 std::unique_ptr<WifiAccessPointVector> wifi_data, |
| 61 std::unique_ptr<CellTowerVector> cell_tower_data); |
| 60 | 62 |
| 61 ~SimpleGeolocationRequest() override; | 63 ~SimpleGeolocationRequest() override; |
| 62 | 64 |
| 63 // Initiates request. | 65 // Initiates request. |
| 64 // Note: if request object is destroyed before callback is called, | 66 // Note: if request object is destroyed before callback is called, |
| 65 // request will be silently cancelled. | 67 // request will be silently cancelled. |
| 66 void MakeRequest(const ResponseCallback& callback); | 68 void MakeRequest(const ResponseCallback& callback); |
| 67 | 69 |
| 68 void set_retry_sleep_on_server_error_for_testing( | 70 void set_retry_sleep_on_server_error_for_testing( |
| 69 const base::TimeDelta value) { | 71 const base::TimeDelta value) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // Stop request on timeout. | 128 // Stop request on timeout. |
| 127 base::OneShotTimer timeout_timer_; | 129 base::OneShotTimer timeout_timer_; |
| 128 | 130 |
| 129 // Number of retry attempts. | 131 // Number of retry attempts. |
| 130 unsigned retries_; | 132 unsigned retries_; |
| 131 | 133 |
| 132 // This is updated on each retry. | 134 // This is updated on each retry. |
| 133 Geoposition position_; | 135 Geoposition position_; |
| 134 | 136 |
| 135 std::unique_ptr<WifiAccessPointVector> wifi_data_; | 137 std::unique_ptr<WifiAccessPointVector> wifi_data_; |
| 138 std::unique_ptr<CellTowerVector> cell_tower_data_; |
| 136 | 139 |
| 137 // Creation and destruction should happen on the same thread. | 140 // Creation and destruction should happen on the same thread. |
| 138 base::ThreadChecker thread_checker_; | 141 base::ThreadChecker thread_checker_; |
| 139 | 142 |
| 140 DISALLOW_COPY_AND_ASSIGN(SimpleGeolocationRequest); | 143 DISALLOW_COPY_AND_ASSIGN(SimpleGeolocationRequest); |
| 141 }; | 144 }; |
| 142 | 145 |
| 143 } // namespace chromeos | 146 } // namespace chromeos |
| 144 | 147 |
| 145 #endif // CHROMEOS_GEOLOCATION_SIMPLE_GEOLOCATION_REQUEST_H_ | 148 #endif // CHROMEOS_GEOLOCATION_SIMPLE_GEOLOCATION_REQUEST_H_ |
| OLD | NEW |