Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(610)

Side by Side Diff: chrome/browser/bookmarks/bookmark_model.h

Issue 242693003: Introduce BookmarkClient interface to abstract embedder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing reviewer comments Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/task/cancelable_task_tracker.h"
21 #include "chrome/browser/bookmarks/bookmark_service.h" 21 #include "chrome/browser/bookmarks/bookmark_service.h"
22 #include "components/bookmarks/core/browser/bookmark_client.h"
22 #include "components/bookmarks/core/browser/bookmark_node.h" 23 #include "components/bookmarks/core/browser/bookmark_node.h"
23 #include "components/favicon_base/favicon_types.h"
24 #include "components/keyed_service/core/keyed_service.h" 24 #include "components/keyed_service/core/keyed_service.h"
25 #include "content/public/browser/notification_observer.h" 25 #include "content/public/browser/notification_observer.h"
26 #include "content/public/browser/notification_registrar.h" 26 #include "content/public/browser/notification_registrar.h"
27 #include "ui/gfx/image/image.h" 27 #include "ui/gfx/image/image.h"
28 #include "url/gurl.h" 28 #include "url/gurl.h"
29 29
30 class BookmarkExpandedStateTracker; 30 class BookmarkExpandedStateTracker;
31 class BookmarkIndex; 31 class BookmarkIndex;
32 class BookmarkLoadDetails; 32 class BookmarkLoadDetails;
33 class BookmarkModelObserver; 33 class BookmarkModelObserver;
34 class BookmarkStorage; 34 class BookmarkStorage;
35 struct BookmarkTitleMatch; 35 struct BookmarkTitleMatch;
36 class Profile; 36 class Profile;
37 class ScopedGroupBookmarkActions; 37 class ScopedGroupBookmarkActions;
38 38
39 namespace base { 39 namespace base {
40 class SequencedTaskRunner; 40 class SequencedTaskRunner;
41 } 41 }
42 42
43 namespace chrome {
44 struct FaviconImageResult;
45 }
46
47 // BookmarkModel -------------------------------------------------------------- 43 // BookmarkModel --------------------------------------------------------------
48 44
49 // BookmarkModel provides a directed acyclic graph of URLs and folders. 45 // BookmarkModel provides a directed acyclic graph of URLs and folders.
50 // Three graphs are provided for the three entry points: those on the 'bookmarks 46 // Three graphs are provided for the three entry points: those on the 'bookmarks
51 // bar', those in the 'other bookmarks' folder and those in the 'mobile' folder. 47 // bar', those in the 'other bookmarks' folder and those in the 'mobile' folder.
52 // 48 //
53 // An observer may be attached to observe relevant events. 49 // An observer may be attached to observe relevant events.
54 // 50 //
55 // You should NOT directly create a BookmarkModel, instead go through the 51 // You should NOT directly create a BookmarkModel, instead go through the
56 // BookmarkModelFactory. 52 // BookmarkModelFactory.
57 class BookmarkModel : public content::NotificationObserver, 53 class BookmarkModel : public content::NotificationObserver,
54 public BookmarkClient,
sky 2014/04/18 17:05:04 I'm confused as to why you're making BookmarkModel
sdefresne 2014/04/18 22:25:49 My plan was to have this inheritance temporarily,
58 public BookmarkService, 55 public BookmarkService,
59 public KeyedService { 56 public KeyedService {
60 public: 57 public:
61 explicit BookmarkModel(Profile* profile); 58 explicit BookmarkModel(Profile* profile);
62 virtual ~BookmarkModel(); 59 virtual ~BookmarkModel();
63 60
61 virtual base::CancelableTaskTracker::TaskId GetFaviconImageForURL(
62 const GURL& page_url,
63 int icon_types,
64 int desired_size_in_dip,
65 const FaviconImageCallback& callback,
66 base::CancelableTaskTracker* tracker) OVERRIDE;
67
68 virtual void GetTypedCountForNodes(
69 const NodeSet& nodes,
70 NodeTypedCountPairs* node_typed_count_pairs) OVERRIDE;
71
72 virtual void RecordAction(const base::UserMetricsAction& action) OVERRIDE;
73
64 // Invoked prior to destruction to release any necessary resources. 74 // Invoked prior to destruction to release any necessary resources.
65 virtual void Shutdown() OVERRIDE; 75 virtual void Shutdown() OVERRIDE;
66 76
67 // Loads the bookmarks. This is called upon creation of the 77 // Loads the bookmarks. This is called upon creation of the
68 // BookmarkModel. You need not invoke this directly. 78 // BookmarkModel. You need not invoke this directly.
69 // All load operations will be executed on |task_runner|. 79 // All load operations will be executed on |io_task_runner|, and callback
70 void Load(const scoped_refptr<base::SequencedTaskRunner>& task_runner); 80 // will be called from |io_task_runner|.
81 void Load(const scoped_refptr<base::SequencedTaskRunner>& io_task_runner,
82 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner);
71 83
72 // Returns true if the model finished loading. 84 // Returns true if the model finished loading.
73 bool loaded() const { return loaded_; } 85 bool loaded() const { return loaded_; }
74 86
75 // Returns the root node. The 'bookmark bar' node and 'other' node are 87 // Returns the root node. The 'bookmark bar' node and 'other' node are
76 // children of the root node. 88 // children of the root node.
77 const BookmarkNode* root_node() { return &root_; } 89 const BookmarkNode* root_node() { return &root_; }
78 90
79 // Returns the 'bookmark bar' node. This is NULL until loaded. 91 // Returns the 'bookmark bar' node. This is NULL until loaded.
80 const BookmarkNode* bookmark_bar_node() { return bookmark_bar_node_; } 92 const BookmarkNode* bookmark_bar_node() { return bookmark_bar_node_; }
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 407
396 // See description of IsDoingExtensiveChanges above. 408 // See description of IsDoingExtensiveChanges above.
397 int extensive_changes_; 409 int extensive_changes_;
398 410
399 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; 411 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_;
400 412
401 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); 413 DISALLOW_COPY_AND_ASSIGN(BookmarkModel);
402 }; 414 };
403 415
404 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ 416 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698