| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_ | 5 #ifndef CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_ |
| 6 #define CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_ | 6 #define CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // Called when a new geo position is available. The second argument indicates | 34 // Called when a new geo position is available. The second argument indicates |
| 35 // whether there was a server error or not. It is true when there was a | 35 // whether there was a server error or not. It is true when there was a |
| 36 // server or network error - either no response or a 500 error code. | 36 // server or network error - either no response or a 500 error code. |
| 37 typedef base::Callback<void(const Geoposition& /* position */, | 37 typedef base::Callback<void(const Geoposition& /* position */, |
| 38 bool /* server_error */, | 38 bool /* server_error */, |
| 39 const base::string16& /* access_token */, | 39 const base::string16& /* access_token */, |
| 40 const WifiData& /* wifi_data */)> | 40 const WifiData& /* wifi_data */)> |
| 41 LocationResponseCallback; | 41 LocationResponseCallback; |
| 42 | 42 |
| 43 // |url| is the server address to which the request wil be sent. | 43 // |url| is the server address to which the request wil be sent. |
| 44 NetworkLocationRequest(net::URLRequestContextGetter* context, | 44 NetworkLocationRequest( |
| 45 const GURL& url, | 45 const scoped_refptr<net::URLRequestContextGetter>& context, |
| 46 LocationResponseCallback callback); | 46 const GURL& url, |
| 47 LocationResponseCallback callback); |
| 47 ~NetworkLocationRequest() override; | 48 ~NetworkLocationRequest() override; |
| 48 | 49 |
| 49 // Makes a new request. Returns true if the new request was successfully | 50 // Makes a new request. Returns true if the new request was successfully |
| 50 // started. In all cases, any currently pending request will be canceled. | 51 // started. In all cases, any currently pending request will be canceled. |
| 51 bool MakeRequest(const base::string16& access_token, | 52 bool MakeRequest(const base::string16& access_token, |
| 52 const WifiData& wifi_data, | 53 const WifiData& wifi_data, |
| 53 const base::Time& wifi_timestamp); | 54 const base::Time& wifi_timestamp); |
| 54 | 55 |
| 55 bool is_request_pending() const { return url_fetcher_ != NULL; } | 56 bool is_request_pending() const { return url_fetcher_ != NULL; } |
| 56 const GURL& url() const { return url_; } | 57 const GURL& url() const { return url_; } |
| 57 | 58 |
| 58 private: | 59 private: |
| 59 // net::URLFetcherDelegate | 60 // net::URLFetcherDelegate |
| 60 void OnURLFetchComplete(const net::URLFetcher* source) override; | 61 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 61 | 62 |
| 62 scoped_refptr<net::URLRequestContextGetter> url_context_; | 63 const scoped_refptr<net::URLRequestContextGetter> url_context_; |
| 63 LocationResponseCallback location_response_callback_; | 64 const LocationResponseCallback location_response_callback_; |
| 64 const GURL url_; | 65 const GURL url_; |
| 65 std::unique_ptr<net::URLFetcher> url_fetcher_; | 66 std::unique_ptr<net::URLFetcher> url_fetcher_; |
| 66 | 67 |
| 67 // Keep a copy of the data sent in the request, so we can refer back to it | 68 // Keep a copy of the data sent in the request, so we can refer back to it |
| 68 // when the response arrives. | 69 // when the response arrives. |
| 69 WifiData wifi_data_; | 70 WifiData wifi_data_; |
| 70 base::Time wifi_timestamp_; | 71 base::Time wifi_timestamp_; |
| 71 | 72 |
| 72 // The start time for the request. | 73 // The start time for the request. |
| 73 base::TimeTicks request_start_time_; | 74 base::TimeTicks request_start_time_; |
| 74 | 75 |
| 75 DISALLOW_COPY_AND_ASSIGN(NetworkLocationRequest); | 76 DISALLOW_COPY_AND_ASSIGN(NetworkLocationRequest); |
| 76 }; | 77 }; |
| 77 | 78 |
| 78 } // namespace content | 79 } // namespace content |
| 79 | 80 |
| 80 #endif // CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_ | 81 #endif // CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_ |
| OLD | NEW |