Index: chrome/browser/bookmarks/bookmark_model.h |
diff --git a/chrome/browser/bookmarks/bookmark_model.h b/chrome/browser/bookmarks/bookmark_model.h |
index 9eaf2408fd36e1f5495f5e04695df59533b92074..0c55028bb9ac4e460f448df3123ec3e159c618d3 100644 |
--- a/chrome/browser/bookmarks/bookmark_model.h |
+++ b/chrome/browser/bookmarks/bookmark_model.h |
@@ -17,13 +17,9 @@ |
#include "base/strings/string16.h" |
#include "base/synchronization/lock.h" |
#include "base/synchronization/waitable_event.h" |
-#include "base/task/cancelable_task_tracker.h" |
+#include "components/bookmarks/core/browser/bookmark_client.h" |
#include "components/bookmarks/core/browser/bookmark_node.h" |
#include "components/bookmarks/core/browser/bookmark_service.h" |
-#include "components/favicon_base/favicon_types.h" |
-#include "components/keyed_service/core/keyed_service.h" |
-#include "content/public/browser/notification_observer.h" |
-#include "content/public/browser/notification_registrar.h" |
#include "ui/gfx/image/image.h" |
#include "url/gurl.h" |
@@ -33,17 +29,22 @@ class BookmarkLoadDetails; |
class BookmarkModelObserver; |
class BookmarkStorage; |
struct BookmarkMatch; |
-class Profile; |
+class PrefService; |
class ScopedGroupBookmarkActions; |
namespace base { |
+class FilePath; |
class SequencedTaskRunner; |
} |
-namespace chrome { |
+namespace favicon_base { |
struct FaviconImageResult; |
} |
+namespace test { |
+class TestBookmarkClient; |
+} |
+ |
// BookmarkModel -------------------------------------------------------------- |
// BookmarkModel provides a directed acyclic graph of URLs and folders. |
@@ -54,22 +55,25 @@ struct FaviconImageResult; |
// |
// You should NOT directly create a BookmarkModel, instead go through the |
// BookmarkModelFactory. |
-class BookmarkModel : public content::NotificationObserver, |
- public BookmarkService, |
- public KeyedService { |
+class BookmarkModel : public BookmarkService { |
public: |
// |index_urls| says whether URLs should be stored in the BookmarkIndex |
// in addition to bookmark titles. |
- BookmarkModel(Profile* profile, bool index_urls); |
+ BookmarkModel(BookmarkClient* client, bool index_urls); |
virtual ~BookmarkModel(); |
// Invoked prior to destruction to release any necessary resources. |
- virtual void Shutdown() OVERRIDE; |
+ void Shutdown(); |
// Loads the bookmarks. This is called upon creation of the |
// BookmarkModel. You need not invoke this directly. |
- // All load operations will be executed on |task_runner|. |
- void Load(const scoped_refptr<base::SequencedTaskRunner>& task_runner); |
+ // All load operations will be executed on |io_task_runner| and the completion |
+ // callback will be called from |ui_task_runner|. |
+ void Load(PrefService* pref_service, |
+ const std::string& accept_languages, |
+ const base::FilePath& profile_path, |
+ const scoped_refptr<base::SequencedTaskRunner>& io_task_runner, |
+ const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner); |
// Returns true if the model finished loading. |
bool loaded() const { return loaded_; } |
@@ -258,14 +262,19 @@ class BookmarkModel : public content::NotificationObserver, |
void SetNodeSyncTransactionVersion(const BookmarkNode* node, |
int64 sync_transaction_version); |
- // Returns the profile that corresponds to this BookmarkModel. |
- Profile* profile() { return profile_; } |
+ // Notify BookmarkModel that the favicons for |urls| have changed and have to |
+ // be refetched. This notification is sent by BookmarkClient. |
+ void OnFaviconChanged(const std::set<GURL>& urls); |
+ |
+ // Returns the client used by this BookmarkModel. |
+ BookmarkClient* client() const { return client_; } |
private: |
friend class BookmarkCodecTest; |
friend class BookmarkModelTest; |
friend class BookmarkStorage; |
friend class ScopedGroupBookmarkActions; |
+ friend class test::TestBookmarkClient; |
// Used to order BookmarkNodes by URL. |
class NodeURLComparator { |
@@ -287,7 +296,7 @@ class BookmarkModel : public content::NotificationObserver, |
// Invoked when loading is finished. Sets |loaded_| and notifies observers. |
// BookmarkModel takes ownership of |details|. |
- void DoneLoading(BookmarkLoadDetails* details); |
+ void DoneLoading(scoped_ptr<BookmarkLoadDetails> details); |
// Populates |nodes_ordered_by_url_set_| from root. |
void PopulateNodesByURL(BookmarkNode* node); |
@@ -306,10 +315,6 @@ class BookmarkModel : public content::NotificationObserver, |
// Remove |node| from |nodes_ordered_by_url_set_|. |
void RemoveNodeFromURLSet(BookmarkNode* node); |
- // Notifies the history backend about urls of removed bookmarks. |
- void NotifyHistoryAboutRemovedBookmarks( |
- const std::set<GURL>& removed_bookmark_urls) const; |
- |
// Adds the |node| at |parent| in the specified |index| and notifies its |
// observers. |
BookmarkNode* AddNode(BookmarkNode* parent, |
@@ -344,11 +349,6 @@ class BookmarkModel : public content::NotificationObserver, |
void BeginGroupedChanges(); |
void EndGroupedChanges(); |
- // content::NotificationObserver: |
- virtual void Observe(int type, |
- const content::NotificationSource& source, |
- const content::NotificationDetails& details) OVERRIDE; |
- |
// Generates and returns the next node ID. |
int64 generate_next_node_id(); |
@@ -359,11 +359,10 @@ class BookmarkModel : public content::NotificationObserver, |
// Creates and returns a new BookmarkLoadDetails. It's up to the caller to |
// delete the returned object. |
- BookmarkLoadDetails* CreateLoadDetails(); |
- |
- content::NotificationRegistrar registrar_; |
+ scoped_ptr<BookmarkLoadDetails> CreateLoadDetails( |
+ const std::string& accept_languages); |
- Profile* profile_; |
+ BookmarkClient* const client_; |
// Whether the initial set of data has been loaded. |
bool loaded_; |