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

Unified Diff: chrome/browser/spellchecker/misspelling.cc

Issue 1665023002: Cheer up spell-checking code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More descriptive variable name Created 4 years, 10 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
Index: chrome/browser/spellchecker/misspelling.cc
diff --git a/chrome/browser/spellchecker/misspelling.cc b/chrome/browser/spellchecker/misspelling.cc
index 86deb0d0674f0415b55867db078c9b8e111e9702..a540cc98bbab5a8daaf5623b52a9c13eb1b19b96 100644
--- a/chrome/browser/spellchecker/misspelling.cc
+++ b/chrome/browser/spellchecker/misspelling.cc
@@ -14,19 +14,19 @@
namespace {
-// Builds a value from a list of spellcheck suggestions. The caller owns the
-// result.
-base::Value* BuildSuggestionsValue(const std::vector<base::string16>& list) {
- base::ListValue* result = new base::ListValue;
+// Builds a value from a list of spellcheck suggestions.
+scoped_ptr<base::Value> BuildSuggestionsValue(
+ const std::vector<base::string16>& list) {
+ scoped_ptr<base::ListValue> result(new base::ListValue);
result->AppendStrings(list);
- return result;
+ return std::move(result);
}
-// Builds a value from a spellcheck action. The caller owns the result.
-base::Value* BuildUserActionValue(const SpellcheckAction& action) {
- base::ListValue* result = new base::ListValue;
+// Builds a value from a spellcheck action.
+scoped_ptr<base::Value> BuildUserActionValue(const SpellcheckAction& action) {
+ scoped_ptr<base::ListValue> result(new base::ListValue);
result->Append(action.Serialize());
- return result;
+ return std::move(result);
}
} // namespace
@@ -48,8 +48,9 @@ Misspelling::Misspelling(const base::string16& context,
Misspelling::~Misspelling() {}
-base::DictionaryValue* SerializeMisspelling(const Misspelling& misspelling) {
- base::DictionaryValue* result = new base::DictionaryValue;
+scoped_ptr<base::DictionaryValue> SerializeMisspelling(
+ const Misspelling& misspelling) {
+ scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue);
result->SetString(
"timestamp",
base::Int64ToString(static_cast<long>(misspelling.timestamp.ToJsTime())));
@@ -57,8 +58,10 @@ base::DictionaryValue* SerializeMisspelling(const Misspelling& misspelling) {
result->SetInteger("misspelledStart", misspelling.location);
result->SetString("originalText", misspelling.context);
result->SetString("suggestionId", base::UintToString(misspelling.hash));
- result->Set("suggestions", BuildSuggestionsValue(misspelling.suggestions));
- result->Set("userActions", BuildUserActionValue(misspelling.action));
+ result->Set("suggestions",
+ BuildSuggestionsValue(misspelling.suggestions).release());
+ result->Set("userActions",
+ BuildUserActionValue(misspelling.action).release());
return result;
}
« no previous file with comments | « chrome/browser/spellchecker/misspelling.h ('k') | chrome/browser/spellchecker/spellcheck_custom_dictionary.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698