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