Commit 3711eb12 authored by Joshua Bell's avatar Joshua Bell Committed by Commit Bot

Make BluetoothAllowedDevicesMap non-refcounted

The type was refcounted, but only ever had a single owner
(StoragePartitionImpl). Change the ownership to unique_ptr and
slightly simplify the class.

Change-Id: Idaed9b5b0443982731b6a78c0027a959014d354c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2028731
Commit-Queue: Joshua Bell <jsbell@chromium.org>
Auto-Submit: Joshua Bell <jsbell@chromium.org>
Reviewed-by: default avatarOvidio de Jesús Ruiz-Henríquez <odejesush@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737010}
parent 1841cc77
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
namespace content { namespace content {
BluetoothAllowedDevicesMap::BluetoothAllowedDevicesMap() {} BluetoothAllowedDevicesMap::BluetoothAllowedDevicesMap() = default;
BluetoothAllowedDevicesMap::~BluetoothAllowedDevicesMap() {} BluetoothAllowedDevicesMap::~BluetoothAllowedDevicesMap() = default;
content::BluetoothAllowedDevices& content::BluetoothAllowedDevices&
BluetoothAllowedDevicesMap::GetOrCreateAllowedDevices( BluetoothAllowedDevicesMap::GetOrCreateAllowedDevices(
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include <map> #include <map>
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "url/origin.h" #include "url/origin.h"
...@@ -18,10 +17,10 @@ class BluetoothAllowedDevices; ...@@ -18,10 +17,10 @@ class BluetoothAllowedDevices;
// Class for keeping track of which origins are allowed to access which // Class for keeping track of which origins are allowed to access which
// Bluetooth devices and their services. // Bluetooth devices and their services.
class CONTENT_EXPORT BluetoothAllowedDevicesMap class CONTENT_EXPORT BluetoothAllowedDevicesMap {
: public base::RefCountedThreadSafe<BluetoothAllowedDevicesMap> {
public: public:
BluetoothAllowedDevicesMap(); BluetoothAllowedDevicesMap();
~BluetoothAllowedDevicesMap();
// Gets a BluetoothAllowedDevices for each origin; creates one if it doesn't // Gets a BluetoothAllowedDevices for each origin; creates one if it doesn't
// exist. // exist.
...@@ -32,8 +31,6 @@ class CONTENT_EXPORT BluetoothAllowedDevicesMap ...@@ -32,8 +31,6 @@ class CONTENT_EXPORT BluetoothAllowedDevicesMap
void Clear(); void Clear();
private: private:
friend class base::RefCountedThreadSafe<BluetoothAllowedDevicesMap>;
~BluetoothAllowedDevicesMap();
std::map<url::Origin, content::BluetoothAllowedDevices> std::map<url::Origin, content::BluetoothAllowedDevices>
origin_to_allowed_devices_map_; origin_to_allowed_devices_map_;
......
...@@ -53,8 +53,7 @@ class BluetoothAllowedDevicesTest : public testing::Test { ...@@ -53,8 +53,7 @@ class BluetoothAllowedDevicesTest : public testing::Test {
} // namespace } // namespace
TEST_F(BluetoothAllowedDevicesTest, UniqueOriginNotSupported) { TEST_F(BluetoothAllowedDevicesTest, UniqueOriginNotSupported) {
scoped_refptr<BluetoothAllowedDevicesMap> allowed_devices_map = auto allowed_devices_map = std::make_unique<BluetoothAllowedDevicesMap>();
new BluetoothAllowedDevicesMap();
EXPECT_DEATH_IF_SUPPORTED( EXPECT_DEATH_IF_SUPPORTED(
allowed_devices_map->GetOrCreateAllowedDevices(url::Origin()), ""); allowed_devices_map->GetOrCreateAllowedDevices(url::Origin()), "");
} }
...@@ -102,8 +101,7 @@ TEST_F(BluetoothAllowedDevicesTest, AddTwoDevices) { ...@@ -102,8 +101,7 @@ TEST_F(BluetoothAllowedDevicesTest, AddTwoDevices) {
} }
TEST_F(BluetoothAllowedDevicesTest, AddTwoDevicesFromTwoOriginsToMap) { TEST_F(BluetoothAllowedDevicesTest, AddTwoDevicesFromTwoOriginsToMap) {
scoped_refptr<BluetoothAllowedDevicesMap> allowed_devices_map = auto allowed_devices_map = std::make_unique<BluetoothAllowedDevicesMap>();
new BluetoothAllowedDevicesMap();
content::BluetoothAllowedDevices& allowed_devices1 = content::BluetoothAllowedDevices& allowed_devices1 =
allowed_devices_map->GetOrCreateAllowedDevices(TestOrigin1()); allowed_devices_map->GetOrCreateAllowedDevices(TestOrigin1());
content::BluetoothAllowedDevices& allowed_devices2 = content::BluetoothAllowedDevices& allowed_devices2 =
...@@ -132,8 +130,7 @@ TEST_F(BluetoothAllowedDevicesTest, AddTwoDevicesFromTwoOriginsToMap) { ...@@ -132,8 +130,7 @@ TEST_F(BluetoothAllowedDevicesTest, AddTwoDevicesFromTwoOriginsToMap) {
} }
TEST_F(BluetoothAllowedDevicesTest, AddDeviceFromTwoOriginsToMap) { TEST_F(BluetoothAllowedDevicesTest, AddDeviceFromTwoOriginsToMap) {
scoped_refptr<BluetoothAllowedDevicesMap> allowed_devices_map = auto allowed_devices_map = std::make_unique<BluetoothAllowedDevicesMap>();
new BluetoothAllowedDevicesMap();
content::BluetoothAllowedDevices& allowed_devices1 = content::BluetoothAllowedDevices& allowed_devices1 =
allowed_devices_map->GetOrCreateAllowedDevices(TestOrigin1()); allowed_devices_map->GetOrCreateAllowedDevices(TestOrigin1());
content::BluetoothAllowedDevices& allowed_devices2 = content::BluetoothAllowedDevices& allowed_devices2 =
...@@ -346,8 +343,7 @@ TEST_F(BluetoothAllowedDevicesTest, AllowedServices_TwoDevices) { ...@@ -346,8 +343,7 @@ TEST_F(BluetoothAllowedDevicesTest, AllowedServices_TwoDevices) {
} }
TEST_F(BluetoothAllowedDevicesTest, AllowedServices_TwoOriginsOneDevice) { TEST_F(BluetoothAllowedDevicesTest, AllowedServices_TwoOriginsOneDevice) {
scoped_refptr<BluetoothAllowedDevicesMap> allowed_devices_map = auto allowed_devices_map = std::make_unique<BluetoothAllowedDevicesMap>();
new BluetoothAllowedDevicesMap();
content::BluetoothAllowedDevices& allowed_devices1 = content::BluetoothAllowedDevices& allowed_devices1 =
allowed_devices_map->GetOrCreateAllowedDevices(TestOrigin1()); allowed_devices_map->GetOrCreateAllowedDevices(TestOrigin1());
content::BluetoothAllowedDevices& allowed_devices2 = content::BluetoothAllowedDevices& allowed_devices2 =
......
...@@ -1778,9 +1778,8 @@ BluetoothAllowedDevices& WebBluetoothServiceImpl::allowed_devices() { ...@@ -1778,9 +1778,8 @@ BluetoothAllowedDevices& WebBluetoothServiceImpl::allowed_devices() {
StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
BrowserContext::GetDefaultStoragePartition( BrowserContext::GetDefaultStoragePartition(
web_contents()->GetBrowserContext())); web_contents()->GetBrowserContext()));
scoped_refptr<BluetoothAllowedDevicesMap> allowed_devices_map = return partition->GetBluetoothAllowedDevicesMap()->GetOrCreateAllowedDevices(
partition->GetBluetoothAllowedDevicesMap(); GetOrigin());
return allowed_devices_map->GetOrCreateAllowedDevices(GetOrigin());
} }
void WebBluetoothServiceImpl::StoreAllowedScanOptions( void WebBluetoothServiceImpl::StoreAllowedScanOptions(
......
...@@ -1375,7 +1375,8 @@ void StoragePartitionImpl::Initialize() { ...@@ -1375,7 +1375,8 @@ void StoragePartitionImpl::Initialize() {
broadcast_channel_provider_ = std::make_unique<BroadcastChannelProvider>(); broadcast_channel_provider_ = std::make_unique<BroadcastChannelProvider>();
bluetooth_allowed_devices_map_ = new BluetoothAllowedDevicesMap(); bluetooth_allowed_devices_map_ =
std::make_unique<BluetoothAllowedDevicesMap>();
scoped_refptr<ChromeBlobStorageContext> blob_context = scoped_refptr<ChromeBlobStorageContext> blob_context =
ChromeBlobStorageContext::GetFor(browser_context_); ChromeBlobStorageContext::GetFor(browser_context_);
......
...@@ -453,7 +453,7 @@ class CONTENT_EXPORT StoragePartitionImpl ...@@ -453,7 +453,7 @@ class CONTENT_EXPORT StoragePartitionImpl
scoped_refptr<BackgroundSyncContextImpl> background_sync_context_; scoped_refptr<BackgroundSyncContextImpl> background_sync_context_;
scoped_refptr<PaymentAppContextImpl> payment_app_context_; scoped_refptr<PaymentAppContextImpl> payment_app_context_;
std::unique_ptr<BroadcastChannelProvider> broadcast_channel_provider_; std::unique_ptr<BroadcastChannelProvider> broadcast_channel_provider_;
scoped_refptr<BluetoothAllowedDevicesMap> bluetooth_allowed_devices_map_; std::unique_ptr<BluetoothAllowedDevicesMap> bluetooth_allowed_devices_map_;
scoped_refptr<BlobRegistryWrapper> blob_registry_; scoped_refptr<BlobRegistryWrapper> blob_registry_;
scoped_refptr<PrefetchURLLoaderService> prefetch_url_loader_service_; scoped_refptr<PrefetchURLLoaderService> prefetch_url_loader_service_;
scoped_refptr<CookieStoreContext> cookie_store_context_; scoped_refptr<CookieStoreContext> cookie_store_context_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment