| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ | 5 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ |
| 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ | 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 17 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
| 18 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
| 19 #include "base/synchronization/waitable_event.h" | 19 #include "base/synchronization/waitable_event.h" |
| 20 #include "base/task/cancelable_task_tracker.h" |
| 20 #include "chrome/browser/bookmarks/bookmark_service.h" | 21 #include "chrome/browser/bookmarks/bookmark_service.h" |
| 21 #include "chrome/common/cancelable_task_tracker.h" | |
| 22 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 22 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
| 23 #include "content/public/browser/notification_observer.h" | 23 #include "content/public/browser/notification_observer.h" |
| 24 #include "content/public/browser/notification_registrar.h" | 24 #include "content/public/browser/notification_registrar.h" |
| 25 #include "ui/base/models/tree_node_model.h" | 25 #include "ui/base/models/tree_node_model.h" |
| 26 #include "ui/gfx/image/image.h" | 26 #include "ui/gfx/image/image.h" |
| 27 #include "url/gurl.h" | 27 #include "url/gurl.h" |
| 28 | 28 |
| 29 class BookmarkExpandedStateTracker; | 29 class BookmarkExpandedStateTracker; |
| 30 class BookmarkIndex; | 30 class BookmarkIndex; |
| 31 class BookmarkLoadDetails; | 31 class BookmarkLoadDetails; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 void set_icon_url(const GURL& icon_url) { | 155 void set_icon_url(const GURL& icon_url) { |
| 156 icon_url_ = icon_url; | 156 icon_url_ = icon_url; |
| 157 } | 157 } |
| 158 | 158 |
| 159 const gfx::Image& favicon() const { return favicon_; } | 159 const gfx::Image& favicon() const { return favicon_; } |
| 160 void set_favicon(const gfx::Image& icon) { favicon_ = icon; } | 160 void set_favicon(const gfx::Image& icon) { favicon_ = icon; } |
| 161 | 161 |
| 162 FaviconState favicon_state() const { return favicon_state_; } | 162 FaviconState favicon_state() const { return favicon_state_; } |
| 163 void set_favicon_state(FaviconState state) { favicon_state_ = state; } | 163 void set_favicon_state(FaviconState state) { favicon_state_ = state; } |
| 164 | 164 |
| 165 CancelableTaskTracker::TaskId favicon_load_task_id() const { | 165 base::CancelableTaskTracker::TaskId favicon_load_task_id() const { |
| 166 return favicon_load_task_id_; | 166 return favicon_load_task_id_; |
| 167 } | 167 } |
| 168 void set_favicon_load_task_id(CancelableTaskTracker::TaskId id) { | 168 void set_favicon_load_task_id(base::CancelableTaskTracker::TaskId id) { |
| 169 favicon_load_task_id_ = id; | 169 favicon_load_task_id_ = id; |
| 170 } | 170 } |
| 171 | 171 |
| 172 // The unique identifier for this node. | 172 // The unique identifier for this node. |
| 173 int64 id_; | 173 int64 id_; |
| 174 | 174 |
| 175 // The URL of this node. BookmarkModel maintains maps off this URL, so changes | 175 // The URL of this node. BookmarkModel maintains maps off this URL, so changes |
| 176 // to the URL must be done through the BookmarkModel. | 176 // to the URL must be done through the BookmarkModel. |
| 177 GURL url_; | 177 GURL url_; |
| 178 | 178 |
| 179 // The type of this node. See enum above. | 179 // The type of this node. See enum above. |
| 180 Type type_; | 180 Type type_; |
| 181 | 181 |
| 182 // Date of when this node was created. | 182 // Date of when this node was created. |
| 183 base::Time date_added_; | 183 base::Time date_added_; |
| 184 | 184 |
| 185 // Date of the last modification. Only used for folders. | 185 // Date of the last modification. Only used for folders. |
| 186 base::Time date_folder_modified_; | 186 base::Time date_folder_modified_; |
| 187 | 187 |
| 188 // The favicon of this node. | 188 // The favicon of this node. |
| 189 gfx::Image favicon_; | 189 gfx::Image favicon_; |
| 190 | 190 |
| 191 // The URL of the node's favicon. | 191 // The URL of the node's favicon. |
| 192 GURL icon_url_; | 192 GURL icon_url_; |
| 193 | 193 |
| 194 // The loading state of the favicon. | 194 // The loading state of the favicon. |
| 195 FaviconState favicon_state_; | 195 FaviconState favicon_state_; |
| 196 | 196 |
| 197 // If not CancelableTaskTracker::kBadTaskId, it indicates we're loading the | 197 // If not base::CancelableTaskTracker::kBadTaskId, it indicates |
| 198 // we're loading the |
| 198 // favicon and the task is tracked by CancelabelTaskTracker. | 199 // favicon and the task is tracked by CancelabelTaskTracker. |
| 199 CancelableTaskTracker::TaskId favicon_load_task_id_; | 200 base::CancelableTaskTracker::TaskId favicon_load_task_id_; |
| 200 | 201 |
| 201 // A map that stores arbitrary meta information about the node. | 202 // A map that stores arbitrary meta information about the node. |
| 202 scoped_ptr<MetaInfoMap> meta_info_map_; | 203 scoped_ptr<MetaInfoMap> meta_info_map_; |
| 203 | 204 |
| 204 // The sync transaction version. Defaults to kInvalidSyncTransactionVersion. | 205 // The sync transaction version. Defaults to kInvalidSyncTransactionVersion. |
| 205 int64 sync_transaction_version_; | 206 int64 sync_transaction_version_; |
| 206 | 207 |
| 207 DISALLOW_COPY_AND_ASSIGN(BookmarkNode); | 208 DISALLOW_COPY_AND_ASSIGN(BookmarkNode); |
| 208 }; | 209 }; |
| 209 | 210 |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 | 554 |
| 554 // Set of nodes ordered by URL. This is not a map to avoid copying the | 555 // Set of nodes ordered by URL. This is not a map to avoid copying the |
| 555 // urls. | 556 // urls. |
| 556 // WARNING: |nodes_ordered_by_url_set_| is accessed on multiple threads. As | 557 // WARNING: |nodes_ordered_by_url_set_| is accessed on multiple threads. As |
| 557 // such, be sure and wrap all usage of it around |url_lock_|. | 558 // such, be sure and wrap all usage of it around |url_lock_|. |
| 558 typedef std::multiset<BookmarkNode*, NodeURLComparator> NodesOrderedByURLSet; | 559 typedef std::multiset<BookmarkNode*, NodeURLComparator> NodesOrderedByURLSet; |
| 559 NodesOrderedByURLSet nodes_ordered_by_url_set_; | 560 NodesOrderedByURLSet nodes_ordered_by_url_set_; |
| 560 base::Lock url_lock_; | 561 base::Lock url_lock_; |
| 561 | 562 |
| 562 // Used for loading favicons. | 563 // Used for loading favicons. |
| 563 CancelableTaskTracker cancelable_task_tracker_; | 564 base::CancelableTaskTracker cancelable_task_tracker_; |
| 564 | 565 |
| 565 // Reads/writes bookmarks to disk. | 566 // Reads/writes bookmarks to disk. |
| 566 scoped_refptr<BookmarkStorage> store_; | 567 scoped_refptr<BookmarkStorage> store_; |
| 567 | 568 |
| 568 scoped_ptr<BookmarkIndex> index_; | 569 scoped_ptr<BookmarkIndex> index_; |
| 569 | 570 |
| 570 base::WaitableEvent loaded_signal_; | 571 base::WaitableEvent loaded_signal_; |
| 571 | 572 |
| 572 // See description of IsDoingExtensiveChanges above. | 573 // See description of IsDoingExtensiveChanges above. |
| 573 int extensive_changes_; | 574 int extensive_changes_; |
| 574 | 575 |
| 575 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; | 576 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; |
| 576 | 577 |
| 577 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); | 578 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); |
| 578 }; | 579 }; |
| 579 | 580 |
| 580 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ | 581 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ |
| OLD | NEW |