Remove stl_util's deletion function use from device/.
BUG=555865 Review-Url: https://codereview.chromium.org/2443803002 Cr-Commit-Position: refs/heads/master@{#427129}
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/stl_util.h"
|
#include "base/memory/ptr_util.h"
|
||||||
#include "dbus/bus.h"
|
#include "dbus/bus.h"
|
||||||
#include "dbus/message.h"
|
#include "dbus/message.h"
|
||||||
#include "dbus/object_manager.h"
|
#include "dbus/object_manager.h"
|
||||||
@@ -20,7 +20,7 @@ namespace bluez {
|
|||||||
FakeBluetoothInputClient::Properties::Properties(
|
FakeBluetoothInputClient::Properties::Properties(
|
||||||
const PropertyChangedCallback& callback)
|
const PropertyChangedCallback& callback)
|
||||||
: BluetoothInputClient::Properties(
|
: BluetoothInputClient::Properties(
|
||||||
NULL,
|
nullptr,
|
||||||
bluetooth_input::kBluetoothInputInterface,
|
bluetooth_input::kBluetoothInputInterface,
|
||||||
callback) {}
|
callback) {}
|
||||||
|
|
||||||
@@ -46,10 +46,7 @@ void FakeBluetoothInputClient::Properties::Set(
|
|||||||
|
|
||||||
FakeBluetoothInputClient::FakeBluetoothInputClient() {}
|
FakeBluetoothInputClient::FakeBluetoothInputClient() {}
|
||||||
|
|
||||||
FakeBluetoothInputClient::~FakeBluetoothInputClient() {
|
FakeBluetoothInputClient::~FakeBluetoothInputClient() {}
|
||||||
// Clean up Properties structures
|
|
||||||
base::STLDeleteValues(&properties_map_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FakeBluetoothInputClient::Init(dbus::Bus* bus) {}
|
void FakeBluetoothInputClient::Init(dbus::Bus* bus) {}
|
||||||
|
|
||||||
@@ -63,10 +60,10 @@ void FakeBluetoothInputClient::RemoveObserver(Observer* observer) {
|
|||||||
|
|
||||||
FakeBluetoothInputClient::Properties* FakeBluetoothInputClient::GetProperties(
|
FakeBluetoothInputClient::Properties* FakeBluetoothInputClient::GetProperties(
|
||||||
const dbus::ObjectPath& object_path) {
|
const dbus::ObjectPath& object_path) {
|
||||||
PropertiesMap::iterator iter = properties_map_.find(object_path);
|
auto iter = properties_map_.find(object_path);
|
||||||
if (iter != properties_map_.end())
|
if (iter != properties_map_.end())
|
||||||
return iter->second;
|
return iter->second.get();
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeBluetoothInputClient::AddInputDevice(
|
void FakeBluetoothInputClient::AddInputDevice(
|
||||||
@@ -74,9 +71,9 @@ void FakeBluetoothInputClient::AddInputDevice(
|
|||||||
if (properties_map_.find(object_path) != properties_map_.end())
|
if (properties_map_.find(object_path) != properties_map_.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Properties* properties =
|
std::unique_ptr<Properties> properties = base::MakeUnique<Properties>(
|
||||||
new Properties(base::Bind(&FakeBluetoothInputClient::OnPropertyChanged,
|
base::Bind(&FakeBluetoothInputClient::OnPropertyChanged,
|
||||||
base::Unretained(this), object_path));
|
base::Unretained(this), object_path));
|
||||||
|
|
||||||
// The LegacyAutopair and DisplayPinCode devices represent a typical mouse
|
// The LegacyAutopair and DisplayPinCode devices represent a typical mouse
|
||||||
// and keyboard respectively, so mark them as ReconnectMode "any". The
|
// and keyboard respectively, so mark them as ReconnectMode "any". The
|
||||||
@@ -93,7 +90,7 @@ void FakeBluetoothInputClient::AddInputDevice(
|
|||||||
bluetooth_input::kAnyReconnectModeProperty);
|
bluetooth_input::kAnyReconnectModeProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
properties_map_[object_path] = properties;
|
properties_map_[object_path] = std::move(properties);
|
||||||
|
|
||||||
for (auto& observer : observers_)
|
for (auto& observer : observers_)
|
||||||
observer.InputAdded(object_path);
|
observer.InputAdded(object_path);
|
||||||
@@ -101,7 +98,7 @@ void FakeBluetoothInputClient::AddInputDevice(
|
|||||||
|
|
||||||
void FakeBluetoothInputClient::RemoveInputDevice(
|
void FakeBluetoothInputClient::RemoveInputDevice(
|
||||||
const dbus::ObjectPath& object_path) {
|
const dbus::ObjectPath& object_path) {
|
||||||
PropertiesMap::iterator it = properties_map_.find(object_path);
|
auto it = properties_map_.find(object_path);
|
||||||
|
|
||||||
if (it == properties_map_.end())
|
if (it == properties_map_.end())
|
||||||
return;
|
return;
|
||||||
@@ -109,7 +106,6 @@ void FakeBluetoothInputClient::RemoveInputDevice(
|
|||||||
for (auto& observer : observers_)
|
for (auto& observer : observers_)
|
||||||
observer.InputRemoved(object_path);
|
observer.InputRemoved(object_path);
|
||||||
|
|
||||||
delete it->second;
|
|
||||||
properties_map_.erase(it);
|
properties_map_.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5,6 +5,8 @@
|
|||||||
#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_INPUT_CLIENT_H_
|
#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_INPUT_CLIENT_H_
|
||||||
#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_INPUT_CLIENT_H_
|
#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_INPUT_CLIENT_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "base/callback.h"
|
#include "base/callback.h"
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "base/observer_list.h"
|
#include "base/observer_list.h"
|
||||||
@@ -52,8 +54,7 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothInputClient
|
|||||||
const std::string& property_name);
|
const std::string& property_name);
|
||||||
|
|
||||||
// Static properties we return.
|
// Static properties we return.
|
||||||
typedef std::map<const dbus::ObjectPath, Properties*> PropertiesMap;
|
std::map<const dbus::ObjectPath, std::unique_ptr<Properties>> properties_map_;
|
||||||
PropertiesMap properties_map_;
|
|
||||||
|
|
||||||
// List of observers interested in event notifications from us.
|
// List of observers interested in event notifications from us.
|
||||||
base::ObserverList<Observer> observers_;
|
base::ObserverList<Observer> observers_;
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include "base/bind.h"
|
#include "base/bind.h"
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "base/stl_util.h"
|
#include "base/memory/ptr_util.h"
|
||||||
#include "device/bluetooth/dbus/bluetooth_media_client.h"
|
#include "device/bluetooth/dbus/bluetooth_media_client.h"
|
||||||
#include "device/bluetooth/dbus/bluez_dbus_manager.h"
|
#include "device/bluetooth/dbus/bluez_dbus_manager.h"
|
||||||
#include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h"
|
#include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h"
|
||||||
@@ -92,18 +92,14 @@ void FakeBluetoothMediaTransportClient::Properties::Set(
|
|||||||
|
|
||||||
FakeBluetoothMediaTransportClient::Transport::Transport(
|
FakeBluetoothMediaTransportClient::Transport::Transport(
|
||||||
const ObjectPath& transport_path,
|
const ObjectPath& transport_path,
|
||||||
Properties* transport_properties)
|
std::unique_ptr<Properties> transport_properties)
|
||||||
: path(transport_path) {
|
: path(transport_path), properties(std::move(transport_properties)) {}
|
||||||
properties.reset(transport_properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
FakeBluetoothMediaTransportClient::Transport::~Transport() {}
|
FakeBluetoothMediaTransportClient::Transport::~Transport() {}
|
||||||
|
|
||||||
FakeBluetoothMediaTransportClient::FakeBluetoothMediaTransportClient() {}
|
FakeBluetoothMediaTransportClient::FakeBluetoothMediaTransportClient() {}
|
||||||
|
|
||||||
FakeBluetoothMediaTransportClient::~FakeBluetoothMediaTransportClient() {
|
FakeBluetoothMediaTransportClient::~FakeBluetoothMediaTransportClient() {}
|
||||||
base::STLDeleteValues(&endpoint_to_transport_map_);
|
|
||||||
}
|
|
||||||
|
|
||||||
// DBusClient override.
|
// DBusClient override.
|
||||||
void FakeBluetoothMediaTransportClient::Init(dbus::Bus* bus) {}
|
void FakeBluetoothMediaTransportClient::Init(dbus::Bus* bus) {}
|
||||||
@@ -182,7 +178,7 @@ void FakeBluetoothMediaTransportClient::SetValid(
|
|||||||
properties->volume.ReplaceValue(kTransportVolume);
|
properties->volume.ReplaceValue(kTransportVolume);
|
||||||
|
|
||||||
endpoint_to_transport_map_[endpoint_path] =
|
endpoint_to_transport_map_[endpoint_path] =
|
||||||
new Transport(transport_path, properties.release());
|
base::MakeUnique<Transport>(transport_path, std::move(properties));
|
||||||
transport_to_endpoint_map_[transport_path] = endpoint_path;
|
transport_to_endpoint_map_[transport_path] = endpoint_path;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -197,7 +193,6 @@ void FakeBluetoothMediaTransportClient::SetValid(
|
|||||||
observer.MediaTransportRemoved(transport_path);
|
observer.MediaTransportRemoved(transport_path);
|
||||||
|
|
||||||
endpoint->ClearConfiguration(transport_path);
|
endpoint->ClearConfiguration(transport_path);
|
||||||
delete transport;
|
|
||||||
endpoint_to_transport_map_.erase(endpoint_path);
|
endpoint_to_transport_map_.erase(endpoint_path);
|
||||||
transport_to_endpoint_map_.erase(transport_path);
|
transport_to_endpoint_map_.erase(transport_path);
|
||||||
}
|
}
|
||||||
@@ -282,7 +277,7 @@ FakeBluetoothMediaTransportClient::Transport*
|
|||||||
FakeBluetoothMediaTransportClient::GetTransport(
|
FakeBluetoothMediaTransportClient::GetTransport(
|
||||||
const ObjectPath& endpoint_path) {
|
const ObjectPath& endpoint_path) {
|
||||||
const auto& it = endpoint_to_transport_map_.find(endpoint_path);
|
const auto& it = endpoint_to_transport_map_.find(endpoint_path);
|
||||||
return (it != endpoint_to_transport_map_.end()) ? it->second : nullptr;
|
return (it != endpoint_to_transport_map_.end()) ? it->second.get() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
FakeBluetoothMediaTransportClient::Transport*
|
FakeBluetoothMediaTransportClient::Transport*
|
||||||
|
@@ -98,7 +98,7 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothMediaTransportClient
|
|||||||
// assigned with a transport path, an object of Transport is created.
|
// assigned with a transport path, an object of Transport is created.
|
||||||
struct Transport {
|
struct Transport {
|
||||||
Transport(const dbus::ObjectPath& transport_path,
|
Transport(const dbus::ObjectPath& transport_path,
|
||||||
Properties* transport_properties);
|
std::unique_ptr<Properties> transport_properties);
|
||||||
~Transport();
|
~Transport();
|
||||||
|
|
||||||
// An unique transport path.
|
// An unique transport path.
|
||||||
@@ -134,7 +134,8 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothMediaTransportClient
|
|||||||
// Map of endpoints with valid transport. Each pair is composed of an endpoint
|
// Map of endpoints with valid transport. Each pair is composed of an endpoint
|
||||||
// path and a Transport structure containing a transport path and its
|
// path and a Transport structure containing a transport path and its
|
||||||
// properties.
|
// properties.
|
||||||
std::map<dbus::ObjectPath, Transport*> endpoint_to_transport_map_;
|
std::map<dbus::ObjectPath, std::unique_ptr<Transport>>
|
||||||
|
endpoint_to_transport_map_;
|
||||||
|
|
||||||
// Map of valid transports. Each pair is composed of a transport path as the
|
// Map of valid transports. Each pair is composed of a transport path as the
|
||||||
// key and an endpoint path as the value. This map is used to get the
|
// key and an endpoint path as the value. This map is used to get the
|
||||||
|
@@ -7,12 +7,14 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/bind.h"
|
#include "base/bind.h"
|
||||||
#include "base/files/file_path.h"
|
#include "base/files/file_path.h"
|
||||||
#include "base/files/file_path_watcher.h"
|
#include "base/files/file_path_watcher.h"
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
|
#include "base/memory/ptr_util.h"
|
||||||
#include "base/memory/ref_counted.h"
|
#include "base/memory/ref_counted.h"
|
||||||
#include "base/sequenced_task_runner.h"
|
#include "base/sequenced_task_runner.h"
|
||||||
#include "base/stl_util.h"
|
#include "base/stl_util.h"
|
||||||
@@ -54,7 +56,6 @@ class TimeZoneMonitorLinuxImpl
|
|||||||
TimeZoneMonitorLinux* owner,
|
TimeZoneMonitorLinux* owner,
|
||||||
scoped_refptr<base::SequencedTaskRunner> file_task_runner)
|
scoped_refptr<base::SequencedTaskRunner> file_task_runner)
|
||||||
: base::RefCountedThreadSafe<TimeZoneMonitorLinuxImpl>(),
|
: base::RefCountedThreadSafe<TimeZoneMonitorLinuxImpl>(),
|
||||||
file_path_watchers_(),
|
|
||||||
main_task_runner_(base::ThreadTaskRunnerHandle::Get()),
|
main_task_runner_(base::ThreadTaskRunnerHandle::Get()),
|
||||||
file_task_runner_(file_task_runner),
|
file_task_runner_(file_task_runner),
|
||||||
owner_(owner) {
|
owner_(owner) {
|
||||||
@@ -77,7 +78,6 @@ class TimeZoneMonitorLinuxImpl
|
|||||||
|
|
||||||
~TimeZoneMonitorLinuxImpl() {
|
~TimeZoneMonitorLinuxImpl() {
|
||||||
DCHECK(!owner_);
|
DCHECK(!owner_);
|
||||||
base::STLDeleteElements(&file_path_watchers_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartWatchingOnFileThread() {
|
void StartWatchingOnFileThread() {
|
||||||
@@ -96,7 +96,7 @@ class TimeZoneMonitorLinuxImpl
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kFilesToWatch); ++index) {
|
for (size_t index = 0; index < arraysize(kFilesToWatch); ++index) {
|
||||||
file_path_watchers_.push_back(new base::FilePathWatcher());
|
file_path_watchers_.push_back(base::MakeUnique<base::FilePathWatcher>());
|
||||||
file_path_watchers_.back()->Watch(
|
file_path_watchers_.back()->Watch(
|
||||||
base::FilePath(kFilesToWatch[index]), false,
|
base::FilePath(kFilesToWatch[index]), false,
|
||||||
base::Bind(&TimeZoneMonitorLinuxImpl::OnTimeZoneFileChanged, this));
|
base::Bind(&TimeZoneMonitorLinuxImpl::OnTimeZoneFileChanged, this));
|
||||||
@@ -105,7 +105,7 @@ class TimeZoneMonitorLinuxImpl
|
|||||||
|
|
||||||
void StopWatchingOnFileThread() {
|
void StopWatchingOnFileThread() {
|
||||||
DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
|
DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
|
||||||
base::STLDeleteElements(&file_path_watchers_);
|
file_path_watchers_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnTimeZoneFileChanged(const base::FilePath& path, bool error) {
|
void OnTimeZoneFileChanged(const base::FilePath& path, bool error) {
|
||||||
@@ -123,7 +123,7 @@ class TimeZoneMonitorLinuxImpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<base::FilePathWatcher*> file_path_watchers_;
|
std::vector<std::unique_ptr<base::FilePathWatcher>> file_path_watchers_;
|
||||||
|
|
||||||
scoped_refptr<base::SequencedTaskRunner> main_task_runner_;
|
scoped_refptr<base::SequencedTaskRunner> main_task_runner_;
|
||||||
scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
|
scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
|
||||||
|
Reference in New Issue
Block a user