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

Side by Side Diff: chrome/common/url_row_type.h

Issue 2106015: Move data types used in the importer process to common/, in preparation for i... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/importer_data_types.h ('k') | chrome/common/url_row_type.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_COMMON_URL_ROW_TYPE_H_
6 #define CHROME_COMMON_URL_ROW_TYPE_H_
7
8 #include <set>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/time.h"
13 #include "googleurl/src/gurl.h"
14
15 // This file includes the URLRow class and ImportedFavIconUsage struct, which
16 // need to be in the common directory because they're accessed by the importer
17 // process as well as the browser process.
18
19 namespace history {
20
21 // URLRow ---------------------------------------------------------------------
22
23 typedef int64 URLID;
24 typedef int64 FavIconID; // For FavIcons.
25
26 // Holds all information globally associated with one URL (one row in the
27 // URL table).
28 //
29 // This keeps track of dirty bits, which are currently unused:
30 //
31 // TODO(brettw) the dirty bits are broken in a number of respects. First, the
32 // database will want to update them on a const object, so they need to be
33 // mutable.
34 //
35 // Second, there is a problem copying. If you make a copy of this structure
36 // (as we allow since we put this into vectors in various places) then the
37 // dirty bits will not be in sync for these copies.
38 class URLRow {
39 public:
40 URLRow() {
41 Initialize();
42 }
43
44 explicit URLRow(const GURL& url) : url_(url) {
45 // Initialize will not set the URL, so our initialization above will stay.
46 Initialize();
47 }
48
49 // We need to be able to set the id of a URLRow that's being passed through
50 // an IPC message. This constructor should probably not be used otherwise.
51 URLRow(const GURL& url, URLID id) : url_(url) {
52 // Initialize will not set the URL, so our initialization above will stay.
53 Initialize();
54 // Initialize will zero the id_, so set it here.
55 id_ = id;
56 }
57
58 virtual ~URLRow() {}
59
60 URLID id() const { return id_; }
61 const GURL& url() const { return url_; }
62
63 const std::wstring& title() const {
64 return title_;
65 }
66 void set_title(const std::wstring& title) {
67 // The title is frequently set to the same thing, so we don't bother
68 // updating unless the string has changed.
69 if (title != title_) {
70 title_ = title;
71 }
72 }
73
74 int visit_count() const {
75 return visit_count_;
76 }
77 void set_visit_count(int visit_count) {
78 visit_count_ = visit_count;
79 }
80
81 // Number of times the URL was typed in the Omnibox.
82 int typed_count() const {
83 return typed_count_;
84 }
85 void set_typed_count(int typed_count) {
86 typed_count_ = typed_count;
87 }
88
89 base::Time last_visit() const {
90 return last_visit_;
91 }
92 void set_last_visit(base::Time last_visit) {
93 last_visit_ = last_visit;
94 }
95
96 // If this is set, we won't autocomplete this URL.
97 bool hidden() const {
98 return hidden_;
99 }
100 void set_hidden(bool hidden) {
101 hidden_ = hidden;
102 }
103
104 // ID of the favicon. A value of 0 means the favicon isn't known yet.
105 FavIconID favicon_id() const { return favicon_id_; }
106 void set_favicon_id(FavIconID favicon_id) {
107 favicon_id_ = favicon_id;
108 }
109
110 // Swaps the contents of this URLRow with another, which allows it to be
111 // destructively copied without memory allocations.
112 // (Virtual because it's overridden by URLResult.)
113 virtual void Swap(URLRow* other);
114
115 private:
116 // This class writes directly into this structure and clears our dirty bits
117 // when reading out of the DB.
118 friend class URLDatabase;
119 friend class HistoryBackend;
120
121 // Initializes all values that need initialization to their defaults.
122 // This excludes objects which autoinitialize such as strings.
123 void Initialize();
124
125 // The row ID of this URL. Immutable except for the database which sets it
126 // when it pulls them out.
127 URLID id_;
128
129 // The URL of this row. Immutable except for the database which sets it
130 // when it pulls them out. If clients want to change it, they must use
131 // the constructor to make a new one.
132 GURL url_;
133
134 std::wstring title_;
135
136 // Total number of times this URL has been visited.
137 int visit_count_;
138
139 // Number of times this URL has been manually entered in the URL bar.
140 int typed_count_;
141
142 // The date of the last visit of this URL, which saves us from having to
143 // loop up in the visit table for things like autocomplete and expiration.
144 base::Time last_visit_;
145
146 // Indicates this entry should now be shown in typical UI or queries, this
147 // is usually for subframes.
148 bool hidden_;
149
150 // The ID of the favicon for this url.
151 FavIconID favicon_id_;
152
153 // We support the implicit copy constuctor and operator=.
154 };
155
156 // Favicons -------------------------------------------------------------------
157
158 // Used by the importer to set favicons for imported bookmarks.
159 struct ImportedFavIconUsage {
160 // The URL of the favicon.
161 GURL favicon_url;
162
163 // The raw png-encoded data.
164 std::vector<unsigned char> png_data;
165
166 // The list of URLs using this favicon.
167 std::set<GURL> urls;
168 };
169
170 } // namespace history
171
172 #endif // CHROME_COMMON_URL_ROW_TYPE_H_
173
174
OLDNEW
« no previous file with comments | « chrome/common/importer_data_types.h ('k') | chrome/common/url_row_type.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698