diff options
author | munjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-13 23:27:13 +0000 |
---|---|---|
committer | munjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-13 23:27:13 +0000 |
commit | 367d707fa4f9a6712ccb7035c530da5788a4f5a2 (patch) | |
tree | 676c59f1f4eec2145a59fcb36c8894afab10042c /chrome/browser/bookmarks/bookmark_codec.h | |
parent | d8241d65b71b1409c9f6581b9ceee68f9bf35c3e (diff) | |
download | chromium_src-367d707fa4f9a6712ccb7035c530da5788a4f5a2.zip chromium_src-367d707fa4f9a6712ccb7035c530da5788a4f5a2.tar.gz chromium_src-367d707fa4f9a6712ccb7035c530da5788a4f5a2.tar.bz2 |
Try the original CL "Always persist bookmark IDs" again with the fix to
Valgrind issue. The fix is in bookmark_storage.h - initialized the newly
added member ids_reassigned_ of LoadDetails class.
See http://codereview.chromium.org/149310 for the original CL.
TEST=NONE
BUG=16068
Review URL: http://codereview.chromium.org/155456
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20565 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/bookmarks/bookmark_codec.h')
-rw-r--r-- | chrome/browser/bookmarks/bookmark_codec.h | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/chrome/browser/bookmarks/bookmark_codec.h b/chrome/browser/bookmarks/bookmark_codec.h index e6292a8..2c13cef 100644 --- a/chrome/browser/bookmarks/bookmark_codec.h +++ b/chrome/browser/bookmarks/bookmark_codec.h @@ -22,7 +22,7 @@ class DictionaryValue; class ListValue; class Value; -// Utility class to help assign unique integer IDs. +// Utility class to help assign unique 64-bit IDs. class UniqueIDGenerator { public: UniqueIDGenerator(); @@ -31,25 +31,26 @@ class UniqueIDGenerator { // 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. - int GetUniqueID(int id); + int64 GetUniqueID(int64 id); // Resets the ID generator to initial state. void Reset(); // Returns the current maximum. - int current_max() const { return current_max_; } + int64 current_max() const { return current_max_; } private: // Checks if the given ID is already assigned. - bool IsIdAssigned(int id) const; + bool IsIdAssigned(int64 id) const; // Records the given ID as assigned. - void RecordId(int id); + void RecordId(int64 id); // Maximum value we have seen so far. - int current_max_; + int64 current_max_; + // All IDs assigned so far. - scoped_ptr<std::set<int> > assigned_ids_; + scoped_ptr<std::set<int64> > assigned_ids_; DISALLOW_COPY_AND_ASSIGN(UniqueIDGenerator); }; @@ -59,14 +60,11 @@ class UniqueIDGenerator { class BookmarkCodec { public: - // Creates an instance of the codec. Encodes/decodes bookmark IDs also if - // persist_ids is true. The default constructor will not encode/decode IDs. - // During decoding, if persist_ids is true and if the IDs in the file are not - // unique, we will reassign IDs to make them unique. There are no guarantees - // on how the IDs are reassigned or about doing minimal reassignments to - // achieve uniqueness. + // Creates an instance of the codec. During decoding, if the IDs in the file + // are not unique, we will reassign IDs to make them unique. There are no + // guarantees on how the IDs are reassigned or about doing minimal + // reassignments to achieve uniqueness. BookmarkCodec(); - explicit BookmarkCodec(bool persist_ids); // Encodes the model to a JSON value. It's up to the caller to delete the // returned object. This is invoked to encode the contents of the bookmark bar @@ -88,7 +86,7 @@ class BookmarkCodec { // |max_node_id| is set to the max id of the nodes. bool Decode(BookmarkNode* bb_node, BookmarkNode* other_folder_node, - int* max_node_id, + int64* max_node_id, const Value& value); // Returns the checksum computed during last encoding/decoding call. @@ -101,6 +99,10 @@ class BookmarkCodec { // user. const std::string& stored_checksum() const { return stored_checksum_; } + // Returns whether the IDs were reassigned during decoding. Always returns + // false after encoding. + bool ids_reassigned() const { return ids_reassigned_; } + // Names of the various keys written to the Value. static const wchar_t* kRootsKey; static const wchar_t* kRootFolderNameKey; @@ -127,7 +129,6 @@ class BookmarkCodec { // Helper to perform decoding. bool DecodeHelper(BookmarkNode* bb_node, BookmarkNode* other_folder_node, - int* max_id, const Value& value); // Decodes the children of the specified node. Returns true on success. @@ -160,11 +161,12 @@ class BookmarkCodec { void InitializeChecksum(); void FinalizeChecksum(); - // Whether to persist IDs or not. - bool persist_ids_; // Unique ID generator used during decoding. UniqueIDGenerator id_generator_; + // Whether or not IDs were reassigned by the codec. + bool ids_reassigned_; + // MD5 context used to compute MD5 hash of all bookmark data. MD5Context md5_context_; |