#ifndef CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_
#define CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "content/browser/geolocation/device_data_provider.h"
#include "content/common/content_export.h"
#include "googleurl/src/gurl.h"
#include "net/url_request/url_fetcher_delegate.h"
namespace content {
struct Geoposition;
}
namespace net {
class URLFetcher;
class URLRequestContextGetter;
}
class NetworkLocationRequest : private net::URLFetcherDelegate {
public:
CONTENT_EXPORT static int url_fetcher_id_for_tests;
class ListenerInterface {
public:
virtual void LocationResponseAvailable(
const content::Geoposition& position,
bool server_error,
const string16& access_token,
const WifiData& wifi_data) = 0;
protected:
virtual ~ListenerInterface() {}
};
NetworkLocationRequest(net::URLRequestContextGetter* context,
const GURL& url,
ListenerInterface* listener);
virtual ~NetworkLocationRequest();
bool MakeRequest(const string16& access_token,
const WifiData& wifi_data,
const base::Time& timestamp);
bool is_request_pending() const { return url_fetcher_ != NULL; }
const GURL& url() const { return url_; }
private:
virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
scoped_refptr<net::URLRequestContextGetter> url_context_;
ListenerInterface* listener_;
const GURL url_;
scoped_ptr<net::URLFetcher> url_fetcher_;
WifiData wifi_data_;
base::Time timestamp_;
DISALLOW_COPY_AND_ASSIGN(NetworkLocationRequest);
};
#endif