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

Unified Diff: components/search_engines/template_url_parser.cc

Issue 2305813002: Remove ScopedVector from importer. (Closed)
Patch Set: pkasting 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 | « components/search_engines/template_url_parser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/search_engines/template_url_parser.cc
diff --git a/components/search_engines/template_url_parser.cc b/components/search_engines/template_url_parser.cc
index 9c93747b27b419ef410f78226027f78762959461..e3eec92f67d54ad73816851fa771332f1518a6eb 100644
--- a/components/search_engines/template_url_parser.cc
+++ b/components/search_engines/template_url_parser.cc
@@ -13,6 +13,7 @@
#include "base/logging.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -140,12 +141,13 @@ class TemplateURLParsingContext {
static void EndElementImpl(void* ctx, const xmlChar* name);
static void CharactersImpl(void* ctx, const xmlChar* ch, int len);
- // Returns a heap-allocated TemplateURL representing the result of parsing.
- // This will be NULL if parsing failed or if the results were invalid for some
- // reason (e.g. the resulting URL was not HTTP[S], a name wasn't supplied,
- // a resulting TemplateURLRef was invalid, etc.).
- TemplateURL* GetTemplateURL(const SearchTermsData& search_terms_data,
- bool show_in_default_list);
+ // Returns a TemplateURL representing the result of parsing. This will be
+ // null if parsing failed or if the results were invalid for some reason (e.g.
+ // the resulting URL was not HTTP[S], a name wasn't supplied, a resulting
+ // TemplateURLRef was invalid, etc.).
+ std::unique_ptr<TemplateURL> GetTemplateURL(
+ const SearchTermsData& search_terms_data,
+ bool show_in_default_list);
private:
// Key is UTF8 encoded.
@@ -299,14 +301,14 @@ void TemplateURLParsingContext::CharactersImpl(void* ctx,
base::StringPiece(reinterpret_cast<const char*>(ch), len));
}
-TemplateURL* TemplateURLParsingContext::GetTemplateURL(
+std::unique_ptr<TemplateURL> TemplateURLParsingContext::GetTemplateURL(
const SearchTermsData& search_terms_data,
bool show_in_default_list) {
// TODO(jcampan): Support engines that use POST; see http://crbug.com/18107
if (method_ == TemplateURLParsingContext::POST ||
data_.short_name().empty() || !IsHTTPRef(data_.url()) ||
!IsHTTPRef(data_.suggestions_url))
- return NULL;
+ return nullptr;
if (suggestion_method_ == TemplateURLParsingContext::POST)
data_.suggestions_url.clear();
@@ -324,15 +326,16 @@ TemplateURL* TemplateURLParsingContext::GetTemplateURL(
data_.show_in_default_list = show_in_default_list;
// Bail if the search URL is empty or if either TemplateURLRef is invalid.
- std::unique_ptr<TemplateURL> template_url(new TemplateURL(data_));
+ std::unique_ptr<TemplateURL> template_url =
+ base::MakeUnique<TemplateURL>(data_);
if (template_url->url().empty() ||
!template_url->url_ref().IsValid(search_terms_data) ||
(!template_url->suggestions_url().empty() &&
!template_url->suggestions_url_ref().IsValid(search_terms_data))) {
- return NULL;
+ return nullptr;
}
- return template_url.release();
+ return template_url;
}
// static
@@ -490,7 +493,7 @@ TemplateURLParsingContext::ElementType
// TemplateURLParser ----------------------------------------------------------
// static
-TemplateURL* TemplateURLParser::Parse(
+std::unique_ptr<TemplateURL> TemplateURLParser::Parse(
const SearchTermsData& search_terms_data,
bool show_in_default_list,
const char* data,
@@ -511,6 +514,6 @@ TemplateURL* TemplateURLParser::Parse(
static_cast<int>(length));
xmlSubstituteEntitiesDefault(last_sub_entities_value);
- return error ?
- NULL : context.GetTemplateURL(search_terms_data, show_in_default_list);
+ return error ? nullptr : context.GetTemplateURL(search_terms_data,
+ show_in_default_list);
}
« no previous file with comments | « components/search_engines/template_url_parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698