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

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

Issue 1546143002: Switch to standard integer types in components/, part 1 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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>
9
10 #include "base/macros.h"
8 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
9 #include "base/task/cancelable_task_tracker.h" 12 #include "base/task/cancelable_task_tracker.h"
10 #include "base/time/time.h" 13 #include "base/time/time.h"
11 #include "components/favicon_base/favicon_types.h" 14 #include "components/favicon_base/favicon_types.h"
12 #include "ui/base/models/tree_node_model.h" 15 #include "ui/base/models/tree_node_model.h"
13 #include "ui/gfx/image/image.h" 16 #include "ui/gfx/image/image.h"
14 #include "url/gurl.h" 17 #include "url/gurl.h"
15 18
16 namespace bookmarks { 19 namespace bookmarks {
17 20
(...skipping 14 matching lines...) Expand all
32 }; 35 };
33 36
34 enum FaviconState { 37 enum FaviconState {
35 INVALID_FAVICON, 38 INVALID_FAVICON,
36 LOADING_FAVICON, 39 LOADING_FAVICON,
37 LOADED_FAVICON, 40 LOADED_FAVICON,
38 }; 41 };
39 42
40 typedef std::map<std::string, std::string> MetaInfoMap; 43 typedef std::map<std::string, std::string> MetaInfoMap;
41 44
42 static const int64 kInvalidSyncTransactionVersion; 45 static const int64_t kInvalidSyncTransactionVersion;
43 46
44 // Creates a new node with an id of 0 and |url|. 47 // Creates a new node with an id of 0 and |url|.
45 explicit BookmarkNode(const GURL& url); 48 explicit BookmarkNode(const GURL& url);
46 // Creates a new node with |id| and |url|. 49 // Creates a new node with |id| and |url|.
47 BookmarkNode(int64 id, const GURL& url); 50 BookmarkNode(int64_t id, const GURL& url);
48 51
49 ~BookmarkNode() override; 52 ~BookmarkNode() override;
50 53
51 // Set the node's internal title. Note that this neither invokes observers 54 // Set the node's internal title. Note that this neither invokes observers
52 // nor updates any bookmark model this node may be in. For that functionality, 55 // nor updates any bookmark model this node may be in. For that functionality,
53 // BookmarkModel::SetTitle(..) should be used instead. 56 // BookmarkModel::SetTitle(..) should be used instead.
54 void SetTitle(const base::string16& title) override; 57 void SetTitle(const base::string16& title) override;
55 58
56 // Returns an unique id for this node. 59 // Returns an unique id for this node.
57 // For bookmark nodes that are managed by the bookmark model, the IDs are 60 // For bookmark nodes that are managed by the bookmark model, the IDs are
58 // persisted across sessions. 61 // persisted across sessions.
59 int64 id() const { return id_; } 62 int64_t id() const { return id_; }
60 void set_id(int64 id) { id_ = id; } 63 void set_id(int64_t id) { id_ = id; }
61 64
62 const GURL& url() const { return url_; } 65 const GURL& url() const { return url_; }
63 void set_url(const GURL& url) { url_ = url; } 66 void set_url(const GURL& url) { url_ = url; }
64 67
65 // Returns the favicon's URL. Returns an empty URL if there is no favicon 68 // Returns the favicon's URL. Returns an empty URL if there is no favicon
66 // associated with this bookmark. 69 // associated with this bookmark.
67 const GURL& icon_url() const { return icon_url_; } 70 const GURL& icon_url() const { return icon_url_; }
68 71
69 Type type() const { return type_; } 72 Type type() const { return type_; }
70 void set_type(Type type) { type_ = type; } 73 void set_type(Type type) { type_ = type; }
(...skipping 28 matching lines...) Expand all
99 // Gets/sets/deletes value of |key| in the meta info represented by 102 // Gets/sets/deletes value of |key| in the meta info represented by
100 // |meta_info_str_|. Return true if key is found in meta info for gets or 103 // |meta_info_str_|. Return true if key is found in meta info for gets or
101 // meta info is changed indeed for sets/deletes. 104 // meta info is changed indeed for sets/deletes.
102 bool GetMetaInfo(const std::string& key, std::string* value) const; 105 bool GetMetaInfo(const std::string& key, std::string* value) const;
103 bool SetMetaInfo(const std::string& key, const std::string& value); 106 bool SetMetaInfo(const std::string& key, const std::string& value);
104 bool DeleteMetaInfo(const std::string& key); 107 bool DeleteMetaInfo(const std::string& key);
105 void SetMetaInfoMap(const MetaInfoMap& meta_info_map); 108 void SetMetaInfoMap(const MetaInfoMap& meta_info_map);
106 // Returns NULL if there are no values in the map. 109 // Returns NULL if there are no values in the map.
107 const MetaInfoMap* GetMetaInfoMap() const; 110 const MetaInfoMap* GetMetaInfoMap() const;
108 111
109 void set_sync_transaction_version(int64 sync_transaction_version) { 112 void set_sync_transaction_version(int64_t sync_transaction_version) {
110 sync_transaction_version_ = sync_transaction_version; 113 sync_transaction_version_ = sync_transaction_version;
111 } 114 }
112 int64 sync_transaction_version() const { 115 int64_t sync_transaction_version() const { return sync_transaction_version_; }
113 return sync_transaction_version_;
114 }
115 116
116 // TODO(sky): Consider adding last visit time here, it'll greatly simplify 117 // TODO(sky): Consider adding last visit time here, it'll greatly simplify
117 // HistoryContentsProvider. 118 // HistoryContentsProvider.
118 119
119 private: 120 private:
120 friend class BookmarkModel; 121 friend class BookmarkModel;
121 122
122 // A helper function to initialize various fields during construction. 123 // A helper function to initialize various fields during construction.
123 void Initialize(int64 id); 124 void Initialize(int64_t id);
124 125
125 // Called when the favicon becomes invalid. 126 // Called when the favicon becomes invalid.
126 void InvalidateFavicon(); 127 void InvalidateFavicon();
127 128
128 // Sets the favicon's URL. 129 // Sets the favicon's URL.
129 void set_icon_url(const GURL& icon_url) { 130 void set_icon_url(const GURL& icon_url) {
130 icon_url_ = icon_url; 131 icon_url_ = icon_url;
131 } 132 }
132 133
133 // Returns the favicon. In nearly all cases you should use the method 134 // Returns the favicon. In nearly all cases you should use the method
134 // BookmarkModel::GetFavicon rather than this one as it takes care of 135 // BookmarkModel::GetFavicon rather than this one as it takes care of
135 // loading the favicon if it isn't already loaded. 136 // loading the favicon if it isn't already loaded.
136 const gfx::Image& favicon() const { return favicon_; } 137 const gfx::Image& favicon() const { return favicon_; }
137 void set_favicon(const gfx::Image& icon) { favicon_ = icon; } 138 void set_favicon(const gfx::Image& icon) { favicon_ = icon; }
138 139
139 favicon_base::IconType favicon_type() const { return favicon_type_; } 140 favicon_base::IconType favicon_type() const { return favicon_type_; }
140 void set_favicon_type(favicon_base::IconType type) { favicon_type_ = type; } 141 void set_favicon_type(favicon_base::IconType type) { favicon_type_ = type; }
141 142
142 FaviconState favicon_state() const { return favicon_state_; } 143 FaviconState favicon_state() const { return favicon_state_; }
143 void set_favicon_state(FaviconState state) { favicon_state_ = state; } 144 void set_favicon_state(FaviconState state) { favicon_state_ = state; }
144 145
145 base::CancelableTaskTracker::TaskId favicon_load_task_id() const { 146 base::CancelableTaskTracker::TaskId favicon_load_task_id() const {
146 return favicon_load_task_id_; 147 return favicon_load_task_id_;
147 } 148 }
148 void set_favicon_load_task_id(base::CancelableTaskTracker::TaskId id) { 149 void set_favicon_load_task_id(base::CancelableTaskTracker::TaskId id) {
149 favicon_load_task_id_ = id; 150 favicon_load_task_id_ = id;
150 } 151 }
151 152
152 // The unique identifier for this node. 153 // The unique identifier for this node.
153 int64 id_; 154 int64_t id_;
154 155
155 // The URL of this node. BookmarkModel maintains maps off this URL, so changes 156 // The URL of this node. BookmarkModel maintains maps off this URL, so changes
156 // to the URL must be done through the BookmarkModel. 157 // to the URL must be done through the BookmarkModel.
157 GURL url_; 158 GURL url_;
158 159
159 // The type of this node. See enum above. 160 // The type of this node. See enum above.
160 Type type_; 161 Type type_;
161 162
162 // Date of when this node was created. 163 // Date of when this node was created.
163 base::Time date_added_; 164 base::Time date_added_;
(...skipping 15 matching lines...) Expand all
179 180
180 // If not base::CancelableTaskTracker::kBadTaskId, it indicates 181 // If not base::CancelableTaskTracker::kBadTaskId, it indicates
181 // we're loading the 182 // we're loading the
182 // favicon and the task is tracked by CancelabelTaskTracker. 183 // favicon and the task is tracked by CancelabelTaskTracker.
183 base::CancelableTaskTracker::TaskId favicon_load_task_id_; 184 base::CancelableTaskTracker::TaskId favicon_load_task_id_;
184 185
185 // A map that stores arbitrary meta information about the node. 186 // A map that stores arbitrary meta information about the node.
186 scoped_ptr<MetaInfoMap> meta_info_map_; 187 scoped_ptr<MetaInfoMap> meta_info_map_;
187 188
188 // The sync transaction version. Defaults to kInvalidSyncTransactionVersion. 189 // The sync transaction version. Defaults to kInvalidSyncTransactionVersion.
189 int64 sync_transaction_version_; 190 int64_t sync_transaction_version_;
190 191
191 DISALLOW_COPY_AND_ASSIGN(BookmarkNode); 192 DISALLOW_COPY_AND_ASSIGN(BookmarkNode);
192 }; 193 };
193 194
194 // BookmarkPermanentNode ------------------------------------------------------- 195 // BookmarkPermanentNode -------------------------------------------------------
195 196
196 // Node used for the permanent folders (excluding the root). 197 // Node used for the permanent folders (excluding the root).
197 class BookmarkPermanentNode : public BookmarkNode { 198 class BookmarkPermanentNode : public BookmarkNode {
198 public: 199 public:
199 explicit BookmarkPermanentNode(int64 id); 200 explicit BookmarkPermanentNode(int64_t id);
200 ~BookmarkPermanentNode() override; 201 ~BookmarkPermanentNode() override;
201 202
202 // WARNING: this code is used for other projects. Contact noyau@ for details. 203 // WARNING: this code is used for other projects. Contact noyau@ for details.
203 void set_visible(bool value) { visible_ = value; } 204 void set_visible(bool value) { visible_ = value; }
204 205
205 // BookmarkNode overrides: 206 // BookmarkNode overrides:
206 bool IsVisible() const override; 207 bool IsVisible() const override;
207 208
208 private: 209 private:
209 bool visible_; 210 bool visible_;
210 211
211 DISALLOW_COPY_AND_ASSIGN(BookmarkPermanentNode); 212 DISALLOW_COPY_AND_ASSIGN(BookmarkPermanentNode);
212 }; 213 };
213 214
214 } // namespace bookmarks 215 } // namespace bookmarks
215 216
216 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_H_ 217 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_H_
OLDNEW
« no previous file with comments | « components/bookmarks/browser/bookmark_model_unittest.cc ('k') | components/bookmarks/browser/bookmark_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698