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

Unified Diff: components/bookmarks/browser/bookmark_codec.cc

Issue 2379863002: Fix object ownership in ui/base/models. (Closed)
Patch Set: fix 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
Index: components/bookmarks/browser/bookmark_codec.cc
diff --git a/components/bookmarks/browser/bookmark_codec.cc b/components/bookmarks/browser/bookmark_codec.cc
index e110ad3d5284a04fb41aee9dc1831175b9470ed1..1d6ff890bb6259ce8930a0697650f23f17fdd21c 100644
--- a/components/bookmarks/browser/bookmark_codec.cc
+++ b/components/bookmarks/browser/bookmark_codec.cc
@@ -10,6 +10,7 @@
#include <utility>
#include "base/json/json_string_value_serializer.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/values.h"
@@ -272,6 +273,12 @@ bool BookmarkCodec::DecodeNode(const base::DictionaryValue& value,
return false;
}
+ // It's not valid to have both a node and a specified parent.
+ if (node && parent) {
+ NOTREACHED();
+ return false;
+ }
+
std::string id_string;
int64_t id = 0;
if (ids_valid_) {
@@ -314,7 +321,7 @@ bool BookmarkCodec::DecodeNode(const base::DictionaryValue& value,
return false; // Node invalid.
if (parent)
- parent->Add(node, parent->child_count());
+ parent->Add(base::WrapUnique(node), parent->child_count());
node->set_type(BookmarkNode::URL);
UpdateChecksumWithUrlNode(id_string, title, url_string);
} else {
@@ -342,7 +349,7 @@ bool BookmarkCodec::DecodeNode(const base::DictionaryValue& value,
node->set_date_folder_modified(Time::FromInternalValue(internal_time));
if (parent)
- parent->Add(node, parent->child_count());
+ parent->Add(base::WrapUnique(node), parent->child_count());
UpdateChecksumWithFolderNode(id_string, title);
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc ('k') | components/bookmarks/browser/bookmark_index.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698