diff options
author | tfarina <tfarina@chromium.org> | 2015-01-12 10:46:48 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-12 18:47:43 +0000 |
commit | a0ec34ea883be550ed4b0bd2c593939eed31c882 (patch) | |
tree | c9f2e861cfb9b1faa36bfa46249fd3a8c71e0013 /components/bookmarks | |
parent | 2f65eb2d9c327d2bd93d079b7b6c2924e1959df5 (diff) | |
download | chromium_src-a0ec34ea883be550ed4b0bd2c593939eed31c882.zip chromium_src-a0ec34ea883be550ed4b0bd2c593939eed31c882.tar.gz chromium_src-a0ec34ea883be550ed4b0bd2c593939eed31c882.tar.bz2 |
bookmarks: Move BookmarkModel into 'bookmarks' namespace.
BUG=370433
TEST=unit_tests, components_unittests
R=sky@chromium.org
TBR=joaodasilva@chromium.org (for components/policy)
Review URL: https://codereview.chromium.org/820603005
Cr-Commit-Position: refs/heads/master@{#311074}
Diffstat (limited to 'components/bookmarks')
13 files changed, 64 insertions, 62 deletions
diff --git a/components/bookmarks/browser/bookmark_codec.h b/components/bookmarks/browser/bookmark_codec.h index f9da4dc..761ee48 100644 --- a/components/bookmarks/browser/bookmark_codec.h +++ b/components/bookmarks/browser/bookmark_codec.h @@ -13,8 +13,6 @@ #include "base/strings/string16.h" #include "components/bookmarks/browser/bookmark_node.h" -class BookmarkModel; - namespace base { class DictionaryValue; class ListValue; @@ -23,6 +21,8 @@ class Value; namespace bookmarks { +class BookmarkModel; + // BookmarkCodec is responsible for encoding and decoding the BookmarkModel // into JSON values. The encoded values are written to disk via the // BookmarkStorage. diff --git a/components/bookmarks/browser/bookmark_expanded_state_tracker.h b/components/bookmarks/browser/bookmark_expanded_state_tracker.h index c960b23..9efc1d0 100644 --- a/components/bookmarks/browser/bookmark_expanded_state_tracker.h +++ b/components/bookmarks/browser/bookmark_expanded_state_tracker.h @@ -9,12 +9,13 @@ #include "components/bookmarks/browser/base_bookmark_model_observer.h" -class BookmarkModel; class BookmarkNode; class PrefService; namespace bookmarks { +class BookmarkModel; + // BookmarkExpandedStateTracker is used to track a set of expanded nodes. The // nodes are persisted in preferences. If an expanded node is removed from the // model BookmarkExpandedStateTracker removes the node. diff --git a/components/bookmarks/browser/bookmark_model.cc b/components/bookmarks/browser/bookmark_model.cc index 8131ec1..153a7d1 100644 --- a/components/bookmarks/browser/bookmark_model.cc +++ b/components/bookmarks/browser/bookmark_model.cc @@ -26,14 +26,8 @@ #include "ui/gfx/favicon_size.h" using base::Time; -using bookmarks::BookmarkClient; -using bookmarks::BookmarkExpandedStateTracker; -using bookmarks::BookmarkIndex; -using bookmarks::BookmarkLoadDetails; -using bookmarks::BookmarkMatch; -using bookmarks::BookmarkModelObserver; -using bookmarks::BookmarkNodeData; -using bookmarks::BookmarkStorage; + +namespace bookmarks { namespace { @@ -154,7 +148,7 @@ void BookmarkModel::Load( const BookmarkNode* BookmarkModel::GetParentForNewNodes() { std::vector<const BookmarkNode*> nodes = - bookmarks::GetMostRecentlyModifiedUserFolders(this, 1); + GetMostRecentlyModifiedUserFolders(this, 1); DCHECK(!nodes.empty()); // This list is always padded with default folders. return nodes[0]; } @@ -294,7 +288,7 @@ void BookmarkModel::Copy(const BookmarkNode* node, std::vector<BookmarkNodeData::Element> elements(drag_data.elements); // CloneBookmarkNode will use BookmarkModel methods to do the job, so we // don't need to send notifications here. - bookmarks::CloneBookmarkNode(this, elements, new_parent, index, true); + CloneBookmarkNode(this, elements, new_parent, index, true); if (store_.get()) store_->ScheduleSave(); @@ -513,7 +507,7 @@ const BookmarkNode* BookmarkModel::GetMostRecentlyAddedUserNodeForURL( const GURL& url) { std::vector<const BookmarkNode*> nodes; GetNodesByURL(url, &nodes); - std::sort(nodes.begin(), nodes.end(), &bookmarks::MoreRecentlyAdded); + std::sort(nodes.begin(), nodes.end(), &MoreRecentlyAdded); // Look for the first node that the user can edit. for (size_t i = 0; i < nodes.size(); ++i) { @@ -1027,3 +1021,5 @@ scoped_ptr<BookmarkLoadDetails> BookmarkModel::CreateLoadDetails( new BookmarkIndex(client_, accept_languages), next_node_id_)); } + +} // namespace bookmarks diff --git a/components/bookmarks/browser/bookmark_model.h b/components/bookmarks/browser/bookmark_model.h index b72d396..076b01b 100644 --- a/components/bookmarks/browser/bookmark_model.h +++ b/components/bookmarks/browser/bookmark_model.h @@ -30,7 +30,16 @@ class FilePath; class SequencedTaskRunner; } +namespace favicon_base { +struct FaviconImageResult; +} + +namespace query_parser { +enum class MatchingAlgorithm; +} + namespace bookmarks { + class BookmarkCodecTest; class BookmarkExpandedStateTracker; class BookmarkIndex; @@ -40,15 +49,6 @@ class BookmarkStorage; class ScopedGroupBookmarkActions; class TestBookmarkClient; struct BookmarkMatch; -} - -namespace favicon_base { -struct FaviconImageResult; -} - -namespace query_parser { -enum class MatchingAlgorithm; -} // BookmarkModel -------------------------------------------------------------- @@ -67,7 +67,7 @@ class BookmarkModel : public KeyedService { base::string16 title; }; - explicit BookmarkModel(bookmarks::BookmarkClient* client); + explicit BookmarkModel(BookmarkClient* client); ~BookmarkModel() override; // KeyedService: @@ -112,8 +112,8 @@ class BookmarkModel : public KeyedService { // (as long as the model is loaded). const BookmarkNode* GetParentForNewNodes(); - void AddObserver(bookmarks::BookmarkModelObserver* observer); - void RemoveObserver(bookmarks::BookmarkModelObserver* observer); + void AddObserver(BookmarkModelObserver* observer); + void RemoveObserver(BookmarkModelObserver* observer); // Notifies the observers that an extensive set of changes is about to happen, // such as during import or sync, so they can delay any expensive UI updates @@ -242,15 +242,14 @@ class BookmarkModel : public KeyedService { // in either the title or the URL. It uses default matching algorithm. void GetBookmarksMatching(const base::string16& text, size_t max_count, - std::vector<bookmarks::BookmarkMatch>* matches); + std::vector<BookmarkMatch>* matches); // Returns up to |max_count| of bookmarks containing each term from |text| // in either the title or the URL. - void GetBookmarksMatching( - const base::string16& text, - size_t max_count, - query_parser::MatchingAlgorithm matching_algorithm, - std::vector<bookmarks::BookmarkMatch>* matches); + void GetBookmarksMatching(const base::string16& text, + size_t max_count, + query_parser::MatchingAlgorithm matching_algorithm, + std::vector<BookmarkMatch>* matches); // Sets the store to NULL, making it so the BookmarkModel does not persist // any changes to disk. This is only useful during testing to speed up @@ -262,7 +261,7 @@ class BookmarkModel : public KeyedService { // Returns the object responsible for tracking the set of expanded nodes in // the bookmark editor. - bookmarks::BookmarkExpandedStateTracker* expanded_state_tracker() { + BookmarkExpandedStateTracker* expanded_state_tracker() { return expanded_state_tracker_.get(); } @@ -302,13 +301,13 @@ class BookmarkModel : public KeyedService { void OnFaviconChanged(const std::set<GURL>& urls); // Returns the client used by this BookmarkModel. - bookmarks::BookmarkClient* client() const { return client_; } + BookmarkClient* client() const { return client_; } private: - friend class bookmarks::BookmarkCodecTest; - friend class bookmarks::BookmarkStorage; - friend class bookmarks::ScopedGroupBookmarkActions; - friend class bookmarks::TestBookmarkClient; + friend class BookmarkCodecTest; + friend class BookmarkStorage; + friend class ScopedGroupBookmarkActions; + friend class TestBookmarkClient; // Used to order BookmarkNodes by URL. class NodeURLComparator { @@ -330,7 +329,7 @@ class BookmarkModel : public KeyedService { // Invoked when loading is finished. Sets |loaded_| and notifies observers. // BookmarkModel takes ownership of |details|. - void DoneLoading(scoped_ptr<bookmarks::BookmarkLoadDetails> details); + void DoneLoading(scoped_ptr<BookmarkLoadDetails> details); // Populates |nodes_ordered_by_url_set_| from root. void PopulateNodesByURL(BookmarkNode* node); @@ -397,10 +396,10 @@ class BookmarkModel : public KeyedService { // Creates and returns a new BookmarkLoadDetails. It's up to the caller to // delete the returned object. - scoped_ptr<bookmarks::BookmarkLoadDetails> CreateLoadDetails( + scoped_ptr<BookmarkLoadDetails> CreateLoadDetails( const std::string& accept_languages); - bookmarks::BookmarkClient* const client_; + BookmarkClient* const client_; // Whether the initial set of data has been loaded. bool loaded_; @@ -417,7 +416,7 @@ class BookmarkModel : public KeyedService { int64 next_node_id_; // The observers. - ObserverList<bookmarks::BookmarkModelObserver> observers_; + ObserverList<BookmarkModelObserver> observers_; // Set of nodes ordered by URL. This is not a map to avoid copying the // urls. @@ -431,20 +430,22 @@ class BookmarkModel : public KeyedService { base::CancelableTaskTracker cancelable_task_tracker_; // Reads/writes bookmarks to disk. - scoped_ptr<bookmarks::BookmarkStorage> store_; + scoped_ptr<BookmarkStorage> store_; - scoped_ptr<bookmarks::BookmarkIndex> index_; + scoped_ptr<BookmarkIndex> index_; base::WaitableEvent loaded_signal_; // See description of IsDoingExtensiveChanges above. int extensive_changes_; - scoped_ptr<bookmarks::BookmarkExpandedStateTracker> expanded_state_tracker_; + scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; std::set<std::string> non_cloned_keys_; DISALLOW_COPY_AND_ASSIGN(BookmarkModel); }; +} // namespace bookmarks + #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ diff --git a/components/bookmarks/browser/bookmark_model_observer.h b/components/bookmarks/browser/bookmark_model_observer.h index f3d5bb6..92d4db9 100644 --- a/components/bookmarks/browser/bookmark_model_observer.h +++ b/components/bookmarks/browser/bookmark_model_observer.h @@ -7,12 +7,13 @@ #include <set> -class BookmarkModel; class BookmarkNode; class GURL; namespace bookmarks { +class BookmarkModel; + // Observer for the BookmarkModel. class BookmarkModelObserver { public: diff --git a/components/bookmarks/browser/bookmark_node.h b/components/bookmarks/browser/bookmark_node.h index ef59ae6..fd3fd1a 100644 --- a/components/bookmarks/browser/bookmark_node.h +++ b/components/bookmarks/browser/bookmark_node.h @@ -13,7 +13,9 @@ #include "ui/gfx/image/image.h" #include "url/gurl.h" +namespace bookmarks { class BookmarkModel; +} // BookmarkNode --------------------------------------------------------------- @@ -115,7 +117,7 @@ class BookmarkNode : public ui::TreeNode<BookmarkNode> { // HistoryContentsProvider. private: - friend class BookmarkModel; + friend class bookmarks::BookmarkModel; // A helper function to initialize various fields during construction. void Initialize(int64 id); diff --git a/components/bookmarks/browser/bookmark_node_data.h b/components/bookmarks/browser/bookmark_node_data.h index 47e85f6..fd7d13d 100644 --- a/components/bookmarks/browser/bookmark_node_data.h +++ b/components/bookmarks/browser/bookmark_node_data.h @@ -12,18 +12,19 @@ #include "base/time/time.h" #include "components/bookmarks/browser/bookmark_node.h" #include "ui/base/clipboard/clipboard_types.h" - #include "url/gurl.h" + #if defined(TOOLKIT_VIEWS) #include "ui/base/dragdrop/os_exchange_data.h" #endif -class BookmarkModel; class Pickle; class PickleIterator; namespace bookmarks { +class BookmarkModel; + // BookmarkNodeData is used to represent the following: // // . A single URL. diff --git a/components/bookmarks/browser/bookmark_storage.h b/components/bookmarks/browser/bookmark_storage.h index 9fa8646..c7f51a5 100644 --- a/components/bookmarks/browser/bookmark_storage.h +++ b/components/bookmarks/browser/bookmark_storage.h @@ -14,8 +14,6 @@ #include "base/memory/weak_ptr.h" #include "components/bookmarks/browser/bookmark_node.h" -class BookmarkModel; - namespace base { class SequencedTaskRunner; } @@ -23,6 +21,7 @@ class SequencedTaskRunner; namespace bookmarks { class BookmarkIndex; +class BookmarkModel; // A list of BookmarkPermanentNodes that owns them. typedef ScopedVector<BookmarkPermanentNode> BookmarkPermanentNodeList; diff --git a/components/bookmarks/browser/bookmark_utils.h b/components/bookmarks/browser/bookmark_utils.h index 9fcbfb5..c10bc08 100644 --- a/components/bookmarks/browser/bookmark_utils.h +++ b/components/bookmarks/browser/bookmark_utils.h @@ -12,7 +12,6 @@ #include "base/strings/utf_offset_string_conversions.h" #include "components/bookmarks/browser/bookmark_node_data.h" -class BookmarkModel; class BookmarkNode; class GURL; @@ -26,6 +25,7 @@ class PrefRegistrySyncable; namespace bookmarks { class BookmarkClient; +class BookmarkModel; // Fields to use when finding matching bookmarks. struct QueryFields { diff --git a/components/bookmarks/browser/scoped_group_bookmark_actions.h b/components/bookmarks/browser/scoped_group_bookmark_actions.h index 965f39f..c2f0997 100644 --- a/components/bookmarks/browser/scoped_group_bookmark_actions.h +++ b/components/bookmarks/browser/scoped_group_bookmark_actions.h @@ -7,10 +7,10 @@ #include "base/macros.h" -class BookmarkModel; - namespace bookmarks { +class BookmarkModel; + // Scopes the grouping of a set of changes into one undoable action. class ScopedGroupBookmarkActions { public: diff --git a/components/bookmarks/test/bookmark_test_helpers.h b/components/bookmarks/test/bookmark_test_helpers.h index a75609e..aeffd42 100644 --- a/components/bookmarks/test/bookmark_test_helpers.h +++ b/components/bookmarks/test/bookmark_test_helpers.h @@ -7,10 +7,11 @@ #include <string> -class BookmarkModel; class BookmarkNode; namespace bookmarks { +class BookmarkModel; + namespace test { // Blocks until |model| finishes loading. diff --git a/components/bookmarks/test/test_bookmark_client.cc b/components/bookmarks/test/test_bookmark_client.cc index e02b2c8..b8b38e9 100644 --- a/components/bookmarks/test/test_bookmark_client.cc +++ b/components/bookmarks/test/test_bookmark_client.cc @@ -19,7 +19,7 @@ TestBookmarkClient::~TestBookmarkClient() {} scoped_ptr<BookmarkModel> TestBookmarkClient::CreateModel() { scoped_ptr<BookmarkModel> bookmark_model(new BookmarkModel(this)); - scoped_ptr<bookmarks::BookmarkLoadDetails> details = + scoped_ptr<BookmarkLoadDetails> details = bookmark_model->CreateLoadDetails(std::string()); details->LoadExtraNodes(); bookmark_model->DoneLoading(details.Pass()); @@ -27,7 +27,7 @@ scoped_ptr<BookmarkModel> TestBookmarkClient::CreateModel() { } void TestBookmarkClient::SetExtraNodesToLoad( - bookmarks::BookmarkPermanentNodeList extra_nodes) { + BookmarkPermanentNodeList extra_nodes) { extra_nodes_to_load_ = extra_nodes.Pass(); // Keep a copy in |extra_nodes_| for the acessor. extra_nodes_ = extra_nodes_to_load_.get(); @@ -63,7 +63,7 @@ bool TestBookmarkClient::IsPermanentNodeVisible( void TestBookmarkClient::RecordAction(const base::UserMetricsAction& action) { } -bookmarks::LoadExtraCallback TestBookmarkClient::GetLoadExtraNodesCallback() { +LoadExtraCallback TestBookmarkClient::GetLoadExtraNodesCallback() { return base::Bind(&TestBookmarkClient::LoadExtraNodes, base::Passed(&extra_nodes_to_load_)); } @@ -82,8 +82,8 @@ bool TestBookmarkClient::CanBeEditedByUser(const BookmarkNode* node) { } // static -bookmarks::BookmarkPermanentNodeList TestBookmarkClient::LoadExtraNodes( - bookmarks::BookmarkPermanentNodeList extra_nodes, +BookmarkPermanentNodeList TestBookmarkClient::LoadExtraNodes( + BookmarkPermanentNodeList extra_nodes, int64* next_id) { return extra_nodes.Pass(); } diff --git a/components/bookmarks/test/test_bookmark_client.h b/components/bookmarks/test/test_bookmark_client.h index 188832d..2c71e1b 100644 --- a/components/bookmarks/test/test_bookmark_client.h +++ b/components/bookmarks/test/test_bookmark_client.h @@ -8,10 +8,10 @@ #include "base/memory/scoped_ptr.h" #include "components/bookmarks/browser/bookmark_client.h" -class BookmarkModel; - namespace bookmarks { +class BookmarkModel; + class TestBookmarkClient : public BookmarkClient { public: TestBookmarkClient(); |