diff options
author | olli.raula <olli.raula@intel.com> | 2016-01-05 01:19:47 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-05 09:20:32 +0000 |
commit | b870999bfbba01d7e09a3c8801b92a79031cc4dc (patch) | |
tree | ebb546e9c76e5feec7c8f1a755a483ade4d76558 /net | |
parent | cf3368493c77dea49a6a76467417ec32416318d4 (diff) | |
download | chromium_src-b870999bfbba01d7e09a3c8801b92a79031cc4dc.zip chromium_src-b870999bfbba01d7e09a3c8801b92a79031cc4dc.tar.gz chromium_src-b870999bfbba01d7e09a3c8801b92a79031cc4dc.tar.bz2 |
Make FactoryMap use scoped_ptr in http_auth_handler_factory
Make FactoryMap use scoped_ptr in http_auth_handler_factory
because is allows some code deletions and cleanings and is safer.
Review URL: https://codereview.chromium.org/1551863004
Cr-Commit-Position: refs/heads/master@{#367501}
Diffstat (limited to 'net')
-rw-r--r-- | net/http/http_auth_handler_factory.cc | 14 | ||||
-rw-r--r-- | net/http/http_auth_handler_factory.h | 2 |
2 files changed, 5 insertions, 11 deletions
diff --git a/net/http/http_auth_handler_factory.cc b/net/http/http_auth_handler_factory.cc index 9e83c09..c03792f 100644 --- a/net/http/http_auth_handler_factory.cc +++ b/net/http/http_auth_handler_factory.cc @@ -100,8 +100,6 @@ HttpAuthHandlerRegistryFactory::HttpAuthHandlerRegistryFactory() { } HttpAuthHandlerRegistryFactory::~HttpAuthHandlerRegistryFactory() { - STLDeleteContainerPairSecondPointers(factory_map_.begin(), - factory_map_.end()); } void HttpAuthHandlerRegistryFactory::SetHttpAuthPreferences( @@ -117,14 +115,10 @@ void HttpAuthHandlerRegistryFactory::RegisterSchemeFactory( HttpAuthHandlerFactory* factory) { factory->set_http_auth_preferences(http_auth_preferences()); std::string lower_scheme = base::ToLowerASCII(scheme); - FactoryMap::iterator it = factory_map_.find(lower_scheme); - if (it != factory_map_.end()) { - delete it->second; - } if (factory) - factory_map_[lower_scheme] = factory; + factory_map_[lower_scheme] = make_scoped_ptr(factory); else - factory_map_.erase(it); + factory_map_.erase(lower_scheme); } HttpAuthHandlerFactory* HttpAuthHandlerRegistryFactory::GetSchemeFactory( @@ -134,7 +128,7 @@ HttpAuthHandlerFactory* HttpAuthHandlerRegistryFactory::GetSchemeFactory( if (it == factory_map_.end()) { return NULL; // |scheme| is not registered. } - return it->second; + return it->second.get(); } // static @@ -158,7 +152,7 @@ HttpAuthHandlerRegistryFactory::Create(const HttpAuthPreferences* prefs, scoped_ptr<HttpAuthHandlerRegistryFactory> registry_factory( CreateAuthHandlerRegistryFactory(*prefs, host_resolver)); registry_factory->set_http_auth_preferences(prefs); - for (auto factory_entry : registry_factory->factory_map_) { + for (auto& factory_entry : registry_factory->factory_map_) { factory_entry.second->set_http_auth_preferences(prefs); } return registry_factory; diff --git a/net/http/http_auth_handler_factory.h b/net/http/http_auth_handler_factory.h index 2cbf345..a98f9d7 100644 --- a/net/http/http_auth_handler_factory.h +++ b/net/http/http_auth_handler_factory.h @@ -184,7 +184,7 @@ class NET_EXPORT HttpAuthHandlerRegistryFactory scoped_ptr<HttpAuthHandler>* handler) override; private: - typedef std::map<std::string, HttpAuthHandlerFactory*> FactoryMap; + using FactoryMap = std::map<std::string, scoped_ptr<HttpAuthHandlerFactory>>; FactoryMap factory_map_; DISALLOW_COPY_AND_ASSIGN(HttpAuthHandlerRegistryFactory); |