Chromium Code Reviews| Index: chromeos/geolocation/simple_geolocation_provider.cc |
| diff --git a/chromeos/geolocation/simple_geolocation_provider.cc b/chromeos/geolocation/simple_geolocation_provider.cc |
| index e083b3edb0460b911f5c2e1398bfc8f75851dd52..046981ed8c2a7f155f226a786e823cec11ca7877 100644 |
| --- a/chromeos/geolocation/simple_geolocation_provider.cc |
| +++ b/chromeos/geolocation/simple_geolocation_provider.cc |
| @@ -9,6 +9,8 @@ |
| #include "base/bind.h" |
| #include "chromeos/geolocation/geoposition.h" |
| +#include "chromeos/network/geolocation_handler.h" |
| +#include "chromeos/network/network_handler.h" |
| #include "net/url_request/url_request_context_getter.h" |
| namespace chromeos { |
| @@ -16,6 +18,23 @@ namespace chromeos { |
| namespace { |
| const char kDefaultGeolocationProviderUrl[] = |
| "https://www.googleapis.com/geolocation/v1/geolocate?"; |
| + |
| +scoped_ptr<WifiAccessPointVector> GetAccessPointData() { |
| + scoped_ptr<WifiAccessPointVector> result; |
| + |
| + if (!chromeos::NetworkHandler::Get()->geolocation_handler()->wifi_enabled()) |
| + return result; |
| + |
| + chromeos::WifiAccessPointVector access_points; |
|
stevenjb
2016/03/22 16:39:49
Rather than allocating this locally and copying th
Alexander Alekseev
2016/03/23 00:04:45
Done.
|
| + int64_t age_ms = 0; |
| + if (!NetworkHandler::Get()->geolocation_handler()->GetWifiAccessPoints( |
| + &access_points, &age_ms)) { |
| + return result; |
| + } |
| + result.reset(new WifiAccessPointVector(access_points)); |
| + return result; |
| +} |
| + |
| } // namespace |
| SimpleGeolocationProvider::SimpleGeolocationProvider( |
| @@ -30,10 +49,14 @@ SimpleGeolocationProvider::~SimpleGeolocationProvider() { |
| void SimpleGeolocationProvider::RequestGeolocation( |
| base::TimeDelta timeout, |
| + bool send_wifi_access_points, |
| SimpleGeolocationRequest::ResponseCallback callback) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| - SimpleGeolocationRequest* request( |
| - new SimpleGeolocationRequest(url_context_getter_.get(), url_, timeout)); |
| + |
| + SimpleGeolocationRequest* request(new SimpleGeolocationRequest( |
| + url_context_getter_.get(), url_, timeout, |
| + send_wifi_access_points ? GetAccessPointData() |
| + : scoped_ptr<WifiAccessPointVector>())); |
|
stevenjb
2016/03/22 16:39:49
: nullptr
Alexander Alekseev
2016/03/23 00:04:45
Done.
|
| requests_.push_back(request); |
| // SimpleGeolocationProvider owns all requests. It is safe to pass unretained |