diff options
author | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-09 20:56:59 +0000 |
---|---|---|
committer | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-09 20:56:59 +0000 |
commit | dddc1b44f4ae8346098bfadecd71d23e7de9299e (patch) | |
tree | 7e7bc78046ccc2e72845aad02bf412cde68dc317 /chrome | |
parent | 02c8af4b05db2cd02da70aeaac176acb1deadf60 (diff) | |
download | chromium_src-dddc1b44f4ae8346098bfadecd71d23e7de9299e.zip chromium_src-dddc1b44f4ae8346098bfadecd71d23e7de9299e.tar.gz chromium_src-dddc1b44f4ae8346098bfadecd71d23e7de9299e.tar.bz2 |
Changes BookmarkModel to not grab the same lock twice.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6391
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3127 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/bookmarks/bookmark_model.cc | 12 | ||||
-rw-r--r-- | chrome/browser/bookmarks/bookmark_model.h | 9 |
2 files changed, 16 insertions, 5 deletions
diff --git a/chrome/browser/bookmarks/bookmark_model.cc b/chrome/browser/bookmarks/bookmark_model.cc index 5e29095..fba0629 100644 --- a/chrome/browser/bookmarks/bookmark_model.cc +++ b/chrome/browser/bookmarks/bookmark_model.cc @@ -302,9 +302,7 @@ void BookmarkModel::GetBookmarks(std::vector<GURL>* urls) { bool BookmarkModel::IsBookmarked(const GURL& url) { AutoLock url_lock(url_lock_); - BookmarkNode tmp_node(this, url); - return (nodes_ordered_by_url_set_.find(&tmp_node) != - nodes_ordered_by_url_set_.end()); + return IsBookmarkedNoLock(url); } BookmarkNode* BookmarkModel::GetNodeByID(int id) { @@ -389,6 +387,12 @@ void BookmarkModel::ResetDateGroupModified(BookmarkNode* node) { SetDateGroupModified(node, Time()); } +bool BookmarkModel::IsBookmarkedNoLock(const GURL& url) { + BookmarkNode tmp_node(this, url); + return (nodes_ordered_by_url_set_.find(&tmp_node) != + nodes_ordered_by_url_set_.end()); +} + void BookmarkModel::FavIconLoaded(BookmarkNode* node) { // Send out notification to the observer. FOR_EACH_OBSERVER(BookmarkModelObserver, observers_, @@ -520,7 +524,7 @@ void BookmarkModel::RemoveAndDeleteNode(BookmarkNode* delete_me) { // allow duplicates we need to remove any entries that are still bookmarked. for (std::set<GURL>::iterator i = details.changed_urls.begin(); i != details.changed_urls.end(); ){ - if (IsBookmarked(*i)) + if (IsBookmarkedNoLock(*i)) i = details.changed_urls.erase(i); else ++i; diff --git a/chrome/browser/bookmarks/bookmark_model.h b/chrome/browser/bookmarks/bookmark_model.h index a9f6308..7c2a6ba 100644 --- a/chrome/browser/bookmarks/bookmark_model.h +++ b/chrome/browser/bookmarks/bookmark_model.h @@ -202,7 +202,8 @@ class BookmarkModel : public NotificationObserver, public BookmarkService { // modified groups. This never returns an empty vector. std::vector<BookmarkNode*> GetMostRecentlyModifiedGroups(size_t max_count); - // Returns the most recently added bookmarks. + // Returns the most recently added bookmarks. This does not return groups, + // only nodes of type url. void GetMostRecentlyAddedEntries(size_t count, std::vector<BookmarkNode*>* nodes); @@ -294,6 +295,8 @@ class BookmarkModel : public NotificationObserver, public BookmarkService { // combobox of most recently modified groups. void ResetDateGroupModified(BookmarkNode* node); + Profile* profile() const { return profile_; } + private: // Used to order BookmarkNodes by URL. class NodeURLComparator { @@ -303,6 +306,10 @@ class BookmarkModel : public NotificationObserver, public BookmarkService { } }; + // Implementation of IsBookmarked. Before calling this the caller must + // obtain a lock on url_lock_. + bool IsBookmarkedNoLock(const GURL& url); + // Overriden to notify the observer the favicon has been loaded. void FavIconLoaded(BookmarkNode* node); |