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

Side by Side Diff: chrome/browser/history/visit_database.cc

Issue 341087: Eliminate QueryOptions::most_recent_visit_only. All non-unittest consumers o... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 1 month 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/browser/history/visit_database.h" 5 #include "chrome/browser/history/visit_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 statement.BindInt(3, transition); 249 statement.BindInt(3, transition);
250 statement.BindInt64(4, 250 statement.BindInt64(4,
251 max_results ? max_results : std::numeric_limits<int64>::max()); 251 max_results ? max_results : std::numeric_limits<int64>::max());
252 252
253 AddEventToVisitLog(VisitLog::SELECT_VISIT); 253 AddEventToVisitLog(VisitLog::SELECT_VISIT);
254 FillVisitVector(statement, visits); 254 FillVisitVector(statement, visits);
255 } 255 }
256 256
257 void VisitDatabase::GetVisibleVisitsInRange(base::Time begin_time, 257 void VisitDatabase::GetVisibleVisitsInRange(base::Time begin_time,
258 base::Time end_time, 258 base::Time end_time,
259 bool most_recent_visit_only,
260 int max_count, 259 int max_count,
261 VisitVector* visits) { 260 VisitVector* visits) {
262 visits->clear(); 261 visits->clear();
263 // The visit_time values can be duplicated in a redirect chain, so we sort 262 // The visit_time values can be duplicated in a redirect chain, so we sort
264 // by id too, to ensure a consistent ordering just in case. 263 // by id too, to ensure a consistent ordering just in case.
265 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, 264 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
266 "SELECT" HISTORY_VISIT_ROW_FIELDS "FROM visits " 265 "SELECT" HISTORY_VISIT_ROW_FIELDS "FROM visits "
267 "WHERE visit_time >= ? AND visit_time < ? " 266 "WHERE visit_time >= ? AND visit_time < ? "
268 "AND (transition & ?) != 0 " // CHAIN_END 267 "AND (transition & ?) != 0 " // CHAIN_END
269 "AND (transition & ?) NOT IN (?, ?, ?) " // NO SUBFRAME or 268 "AND (transition & ?) NOT IN (?, ?, ?) " // NO SUBFRAME or
(...skipping 12 matching lines...) Expand all
282 statement.BindInt(3, PageTransition::CORE_MASK); 281 statement.BindInt(3, PageTransition::CORE_MASK);
283 statement.BindInt(4, PageTransition::AUTO_SUBFRAME); 282 statement.BindInt(4, PageTransition::AUTO_SUBFRAME);
284 statement.BindInt(5, PageTransition::MANUAL_SUBFRAME); 283 statement.BindInt(5, PageTransition::MANUAL_SUBFRAME);
285 statement.BindInt(6, PageTransition::KEYWORD_GENERATED); 284 statement.BindInt(6, PageTransition::KEYWORD_GENERATED);
286 285
287 AddEventToVisitLog(VisitLog::SELECT_VISIT); 286 AddEventToVisitLog(VisitLog::SELECT_VISIT);
288 std::set<URLID> found_urls; 287 std::set<URLID> found_urls;
289 while (statement.Step()) { 288 while (statement.Step()) {
290 VisitRow visit; 289 VisitRow visit;
291 FillVisitRow(statement, &visit); 290 FillVisitRow(statement, &visit);
292 if (most_recent_visit_only) { 291 // Make sure the URL this visit corresponds to is unique.
293 // Make sure the URL this visit corresponds to is unique if required. 292 if (found_urls.find(visit.url_id) != found_urls.end())
294 if (found_urls.find(visit.url_id) != found_urls.end()) 293 continue;
295 continue; 294 found_urls.insert(visit.url_id);
296 found_urls.insert(visit.url_id);
297 }
298 visits->push_back(visit); 295 visits->push_back(visit);
299 296
300 if (max_count > 0 && static_cast<int>(visits->size()) >= max_count) 297 if (max_count > 0 && static_cast<int>(visits->size()) >= max_count)
301 break; 298 break;
302 } 299 }
303 } 300 }
304 301
305 VisitID VisitDatabase::GetMostRecentVisitForURL(URLID url_id, 302 VisitID VisitDatabase::GetMostRecentVisitForURL(URLID url_id,
306 VisitRow* visit_row) { 303 VisitRow* visit_row) {
307 // The visit_time values can be duplicated in a redirect chain, so we sort 304 // The visit_time values can be duplicated in a redirect chain, so we sort
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 AddEventToVisitLog(VisitLog::SELECT_VISIT); 446 AddEventToVisitLog(VisitLog::SELECT_VISIT);
450 if (!statement || !statement.Step() || statement.ColumnInt64(0) == 0) { 447 if (!statement || !statement.Step() || statement.ColumnInt64(0) == 0) {
451 *first_visit = base::Time::Now(); 448 *first_visit = base::Time::Now();
452 return false; 449 return false;
453 } 450 }
454 *first_visit = base::Time::FromInternalValue(statement.ColumnInt64(0)); 451 *first_visit = base::Time::FromInternalValue(statement.ColumnInt64(0));
455 return true; 452 return true;
456 } 453 }
457 454
458 } // namespace history 455 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/visit_database.h ('k') | chrome/browser/history/visit_database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698