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

Unified Diff: chromeos/geolocation/simple_geolocation_request.h

Issue 1819173002: SimpleGeolocation should support sending WiFi AP data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update after review. Created 4 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 side-by-side diff with in-line comments
Download patch
Index: chromeos/geolocation/simple_geolocation_request.h
diff --git a/chromeos/geolocation/simple_geolocation_request.h b/chromeos/geolocation/simple_geolocation_request.h
index 8771e5d563d6e9ecf99a2916306a3e2a942313f6..19ff507d607c99d32a2599268bb7aa4fe8292e50 100644
--- a/chromeos/geolocation/simple_geolocation_request.h
+++ b/chromeos/geolocation/simple_geolocation_request.h
@@ -12,7 +12,9 @@
#include "base/memory/scoped_ptr.h"
#include "base/threading/thread_checker.h"
#include "base/timer/timer.h"
+#include "chromeos/chromeos_export.h"
#include "chromeos/geolocation/geoposition.h"
+#include "chromeos/network/network_util.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_fetcher_delegate.h"
#include "url/gurl.h"
@@ -23,6 +25,8 @@ class URLRequestContextGetter;
namespace chromeos {
+class SimpleGeolocationRequestTestMonitor;
+
// Sends request to a server to get local geolocation information.
// It performs formatting of the request and interpretation of the response.
// Request is owned and destroyed by caller (usually SimpleGeolocationProvider).
@@ -32,7 +36,10 @@ namespace chromeos {
// (position.status is set to STATUS_TIMEOUT.)
// - If request is destroyed while callback has not beed called yet, request
// is silently cancelled.
-class SimpleGeolocationRequest : private net::URLFetcherDelegate {
+//
+// Note: we need CHROMEOS_EXPORT for tests.
+class CHROMEOS_EXPORT SimpleGeolocationRequest
+ : private net::URLFetcherDelegate {
public:
// Called when a new geo geolocation information is available.
// The second argument indicates whether there was a server error or not.
@@ -44,9 +51,11 @@ class SimpleGeolocationRequest : private net::URLFetcherDelegate {
// |url| is the server address to which the request wil be sent.
// |timeout| retry request on error until timeout.
+ // If wifi_data is not null, it will be sent to the geolocation server.
SimpleGeolocationRequest(net::URLRequestContextGetter* url_context_getter,
const GURL& service_url,
- base::TimeDelta timeout);
+ base::TimeDelta timeout,
+ scoped_ptr<WifiAccessPointVector> wifi_data);
~SimpleGeolocationRequest() override;
@@ -65,6 +74,11 @@ class SimpleGeolocationRequest : private net::URLFetcherDelegate {
retry_sleep_on_bad_response_ = value;
}
+ // Sets global requests monitoring object for testing.
+ static void SetTestMonitor(SimpleGeolocationRequestTestMonitor* monitor);
+
+ std::string FormatRequestBodyForTesting() const;
+
private:
// net::URLFetcherDelegate
void OnURLFetchComplete(const net::URLFetcher* source) override;
@@ -81,6 +95,9 @@ class SimpleGeolocationRequest : private net::URLFetcherDelegate {
// Called by timeout_timer_ .
void OnTimeout();
+ // Returns API request body.
+ std::string FormatRequestBody() const;
+
scoped_refptr<net::URLRequestContextGetter> url_context_getter_;
// Service URL from constructor arguments.
@@ -114,6 +131,8 @@ class SimpleGeolocationRequest : private net::URLFetcherDelegate {
// This is updated on each retry.
Geoposition position_;
+ scoped_ptr<WifiAccessPointVector> wifi_data_;
+
// Creation and destruction should happen on the same thread.
base::ThreadChecker thread_checker_;
« no previous file with comments | « chromeos/geolocation/simple_geolocation_provider.cc ('k') | chromeos/geolocation/simple_geolocation_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698