diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-13 21:54:33 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-13 21:54:33 +0000 |
commit | be341c7eacdfccf1720a3e7d96ff96a38a4fb187 (patch) | |
tree | 7f70477ac5b95d5821593bc66a7bae44deee24e2 /chrome/browser/bookmarks/bookmark_codec.h | |
parent | ec584a1b5c8d4a454a8c008492774a725f0c5513 (diff) | |
download | chromium_src-be341c7eacdfccf1720a3e7d96ff96a38a4fb187.zip chromium_src-be341c7eacdfccf1720a3e7d96ff96a38a4fb187.tar.gz chromium_src-be341c7eacdfccf1720a3e7d96ff96a38a4fb187.tar.bz2 |
Revert "Always persist bookmark IDs."
This reverts commit r20532 because valgrind was complaining
about uninitialized memory:
http://build.chromium.org/buildbot/waterfall/builders/Chromium%20Linux%20(valgrind)/builds/697/steps/valgrind%20test:%20unit/logs/stdio
TBR=munjal
Review URL: http://codereview.chromium.org/155448
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20550 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, 18 insertions, 20 deletions
diff --git a/chrome/browser/bookmarks/bookmark_codec.h b/chrome/browser/bookmarks/bookmark_codec.h index 2c13cef..e6292a8 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 64-bit IDs. +// Utility class to help assign unique integer IDs. class UniqueIDGenerator { public: UniqueIDGenerator(); @@ -31,26 +31,25 @@ 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. - int64 GetUniqueID(int64 id); + int GetUniqueID(int id); // Resets the ID generator to initial state. void Reset(); // Returns the current maximum. - int64 current_max() const { return current_max_; } + int current_max() const { return current_max_; } private: // Checks if the given ID is already assigned. - bool IsIdAssigned(int64 id) const; + bool IsIdAssigned(int id) const; // Records the given ID as assigned. - void RecordId(int64 id); + void RecordId(int id); // Maximum value we have seen so far. - int64 current_max_; - + int current_max_; // All IDs assigned so far. - scoped_ptr<std::set<int64> > assigned_ids_; + scoped_ptr<std::set<int> > assigned_ids_; DISALLOW_COPY_AND_ASSIGN(UniqueIDGenerator); }; @@ -60,11 +59,14 @@ class UniqueIDGenerator { class BookmarkCodec { public: - // 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. + // 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. 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 @@ -86,7 +88,7 @@ class BookmarkCodec { // |max_node_id| is set to the max id of the nodes. bool Decode(BookmarkNode* bb_node, BookmarkNode* other_folder_node, - int64* max_node_id, + int* max_node_id, const Value& value); // Returns the checksum computed during last encoding/decoding call. @@ -99,10 +101,6 @@ 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; @@ -129,6 +127,7 @@ 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. @@ -161,12 +160,11 @@ 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_; |