15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_HISTORY_VISIT_DATABASE_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_HISTORY_VISIT_DATABASE_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <vector> 92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 101320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "components/history/core/browser/history_types.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace sql { 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Connection; 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Statement; 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace history { 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class VisitFilter; 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// A visit database is one which stores visits for URLs, that is, times and 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// linking information. A visit database must also be a URLDatabase, as this 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// modifies tables used by URLs directly and could be thought of as inheriting 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// from URLDatabase. However, this inheritance is not explicit as things would 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// get too complicated and have multiple inheritance. 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class VisitDatabase { 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Must call InitVisitTable() before using to make sure the database is 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // initialized. 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) VisitDatabase(); 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~VisitDatabase(); 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Deletes the visit table. Used for rapidly clearing all visits. In this 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // case, InitVisitTable would be called immediately afterward to re-create it. 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true on success. 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool DropVisitTable(); 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Adds a line to the visit database with the given information, returning 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the added row ID on success, 0 on failure. The given visit is updated with 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the new row ID on success. In addition, adds its source into visit_source 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // table. 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) VisitID AddVisit(VisitRow* visit, VisitSource source); 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Deletes the given visit from the database. If a visit with the given ID 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // doesn't exist, it will not do anything. 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void DeleteVisit(const VisitRow& visit); 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Query a VisitInfo giving an visit id, filling the given VisitRow. 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true on success. 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool GetRowForVisit(VisitID visit_id, VisitRow* out_visit); 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Updates an existing row. The new information is set on the row, using the 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // VisitID as the key. The visit must exist. Returns true on success. 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool UpdateVisitRow(const VisitRow& visit); 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Fills in the given vector with all of the visits for the given page ID, 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // sorted in ascending order of date. Returns true on success (although there 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // may still be no matches). 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool GetVisitsForURL(URLID url_id, VisitVector* visits); 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 61eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Fills in the given vector with the visits for the given page ID which 624e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // should be user-visible, which excludes things like redirects and subframes, 634e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // and match the set of options passed, sorted in ascending order of date. 64eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // 65eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Returns true if there are more results available, i.e. if the number of 66eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // results was restricted by |options.max_count|. 674e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) bool GetVisibleVisitsForURL(URLID url_id, 684e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) const QueryOptions& options, 694e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) VisitVector* visits); 70eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Fills the vector with all visits with times in the given list. 722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // 732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // The results will be in no particular order. Also, no duplicate 742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // detection is performed, so if |times| has duplicate times, 752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // |visits| may have duplicate visits. 762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool GetVisitsForTimes(const std::vector<base::Time>& times, 772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) VisitVector* visits); 782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Fills all visits in the time range [begin, end) to the given vector. Either 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // time can be is_null(), in which case the times in that direction are 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // unbounded. 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If |max_results| is non-zero, up to that many results will be returned. If 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // there are more results than that, the oldest ones will be returned. (This 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // is used for history expiration.) 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The results will be in increasing order of date. 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool GetAllVisitsInRange(base::Time begin_time, base::Time end_time, 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int max_results, VisitVector* visits); 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Fills all visits with specified transition in the time range [begin, end) 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // to the given vector. Either time can be is_null(), in which case the times 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // in that direction are unbounded. 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If |max_results| is non-zero, up to that many results will be returned. If 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // there are more results than that, the oldest ones will be returned. (This 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // is used for history expiration.) 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The results will be in increasing order of date. 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool GetVisitsInRangeForTransition(base::Time begin_time, 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::Time end_time, 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int max_results, 1031320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ui::PageTransition transition, 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) VisitVector* visits); 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Fills all visits in the given time range into the given vector that should 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // be user-visible, which excludes things like redirects and subframes. The 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // begin time is inclusive, the end time is exclusive. Either time can be 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // is_null(), in which case the times in that direction are unbounded. 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Up to |max_count| visits will be returned. If there are more visits than 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // that, the most recent |max_count| will be returned. If 0, all visits in the 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // range will be computed. 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Only one visit for each URL will be returned, and it will be the most 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // recent one in the time range. 1172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // 1182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Returns true if there are more results available, i.e. if the number of 1192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // results was restricted by |options.max_count|. 1202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool GetVisibleVisitsInRange(const QueryOptions& options, 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) VisitVector* visits); 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Fills all visits in the given time ranges into the given vector that are 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // visits made directly by the user (typed or bookmarked visits only). The 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // begin time is inclusive, the end time is exclusive. 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Up to |max_count| visits will be returned. If there are more visits than 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // that, the most recent |max_count| will be returned. If 0, all visits in the 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // range will be computed. 1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void GetDirectVisitsDuringTimes(const VisitFilter& time_filter, 1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int max_count, 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) VisitVector* visits); 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the visit ID for the most recent visit of the given URL ID, or 0 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // if there is no visit for the URL. 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If non-NULL, the given visit row will be filled with the information of 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the found visit. When no visit is found, the row will be unchanged. 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) VisitID GetMostRecentVisitForURL(URLID url_id, 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) VisitRow* visit_row); 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the |max_results| most recent visit sessions for |url_id|. 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns false if there's a failure preparing the statement. True 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // otherwise. (No results are indicated with an empty |visits| 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // vector.) 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool GetMostRecentVisitsForURL(URLID url_id, 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int max_results, 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) VisitVector* visits); 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Finds a redirect coming from the given |from_visit|. If a redirect is 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // found, it fills the visit ID and URL into the out variables and returns 1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // true. If there is no redirect from the given visit, returns false. 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If there is more than one redirect, this will compute a random one. But 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // duplicates should be very rare, and we don't actually care which one we 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // get in most cases. These will occur when the user goes back and gets 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // redirected again. 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // to_visit and to_url can be NULL in which case they are ignored. 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool GetRedirectFromVisit(VisitID from_visit, 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) VisitID* to_visit, 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL* to_url); 1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Similar to the above function except finds a redirect going to a given 1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |to_visit|. 1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool GetRedirectToVisit(VisitID to_visit, 1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) VisitID* from_visit, 1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL* from_url); 1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Gets the number of user-visible visits to all URLs on the same 1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // scheme/host/port as |url|, as well as the time of the earliest visit. 1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // "User-visible" is defined as in GetVisibleVisitsInRange() above, i.e. 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // excluding redirects and subframes. 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This function is only valid for HTTP and HTTPS URLs; all other schemes 1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // cause the function to return false. 1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool GetVisibleVisitCountToHost(const GURL& url, 1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int* count, 1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::Time* first_visit); 1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Get the time of the first item in our database. 1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool GetStartDate(base::Time* first_visit); 1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Get the source information about the given visits. 1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void GetVisitsSource(const VisitVector& visits, 1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) VisitSourceMap* sources); 1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Obtains BriefVisitInfo for the specified number of most recent visits 1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // from the visit database. 1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void GetBriefVisitInfoOfMostRecentVisits( 1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int max_visits, 1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::vector<BriefVisitInfo>* result_vector); 1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected: 1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the database for the functions in this interface. 1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual sql::Connection& GetDB() = 0; 1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called by the derived classes on initialization to make sure the tables 1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // and indices are properly set up. Must be called before anything else. 2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool InitVisitTable(); 2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Convenience to fill a VisitRow. Assumes the visit values are bound starting 2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // at index 0. 2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static void FillVisitRow(sql::Statement& statement, VisitRow* visit); 2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Convenience to fill a VisitVector. Assumes that statement.step() 2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // hasn't happened yet. 2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool FillVisitVector(sql::Statement& statement, VisitVector* visits); 2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 210eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Convenience to fill a VisitVector while respecting the set of options. 211eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // |statement| should order the query decending by visit_time to ensure 212eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // correct duplicate management behavior. Assumes that statement.step() 213eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // hasn't happened yet. 214eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch static bool FillVisitVectorWithOptions(sql::Statement& statement, 215eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch const QueryOptions& options, 216eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch VisitVector* visits); 217eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called by the derived classes to migrate the older visits table which 2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // don't have visit_duration column yet. 2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool MigrateVisitsWithoutDuration(); 2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(VisitDatabase); 2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Rows, in order, of the visit table. 2282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define HISTORY_VISIT_ROW_FIELDS \ 229bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch " id,url,visit_time,from_visit,transition,segment_id,visit_duration " 2302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 231eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch} // namespace history 2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CHROME_BROWSER_HISTORY_VISIT_DATABASE_H_ 234