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

Side by Side Diff: components/bookmarks/browser/bookmark_node.h

Issue 2883523002: Reduce the memory usage of bookmarks storage (Closed)
Patch Set: MakeUnique Created 3 years, 6 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 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_NODE_H_ 5 #ifndef COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_H_
6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_H_ 6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h"
13 #include "base/task/cancelable_task_tracker.h" 14 #include "base/task/cancelable_task_tracker.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "components/bookmarks/browser/titled_url_node.h" 16 #include "components/bookmarks/browser/titled_url_node.h"
16 #include "components/favicon_base/favicon_types.h" 17 #include "components/favicon_base/favicon_types.h"
17 #include "ui/base/models/tree_node_model.h" 18 #include "ui/base/models/tree_node_model.h"
18 #include "ui/gfx/image/image.h" 19 #include "ui/gfx/image/image.h"
19 #include "url/gurl.h" 20 #include "url/gurl.h"
20 21
21 namespace bookmarks { 22 namespace bookmarks {
22 23
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // For bookmark nodes that are managed by the bookmark model, the IDs are 63 // For bookmark nodes that are managed by the bookmark model, the IDs are
63 // persisted across sessions. 64 // persisted across sessions.
64 int64_t id() const { return id_; } 65 int64_t id() const { return id_; }
65 void set_id(int64_t id) { id_ = id; } 66 void set_id(int64_t id) { id_ = id; }
66 67
67 const GURL& url() const { return url_; } 68 const GURL& url() const { return url_; }
68 void set_url(const GURL& url) { url_ = url; } 69 void set_url(const GURL& url) { url_ = url; }
69 70
70 // Returns the favicon's URL. Returns an empty URL if there is no favicon 71 // Returns the favicon's URL. Returns an empty URL if there is no favicon
71 // associated with this bookmark. 72 // associated with this bookmark.
72 const GURL& icon_url() const { return icon_url_; } 73 const GURL* icon_url() const { return icon_url_ ? icon_url_.get() : nullptr; }
73 74
74 Type type() const { return type_; } 75 Type type() const { return type_; }
75 void set_type(Type type) { type_ = type; } 76 void set_type(Type type) { type_ = type; }
76 77
77 // Returns the time the node was added. 78 // Returns the time the node was added.
78 const base::Time& date_added() const { return date_added_; } 79 const base::Time& date_added() const { return date_added_; }
79 void set_date_added(const base::Time& date) { date_added_ = date; } 80 void set_date_added(const base::Time& date) { date_added_ = date; }
80 81
81 // Returns the last time the folder was modified. This is only maintained 82 // Returns the last time the folder was modified. This is only maintained
82 // for folders (including the bookmark bar and other folder). 83 // for folders (including the bookmark bar and other folder).
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 friend class BookmarkModel; 128 friend class BookmarkModel;
128 129
129 // A helper function to initialize various fields during construction. 130 // A helper function to initialize various fields during construction.
130 void Initialize(int64_t id); 131 void Initialize(int64_t id);
131 132
132 // Called when the favicon becomes invalid. 133 // Called when the favicon becomes invalid.
133 void InvalidateFavicon(); 134 void InvalidateFavicon();
134 135
135 // Sets the favicon's URL. 136 // Sets the favicon's URL.
136 void set_icon_url(const GURL& icon_url) { 137 void set_icon_url(const GURL& icon_url) {
137 icon_url_ = icon_url; 138 icon_url_ = base::MakeUnique<GURL>(icon_url);
138 } 139 }
139 140
140 // Returns the favicon. In nearly all cases you should use the method 141 // Returns the favicon. In nearly all cases you should use the method
141 // BookmarkModel::GetFavicon rather than this one as it takes care of 142 // BookmarkModel::GetFavicon rather than this one as it takes care of
142 // loading the favicon if it isn't already loaded. 143 // loading the favicon if it isn't already loaded.
143 const gfx::Image& favicon() const { return favicon_; } 144 const gfx::Image& favicon() const { return favicon_; }
144 void set_favicon(const gfx::Image& icon) { favicon_ = icon; } 145 void set_favicon(const gfx::Image& icon) { favicon_ = icon; }
145 146
146 favicon_base::IconType favicon_type() const { return favicon_type_; } 147 favicon_base::IconType favicon_type() const { return favicon_type_; }
147 void set_favicon_type(favicon_base::IconType type) { favicon_type_ = type; } 148 void set_favicon_type(favicon_base::IconType type) { favicon_type_ = type; }
(...skipping 24 matching lines...) Expand all
172 // Date of the last modification. Only used for folders. 173 // Date of the last modification. Only used for folders.
173 base::Time date_folder_modified_; 174 base::Time date_folder_modified_;
174 175
175 // The favicon of this node. 176 // The favicon of this node.
176 gfx::Image favicon_; 177 gfx::Image favicon_;
177 178
178 // The type of favicon currently loaded. 179 // The type of favicon currently loaded.
179 favicon_base::IconType favicon_type_; 180 favicon_base::IconType favicon_type_;
180 181
181 // The URL of the node's favicon. 182 // The URL of the node's favicon.
182 GURL icon_url_; 183 std::unique_ptr<GURL> icon_url_;
183 184
184 // The loading state of the favicon. 185 // The loading state of the favicon.
185 FaviconState favicon_state_; 186 FaviconState favicon_state_;
186 187
187 // If not base::CancelableTaskTracker::kBadTaskId, it indicates 188 // If not base::CancelableTaskTracker::kBadTaskId, it indicates
188 // we're loading the 189 // we're loading the
189 // favicon and the task is tracked by CancelabelTaskTracker. 190 // favicon and the task is tracked by CancelabelTaskTracker.
190 base::CancelableTaskTracker::TaskId favicon_load_task_id_; 191 base::CancelableTaskTracker::TaskId favicon_load_task_id_;
191 192
192 // A map that stores arbitrary meta information about the node. 193 // A map that stores arbitrary meta information about the node.
(...skipping 21 matching lines...) Expand all
214 215
215 private: 216 private:
216 bool visible_; 217 bool visible_;
217 218
218 DISALLOW_COPY_AND_ASSIGN(BookmarkPermanentNode); 219 DISALLOW_COPY_AND_ASSIGN(BookmarkPermanentNode);
219 }; 220 };
220 221
221 } // namespace bookmarks 222 } // namespace bookmarks
222 223
223 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_H_ 224 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_H_
OLDNEW
« no previous file with comments | « components/bookmarks/browser/bookmark_model.cc ('k') | components/bookmarks/browser/bookmark_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698