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 <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/deferred_sequenced_task_runner.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
16 #include "base/string16.h" | 17 #include "base/string16.h" |
17 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
18 #include "base/synchronization/waitable_event.h" | 19 #include "base/synchronization/waitable_event.h" |
19 #include "chrome/browser/bookmarks/bookmark_service.h" | 20 #include "chrome/browser/bookmarks/bookmark_service.h" |
20 #include "chrome/browser/profiles/profile_keyed_service.h" | 21 #include "chrome/browser/profiles/profile_keyed_service.h" |
21 #include "chrome/common/cancelable_task_tracker.h" | 22 #include "chrome/common/cancelable_task_tracker.h" |
22 #include "content/public/browser/notification_observer.h" | 23 #include "content/public/browser/notification_observer.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 explicit BookmarkModel(Profile* profile); | 232 explicit BookmarkModel(Profile* profile); |
232 virtual ~BookmarkModel(); | 233 virtual ~BookmarkModel(); |
233 | 234 |
234 // Invoked prior to destruction to release any necessary resources. | 235 // Invoked prior to destruction to release any necessary resources. |
235 virtual void Shutdown() OVERRIDE; | 236 virtual void Shutdown() OVERRIDE; |
236 | 237 |
237 // Loads the bookmarks. This is called upon creation of the | 238 // Loads the bookmarks. This is called upon creation of the |
238 // BookmarkModel. You need not invoke this directly. | 239 // BookmarkModel. You need not invoke this directly. |
239 void Load(); | 240 void Load(); |
240 | 241 |
| 242 // Starts loading the bookmarks. This is decoupled from Load, giving the |
| 243 // caller the possibility to start loading the bookmarks after the |
| 244 // creation of the BookmarkModel. |
| 245 void StartLoading(); |
| 246 |
241 // Returns true if the model finished loading. | 247 // Returns true if the model finished loading. |
242 // This is virtual so it can be mocked. | 248 // This is virtual so it can be mocked. |
243 virtual bool IsLoaded() const; | 249 virtual bool IsLoaded() const; |
244 | 250 |
245 // Returns the root node. The 'bookmark bar' node and 'other' node are | 251 // Returns the root node. The 'bookmark bar' node and 'other' node are |
246 // children of the root node. | 252 // children of the root node. |
247 const BookmarkNode* root_node() { return &root_; } | 253 const BookmarkNode* root_node() { return &root_; } |
248 | 254 |
249 // Returns the 'bookmark bar' node. This is NULL until loaded. | 255 // Returns the 'bookmark bar' node. This is NULL until loaded. |
250 const BookmarkNode* bookmark_bar_node() { return bookmark_bar_node_; } | 256 const BookmarkNode* bookmark_bar_node() { return bookmark_bar_node_; } |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 | 483 |
478 // Sets the maximum node ID to the given value. | 484 // Sets the maximum node ID to the given value. |
479 // This is used by BookmarkCodec to report the maximum ID after it's done | 485 // This is used by BookmarkCodec to report the maximum ID after it's done |
480 // decoding since during decoding codec assigns node IDs. | 486 // decoding since during decoding codec assigns node IDs. |
481 void set_next_node_id(int64 id) { next_node_id_ = id; } | 487 void set_next_node_id(int64 id) { next_node_id_ = id; } |
482 | 488 |
483 // Creates and returns a new BookmarkLoadDetails. It's up to the caller to | 489 // Creates and returns a new BookmarkLoadDetails. It's up to the caller to |
484 // delete the returned object. | 490 // delete the returned object. |
485 BookmarkLoadDetails* CreateLoadDetails(); | 491 BookmarkLoadDetails* CreateLoadDetails(); |
486 | 492 |
| 493 // Returns sequenced task runner where all bookmarks I/O operations are |
| 494 // performed. |
| 495 scoped_refptr<base::DeferredSequencedTaskRunner> GetBookmarkTaskRunner(); |
| 496 |
487 content::NotificationRegistrar registrar_; | 497 content::NotificationRegistrar registrar_; |
488 | 498 |
489 Profile* profile_; | 499 Profile* profile_; |
490 | 500 |
491 // Whether the initial set of data has been loaded. | 501 // Whether the initial set of data has been loaded. |
492 bool loaded_; | 502 bool loaded_; |
493 | 503 |
494 // The root node. This contains the bookmark bar node and the 'other' node as | 504 // The root node. This contains the bookmark bar node and the 'other' node as |
495 // children. | 505 // children. |
496 BookmarkNode root_; | 506 BookmarkNode root_; |
(...skipping 24 matching lines...) Expand all Loading... |
521 | 531 |
522 scoped_ptr<BookmarkIndex> index_; | 532 scoped_ptr<BookmarkIndex> index_; |
523 | 533 |
524 base::WaitableEvent loaded_signal_; | 534 base::WaitableEvent loaded_signal_; |
525 | 535 |
526 // See description of IsDoingExtensiveChanges above. | 536 // See description of IsDoingExtensiveChanges above. |
527 int extensive_changes_; | 537 int extensive_changes_; |
528 | 538 |
529 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; | 539 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; |
530 | 540 |
| 541 scoped_refptr<base::DeferredSequencedTaskRunner> bookmark_task_runner_; |
| 542 |
531 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); | 543 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); |
532 }; | 544 }; |
533 | 545 |
534 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ | 546 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ |
OLD | NEW |