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

Unified Diff: chrome/browser/chromeos/extensions/default_app_order.cc

Issue 1405083003: Fix memory leaks in chrome/browser/chromeos/extensions/default_app_order.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/extensions/default_app_order.cc
diff --git a/chrome/browser/chromeos/extensions/default_app_order.cc b/chrome/browser/chromeos/extensions/default_app_order.cc
index 855b5371b2ef0b6e976ae7a60d4cede8c0b7f9c1..e1df4f797398b6474fb8b55bf7cc759cb200a12e 100644
--- a/chrome/browser/chromeos/extensions/default_app_order.cc
+++ b/chrome/browser/chromeos/extensions/default_app_order.cc
@@ -59,26 +59,26 @@ const char* const kDefaultAppOrder[] = {
// Reads external ordinal json file and returned the parsed value. Returns NULL
// if the file does not exist or could not be parsed properly. Caller takes
// ownership of the returned value.
-base::ListValue* ReadExternalOrdinalFile(const base::FilePath& path) {
+scoped_ptr<base::ListValue> ReadExternalOrdinalFile(
+ const base::FilePath& path) {
if (!base::PathExists(path))
return NULL;
JSONFileValueDeserializer deserializer(path);
std::string error_msg;
- base::Value* value = deserializer.Deserialize(NULL, &error_msg).release();
+ scoped_ptr<base::Value> value = deserializer.Deserialize(NULL, &error_msg);
if (!value) {
LOG(WARNING) << "Unable to deserialize default app ordinals json data:"
<< error_msg << ", file=" << path.value();
return NULL;
}
- base::ListValue* ordinal_list_value = NULL;
- if (value->GetAsList(&ordinal_list_value))
- return ordinal_list_value;
+ scoped_ptr<base::ListValue> ordinal_list_value =
+ base::ListValue::From(value.Pass());
+ if (!ordinal_list_value)
+ LOG(WARNING) << "Expect a JSON list in file " << path.value();
- LOG(WARNING) << "Expect a JSON list in file " << path.value();
- // TODO(Olli Raula) possible memory leak http://crbug.com/543015
- return NULL;
+ return ordinal_list_value;
}
std::string GetLocaleSpecificStringImpl(
@@ -152,8 +152,8 @@ void ExternalLoader::Load() {
base::FilePath ordinals_file;
CHECK(PathService::Get(chromeos::FILE_DEFAULT_APP_ORDER, &ordinals_file));
- scoped_ptr<base::ListValue> ordinals_value(
- ReadExternalOrdinalFile(ordinals_file));
+ scoped_ptr<base::ListValue> ordinals_value =
+ ReadExternalOrdinalFile(ordinals_file);
if (ordinals_value) {
std::string locale = g_browser_process->GetApplicationLocale();
for (size_t i = 0; i < ordinals_value->GetSize(); ++i) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698