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

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

Issue 6597044: Revert 76228 - Move core pieces of geolocation from chrome to content.This is... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_
6 #define CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/ref_counted.h"
13 #include "base/scoped_ptr.h"
14 #include "chrome/common/net/url_fetcher.h"
15 #include "content/browser/geolocation/device_data_provider.h"
16 #include "googleurl/src/gurl.h"
17
18 class URLRequestContextGetter;
19 class URLFetcher;
20 struct Geoposition;
21 struct Position;
22
23 // Takes a set of device data and sends it to a server to get a position fix.
24 // It performs formatting of the request and interpretation of the response.
25 class NetworkLocationRequest : private URLFetcher::Delegate {
26 public:
27 // ID passed to URLFetcher::Create(). Used for testing.
28 static int url_fetcher_id_for_tests;
29 // Interface for receiving callbacks from a NetworkLocationRequest object.
30 class ListenerInterface {
31 public:
32 // Updates the listener with a new position. server_error indicates whether
33 // was a server or network error - either no response or a 500 error code.
34 virtual void LocationResponseAvailable(
35 const Geoposition& position,
36 bool server_error,
37 const string16& access_token,
38 const GatewayData& gateway_data,
39 const RadioData& radio_data,
40 const WifiData& wifi_data) = 0;
41
42 protected:
43 virtual ~ListenerInterface() {}
44 };
45
46 // |url| is the server address to which the request wil be sent.
47 NetworkLocationRequest(URLRequestContextGetter* context,
48 const GURL& url,
49 ListenerInterface* listener);
50 virtual ~NetworkLocationRequest();
51
52 // Makes a new request. Returns true if the new request was successfully
53 // started. In all cases, any currently pending request will be canceled.
54 bool MakeRequest(const std::string& host,
55 const string16& access_token,
56 const GatewayData& gateway_data,
57 const RadioData& radio_data,
58 const WifiData& wifi_data,
59 const base::Time& timestamp);
60
61 bool is_request_pending() const { return url_fetcher_ != NULL; }
62 const GURL& url() const { return url_; }
63
64 private:
65 // URLFetcher::Delegate
66 virtual void OnURLFetchComplete(const URLFetcher* source,
67 const GURL& url,
68 const net::URLRequestStatus& status,
69 int response_code,
70 const ResponseCookies& cookies,
71 const std::string& data);
72
73 scoped_refptr<URLRequestContextGetter> url_context_;
74 ListenerInterface* listener_;
75 const GURL url_;
76 scoped_ptr<URLFetcher> url_fetcher_;
77
78 // Keep a copy of the data sent in the request, so we can refer back to it
79 // when the response arrives.
80 GatewayData gateway_data_;
81 RadioData radio_data_;
82 WifiData wifi_data_;
83 base::Time timestamp_; // Timestamp of the above data, not of the request.
84
85 DISALLOW_COPY_AND_ASSIGN(NetworkLocationRequest);
86 };
87
88 #endif // CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698