diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-02 08:03:16 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-02 08:03:16 +0000 |
commit | 9c92d191fd78a2f9c8b9c35519fbd0bc6d0940e7 (patch) | |
tree | 8c40767e736727e95fb735cfe1ab50f1cc984bdc /chrome/browser/bookmarks | |
parent | 5ef9898d7c51f934efdd45d5fdbc0e1faacec189 (diff) | |
download | chromium_src-9c92d191fd78a2f9c8b9c35519fbd0bc6d0940e7.zip chromium_src-9c92d191fd78a2f9c8b9c35519fbd0bc6d0940e7.tar.gz chromium_src-9c92d191fd78a2f9c8b9c35519fbd0bc6d0940e7.tar.bz2 |
[GTTF] Reduce header dependencies in chrome.
Review URL: http://codereview.chromium.org/457025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33561 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/bookmarks')
-rw-r--r-- | chrome/browser/bookmarks/bookmark_context_menu_controller.h | 3 | ||||
-rw-r--r-- | chrome/browser/bookmarks/bookmark_drag_data.h | 1 | ||||
-rw-r--r-- | chrome/browser/bookmarks/bookmark_model.cc | 9 | ||||
-rw-r--r-- | chrome/browser/bookmarks/bookmark_model.h | 13 | ||||
-rw-r--r-- | chrome/browser/bookmarks/bookmark_model_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/bookmarks/bookmark_storage.cc | 6 | ||||
-rw-r--r-- | chrome/browser/bookmarks/bookmark_storage.h | 133 |
7 files changed, 86 insertions, 81 deletions
diff --git a/chrome/browser/bookmarks/bookmark_context_menu_controller.h b/chrome/browser/bookmarks/bookmark_context_menu_controller.h index 66f9f61..0934b70 100644 --- a/chrome/browser/bookmarks/bookmark_context_menu_controller.h +++ b/chrome/browser/bookmarks/bookmark_context_menu_controller.h @@ -9,10 +9,11 @@ #include "app/gfx/native_widget_types.h" #include "base/basictypes.h" -#include "chrome/browser/bookmarks/bookmark_model.h" +#include "chrome/browser/bookmarks/bookmark_model_observer.h" class Browser; class PageNavigator; +class Profile; // An interface implemented by an object that performs actions on the actual // menu for the controller. diff --git a/chrome/browser/bookmarks/bookmark_drag_data.h b/chrome/browser/bookmarks/bookmark_drag_data.h index 0b9736c..2699234 100644 --- a/chrome/browser/bookmarks/bookmark_drag_data.h +++ b/chrome/browser/bookmarks/bookmark_drag_data.h @@ -8,7 +8,6 @@ #include <string> #include <vector> -#include "chrome/browser/history/history.h" #include "googleurl/src/gurl.h" // TODO(port): Port this file. diff --git a/chrome/browser/bookmarks/bookmark_model.cc b/chrome/browser/bookmarks/bookmark_model.cc index daab3c7..f75577c 100644 --- a/chrome/browser/bookmarks/bookmark_model.cc +++ b/chrome/browser/bookmarks/bookmark_model.cc @@ -12,6 +12,7 @@ #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/bookmarks/bookmark_storage.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/history/history_notifications.h" #include "chrome/browser/profile.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_service.h" @@ -449,9 +450,9 @@ void BookmarkModel::RemoveNode(BookmarkNode* node, } void BookmarkModel::DoneLoading( - BookmarkStorage::LoadDetails* details_delete_me) { + BookmarkLoadDetails* details_delete_me) { DCHECK(details_delete_me); - scoped_ptr<BookmarkStorage::LoadDetails> details(details_delete_me); + scoped_ptr<BookmarkLoadDetails> details(details_delete_me); if (loaded_) { // We should only ever be loaded once. NOTREACHED(); @@ -727,9 +728,9 @@ void BookmarkModel::SetFileChanged() { file_changed_ = true; } -BookmarkStorage::LoadDetails* BookmarkModel::CreateLoadDetails() { +BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() { BookmarkNode* bb_node = CreateBookmarkNode(); BookmarkNode* other_folder_node = CreateOtherBookmarksNode(); - return new BookmarkStorage::LoadDetails( + return new BookmarkLoadDetails( bb_node, other_folder_node, new BookmarkIndex(profile()), next_node_id_); } diff --git a/chrome/browser/bookmarks/bookmark_model.h b/chrome/browser/bookmarks/bookmark_model.h index 88286a09..5d03af7 100644 --- a/chrome/browser/bookmarks/bookmark_model.h +++ b/chrome/browser/bookmarks/bookmark_model.h @@ -16,7 +16,6 @@ #include "base/waitable_event.h" #include "chrome/browser/bookmarks/bookmark_model_observer.h" #include "chrome/browser/bookmarks/bookmark_service.h" -#include "chrome/browser/bookmarks/bookmark_storage.h" #include "chrome/browser/cancelable_request.h" #include "chrome/browser/favicon_service.h" #include "chrome/browser/history/history.h" @@ -26,10 +25,12 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "testing/gtest/include/gtest/gtest_prod.h" +class BookmarkCodec; class BookmarkEditorView; class BookmarkIndex; +class BookmarkLoadDetails; class BookmarkModel; -class BookmarkCodec; +class BookmarkStorage; class Profile; namespace bookmark_utils { @@ -332,7 +333,7 @@ class BookmarkModel : public NotificationObserver, public BookmarkService { // Invoked when loading is finished. Sets loaded_ and notifies observers. // BookmarkModel takes ownership of |details|. - void DoneLoading(BookmarkStorage::LoadDetails* details); + void DoneLoading(BookmarkLoadDetails* details); // Populates nodes_ordered_by_url_set_ from root. void PopulateNodesByURL(BookmarkNode* node); @@ -400,9 +401,9 @@ class BookmarkModel : public NotificationObserver, public BookmarkService { // Records that the bookmarks file was changed externally. void SetFileChanged(); - // Creates and returns a new LoadDetails. It's up to the caller to delete - // the returned object. - BookmarkStorage::LoadDetails* CreateLoadDetails(); + // Creates and returns a new BookmarkLoadDetails. It's up to the caller to + // delete the returned object. + BookmarkLoadDetails* CreateLoadDetails(); NotificationRegistrar registrar_; diff --git a/chrome/browser/bookmarks/bookmark_model_unittest.cc b/chrome/browser/bookmarks/bookmark_model_unittest.cc index 1e5b90e..0624b74 100644 --- a/chrome/browser/bookmarks/bookmark_model_unittest.cc +++ b/chrome/browser/bookmarks/bookmark_model_unittest.cc @@ -11,6 +11,8 @@ #include "chrome/browser/bookmarks/bookmark_codec.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/bookmarks/bookmark_utils.h" +#include "chrome/browser/chrome_thread.h" +#include "chrome/browser/history/history_notifications.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/notification_registrar.h" diff --git a/chrome/browser/bookmarks/bookmark_storage.cc b/chrome/browser/bookmarks/bookmark_storage.cc index 387fa71..0b7d895 100644 --- a/chrome/browser/bookmarks/bookmark_storage.cc +++ b/chrome/browser/bookmarks/bookmark_storage.cc @@ -64,7 +64,7 @@ class BookmarkStorage::LoadTask : public Task { public: LoadTask(const FilePath& path, BookmarkStorage* storage, - LoadDetails* details) + BookmarkLoadDetails* details) : path_(path), storage_(storage), details_(details) { @@ -120,7 +120,7 @@ class BookmarkStorage::LoadTask : public Task { const FilePath path_; scoped_refptr<BookmarkStorage> storage_; - LoadDetails* details_; + BookmarkLoadDetails* details_; DISALLOW_COPY_AND_ASSIGN(LoadTask); }; @@ -143,7 +143,7 @@ BookmarkStorage::~BookmarkStorage() { writer_.DoScheduledWrite(); } -void BookmarkStorage::LoadBookmarks(LoadDetails* details) { +void BookmarkStorage::LoadBookmarks(BookmarkLoadDetails* details) { DCHECK(!details_.get()); DCHECK(details); details_.reset(details); diff --git a/chrome/browser/bookmarks/bookmark_storage.h b/chrome/browser/bookmarks/bookmark_storage.h index e3e1337..0edf5a0 100644 --- a/chrome/browser/bookmarks/bookmark_storage.h +++ b/chrome/browser/bookmarks/bookmark_storage.h @@ -19,6 +19,69 @@ class Profile; class Task; class Value; +// BookmarkLoadDetails is used by BookmarkStorage when loading bookmarks. +// BookmarkModel creates a BookmarkLoadDetails and passes it (including +// ownership) to BookmarkStorage. BoomarkStorage loads the bookmarks (and index) +// in the background thread, then calls back to the BookmarkModel (on the main +// thread) when loading is done, passing ownership back to the BookmarkModel. +// While loading BookmarkModel does not maintain references to the contents +// of the BookmarkLoadDetails, this ensures we don't have any threading +// problems. +class BookmarkLoadDetails { + public: + BookmarkLoadDetails(BookmarkNode* bb_node, + BookmarkNode* other_folder_node, + BookmarkIndex* index, + int64 max_id) + : bb_node_(bb_node), + other_folder_node_(other_folder_node), + index_(index), + max_id_(max_id), + ids_reassigned_(false) { + } + + void release() { + bb_node_.release(); + other_folder_node_.release(); + index_.release(); + } + + BookmarkNode* bb_node() { return bb_node_.get(); } + BookmarkNode* other_folder_node() { return other_folder_node_.get(); } + BookmarkIndex* index() { return index_.get(); } + + // Max id of the nodes. + void set_max_id(int64 max_id) { max_id_ = max_id; } + int64 max_id() const { return max_id_; } + + // Computed checksum. + void set_computed_checksum(const std::string& value) { + computed_checksum_ = value; + } + const std::string& computed_checksum() const { return computed_checksum_; } + + // Stored checksum. + void set_stored_checksum(const std::string& value) { + stored_checksum_ = value; + } + const std::string& stored_checksum() const { return stored_checksum_; } + + // Whether ids were reassigned. + void set_ids_reassigned(bool value) { ids_reassigned_ = value; } + bool ids_reassigned() const { return ids_reassigned_; } + + private: + scoped_ptr<BookmarkNode> bb_node_; + scoped_ptr<BookmarkNode> other_folder_node_; + scoped_ptr<BookmarkIndex> index_; + int64 max_id_; + std::string computed_checksum_; + std::string stored_checksum_; + bool ids_reassigned_; + + DISALLOW_COPY_AND_ASSIGN(BookmarkLoadDetails); +}; + // BookmarkStorage handles reading/write the bookmark bar model. The // BookmarkModel uses the BookmarkStorage to load bookmarks from disk, as well // as notifying the BookmarkStorage every time the model changes. @@ -28,74 +91,12 @@ class BookmarkStorage : public NotificationObserver, public ImportantFileWriter::DataSerializer, public base::RefCountedThreadSafe<BookmarkStorage> { public: - // LoadDetails is used by BookmarkStorage when loading bookmarks. - // BookmarkModel creates a LoadDetails and passes it (including ownership) to - // BookmarkStorage. BoomarkStorage loads the bookmarks (and index) in the - // background thread, then calls back to the BookmarkModel (on the main - // thread) when loading is done, passing ownership back to the BookmarkModel. - // While loading BookmarkModel does not maintain references to the contents - // of the LoadDetails, this ensures we don't have any threading problems. - class LoadDetails { - public: - LoadDetails(BookmarkNode* bb_node, - BookmarkNode* other_folder_node, - BookmarkIndex* index, - int64 max_id) - : bb_node_(bb_node), - other_folder_node_(other_folder_node), - index_(index), - max_id_(max_id), - ids_reassigned_(false) { - } - - void release() { - bb_node_.release(); - other_folder_node_.release(); - index_.release(); - } - - BookmarkNode* bb_node() { return bb_node_.get(); } - BookmarkNode* other_folder_node() { return other_folder_node_.get(); } - BookmarkIndex* index() { return index_.get(); } - - // Max id of the nodes. - void set_max_id(int64 max_id) { max_id_ = max_id; } - int64 max_id() const { return max_id_; } - - // Computed checksum. - void set_computed_checksum(const std::string& value) { - computed_checksum_ = value; - } - const std::string& computed_checksum() const { return computed_checksum_; } - - // Stored checksum. - void set_stored_checksum(const std::string& value) { - stored_checksum_ = value; - } - const std::string& stored_checksum() const { return stored_checksum_; } - - // Whether ids were reassigned. - void set_ids_reassigned(bool value) { ids_reassigned_ = value; } - bool ids_reassigned() const { return ids_reassigned_; } - - private: - scoped_ptr<BookmarkNode> bb_node_; - scoped_ptr<BookmarkNode> other_folder_node_; - scoped_ptr<BookmarkIndex> index_; - int64 max_id_; - std::string computed_checksum_; - std::string stored_checksum_; - bool ids_reassigned_; - - DISALLOW_COPY_AND_ASSIGN(LoadDetails); - }; - // Creates a BookmarkStorage for the specified model BookmarkStorage(Profile* profile, BookmarkModel* model); // Loads the bookmarks into the model, notifying the model when done. This - // takes ownership of |details|. See LoadDetails for details. - void LoadBookmarks(LoadDetails* details); + // takes ownership of |details|. See BookmarkLoadDetails for details. + void LoadBookmarks(BookmarkLoadDetails* details); // Schedules saving the bookmark bar model to disk. void ScheduleSave(); @@ -157,8 +158,8 @@ class BookmarkStorage : public NotificationObserver, // Path to temporary file created during migrating bookmarks from history. const FilePath tmp_history_path_; - // See class description of LoadDetails for details on this. - scoped_ptr<LoadDetails> details_; + // See class description of BookmarkLoadDetails for details on this. + scoped_ptr<BookmarkLoadDetails> details_; DISALLOW_COPY_AND_ASSIGN(BookmarkStorage); }; |