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

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

Issue 155560: Don't use ID generation logic always. Only reassign IDs... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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/bookmarks/bookmark_codec.h
===================================================================
--- chrome/browser/bookmarks/bookmark_codec.h (revision 20638)
+++ chrome/browser/bookmarks/bookmark_codec.h (working copy)
@@ -9,7 +9,6 @@
#ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_CODEC_H_
#define CHROME_BROWSER_BOOKMARKS_BOOKMARK_CODEC_H_
-#include <set>
#include <string>
#include "base/basictypes.h"
@@ -22,39 +21,6 @@
class ListValue;
class Value;
-// Utility class to help assign unique 64-bit IDs.
-class UniqueIDGenerator {
- public:
- UniqueIDGenerator();
-
- // Checks whether the given ID can be used as a unique ID or not. If it can,
- // returns the id itself, otherwise generates a new unique id in a simple way
- // and returns that.
- // NOTE that if id is 0, a new unique id is returned.
- int64 GetUniqueID(int64 id);
-
- // Resets the ID generator to initial state.
- void Reset();
-
- // Returns the current maximum.
- int64 current_max() const { return current_max_; }
-
- private:
- // Checks if the given ID is already assigned.
- bool IsIdAssigned(int64 id) const;
-
- // Records the given ID as assigned.
- void RecordId(int64 id);
-
- // Maximum value we have seen so far.
- int64 current_max_;
-
- // All IDs assigned so far.
- scoped_ptr<std::set<int64> > assigned_ids_;
-
- DISALLOW_COPY_AND_ASSIGN(UniqueIDGenerator);
-};
-
// BookmarkCodec is responsible for encoding/decoding bookmarks into JSON
// values. BookmarkCodec is used by BookmarkService.
@@ -135,6 +101,12 @@
bool DecodeChildren(const ListValue& child_value_list,
BookmarkNode* parent);
+ // Reassigns bookmark IDs for all nodes.
+ void ReassignIDs(BookmarkNode* bb_node, BookmarkNode* other_node);
+
+ // Helper to recursively reassign IDs.
+ void ReassignIDsHelper(BookmarkNode* node);
+
// Decodes the supplied node from the supplied value. Child nodes are
// created appropriately by way of DecodeChildren. If node is NULL a new
// node is created and added to parent, otherwise node is used.
@@ -161,12 +133,12 @@
void InitializeChecksum();
void FinalizeChecksum();
- // Unique ID generator used during decoding.
- UniqueIDGenerator id_generator_;
-
// Whether or not IDs were reassigned by the codec.
bool ids_reassigned_;
+ // Whether or not IDs were missing for some bookmark nodes during decoding.
+ bool ids_missing_;
+
// MD5 context used to compute MD5 hash of all bookmark data.
MD5Context md5_context_;
@@ -174,6 +146,9 @@
std::string computed_checksum_;
std::string stored_checksum_;
+ // Maximum ID assigned when decoding data.
+ int64 maximum_id_;
+
DISALLOW_COPY_AND_ASSIGN(BookmarkCodec);
};
« no previous file with comments | « no previous file | chrome/browser/bookmarks/bookmark_codec.cc » ('j') | chrome/browser/bookmarks/bookmark_codec.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698