diff options
author | munjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-30 23:09:01 +0000 |
---|---|---|
committer | munjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-30 23:09:01 +0000 |
commit | 814a2d33e8655daf6d699bf6aa5c0da6a88919e2 (patch) | |
tree | 7643729895f84a32031c175bf66128d8ada3020b /chrome/browser/bookmarks/bookmark_model.h | |
parent | a0580124bbc7affc8d7517ca6b7f972c5da882fc (diff) | |
download | chromium_src-814a2d33e8655daf6d699bf6aa5c0da6a88919e2.zip chromium_src-814a2d33e8655daf6d699bf6aa5c0da6a88919e2.tar.gz chromium_src-814a2d33e8655daf6d699bf6aa5c0da6a88919e2.tar.bz2 |
Implement ID persistence for bookmarks:
- Bookmark codec now takes in a ctor argument persist_ids
- If it's true, it will serialize IDs of bookmarks when encoding, and
deserialize already serialized IDs (if present) when decoding.
- During decoding, unique-ify the IDs if they are not unique.
- Add unit tests for all new code.
Coming up in a separate changelist:
- Move ID generation logic to bookmark model, and make it non-static.
Review URL: http://codereview.chromium.org/99217
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15013 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/bookmarks/bookmark_model.h')
-rw-r--r-- | chrome/browser/bookmarks/bookmark_model.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/chrome/browser/bookmarks/bookmark_model.h b/chrome/browser/bookmarks/bookmark_model.h index 5f63b73..b5ad92a 100644 --- a/chrome/browser/bookmarks/bookmark_model.h +++ b/chrome/browser/bookmarks/bookmark_model.h @@ -43,13 +43,17 @@ class BookmarkNode : public views::TreeNode<BookmarkNode> { friend class BookmarkModel; friend class BookmarkCodec; friend class history::StarredURLDatabase; + FRIEND_TEST(BookmarkCodecTest, PersistIDsTest); FRIEND_TEST(BookmarkEditorViewTest, ChangeParentAndURL); FRIEND_TEST(BookmarkEditorViewTest, EditURLKeepsPosition); FRIEND_TEST(BookmarkModelTest, MostRecentlyAddedEntries); FRIEND_TEST(BookmarkModelTest, GetMostRecentlyAddedNodeForURL); public: + // Creates a new node with the given properties. If the ID is not given or is + // 0, it is automatically assigned. BookmarkNode(BookmarkModel* model, const GURL& url); + BookmarkNode(BookmarkModel* model, int id, const GURL& url); virtual ~BookmarkNode() {} // Returns the favicon for the this node. If the favicon has not yet been @@ -92,14 +96,23 @@ class BookmarkNode : public views::TreeNode<BookmarkNode> { // HistoryContentsProvider. private: + // Sets the next ID for bookmark node ID generation. + static void SetNextId(int next_id); + + // helper to initialize various fields during construction. + void Initialize(BookmarkModel* model, int id); + // Resets the properties of the node from the supplied entry. void Reset(const history::StarredEntry& entry); + // Sets the id to the given value. + void set_id(int id) { id_ = id; } + // The model. This is NULL when created by StarredURLDatabase for migration. BookmarkModel* model_; // Unique identifier for this node. - const int id_; + int id_; // Whether the favicon has been loaded. bool loaded_favicon_; |