| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_STORAGE_H_ | 5 #ifndef COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_STORAGE_H_ |
| 6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_STORAGE_H_ | 6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_STORAGE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback_forward.h" | 14 #include "base/callback_forward.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/files/important_file_writer.h" | 16 #include "base/files/important_file_writer.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "components/bookmarks/browser/bookmark_index.h" | |
| 21 #include "components/bookmarks/browser/bookmark_node.h" | 20 #include "components/bookmarks/browser/bookmark_node.h" |
| 21 #include "components/bookmarks/browser/titled_url_index.h" |
| 22 | 22 |
| 23 namespace base { | 23 namespace base { |
| 24 class SequencedTaskRunner; | 24 class SequencedTaskRunner; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace bookmarks { | 27 namespace bookmarks { |
| 28 | 28 |
| 29 class BookmarkModel; | 29 class BookmarkModel; |
| 30 | 30 |
| 31 // A list of BookmarkPermanentNodes that owns them. | 31 // A list of BookmarkPermanentNodes that owns them. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 44 // the main thread) when loading is done, passing ownership back to the | 44 // the main thread) when loading is done, passing ownership back to the |
| 45 // BookmarkModel. While loading BookmarkModel does not maintain references to | 45 // BookmarkModel. While loading BookmarkModel does not maintain references to |
| 46 // the contents of the BookmarkLoadDetails, this ensures we don't have any | 46 // the contents of the BookmarkLoadDetails, this ensures we don't have any |
| 47 // threading problems. | 47 // threading problems. |
| 48 class BookmarkLoadDetails { | 48 class BookmarkLoadDetails { |
| 49 public: | 49 public: |
| 50 BookmarkLoadDetails(BookmarkPermanentNode* bb_node, | 50 BookmarkLoadDetails(BookmarkPermanentNode* bb_node, |
| 51 BookmarkPermanentNode* other_folder_node, | 51 BookmarkPermanentNode* other_folder_node, |
| 52 BookmarkPermanentNode* mobile_folder_node, | 52 BookmarkPermanentNode* mobile_folder_node, |
| 53 const LoadExtraCallback& load_extra_callback, | 53 const LoadExtraCallback& load_extra_callback, |
| 54 BookmarkIndex* index, | 54 TitledUrlIndex* index, |
| 55 int64_t max_id); | 55 int64_t max_id); |
| 56 ~BookmarkLoadDetails(); | 56 ~BookmarkLoadDetails(); |
| 57 | 57 |
| 58 void LoadExtraNodes(); | 58 void LoadExtraNodes(); |
| 59 | 59 |
| 60 BookmarkPermanentNode* bb_node() { return bb_node_.get(); } | 60 BookmarkPermanentNode* bb_node() { return bb_node_.get(); } |
| 61 std::unique_ptr<BookmarkPermanentNode> owned_bb_node() { | 61 std::unique_ptr<BookmarkPermanentNode> owned_bb_node() { |
| 62 return std::move(bb_node_); | 62 return std::move(bb_node_); |
| 63 } | 63 } |
| 64 BookmarkPermanentNode* mobile_folder_node() { | 64 BookmarkPermanentNode* mobile_folder_node() { |
| 65 return mobile_folder_node_.get(); | 65 return mobile_folder_node_.get(); |
| 66 } | 66 } |
| 67 std::unique_ptr<BookmarkPermanentNode> owned_mobile_folder_node() { | 67 std::unique_ptr<BookmarkPermanentNode> owned_mobile_folder_node() { |
| 68 return std::move(mobile_folder_node_); | 68 return std::move(mobile_folder_node_); |
| 69 } | 69 } |
| 70 BookmarkPermanentNode* other_folder_node() { | 70 BookmarkPermanentNode* other_folder_node() { |
| 71 return other_folder_node_.get(); | 71 return other_folder_node_.get(); |
| 72 } | 72 } |
| 73 std::unique_ptr<BookmarkPermanentNode> owned_other_folder_node() { | 73 std::unique_ptr<BookmarkPermanentNode> owned_other_folder_node() { |
| 74 return std::move(other_folder_node_); | 74 return std::move(other_folder_node_); |
| 75 } | 75 } |
| 76 const BookmarkPermanentNodeList& extra_nodes() { | 76 const BookmarkPermanentNodeList& extra_nodes() { |
| 77 return extra_nodes_; | 77 return extra_nodes_; |
| 78 } | 78 } |
| 79 BookmarkPermanentNodeList owned_extra_nodes() { | 79 BookmarkPermanentNodeList owned_extra_nodes() { |
| 80 return std::move(extra_nodes_); | 80 return std::move(extra_nodes_); |
| 81 } | 81 } |
| 82 BookmarkIndex* index() { return index_.get(); } | 82 TitledUrlIndex* index() { return index_.get(); } |
| 83 std::unique_ptr<BookmarkIndex> owned_index() { return std::move(index_); } | 83 std::unique_ptr<TitledUrlIndex> owned_index() { return std::move(index_); } |
| 84 | 84 |
| 85 const BookmarkNode::MetaInfoMap& model_meta_info_map() const { | 85 const BookmarkNode::MetaInfoMap& model_meta_info_map() const { |
| 86 return model_meta_info_map_; | 86 return model_meta_info_map_; |
| 87 } | 87 } |
| 88 void set_model_meta_info_map(const BookmarkNode::MetaInfoMap& meta_info_map) { | 88 void set_model_meta_info_map(const BookmarkNode::MetaInfoMap& meta_info_map) { |
| 89 model_meta_info_map_ = meta_info_map; | 89 model_meta_info_map_ = meta_info_map; |
| 90 } | 90 } |
| 91 | 91 |
| 92 int64_t model_sync_transaction_version() const { | 92 int64_t model_sync_transaction_version() const { |
| 93 return model_sync_transaction_version_; | 93 return model_sync_transaction_version_; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 118 // reassign the ids to ensure they are unique. | 118 // reassign the ids to ensure they are unique. |
| 119 void set_ids_reassigned(bool value) { ids_reassigned_ = value; } | 119 void set_ids_reassigned(bool value) { ids_reassigned_ = value; } |
| 120 bool ids_reassigned() const { return ids_reassigned_; } | 120 bool ids_reassigned() const { return ids_reassigned_; } |
| 121 | 121 |
| 122 private: | 122 private: |
| 123 std::unique_ptr<BookmarkPermanentNode> bb_node_; | 123 std::unique_ptr<BookmarkPermanentNode> bb_node_; |
| 124 std::unique_ptr<BookmarkPermanentNode> other_folder_node_; | 124 std::unique_ptr<BookmarkPermanentNode> other_folder_node_; |
| 125 std::unique_ptr<BookmarkPermanentNode> mobile_folder_node_; | 125 std::unique_ptr<BookmarkPermanentNode> mobile_folder_node_; |
| 126 LoadExtraCallback load_extra_callback_; | 126 LoadExtraCallback load_extra_callback_; |
| 127 BookmarkPermanentNodeList extra_nodes_; | 127 BookmarkPermanentNodeList extra_nodes_; |
| 128 std::unique_ptr<BookmarkIndex> index_; | 128 std::unique_ptr<TitledUrlIndex> index_; |
| 129 BookmarkNode::MetaInfoMap model_meta_info_map_; | 129 BookmarkNode::MetaInfoMap model_meta_info_map_; |
| 130 int64_t model_sync_transaction_version_; | 130 int64_t model_sync_transaction_version_; |
| 131 int64_t max_id_; | 131 int64_t max_id_; |
| 132 std::string computed_checksum_; | 132 std::string computed_checksum_; |
| 133 std::string stored_checksum_; | 133 std::string stored_checksum_; |
| 134 bool ids_reassigned_; | 134 bool ids_reassigned_; |
| 135 | 135 |
| 136 DISALLOW_COPY_AND_ASSIGN(BookmarkLoadDetails); | 136 DISALLOW_COPY_AND_ASSIGN(BookmarkLoadDetails); |
| 137 }; | 137 }; |
| 138 | 138 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_; | 206 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_; |
| 207 | 207 |
| 208 base::WeakPtrFactory<BookmarkStorage> weak_factory_; | 208 base::WeakPtrFactory<BookmarkStorage> weak_factory_; |
| 209 | 209 |
| 210 DISALLOW_COPY_AND_ASSIGN(BookmarkStorage); | 210 DISALLOW_COPY_AND_ASSIGN(BookmarkStorage); |
| 211 }; | 211 }; |
| 212 | 212 |
| 213 } // namespace bookmarks | 213 } // namespace bookmarks |
| 214 | 214 |
| 215 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_STORAGE_H_ | 215 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_STORAGE_H_ |
| OLD | NEW |