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

Unified Diff: extensions/browser/api/vpn_provider/vpn_service.cc

Issue 2344273002: Remove stl_util's STLDeleteContainerPairSecondPointers from extensions. (Closed)
Patch Set: devlin Created 4 years, 3 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
« no previous file with comments | « extensions/browser/api/vpn_provider/vpn_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/api/vpn_provider/vpn_service.cc
diff --git a/extensions/browser/api/vpn_provider/vpn_service.cc b/extensions/browser/api/vpn_provider/vpn_service.cc
index 36d85d7820051757ef8a3dbebfb7910e9313d597..b8fffefc9151b7a466930c9bc74b181e2af4701e 100644
--- a/extensions/browser/api/vpn_provider/vpn_service.cc
+++ b/extensions/browser/api/vpn_provider/vpn_service.cc
@@ -16,7 +16,6 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/single_thread_task_runner.h"
-#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -243,8 +242,6 @@ VpnService::~VpnService() {
network_configuration_handler_->RemoveObserver(this);
network_state_handler_->RemoveObserver(this, FROM_HERE);
extension_registry_->RemoveObserver(this);
- base::STLDeleteContainerPairSecondPointers(key_to_configuration_map_.begin(),
- key_to_configuration_map_.end());
}
void VpnService::SendShowAddDialogToExtension(const std::string& extension_id) {
@@ -448,7 +445,7 @@ void VpnService::DestroyConfiguration(const std::string& extension_id,
return;
}
- VpnConfiguration* configuration = key_to_configuration_map_[key];
+ VpnConfiguration* configuration = key_to_configuration_map_[key].get();
const std::string service_path = configuration->service_path();
if (service_path.empty()) {
failure.Run(std::string(), std::string("Pending create."));
@@ -529,7 +526,7 @@ void VpnService::DestroyConfigurationsForExtension(
std::vector<VpnConfiguration*> to_be_destroyed;
for (const auto& iter : key_to_configuration_map_) {
if (iter.second->extension_id() == extension->id()) {
- to_be_destroyed.push_back(iter.second);
+ to_be_destroyed.push_back(iter.second.get());
}
}
@@ -630,12 +627,13 @@ VpnService::VpnConfiguration* VpnService::CreateConfigurationInternal(
const std::string& key) {
VpnConfiguration* configuration = new VpnConfiguration(
extension_id, configuration_name, key, weak_factory_.GetWeakPtr());
- // The object is owned by key_to_configuration_map_ henceforth.
- key_to_configuration_map_[key] = configuration;
+ key_to_configuration_map_[key] = base::WrapUnique(configuration);
return configuration;
}
void VpnService::DestroyConfigurationInternal(VpnConfiguration* configuration) {
+ std::unique_ptr<VpnConfiguration> configuration_ptr =
+ std::move(key_to_configuration_map_[configuration->key()]);
key_to_configuration_map_.erase(configuration->key());
if (active_configuration_ == configuration) {
active_configuration_ = nullptr;
@@ -645,7 +643,6 @@ void VpnService::DestroyConfigurationInternal(VpnConfiguration* configuration) {
configuration->object_path());
service_path_to_configuration_map_.erase(configuration->service_path());
}
- delete configuration;
}
bool VpnService::DoesActiveConfigurationExistAndIsAccessAuthorized(
@@ -671,7 +668,7 @@ void VpnService::Bind(
return;
}
- VpnConfiguration* configuration = key_to_configuration_map_[key];
+ VpnConfiguration* configuration = key_to_configuration_map_[key].get();
if (active_configuration_ != configuration) {
failure.Run(std::string(), std::string("Unauthorized access. "
"The configuration is not active."));
« no previous file with comments | « extensions/browser/api/vpn_provider/vpn_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698