summaryrefslogtreecommitdiff
path: root/chromium/services/device/geolocation
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-05-24 11:40:17 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-05-24 12:42:11 +0000
commit5d87695f37678f96492b258bbab36486c59866b4 (patch)
treebe9783bbaf04fb930c4d74ca9c00b5e7954c8bc6 /chromium/services/device/geolocation
parent6c11fb357ec39bf087b8b632e2b1e375aef1b38b (diff)
downloadqtwebengine-chromium-5d87695f37678f96492b258bbab36486c59866b4.tar.gz
BASELINE: Update Chromium to 75.0.3770.56
Change-Id: I86d2007fd27a45d5797eee06f4c9369b8b50ac4f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/services/device/geolocation')
-rw-r--r--chromium/services/device/geolocation/BUILD.gn2
-rw-r--r--chromium/services/device/geolocation/OWNERS4
-rw-r--r--chromium/services/device/geolocation/fake_position_cache.cc4
-rw-r--r--chromium/services/device/geolocation/fake_position_cache.h1
-rw-r--r--chromium/services/device/geolocation/geolocation_service_unittest.cc6
-rw-r--r--chromium/services/device/geolocation/network_location_provider.cc8
-rw-r--r--chromium/services/device/geolocation/position_cache.h3
-rw-r--r--chromium/services/device/geolocation/position_cache_impl.cc4
-rw-r--r--chromium/services/device/geolocation/position_cache_impl.h2
-rw-r--r--chromium/services/device/geolocation/position_cache_impl_unittest.cc16
-rw-r--r--chromium/services/device/geolocation/wifi_data_provider_chromeos_unittest.cc11
11 files changed, 50 insertions, 11 deletions
diff --git a/chromium/services/device/geolocation/BUILD.gn b/chromium/services/device/geolocation/BUILD.gn
index ea8b7c73736..49b282778d7 100644
--- a/chromium/services/device/geolocation/BUILD.gn
+++ b/chromium/services/device/geolocation/BUILD.gn
@@ -110,7 +110,7 @@ source_set("geolocation") {
}
if (is_chromeos) {
deps += [
- "//chromeos/dbus",
+ "//chromeos/dbus/shill",
"//chromeos/network",
]
}
diff --git a/chromium/services/device/geolocation/OWNERS b/chromium/services/device/geolocation/OWNERS
index 2ce1e4aebeb..2596b2d67e8 100644
--- a/chromium/services/device/geolocation/OWNERS
+++ b/chromium/services/device/geolocation/OWNERS
@@ -1,6 +1,8 @@
mattreynolds@chromium.org
+
+# Original (legacy) owners.
mcasas@chromium.org
timvolodine@chromium.org
+# COMPONENT: Blink>Geolocation
# TEAM: device-dev@chromium.org
-# COMPONENT: Blink>Location
diff --git a/chromium/services/device/geolocation/fake_position_cache.cc b/chromium/services/device/geolocation/fake_position_cache.cc
index 7447bd0f24f..6d2d35d477a 100644
--- a/chromium/services/device/geolocation/fake_position_cache.cc
+++ b/chromium/services/device/geolocation/fake_position_cache.cc
@@ -44,6 +44,10 @@ const mojom::Geoposition* FakePositionCache::FindPosition(
return it == data.end() ? nullptr : &(it->second);
}
+size_t FakePositionCache::GetPositionCacheSize() const {
+ return data.size();
+}
+
const mojom::Geoposition& FakePositionCache::GetLastUsedNetworkPosition()
const {
return last_used_position;
diff --git a/chromium/services/device/geolocation/fake_position_cache.h b/chromium/services/device/geolocation/fake_position_cache.h
index ec7c951ea06..998f12aab0c 100644
--- a/chromium/services/device/geolocation/fake_position_cache.h
+++ b/chromium/services/device/geolocation/fake_position_cache.h
@@ -23,6 +23,7 @@ class FakePositionCache : public PositionCache {
const mojom::Geoposition& position) override;
const mojom::Geoposition* FindPosition(
const WifiData& wifi_data) const override;
+ size_t GetPositionCacheSize() const override;
const mojom::Geoposition& GetLastUsedNetworkPosition() const override;
void SetLastUsedNetworkPosition(const mojom::Geoposition& position) override;
diff --git a/chromium/services/device/geolocation/geolocation_service_unittest.cc b/chromium/services/device/geolocation/geolocation_service_unittest.cc
index 3d69c7a6cd6..36f6ffebd76 100644
--- a/chromium/services/device/geolocation/geolocation_service_unittest.cc
+++ b/chromium/services/device/geolocation/geolocation_service_unittest.cc
@@ -7,7 +7,7 @@
#include "base/test/bind_test_util.h"
#include "build/build_config.h"
#if defined(OS_CHROMEOS)
-#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/dbus/shill/shill_clients.h"
#include "chromeos/network/geolocation_handler.h"
#endif
#include "mojo/public/cpp/bindings/interface_ptr.h"
@@ -40,7 +40,7 @@ class GeolocationServiceUnitTest : public DeviceServiceTestBase {
protected:
void SetUp() override {
#if defined(OS_CHROMEOS)
- chromeos::DBusThreadManager::Initialize();
+ chromeos::shill_clients::InitializeFakes();
chromeos::NetworkHandler::Initialize();
#endif
network_change_notifier_.reset(net::NetworkChangeNotifier::CreateMock());
@@ -60,7 +60,7 @@ class GeolocationServiceUnitTest : public DeviceServiceTestBase {
#if defined(OS_CHROMEOS)
chromeos::NetworkHandler::Shutdown();
- chromeos::DBusThreadManager::Shutdown();
+ chromeos::shill_clients::Shutdown();
#endif
// Let the GeolocationImpl destruct earlier than GeolocationProviderImpl to
diff --git a/chromium/services/device/geolocation/network_location_provider.cc b/chromium/services/device/geolocation/network_location_provider.cc
index 99412f3103e..d04b5503892 100644
--- a/chromium/services/device/geolocation/network_location_provider.cc
+++ b/chromium/services/device/geolocation/network_location_provider.cc
@@ -8,6 +8,8 @@
#include "base/bind.h"
#include "base/location.h"
+#include "base/metrics/histogram_macros.h"
+#include "base/numerics/ranges.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -179,6 +181,12 @@ void NetworkLocationProvider::RequestPosition() {
const mojom::Geoposition* cached_position =
position_cache_->FindPosition(wifi_data_);
+
+ UMA_HISTOGRAM_BOOLEAN("Geolocation.PositionCache.CacheHit",
+ cached_position != nullptr);
+ UMA_HISTOGRAM_COUNTS_100("Geolocation.PositionCache.CacheSize",
+ position_cache_->GetPositionCacheSize());
+
if (cached_position) {
mojom::Geoposition position(*cached_position);
DCHECK(ValidateGeoposition(position));
diff --git a/chromium/services/device/geolocation/position_cache.h b/chromium/services/device/geolocation/position_cache.h
index eae8d577c31..f9b526f617a 100644
--- a/chromium/services/device/geolocation/position_cache.h
+++ b/chromium/services/device/geolocation/position_cache.h
@@ -31,6 +31,9 @@ class PositionCache {
virtual const mojom::Geoposition* FindPosition(
const WifiData& wifi_data) const = 0;
+ // Returns the number of cached position responses stored in the cache.
+ virtual size_t GetPositionCacheSize() const = 0;
+
// Returns most recently used position, or an invalid Geoposition if
// SetLastUsedNetworkPosition wasn't called yet.
virtual const mojom::Geoposition& GetLastUsedNetworkPosition() const = 0;
diff --git a/chromium/services/device/geolocation/position_cache_impl.cc b/chromium/services/device/geolocation/position_cache_impl.cc
index 11cf0798f24..1aa09e02dc2 100644
--- a/chromium/services/device/geolocation/position_cache_impl.cc
+++ b/chromium/services/device/geolocation/position_cache_impl.cc
@@ -81,6 +81,10 @@ const mojom::Geoposition* PositionCacheImpl::FindPosition(
return it == data_.end() ? nullptr : (it->position());
}
+size_t PositionCacheImpl::GetPositionCacheSize() const {
+ return data_.size();
+}
+
const mojom::Geoposition& PositionCacheImpl::GetLastUsedNetworkPosition()
const {
return last_used_position_;
diff --git a/chromium/services/device/geolocation/position_cache_impl.h b/chromium/services/device/geolocation/position_cache_impl.h
index 1ee5a1fe657..5c931a60451 100644
--- a/chromium/services/device/geolocation/position_cache_impl.h
+++ b/chromium/services/device/geolocation/position_cache_impl.h
@@ -44,6 +44,8 @@ class PositionCacheImpl
const mojom::Geoposition* FindPosition(
const WifiData& wifi_data) const override;
+ size_t GetPositionCacheSize() const override;
+
const mojom::Geoposition& GetLastUsedNetworkPosition() const override;
void SetLastUsedNetworkPosition(const mojom::Geoposition& position) override;
diff --git a/chromium/services/device/geolocation/position_cache_impl_unittest.cc b/chromium/services/device/geolocation/position_cache_impl_unittest.cc
index 1d7a6056e67..251ddab87be 100644
--- a/chromium/services/device/geolocation/position_cache_impl_unittest.cc
+++ b/chromium/services/device/geolocation/position_cache_impl_unittest.cc
@@ -34,6 +34,7 @@ class PositionCacheImplTest : public ::testing::Test {
TEST_F(PositionCacheImplTest, EmptyCacheReturnsNoLocations) {
WifiData empty_wifi_data;
EXPECT_EQ(nullptr, cache_.FindPosition(empty_wifi_data));
+ EXPECT_EQ(0U, cache_.GetPositionCacheSize());
}
TEST_F(PositionCacheImplTest, CanAddEmptyWifiData) {
@@ -45,6 +46,7 @@ TEST_F(PositionCacheImplTest, CanAddEmptyWifiData) {
cache_.FindPosition(empty_wifi_data);
ASSERT_NE(nullptr, found_position);
EXPECT_TRUE(geoposition.Equals(*found_position));
+ EXPECT_EQ(1U, cache_.GetPositionCacheSize());
}
TEST_F(PositionCacheImplTest, FirstAddedWifiDataReturned) {
@@ -55,6 +57,7 @@ TEST_F(PositionCacheImplTest, FirstAddedWifiDataReturned) {
const mojom::Geoposition* found_position = cache_.FindPosition(wifi_data);
ASSERT_NE(nullptr, found_position);
EXPECT_TRUE(geoposition.Equals(*found_position));
+ EXPECT_EQ(1U, cache_.GetPositionCacheSize());
}
TEST_F(PositionCacheImplTest, LastAddedWifiDataReturned) {
@@ -71,6 +74,7 @@ TEST_F(PositionCacheImplTest, LastAddedWifiDataReturned) {
cache_.FindPosition(final_wifi_data);
ASSERT_NE(nullptr, found_position);
EXPECT_TRUE(final_geoposition.Equals(*found_position));
+ EXPECT_EQ(3U, cache_.GetPositionCacheSize());
}
TEST_F(PositionCacheImplTest, MaxPositionsFound) {
@@ -84,6 +88,7 @@ TEST_F(PositionCacheImplTest, MaxPositionsFound) {
for (const auto& test_data_pair : test_data) {
cache_.CachePosition(test_data_pair.first, test_data_pair.second);
}
+ EXPECT_EQ(PositionCacheImpl::kMaximumSize, cache_.GetPositionCacheSize());
// Make sure all elements are cached.
for (const auto& test_data_pair : test_data) {
const mojom::Geoposition* found_position =
@@ -97,6 +102,7 @@ TEST_F(PositionCacheImplTest, Eviction) {
WifiData initial_wifi_data = testing::CreateDefaultUniqueWifiData();
mojom::Geoposition initial_geoposition = testing::CreateGeoposition(1);
cache_.CachePosition(initial_wifi_data, initial_geoposition);
+ EXPECT_EQ(1U, cache_.GetPositionCacheSize());
// Add as many entries as the cache's size limit, which should evict
// |initial_wifi_data|.
@@ -104,6 +110,7 @@ TEST_F(PositionCacheImplTest, Eviction) {
cache_.CachePosition(testing::CreateDefaultUniqueWifiData(),
testing::CreateGeoposition(i));
}
+ EXPECT_EQ(PositionCacheImpl::kMaximumSize, cache_.GetPositionCacheSize());
// |initial_wifi_data| can no longer be found in cache_.
ASSERT_EQ(nullptr, cache_.FindPosition(initial_wifi_data));
@@ -128,17 +135,20 @@ TEST_F(PositionCacheImplTest, EntryEvictedAfterMaxLifetimeReached) {
cache_.FindPosition(initial_wifi_data);
ASSERT_NE(nullptr, found_position);
EXPECT_TRUE(initial_geoposition.Equals(*found_position));
+ EXPECT_EQ(1U, cache_.GetPositionCacheSize());
task_environment_.FastForwardBy(PositionCacheImpl::kMaximumLifetime);
// Position was evicted.
EXPECT_EQ(nullptr, cache_.FindPosition(initial_wifi_data));
+ EXPECT_EQ(0U, cache_.GetPositionCacheSize());
}
TEST_F(PositionCacheImplTest, OnlyOldEntriesEvicted) {
WifiData older_wifi_data = testing::CreateDefaultUniqueWifiData();
mojom::Geoposition older_geoposition = testing::CreateGeoposition(1);
cache_.CachePosition(older_wifi_data, older_geoposition);
+ EXPECT_EQ(1U, cache_.GetPositionCacheSize());
// Some time passes, but less than kMaximumLifetime
task_environment_.FastForwardBy(PositionCacheImpl::kMaximumLifetime * 0.5);
@@ -148,11 +158,13 @@ TEST_F(PositionCacheImplTest, OnlyOldEntriesEvicted) {
cache_.FindPosition(older_wifi_data);
ASSERT_NE(nullptr, found_position);
EXPECT_TRUE(older_geoposition.Equals(*found_position));
+ EXPECT_EQ(1U, cache_.GetPositionCacheSize());
// New position is added.
WifiData newer_wifi_data = testing::CreateDefaultUniqueWifiData();
mojom::Geoposition newer_geoposition = testing::CreateGeoposition(2);
cache_.CachePosition(newer_wifi_data, newer_geoposition);
+ EXPECT_EQ(2U, cache_.GetPositionCacheSize());
// Enough time passes to evict the older entry, but not enough to evict the
// newer one.
@@ -164,6 +176,7 @@ TEST_F(PositionCacheImplTest, OnlyOldEntriesEvicted) {
cache_.FindPosition(newer_wifi_data);
ASSERT_NE(nullptr, found_newer_position);
EXPECT_TRUE(newer_geoposition.Equals(*found_newer_position));
+ EXPECT_EQ(1U, cache_.GetPositionCacheSize());
}
TEST_F(PositionCacheImplTest, NetworkChangeClearsEmptyWifiDataPosition) {
@@ -171,11 +184,13 @@ TEST_F(PositionCacheImplTest, NetworkChangeClearsEmptyWifiDataPosition) {
WifiData initial_wifi_data = testing::CreateDefaultUniqueWifiData();
mojom::Geoposition initial_geoposition = testing::CreateGeoposition(1);
cache_.CachePosition(initial_wifi_data, initial_geoposition);
+ EXPECT_EQ(1U, cache_.GetPositionCacheSize());
// Cache a position for empty WifiData (wired network).
WifiData empty_wifi_data;
mojom::Geoposition empty_data_geoposition = testing::CreateGeoposition(2);
cache_.CachePosition(empty_wifi_data, empty_data_geoposition);
+ EXPECT_EQ(2U, cache_.GetPositionCacheSize());
cache_.SetLastUsedNetworkPosition(initial_geoposition);
@@ -197,5 +212,6 @@ TEST_F(PositionCacheImplTest, NetworkChangeClearsEmptyWifiDataPosition) {
cache_.FindPosition(initial_wifi_data);
ASSERT_NE(nullptr, found_position);
EXPECT_TRUE(initial_geoposition.Equals(*found_position));
+ EXPECT_EQ(1U, cache_.GetPositionCacheSize());
}
} // namespace device
diff --git a/chromium/services/device/geolocation/wifi_data_provider_chromeos_unittest.cc b/chromium/services/device/geolocation/wifi_data_provider_chromeos_unittest.cc
index 9b934b13fc9..a76e2bdd336 100644
--- a/chromium/services/device/geolocation/wifi_data_provider_chromeos_unittest.cc
+++ b/chromium/services/device/geolocation/wifi_data_provider_chromeos_unittest.cc
@@ -8,8 +8,8 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_task_environment.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/shill_manager_client.h"
+#include "chromeos/dbus/shill/shill_clients.h"
+#include "chromeos/dbus/shill/shill_manager_client.h"
#include "chromeos/network/geolocation_handler.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -23,10 +23,9 @@ class GeolocationChromeOsWifiDataProviderTest : public testing::Test {
base::test::ScopedTaskEnvironment::MainThreadType::UI) {}
void SetUp() override {
- chromeos::DBusThreadManager::Initialize();
+ chromeos::shill_clients::InitializeFakes();
chromeos::NetworkHandler::Initialize();
- manager_client_ =
- chromeos::DBusThreadManager::Get()->GetShillManagerClient();
+ manager_client_ = chromeos::ShillManagerClient::Get();
manager_test_ = manager_client_->GetTestInterface();
provider_ = new WifiDataProviderChromeOs();
base::RunLoop().RunUntilIdle();
@@ -35,7 +34,7 @@ class GeolocationChromeOsWifiDataProviderTest : public testing::Test {
void TearDown() override {
provider_ = NULL;
chromeos::NetworkHandler::Shutdown();
- chromeos::DBusThreadManager::Shutdown();
+ chromeos::shill_clients::Shutdown();
}
bool GetAccessPointData() { return provider_->GetAccessPointData(&ap_data_); }