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

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

Issue 268001: Makes sure bookmark ids are unique on reading from file. If not unique... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | « chrome/browser/bookmarks/bookmark_codec.h ('k') | chrome/browser/bookmarks/bookmark_model_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/bookmarks/bookmark_codec.cc
===================================================================
--- chrome/browser/bookmarks/bookmark_codec.cc (revision 28175)
+++ chrome/browser/bookmarks/bookmark_codec.cc (working copy)
@@ -35,7 +35,7 @@
BookmarkCodec::BookmarkCodec()
: ids_reassigned_(false),
- ids_missing_(false),
+ ids_valid_(true),
maximum_id_(0) {
}
@@ -66,15 +66,17 @@
BookmarkNode* other_folder_node,
int64* max_id,
const Value& value) {
+ ids_.clear();
ids_reassigned_ = false;
- ids_missing_ = false;
+ ids_valid_ = true;
maximum_id_ = 0;
stored_checksum_.clear();
InitializeChecksum();
bool success = DecodeHelper(bb_node, other_folder_node, value);
FinalizeChecksum();
- // If either the checksums differ or some IDs were missing, reassign IDs.
- if (ids_missing_ || computed_checksum() != stored_checksum())
+ // If either the checksums differ or some IDs were missing/not unique,
+ // reassign IDs.
+ if (!ids_valid_ || computed_checksum() != stored_checksum())
ReassignIDs(bb_node, other_folder_node);
*max_id = maximum_id_ + 1;
return success;
@@ -189,8 +191,15 @@
std::string id_string;
int64 id = 0;
- if (!value.GetString(kIdKey, &id_string) || !StringToInt64(id_string, &id))
- ids_missing_ = true;
+ if (ids_valid_) {
+ if (!value.GetString(kIdKey, &id_string) ||
+ !StringToInt64(id_string, &id) ||
+ ids_.count(id) != 0) {
+ ids_valid_ = false;
+ } else {
+ ids_.insert(id);
+ }
+ }
maximum_id_ = std::max(maximum_id_, id);
« no previous file with comments | « chrome/browser/bookmarks/bookmark_codec.h ('k') | chrome/browser/bookmarks/bookmark_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698