Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: content/browser/geolocation/network_location_request.h

Issue 8373021: Convert URLFetcher::Delegates to use an interface in content/public/common. Also remove the old U... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync and remove unncessary forward declares Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "content/browser/geolocation/device_data_provider.h" 14 #include "content/browser/geolocation/device_data_provider.h"
15 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
16 #include "content/common/net/url_fetcher.h" 16 #include "content/public/common/url_fetcher_delegate.h"
17 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
18 18
19 class URLFetcher; 19 class URLFetcher;
20 20
21 namespace net { 21 namespace net {
22 class URLRequestContextGetter; 22 class URLRequestContextGetter;
23 } 23 }
24 24
25 struct Geoposition; 25 struct Geoposition;
26 struct Position; 26 struct Position;
27 27
28 // Takes a set of device data and sends it to a server to get a position fix. 28 // Takes a set of device data and sends it to a server to get a position fix.
29 // It performs formatting of the request and interpretation of the response. 29 // It performs formatting of the request and interpretation of the response.
30 class NetworkLocationRequest : private URLFetcher::Delegate { 30 class NetworkLocationRequest : private content::URLFetcherDelegate {
31 public: 31 public:
32 // ID passed to URLFetcher::Create(). Used for testing. 32 // ID passed to URLFetcher::Create(). Used for testing.
33 CONTENT_EXPORT static int url_fetcher_id_for_tests; 33 CONTENT_EXPORT static int url_fetcher_id_for_tests;
34 // Interface for receiving callbacks from a NetworkLocationRequest object. 34 // Interface for receiving callbacks from a NetworkLocationRequest object.
35 class ListenerInterface { 35 class ListenerInterface {
36 public: 36 public:
37 // Updates the listener with a new position. server_error indicates whether 37 // Updates the listener with a new position. server_error indicates whether
38 // was a server or network error - either no response or a 500 error code. 38 // was a server or network error - either no response or a 500 error code.
39 virtual void LocationResponseAvailable( 39 virtual void LocationResponseAvailable(
40 const Geoposition& position, 40 const Geoposition& position,
(...skipping 17 matching lines...) Expand all
58 bool MakeRequest(const std::string& host, 58 bool MakeRequest(const std::string& host,
59 const string16& access_token, 59 const string16& access_token,
60 const RadioData& radio_data, 60 const RadioData& radio_data,
61 const WifiData& wifi_data, 61 const WifiData& wifi_data,
62 const base::Time& timestamp); 62 const base::Time& timestamp);
63 63
64 bool is_request_pending() const { return url_fetcher_ != NULL; } 64 bool is_request_pending() const { return url_fetcher_ != NULL; }
65 const GURL& url() const { return url_; } 65 const GURL& url() const { return url_; }
66 66
67 private: 67 private:
68 // URLFetcher::Delegate 68 // content::URLFetcherDelegate
69 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE; 69 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE;
70 70
71 scoped_refptr<net::URLRequestContextGetter> url_context_; 71 scoped_refptr<net::URLRequestContextGetter> url_context_;
72 ListenerInterface* listener_; 72 ListenerInterface* listener_;
73 const GURL url_; 73 const GURL url_;
74 scoped_ptr<URLFetcher> url_fetcher_; 74 scoped_ptr<URLFetcher> url_fetcher_;
75 75
76 // Keep a copy of the data sent in the request, so we can refer back to it 76 // Keep a copy of the data sent in the request, so we can refer back to it
77 // when the response arrives. 77 // when the response arrives.
78 RadioData radio_data_; 78 RadioData radio_data_;
79 WifiData wifi_data_; 79 WifiData wifi_data_;
80 base::Time timestamp_; // Timestamp of the above data, not of the request. 80 base::Time timestamp_; // Timestamp of the above data, not of the request.
81 81
82 DISALLOW_COPY_AND_ASSIGN(NetworkLocationRequest); 82 DISALLOW_COPY_AND_ASSIGN(NetworkLocationRequest);
83 }; 83 };
84 84
85 #endif // CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_ 85 #endif // CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698