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" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "content/browser/geolocation/device_data_provider.h" | 12 #include "content/browser/geolocation/device_data_provider.h" |
13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
14 #include "content/public/common/url_fetcher_delegate.h" | 14 #include "content/public/common/url_fetcher_delegate.h" |
15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
16 | 16 |
| 17 class URLFetcher; |
| 18 |
| 19 namespace content { |
17 struct Geoposition; | 20 struct Geoposition; |
18 class URLFetcher; | 21 } |
19 | 22 |
20 namespace net { | 23 namespace net { |
21 class URLRequestContextGetter; | 24 class URLRequestContextGetter; |
22 } | 25 } |
23 | 26 |
24 // Takes a set of device data and sends it to a server to get a position fix. | 27 // Takes a set of device data and sends it to a server to get a position fix. |
25 // It performs formatting of the request and interpretation of the response. | 28 // It performs formatting of the request and interpretation of the response. |
26 class NetworkLocationRequest : private content::URLFetcherDelegate { | 29 class NetworkLocationRequest : private content::URLFetcherDelegate { |
27 public: | 30 public: |
28 // ID passed to URLFetcher::Create(). Used for testing. | 31 // ID passed to URLFetcher::Create(). Used for testing. |
29 CONTENT_EXPORT static int url_fetcher_id_for_tests; | 32 CONTENT_EXPORT static int url_fetcher_id_for_tests; |
30 // Interface for receiving callbacks from a NetworkLocationRequest object. | 33 // Interface for receiving callbacks from a NetworkLocationRequest object. |
31 class ListenerInterface { | 34 class ListenerInterface { |
32 public: | 35 public: |
33 // Updates the listener with a new position. server_error indicates whether | 36 // Updates the listener with a new position. server_error indicates whether |
34 // was a server or network error - either no response or a 500 error code. | 37 // was a server or network error - either no response or a 500 error code. |
35 virtual void LocationResponseAvailable( | 38 virtual void LocationResponseAvailable( |
36 const Geoposition& position, | 39 const content::Geoposition& position, |
37 bool server_error, | 40 bool server_error, |
38 const string16& access_token, | 41 const string16& access_token, |
39 const RadioData& radio_data, | 42 const RadioData& radio_data, |
40 const WifiData& wifi_data) = 0; | 43 const WifiData& wifi_data) = 0; |
41 | 44 |
42 protected: | 45 protected: |
43 virtual ~ListenerInterface() {} | 46 virtual ~ListenerInterface() {} |
44 }; | 47 }; |
45 | 48 |
46 // |url| is the server address to which the request wil be sent. | 49 // |url| is the server address to which the request wil be sent. |
(...skipping 24 matching lines...) Expand all Loading... |
71 // Keep a copy of the data sent in the request, so we can refer back to it | 74 // Keep a copy of the data sent in the request, so we can refer back to it |
72 // when the response arrives. | 75 // when the response arrives. |
73 RadioData radio_data_; | 76 RadioData radio_data_; |
74 WifiData wifi_data_; | 77 WifiData wifi_data_; |
75 base::Time timestamp_; // Timestamp of the above data, not of the request. | 78 base::Time timestamp_; // Timestamp of the above data, not of the request. |
76 | 79 |
77 DISALLOW_COPY_AND_ASSIGN(NetworkLocationRequest); | 80 DISALLOW_COPY_AND_ASSIGN(NetworkLocationRequest); |
78 }; | 81 }; |
79 | 82 |
80 #endif // CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_ | 83 #endif // CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_ |
OLD | NEW |