Commit 61bf6135 authored by rdevlin.cronin's avatar rdevlin.cronin Committed by Commit bot

[Extensions] Make feature-related singletons leaky

It seems that feature-related singleton classes can be potentially
accessed during shutdown, which will crash. Make these classes
leaky, which is now the preference anyway.

BUG=646275

Review-Url: https://codereview.chromium.org/2338273005
Cr-Commit-Position: refs/heads/master@{#418979}
parent aa371775
......@@ -99,7 +99,7 @@ struct Static {
std::unique_ptr<ExtensionAPI> api;
};
base::LazyInstance<Static> g_lazy_instance = LAZY_INSTANCE_INITIALIZER;
base::LazyInstance<Static>::Leaky g_lazy_instance = LAZY_INSTANCE_INITIALIZER;
// May override |g_lazy_instance| for a test.
ExtensionAPI* g_shared_instance_for_test = NULL;
......
......@@ -23,16 +23,6 @@ namespace {
class Static {
public:
FeatureProvider* GetFeatures(const std::string& name) const {
auto it = feature_providers_.find(name);
if (it == feature_providers_.end())
CRASH_WITH_MINIDUMP("FeatureProvider \"" + name + "\" not found");
return it->second.get();
}
private:
friend struct base::DefaultLazyInstanceTraits<Static>;
Static() {
TRACE_EVENT0("startup", "extensions::FeatureProvider::Static");
base::Time begin_time = base::Time::Now();
......@@ -59,10 +49,20 @@ class Static {
}
}
FeatureProvider* GetFeatures(const std::string& name) const {
auto it = feature_providers_.find(name);
if (it == feature_providers_.end())
CRASH_WITH_MINIDUMP("FeatureProvider \"" + name + "\" not found");
return it->second.get();
}
private:
std::map<std::string, std::unique_ptr<FeatureProvider>> feature_providers_;
DISALLOW_COPY_AND_ASSIGN(Static);
};
base::LazyInstance<Static> g_static = LAZY_INSTANCE_INITIALIZER;
base::LazyInstance<Static>::Leaky g_static = LAZY_INSTANCE_INITIALIZER;
const Feature* GetFeatureFromProviderByName(const std::string& provider_name,
const std::string& feature_name) {
......
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