Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(446)

Unified Diff: chrome/browser/bookmarks/bookmark_model.h

Issue 242693003: Introduce BookmarkClient interface to abstract embedder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/bookmarks/bookmark_model.h
diff --git a/chrome/browser/bookmarks/bookmark_model.h b/chrome/browser/bookmarks/bookmark_model.h
index b6dfd70b8a686ff717d27f8dce654b201fe2b273..f3ad89b71844f9d118477099d998443967000896 100644
--- a/chrome/browser/bookmarks/bookmark_model.h
+++ b/chrome/browser/bookmarks/bookmark_model.h
@@ -18,12 +18,9 @@
#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 +30,22 @@ class BookmarkLoadDetails;
class BookmarkModelObserver;
class BookmarkStorage;
struct BookmarkTitleMatch;
-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,20 +56,22 @@ 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:
- explicit BookmarkModel(Profile* profile);
+ explicit BookmarkModel(BookmarkClient* client);
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 callback
+ // will be called from |io_task_runner|.
+ void Load(PrefService* pref_service,
+ 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_; }
@@ -245,14 +249,17 @@ 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_; }
+ // Returns the BookmarkClient that corresponds to this BookmarkModel.
+ BookmarkClient* client() { return client_; }
+
+ void OnFaviconChanged(const std::set<GURL>& urls);
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 {
@@ -293,10 +300,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,
@@ -331,11 +334,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();
@@ -348,9 +346,7 @@ class BookmarkModel : public content::NotificationObserver,
// delete the returned object.
BookmarkLoadDetails* CreateLoadDetails();
- content::NotificationRegistrar registrar_;
-
- Profile* profile_;
+ BookmarkClient* client_;
// Whether the initial set of data has been loaded.
bool loaded_;

Powered by Google App Engine
This is Rietveld 408576698