| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_ | 5 #ifndef CHROME_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_ |
| 6 #define CHROME_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_ | 6 #define CHROME_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 static int url_fetcher_id_for_tests; | 27 static int url_fetcher_id_for_tests; |
| 28 // Interface for receiving callbacks from a NetworkLocationRequest object. | 28 // Interface for receiving callbacks from a NetworkLocationRequest object. |
| 29 class ListenerInterface { | 29 class ListenerInterface { |
| 30 public: | 30 public: |
| 31 // Updates the listener with a new position. server_error indicates whether | 31 // Updates the listener with a new position. server_error indicates whether |
| 32 // was a server or network error - either no response or a 500 error code. | 32 // was a server or network error - either no response or a 500 error code. |
| 33 virtual void LocationResponseAvailable( | 33 virtual void LocationResponseAvailable( |
| 34 const Geoposition& position, | 34 const Geoposition& position, |
| 35 bool server_error, | 35 bool server_error, |
| 36 const string16& access_token, | 36 const string16& access_token, |
| 37 const GatewayData& gateway_data, |
| 37 const RadioData& radio_data, | 38 const RadioData& radio_data, |
| 38 const WifiData& wifi_data) = 0; | 39 const WifiData& wifi_data) = 0; |
| 39 | 40 |
| 40 protected: | 41 protected: |
| 41 virtual ~ListenerInterface() {} | 42 virtual ~ListenerInterface() {} |
| 42 }; | 43 }; |
| 43 | 44 |
| 44 // |url| is the server address to which the request wil be sent. | 45 // |url| is the server address to which the request wil be sent. |
| 45 NetworkLocationRequest(URLRequestContextGetter* context, | 46 NetworkLocationRequest(URLRequestContextGetter* context, |
| 46 const GURL& url, | 47 const GURL& url, |
| 47 ListenerInterface* listener); | 48 ListenerInterface* listener); |
| 48 virtual ~NetworkLocationRequest(); | 49 virtual ~NetworkLocationRequest(); |
| 49 | 50 |
| 50 // Makes a new request. Returns true if the new request was successfully | 51 // Makes a new request. Returns true if the new request was successfully |
| 51 // started. In all cases, any currently pending request will be canceled. | 52 // started. In all cases, any currently pending request will be canceled. |
| 52 bool MakeRequest(const std::string& host, | 53 bool MakeRequest(const std::string& host, |
| 53 const string16& access_token, | 54 const string16& access_token, |
| 55 const GatewayData& gateway_data, |
| 54 const RadioData& radio_data, | 56 const RadioData& radio_data, |
| 55 const WifiData& wifi_data, | 57 const WifiData& wifi_data, |
| 56 const base::Time& timestamp); | 58 const base::Time& timestamp); |
| 57 | 59 |
| 58 bool is_request_pending() const { return url_fetcher_ != NULL; } | 60 bool is_request_pending() const { return url_fetcher_ != NULL; } |
| 59 const GURL& url() const { return url_; } | 61 const GURL& url() const { return url_; } |
| 60 | 62 |
| 61 private: | 63 private: |
| 62 // URLFetcher::Delegate | 64 // URLFetcher::Delegate |
| 63 virtual void OnURLFetchComplete(const URLFetcher* source, | 65 virtual void OnURLFetchComplete(const URLFetcher* source, |
| 64 const GURL& url, | 66 const GURL& url, |
| 65 const URLRequestStatus& status, | 67 const URLRequestStatus& status, |
| 66 int response_code, | 68 int response_code, |
| 67 const ResponseCookies& cookies, | 69 const ResponseCookies& cookies, |
| 68 const std::string& data); | 70 const std::string& data); |
| 69 | 71 |
| 70 scoped_refptr<URLRequestContextGetter> url_context_; | 72 scoped_refptr<URLRequestContextGetter> url_context_; |
| 71 ListenerInterface* listener_; | 73 ListenerInterface* listener_; |
| 72 const GURL url_; | 74 const GURL url_; |
| 73 scoped_ptr<URLFetcher> url_fetcher_; | 75 scoped_ptr<URLFetcher> url_fetcher_; |
| 74 | 76 |
| 75 // Keep a copy of the data sent in the request, so we can refer back to it | 77 // Keep a copy of the data sent in the request, so we can refer back to it |
| 76 // when the response arrives. | 78 // when the response arrives. |
| 79 GatewayData gateway_data_; |
| 77 RadioData radio_data_; | 80 RadioData radio_data_; |
| 78 WifiData wifi_data_; | 81 WifiData wifi_data_; |
| 79 base::Time timestamp_; // Timestamp of the above data, not of the request. | 82 base::Time timestamp_; // Timestamp of the above data, not of the request. |
| 80 | 83 |
| 81 DISALLOW_COPY_AND_ASSIGN(NetworkLocationRequest); | 84 DISALLOW_COPY_AND_ASSIGN(NetworkLocationRequest); |
| 82 }; | 85 }; |
| 83 | 86 |
| 84 #endif // CHROME_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_ | 87 #endif // CHROME_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_ |
| OLD | NEW |