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

Side by Side Diff: components/history/core/browser/history_types.cc

Issue 2781263002: Some C++11 cleanup of history types. (Closed)
Patch Set: Fix Android Created 3 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 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 #include "components/history/core/browser/history_types.h" 5 #include "components/history/core/browser/history_types.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "components/history/core/browser/page_usage_data.h" 11 #include "components/history/core/browser/page_usage_data.h"
12 12
13 namespace history { 13 namespace history {
14 14
15 // VisitRow -------------------------------------------------------------------- 15 // VisitRow --------------------------------------------------------------------
16 16
17 VisitRow::VisitRow() 17 VisitRow::VisitRow() {}
18 : visit_id(0),
19 url_id(0),
20 referring_visit(0),
21 transition(ui::PAGE_TRANSITION_LINK),
22 segment_id(0) {
23 }
24 18
25 VisitRow::VisitRow(URLID arg_url_id, 19 VisitRow::VisitRow(URLID arg_url_id,
26 base::Time arg_visit_time, 20 base::Time arg_visit_time,
27 VisitID arg_referring_visit, 21 VisitID arg_referring_visit,
28 ui::PageTransition arg_transition, 22 ui::PageTransition arg_transition,
29 SegmentID arg_segment_id) 23 SegmentID arg_segment_id)
30 : visit_id(0), 24 : url_id(arg_url_id),
31 url_id(arg_url_id),
32 visit_time(arg_visit_time), 25 visit_time(arg_visit_time),
33 referring_visit(arg_referring_visit), 26 referring_visit(arg_referring_visit),
34 transition(arg_transition), 27 transition(arg_transition),
35 segment_id(arg_segment_id) { 28 segment_id(arg_segment_id) {}
36 }
37 29
38 VisitRow::~VisitRow() { 30 VisitRow::~VisitRow() {
39 } 31 }
40 32
41 // QueryResults ---------------------------------------------------------------- 33 // QueryResults ----------------------------------------------------------------
42 34
43 QueryResults::QueryResults() : reached_beginning_(false) { 35 QueryResults::QueryResults() : reached_beginning_(false) {
44 } 36 }
45 37
46 QueryResults::~QueryResults() {} 38 QueryResults::~QueryResults() {}
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 std::set<GURL> urls_modified; 84 std::set<GURL> urls_modified;
93 for (size_t i = begin; i <= end; i++) { 85 for (size_t i = begin; i <= end; i++) {
94 urls_modified.insert(results_[i]->url()); 86 urls_modified.insert(results_[i]->url());
95 } 87 }
96 88
97 // Now just delete that range in the vector en masse (the STL ending is 89 // Now just delete that range in the vector en masse (the STL ending is
98 // exclusive, while ours is inclusive, hence the +1). 90 // exclusive, while ours is inclusive, hence the +1).
99 results_.erase(results_.begin() + begin, results_.begin() + end + 1); 91 results_.erase(results_.begin() + begin, results_.begin() + end + 1);
100 92
101 // Delete the indicies referencing the deleted entries. 93 // Delete the indicies referencing the deleted entries.
102 for (std::set<GURL>::const_iterator url = urls_modified.begin(); 94 for (const auto& url : urls_modified) {
103 url != urls_modified.end(); ++url) { 95 URLToResultIndices::iterator found = url_to_results_.find(url);
104 URLToResultIndices::iterator found = url_to_results_.find(*url);
105 if (found == url_to_results_.end()) { 96 if (found == url_to_results_.end()) {
106 NOTREACHED(); 97 NOTREACHED();
107 continue; 98 continue;
108 } 99 }
109 100
110 // Need a signed loop type since we do -- which may take us to -1. 101 // Need a signed loop type since we do -- which may take us to -1.
111 for (int match = 0; match < static_cast<int>(found->second->size()); 102 for (int match = 0; match < static_cast<int>(found->second->size());
112 match++) { 103 match++) {
113 if (found->second[match] >= begin && found->second[match] <= end) { 104 if (found->second[match] >= begin && found->second[match] <= end) {
114 // Remove this referece from the list. 105 // Remove this referece from the list.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 for (size_t match = 0; match < i->second->size(); match++) { 138 for (size_t match = 0; match < i->second->size(); match++) {
148 size_t match_index = i->second[match]; 139 size_t match_index = i->second[match];
149 if (match_index >= begin && match_index <= end) 140 if (match_index >= begin && match_index <= end)
150 i->second[match] += delta; 141 i->second[match] += delta;
151 } 142 }
152 } 143 }
153 } 144 }
154 145
155 // QueryOptions ---------------------------------------------------------------- 146 // QueryOptions ----------------------------------------------------------------
156 147
157 QueryOptions::QueryOptions() 148 QueryOptions::QueryOptions() {}
158 : max_count(0),
159 duplicate_policy(QueryOptions::REMOVE_ALL_DUPLICATES),
160 matching_algorithm(query_parser::MatchingAlgorithm::DEFAULT) {}
161 149
162 void QueryOptions::SetRecentDayRange(int days_ago) { 150 void QueryOptions::SetRecentDayRange(int days_ago) {
163 end_time = base::Time::Now(); 151 end_time = base::Time::Now();
164 begin_time = end_time - base::TimeDelta::FromDays(days_ago); 152 begin_time = end_time - base::TimeDelta::FromDays(days_ago);
165 } 153 }
166 154
167 int64_t QueryOptions::EffectiveBeginTime() const { 155 int64_t QueryOptions::EffectiveBeginTime() const {
168 return begin_time.ToInternalValue(); 156 return begin_time.ToInternalValue();
169 } 157 }
170 158
171 int64_t QueryOptions::EffectiveEndTime() const { 159 int64_t QueryOptions::EffectiveEndTime() const {
172 return end_time.is_null() ? std::numeric_limits<int64_t>::max() 160 return end_time.is_null() ? std::numeric_limits<int64_t>::max()
173 : end_time.ToInternalValue(); 161 : end_time.ToInternalValue();
174 } 162 }
175 163
176 int QueryOptions::EffectiveMaxCount() const { 164 int QueryOptions::EffectiveMaxCount() const {
177 return max_count ? max_count : std::numeric_limits<int>::max(); 165 return max_count ? max_count : std::numeric_limits<int>::max();
178 } 166 }
179 167
180 // QueryURLResult ------------------------------------------------------------- 168 // QueryURLResult -------------------------------------------------------------
181 169
182 QueryURLResult::QueryURLResult() : success(false) { 170 QueryURLResult::QueryURLResult() {}
183 }
184 171
185 QueryURLResult::~QueryURLResult() { 172 QueryURLResult::~QueryURLResult() {
186 } 173 }
187 174
188 // MostVisitedURL -------------------------------------------------------------- 175 // MostVisitedURL --------------------------------------------------------------
189 176
190 MostVisitedURL::MostVisitedURL() {} 177 MostVisitedURL::MostVisitedURL() {}
191 178
192 MostVisitedURL::MostVisitedURL(const GURL& url, 179 MostVisitedURL::MostVisitedURL(const GURL& url,
193 const base::string16& title)
194 : url(url),
195 title(title) {
196 }
197
198 MostVisitedURL::MostVisitedURL(const GURL& url,
199 const base::string16& title, 180 const base::string16& title,
200 const base::Time& last_forced_time) 181 base::Time last_forced_time)
201 : url(url), 182 : url(url), title(title), last_forced_time(last_forced_time) {}
202 title(title),
203 last_forced_time(last_forced_time) {
204 }
205 183
206 MostVisitedURL::MostVisitedURL(const MostVisitedURL& other) = default; 184 MostVisitedURL::MostVisitedURL(const MostVisitedURL& other) = default;
207 185
186 // TODO(bug 706963) this should be implemented as "= default" when Android
187 // toolchain is updated.
188 MostVisitedURL::MostVisitedURL(MostVisitedURL&& other) noexcept
189 : url(std::move(other.url)),
190 title(std::move(other.title)),
191 last_forced_time(other.last_forced_time),
192 redirects(std::move(other.redirects)) {}
193
208 MostVisitedURL::~MostVisitedURL() {} 194 MostVisitedURL::~MostVisitedURL() {}
209 195
196 MostVisitedURL& MostVisitedURL::operator=(const MostVisitedURL&) = default;
197
210 // FilteredURL ----------------------------------------------------------------- 198 // FilteredURL -----------------------------------------------------------------
211 199
212 FilteredURL::FilteredURL() : score(0.0) {} 200 FilteredURL::FilteredURL() {}
213 201
214 FilteredURL::FilteredURL(const PageUsageData& page_data) 202 FilteredURL::FilteredURL(const PageUsageData& page_data)
215 : url(page_data.GetURL()), 203 : url(page_data.GetURL()),
216 title(page_data.GetTitle()), 204 title(page_data.GetTitle()),
217 score(page_data.GetScore()) { 205 score(page_data.GetScore()) {
218 } 206 }
219 207
208 FilteredURL::FilteredURL(FilteredURL&& other) noexcept = default;
209
220 FilteredURL::~FilteredURL() {} 210 FilteredURL::~FilteredURL() {}
221 211
222 // FilteredURL::ExtendedInfo --------------------------------------------------- 212 // FilteredURL::ExtendedInfo ---------------------------------------------------
223 213
224 FilteredURL::ExtendedInfo::ExtendedInfo() 214 FilteredURL::ExtendedInfo::ExtendedInfo() = default;
225 : total_visits(0),
226 visits(0),
227 duration_opened(0) {
228 }
229 215
230 // Images --------------------------------------------------------------------- 216 // Images ---------------------------------------------------------------------
231 217
232 Images::Images() {} 218 Images::Images() {}
233 219
234 Images::Images(const Images& other) = default; 220 Images::Images(const Images& other) = default;
235 221
236 Images::~Images() {} 222 Images::~Images() {}
237 223
238 // TopSitesDelta -------------------------------------------------------------- 224 // TopSitesDelta --------------------------------------------------------------
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 ThumbnailMigration::~ThumbnailMigration() {} 278 ThumbnailMigration::~ThumbnailMigration() {}
293 279
294 // MostVisitedThumbnails ------------------------------------------------------ 280 // MostVisitedThumbnails ------------------------------------------------------
295 281
296 MostVisitedThumbnails::MostVisitedThumbnails() {} 282 MostVisitedThumbnails::MostVisitedThumbnails() {}
297 283
298 MostVisitedThumbnails::~MostVisitedThumbnails() {} 284 MostVisitedThumbnails::~MostVisitedThumbnails() {}
299 285
300 // IconMapping ---------------------------------------------------------------- 286 // IconMapping ----------------------------------------------------------------
301 287
302 IconMapping::IconMapping() 288 IconMapping::IconMapping() {}
303 : mapping_id(0), icon_id(0), icon_type(favicon_base::INVALID_ICON) {} 289 IconMapping::IconMapping(const IconMapping&) = default;
290 IconMapping::IconMapping(IconMapping&&) noexcept = default;
304 291
305 IconMapping::~IconMapping() {} 292 IconMapping::~IconMapping() {}
306 293
294 IconMapping& IconMapping::operator=(const IconMapping&) = default;
295
307 // FaviconBitmapIDSize --------------------------------------------------------- 296 // FaviconBitmapIDSize ---------------------------------------------------------
308 297
309 FaviconBitmapIDSize::FaviconBitmapIDSize() 298 FaviconBitmapIDSize::FaviconBitmapIDSize() {}
310 : bitmap_id(0) {
311 }
312 299
313 FaviconBitmapIDSize::~FaviconBitmapIDSize() { 300 FaviconBitmapIDSize::~FaviconBitmapIDSize() {}
314 }
315 301
316 // FaviconBitmap -------------------------------------------------------------- 302 // FaviconBitmap --------------------------------------------------------------
317 303
318 FaviconBitmap::FaviconBitmap() 304 FaviconBitmap::FaviconBitmap() {}
319 : bitmap_id(0),
320 icon_id(0) {
321 }
322 305
323 FaviconBitmap::FaviconBitmap(const FaviconBitmap& other) = default; 306 FaviconBitmap::FaviconBitmap(const FaviconBitmap& other) = default;
324 307
325 FaviconBitmap::~FaviconBitmap() { 308 FaviconBitmap::~FaviconBitmap() {}
326 }
327 309
328 // ExpireHistoryArgs ---------------------------------------------------------- 310 // ExpireHistoryArgs ----------------------------------------------------------
329 311
330 ExpireHistoryArgs::ExpireHistoryArgs() { 312 ExpireHistoryArgs::ExpireHistoryArgs() {
331 } 313 }
332 314
333 ExpireHistoryArgs::ExpireHistoryArgs(const ExpireHistoryArgs& other) = default; 315 ExpireHistoryArgs::ExpireHistoryArgs(const ExpireHistoryArgs& other) = default;
334 316
335 ExpireHistoryArgs::~ExpireHistoryArgs() { 317 ExpireHistoryArgs::~ExpireHistoryArgs() {
336 } 318 }
337 319
338 void ExpireHistoryArgs::SetTimeRangeForOneDay(base::Time time) { 320 void ExpireHistoryArgs::SetTimeRangeForOneDay(base::Time time) {
339 begin_time = time.LocalMidnight(); 321 begin_time = time.LocalMidnight();
340 322
341 // Due to DST, leap seconds, etc., the next day at midnight may be more than 323 // Due to DST, leap seconds, etc., the next day at midnight may be more than
342 // 24 hours away, so add 36 hours and round back down to midnight. 324 // 24 hours away, so add 36 hours and round back down to midnight.
343 end_time = (begin_time + base::TimeDelta::FromHours(36)).LocalMidnight(); 325 end_time = (begin_time + base::TimeDelta::FromHours(36)).LocalMidnight();
344 } 326 }
345 327
346 } // namespace history 328 } // namespace history
OLDNEW
« no previous file with comments | « components/history/core/browser/history_types.h ('k') | components/history/core/browser/url_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698