summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-11 21:32:09 +0000
committerjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-11 21:32:09 +0000
commit2511cef12cee4b2089094ae1f455e31f0b3ca800 (patch)
tree43f24818b5e20b9c0e1a5c13cd9dbd4a14a77b8d
parent63f79e6602028ea7cbf4177165c94ca2cd367116 (diff)
downloadchromium_src-2511cef12cee4b2089094ae1f455e31f0b3ca800.zip
chromium_src-2511cef12cee4b2089094ae1f455e31f0b3ca800.tar.gz
chromium_src-2511cef12cee4b2089094ae1f455e31f0b3ca800.tar.bz2
Try to fix the memory leak reports in g_restrictions.
This updates the Restrictions usage to be more consistent with other LazyInstances: - do not copy and assign - use static keyword - use LAZY_INSTANCE_INITIALIZER BUG=106571 TEST=existing Review URL: http://codereview.chromium.org/9027007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117292 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/common/extensions/manifest.cc11
-rw-r--r--tools/valgrind/memcheck/suppressions.txt12
2 files changed, 7 insertions, 16 deletions
diff --git a/chrome/common/extensions/manifest.cc b/chrome/common/extensions/manifest.cc
index 78976eb..428f86f 100644
--- a/chrome/common/extensions/manifest.cc
+++ b/chrome/common/extensions/manifest.cc
@@ -97,9 +97,12 @@ struct Restrictions {
}
RestrictionMap map;
+
+ DISALLOW_COPY_AND_ASSIGN(Restrictions);
};
-base::LazyInstance<Restrictions> g_restrictions;
+static base::LazyInstance<Restrictions> g_restrictions =
+ LAZY_INSTANCE_INITIALIZER;
} // namespace
@@ -116,7 +119,7 @@ Manifest::Manifest(DictionaryValue* value) : value_(value) {}
Manifest::~Manifest() {}
bool Manifest::ValidateManifest(string16* error) const {
- Restrictions restrictions = g_restrictions.Get();
+ const Restrictions& restrictions = g_restrictions.Get();
Type type = GetType();
for (DictionaryValue::key_iterator key = value_->begin_keys();
@@ -140,7 +143,7 @@ bool Manifest::ValidateManifest(string16* error) const {
}
bool Manifest::HasKey(const std::string& key) const {
- Restrictions restrictions = g_restrictions.Get();
+ const Restrictions& restrictions = g_restrictions.Get();
return restrictions.CanAccessKey(key, GetType()) && value_->HasKey(key);
}
@@ -225,7 +228,7 @@ bool Manifest::CanAccessPath(const std::string& path) const {
std::vector<std::string> components;
base::SplitString(path, '.', &components);
- Restrictions restrictions = g_restrictions.Get();
+ const Restrictions& restrictions = g_restrictions.Get();
return restrictions.CanAccessKey(components[0], GetType());
}
diff --git a/tools/valgrind/memcheck/suppressions.txt b/tools/valgrind/memcheck/suppressions.txt
index 927ce63..b4236d7 100644
--- a/tools/valgrind/memcheck/suppressions.txt
+++ b/tools/valgrind/memcheck/suppressions.txt
@@ -5084,18 +5084,6 @@
fun:_ZN23ExtensionTestingProfileD0Ev
}
{
- bug_106571
- Memcheck:Leak
- fun:_Znw*
- ...
- fun:_ZN10extensions12_GLOBAL__N_112RestrictionsC1ERKS1_
- ...
- fun:_ZN9Extension13InitFromValueEPN10extensions8ManifestEiPSbItN4base20string16_char_traitsESaItEE
- fun:_ZN9Extension6CreateERK8FilePathNS_8LocationERKN4base15DictionaryValueEiPSs
- fun:_ZNK26ExtensionMsg_Loaded_Params18ConvertToExtensionEv
- fun:_ZN19ExtensionDispatcher8OnLoadedERKSt6vectorI26ExtensionMsg_Loaded_ParamsSaIS1_EE
-}
-{
bug_107503
Memcheck:Uninitialized
...