summaryrefslogtreecommitdiffstats
path: root/extensions/common
diff options
context:
space:
mode:
authorlimasdf <limasdf@gmail.com>2016-03-07 05:24:40 -0800
committerCommit bot <commit-bot@chromium.org>2016-03-07 13:26:13 +0000
commita7670dbc0a6b94e2c1c427f6a1ddae933bdb6f53 (patch)
tree5d8d03579557e5764b722d75e6d81caceae0beb5 /extensions/common
parent3530ee063bf77263b200026b37ad79b097229362 (diff)
downloadchromium_src-a7670dbc0a6b94e2c1c427f6a1ddae933bdb6f53.zip
chromium_src-a7670dbc0a6b94e2c1c427f6a1ddae933bdb6f53.tar.gz
chromium_src-a7670dbc0a6b94e2c1c427f6a1ddae933bdb6f53.tar.bz2
Use scoped_ptr instead of linked_ptr from /e/c/features/*
BUG=556939 TBR=rdevlin.cronin@chromium.org Review URL: https://codereview.chromium.org/1768103002 Cr-Commit-Position: refs/heads/master@{#379547}
Diffstat (limited to 'extensions/common')
-rw-r--r--extensions/common/features/base_feature_provider.cc25
-rw-r--r--extensions/common/features/base_feature_provider.h10
-rw-r--r--extensions/common/features/feature_provider.cc20
3 files changed, 24 insertions, 31 deletions
diff --git a/extensions/common/features/base_feature_provider.cc b/extensions/common/features/base_feature_provider.cc
index 4f31527..8bcec82 100644
--- a/extensions/common/features/base_feature_provider.cc
+++ b/extensions/common/features/base_feature_provider.cc
@@ -11,6 +11,7 @@
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
+#include "base/values.h"
#include "extensions/common/extensions_client.h"
#include "extensions/common/features/complex_feature.h"
#include "extensions/common/features/simple_feature.h"
@@ -52,7 +53,7 @@ BaseFeatureProvider::BaseFeatureProvider(const base::DictionaryValue& root,
}
if (iter.value().GetType() == base::Value::TYPE_DICTIONARY) {
- linked_ptr<SimpleFeature> feature((*factory_)());
+ scoped_ptr<SimpleFeature> feature((*factory_)());
std::vector<std::string> split = base::SplitString(
iter.key(), ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
@@ -106,7 +107,7 @@ BaseFeatureProvider::BaseFeatureProvider(const base::DictionaryValue& root,
if (parse_error)
continue;
- features_[iter.key()] = feature;
+ features_[iter.key()] = std::move(feature);
} else if (iter.value().GetType() == base::Value::TYPE_LIST) {
// This is a complex feature.
const base::ListValue* list =
@@ -133,11 +134,11 @@ BaseFeatureProvider::BaseFeatureProvider(const base::DictionaryValue& root,
features->push_back(std::move(feature));
}
- linked_ptr<ComplexFeature> feature(
+ scoped_ptr<ComplexFeature> feature(
new ComplexFeature(std::move(features)));
feature->set_name(iter.key());
- features_[iter.key()] = feature;
+ features_[iter.key()] = std::move(feature);
} else {
LOG(ERROR) << iter.key() << ": Feature description must be dictionary or"
<< " list of dictionaries.";
@@ -151,10 +152,8 @@ BaseFeatureProvider::~BaseFeatureProvider() {
const std::vector<std::string>& BaseFeatureProvider::GetAllFeatureNames()
const {
if (feature_names_.empty()) {
- for (FeatureMap::const_iterator iter = features_.begin();
- iter != features_.end(); ++iter) {
- feature_names_.push_back(iter->first);
- }
+ for (const auto& feature : features_)
+ feature_names_.push_back(feature.first);
// A std::map is sorted by its keys, so we don't need to sort feature_names_
// now.
}
@@ -162,7 +161,7 @@ const std::vector<std::string>& BaseFeatureProvider::GetAllFeatureNames()
}
Feature* BaseFeatureProvider::GetFeature(const std::string& name) const {
- FeatureMap::const_iterator iter = features_.find(name);
+ const auto iter = features_.find(name);
if (iter != features_.end())
return iter->second.get();
else
@@ -187,17 +186,15 @@ Feature* BaseFeatureProvider::GetParent(Feature* feature) const {
std::vector<Feature*> BaseFeatureProvider::GetChildren(const Feature& parent)
const {
std::string prefix = parent.name() + ".";
- const FeatureMap::const_iterator first_child = features_.lower_bound(prefix);
+ const auto first_child = features_.lower_bound(prefix);
// All children have names before (parent.name() + ('.'+1)).
++prefix[prefix.size() - 1];
- const FeatureMap::const_iterator after_children =
- features_.lower_bound(prefix);
+ const auto after_children = features_.lower_bound(prefix);
std::vector<Feature*> result;
result.reserve(std::distance(first_child, after_children));
- for (FeatureMap::const_iterator it = first_child; it != after_children;
- ++it) {
+ for (auto it = first_child; it != after_children; ++it) {
result.push_back(it->second.get());
}
return result;
diff --git a/extensions/common/features/base_feature_provider.h b/extensions/common/features/base_feature_provider.h
index e82c46d..3b766c8 100644
--- a/extensions/common/features/base_feature_provider.h
+++ b/extensions/common/features/base_feature_provider.h
@@ -9,11 +9,14 @@
#include <string>
#include <vector>
-#include "base/memory/linked_ptr.h"
-#include "base/values.h"
+#include "base/memory/scoped_ptr.h"
#include "extensions/common/features/feature_provider.h"
#include "extensions/common/features/simple_feature.h"
+namespace Base {
+class DictionaryValue;
+}
+
namespace extensions {
// Reads Features out of a simple JSON file description.
@@ -35,8 +38,7 @@ class BaseFeatureProvider : public FeatureProvider {
const std::vector<std::string>& GetAllFeatureNames() const override;
private:
- typedef std::map<std::string, linked_ptr<Feature> > FeatureMap;
- FeatureMap features_;
+ std::map<std::string, scoped_ptr<Feature>> features_;
// Populated on first use.
mutable std::vector<std::string> feature_names_;
diff --git a/extensions/common/features/feature_provider.cc b/extensions/common/features/feature_provider.cc
index 7f93ba9..e420094 100644
--- a/extensions/common/features/feature_provider.cc
+++ b/extensions/common/features/feature_provider.cc
@@ -8,7 +8,7 @@
#include "base/command_line.h"
#include "base/lazy_instance.h"
-#include "base/memory/linked_ptr.h"
+#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/trace_event/trace_event.h"
#include "content/public/common/content_switches.h"
@@ -23,7 +23,7 @@ namespace {
class Static {
public:
FeatureProvider* GetFeatures(const std::string& name) const {
- FeatureProviderMap::const_iterator it = feature_providers_.find(name);
+ auto it = feature_providers_.find(name);
if (it == feature_providers_.end())
CRASH_WITH_MINIDUMP("FeatureProvider \"" + name + "\" not found");
return it->second.get();
@@ -37,14 +37,11 @@ class Static {
base::Time begin_time = base::Time::Now();
ExtensionsClient* client = ExtensionsClient::Get();
- feature_providers_["api"] =
- make_linked_ptr(client->CreateFeatureProvider("api").release());
- feature_providers_["manifest"] =
- make_linked_ptr(client->CreateFeatureProvider("manifest").release());
+ feature_providers_["api"] = client->CreateFeatureProvider("api");
+ feature_providers_["manifest"] = client->CreateFeatureProvider("manifest");
feature_providers_["permission"] =
- make_linked_ptr(client->CreateFeatureProvider("permission").release());
- feature_providers_["behavior"] =
- make_linked_ptr(client->CreateFeatureProvider("behavior").release());
+ client->CreateFeatureProvider("permission");
+ feature_providers_["behavior"] = client->CreateFeatureProvider("behavior");
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
std::string process_type =
@@ -61,10 +58,7 @@ class Static {
}
}
- typedef std::map<std::string, linked_ptr<FeatureProvider> >
- FeatureProviderMap;
-
- FeatureProviderMap feature_providers_;
+ std::map<std::string, scoped_ptr<FeatureProvider>> feature_providers_;
};
base::LazyInstance<Static> g_static = LAZY_INSTANCE_INITIALIZER;