16e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 26e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 36e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// found in the LICENSE file. 46e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 56e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#ifndef COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_TYPES_H_ 66e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_TYPES_H_ 76e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 86e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include <deque> 96e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include <map> 106e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include <set> 116e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include <string> 126e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include <vector> 136e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 146e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "base/basictypes.h" 156e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "base/containers/stack_container.h" 166e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "base/memory/ref_counted_memory.h" 176e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "base/memory/scoped_vector.h" 186e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "base/strings/string16.h" 196e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "base/time/time.h" 206e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "components/favicon_base/favicon_types.h" 216e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "components/history/core/browser/url_row.h" 226e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "components/history/core/common/thumbnail_score.h" 231320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "ui/base/page_transition_types.h" 246e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "ui/gfx/size.h" 256e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "url/gurl.h" 266e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 276e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)class PageUsageData; 286e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 291320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// TODO(sdefresne): remove, http://crbug.com/371816 301320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccinamespace content { 311320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass WebContents; 321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci} 331320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 346e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)namespace history { 356e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 366e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Forward declaration for friend statements. 376e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)class HistoryBackend; 386e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)class URLDatabase; 396e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 406e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Container for a list of URLs. 416e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)typedef std::vector<GURL> RedirectList; 426e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 436e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)typedef int64 FaviconBitmapID; // Identifier for a bitmap in a favicon. 446e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)typedef int64 SegmentID; // URL segments for the most visited view. 456e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)typedef int64 IconMappingID; // For page url and icon mapping. 466e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 471320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Identifier for a context to scope page ids. (ContextIDs are used in 481320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// comparisons only and are never dereferenced.) 491320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// NB: The use of WebContents here is temporary; when the dependency on content 501320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// is broken, some other type will take its place. 511320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccitypedef content::WebContents* ContextID; 521320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 536e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// The enumeration of all possible sources of visits is listed below. 546e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// The source will be propagated along with a URL or a visit item 556e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// and eventually be stored in the history database, 566e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// visit_source table specifically. 576e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Different from page transition types, they describe the origins of visits. 586e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// (Warning): Please don't change any existing values while it is ok to add 596e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// new values when needed. 606e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)enum VisitSource { 616e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) SOURCE_SYNCED = 0, // Synchronized from somewhere else. 626e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) SOURCE_BROWSED = 1, // User browsed. 636e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) SOURCE_EXTENSION = 2, // Added by an extension. 646e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) SOURCE_FIREFOX_IMPORTED = 3, 656e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) SOURCE_IE_IMPORTED = 4, 666e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) SOURCE_SAFARI_IMPORTED = 5, 676e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}; 686e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 696e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)typedef int64 VisitID; 706e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Structure to hold the mapping between each visit's id and its source. 716e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)typedef std::map<VisitID, VisitSource> VisitSourceMap; 726e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 731320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// VisitRow ------------------------------------------------------------------- 741320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 751320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Holds all information associated with a specific visit. A visit holds time 761320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// and referrer information for one time a URL is visited. 771320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass VisitRow { 781320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci public: 791320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci VisitRow(); 801320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci VisitRow(URLID arg_url_id, 811320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci base::Time arg_visit_time, 821320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci VisitID arg_referring_visit, 831320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ui::PageTransition arg_transition, 841320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci SegmentID arg_segment_id); 851320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ~VisitRow(); 861320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 871320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // ID of this row (visit ID, used a a referrer for other visits). 881320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci VisitID visit_id; 891320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 901320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // Row ID into the URL table of the URL that this page is. 911320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci URLID url_id; 921320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 931320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci base::Time visit_time; 941320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 951320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // Indicates another visit that was the referring page for this one. 961320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // 0 indicates no referrer. 971320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci VisitID referring_visit; 981320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 991320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // A combination of bits from PageTransition. 1001320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ui::PageTransition transition; 1011320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 1021320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // The segment id (see visitsegment_database.*). 1031320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // If 0, the segment id is null in the table. 1041320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci SegmentID segment_id; 1051320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 1061320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // Record how much time a user has this visit starting from the user 1071320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // opened this visit to the user closed or ended this visit. 1081320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // This includes both active and inactive time as long as 1091320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // the visit was present. 1101320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci base::TimeDelta visit_duration; 1111320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 1121320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // Compares two visits based on dates, for sorting. 1131320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci bool operator<(const VisitRow& other) { 1141320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci return visit_time < other.visit_time; 1151320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci } 1161320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 1171320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // We allow the implicit copy constuctor and operator=. 1181320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}; 1191320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 1201320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// We pass around vectors of visits a lot 1211320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccitypedef std::vector<VisitRow> VisitVector; 1221320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 1231320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// The basic information associated with a visit (timestamp, type of visit), 1241320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// used by HistoryBackend::AddVisits() to create new visits for a URL. 1251320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccitypedef std::pair<base::Time, ui::PageTransition> VisitInfo; 1261320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 1276e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// PageVisit ------------------------------------------------------------------ 1286e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 1296e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Represents a simplified version of a visit for external users. Normally, 1306e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// views are only interested in the time, and not the other information 1316e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// associated with a VisitRow. 1326e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)struct PageVisit { 1336e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) URLID page_id; 1346e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::Time visit_time; 1356e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}; 1366e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 1376e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// QueryResults ---------------------------------------------------------------- 1386e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 1396e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Encapsulates the results of a history query. It supports an ordered list of 1406e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// URLResult objects, plus an efficient way of looking up the index of each time 1416e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// a given URL appears in those results. 1426e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)class QueryResults { 1436e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) public: 1446e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) typedef std::vector<URLResult*> URLResultVector; 1456e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 1466e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) QueryResults(); 1476e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) ~QueryResults(); 1486e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 1496e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Indicates the first time that the query includes results for (queries are 1506e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // clipped at the beginning, so it will always include to the end of the time 1516e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // queried). 1526e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // 1536e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // If the number of results was clipped as a result of the max count, this 1546e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // will be the time of the first query returned. If there were fewer results 1556e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // than we were allowed to return, this represents the first date considered 1566e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // in the query (this will be before the first result if there was time 1576e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // queried with no results). 1586e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // 1596e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // TODO(brettw): bug 1203054: This field is not currently set properly! Do 1606e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // not use until the bug is fixed. 1616e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::Time first_time_searched() const { return first_time_searched_; } 1626e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) void set_first_time_searched(base::Time t) { first_time_searched_ = t; } 1636e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Note: If you need end_time_searched, it can be added. 1646e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 1656e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) void set_reached_beginning(bool reached) { reached_beginning_ = reached; } 1666e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) bool reached_beginning() { return reached_beginning_; } 1676e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 1686e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) size_t size() const { return results_.size(); } 1696e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) bool empty() const { return results_.empty(); } 1706e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 1716e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) URLResult& back() { return *results_.back(); } 1726e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const URLResult& back() const { return *results_.back(); } 1736e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 1746e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) URLResult& operator[](size_t i) { return *results_[i]; } 1756e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const URLResult& operator[](size_t i) const { return *results_[i]; } 1766e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 1776e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) URLResultVector::const_iterator begin() const { return results_.begin(); } 1786e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) URLResultVector::const_iterator end() const { return results_.end(); } 1796e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) URLResultVector::const_reverse_iterator rbegin() const { 1806e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) return results_.rbegin(); 1816e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) } 1826e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) URLResultVector::const_reverse_iterator rend() const { 1836e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) return results_.rend(); 1846e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) } 1856e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 1866e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Returns a pointer to the beginning of an array of all matching indices 1876e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // for entries with the given URL. The array will be |*num_matches| long. 1886e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // |num_matches| can be NULL if the caller is not interested in the number of 1896e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // results (commonly it will only be interested in the first one and can test 1906e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // the pointer for NULL). 1916e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // 1926e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // When there is no match, it will return NULL and |*num_matches| will be 0. 1936e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const size_t* MatchesForURL(const GURL& url, size_t* num_matches) const; 1946e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 1956e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Swaps the current result with another. This allows ownership to be 1966e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // efficiently transferred without copying. 1976e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) void Swap(QueryResults* other); 1986e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 1996e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Adds the given result to the map, using swap() on the members to avoid 2006e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // copying (there are a lot of strings and vectors). This means the parameter 2016e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // object will be cleared after this call. 2026e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) void AppendURLBySwapping(URLResult* result); 2036e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2046e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Removes all instances of the given URL from the result set. 2056e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) void DeleteURL(const GURL& url); 2066e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2076e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Deletes the given range of items in the result set. 2086e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) void DeleteRange(size_t begin, size_t end); 2096e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2106e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) private: 2116e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Maps the given URL to a list of indices into results_ which identify each 2126e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // time an entry with that URL appears. Normally, each URL will have one or 2136e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // very few indices after it, so we optimize this to use statically allocated 2146e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // memory when possible. 2156e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) typedef std::map<GURL, base::StackVector<size_t, 4> > URLToResultIndices; 2166e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2176e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Inserts an entry into the |url_to_results_| map saying that the given URL 2186e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // is at the given index in the results_. 2196e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) void AddURLUsageAtIndex(const GURL& url, size_t index); 2206e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2216e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Adds |delta| to each index in url_to_results_ in the range [begin,end] 2226e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // (this is inclusive). This is used when inserting or deleting. 2236e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) void AdjustResultMap(size_t begin, size_t end, ptrdiff_t delta); 2246e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2256e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::Time first_time_searched_; 2266e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2276e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Whether the query reaches the beginning of the database. 2286e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) bool reached_beginning_; 2296e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2306e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // The ordered list of results. The pointers inside this are owned by this 2316e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // QueryResults object. 2326e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) ScopedVector<URLResult> results_; 2336e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2346e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Maps URLs to entries in results_. 2356e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) URLToResultIndices url_to_results_; 2366e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2376e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(QueryResults); 2386e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}; 2396e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2406e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// QueryOptions ---------------------------------------------------------------- 2416e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2426e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)struct QueryOptions { 2436e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) QueryOptions(); 2446e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2456e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // The time range to search for matches in. The beginning is inclusive and 2466e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // the ending is exclusive. Either one (or both) may be null. 2476e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // 2486e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // This will match only the one recent visit of a URL. For text search 2496e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // queries, if the URL was visited in the given time period, but has also 2506e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // been visited more recently than that, it will not be returned. When the 2516e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // text query is empty, this will return the most recent visit within the 2526e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // time range. 2536e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::Time begin_time; 2546e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::Time end_time; 2556e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2566e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Sets the query time to the last |days_ago| days to the present time. 2576e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) void SetRecentDayRange(int days_ago); 2586e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2596e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // The maximum number of results to return. The results will be sorted with 2606e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // the most recent first, so older results may not be returned if there is not 2616e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // enough room. When 0, this will return everything (the default). 2626e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) int max_count; 2636e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2646e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) enum DuplicateHandling { 2656e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Omit visits for which there is a more recent visit to the same URL. 2666e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Each URL in the results will appear only once. 2676e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) REMOVE_ALL_DUPLICATES, 2686e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2696e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Omit visits for which there is a more recent visit to the same URL on 2706e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // the same day. Each URL will appear no more than once per day, where the 2716e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // day is defined by the local timezone. 2726e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) REMOVE_DUPLICATES_PER_DAY, 2736e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2746e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Return all visits without deduping. 2756e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) KEEP_ALL_DUPLICATES 2766e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) }; 2776e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2786e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Allows the caller to specify how duplicate URLs in the result set should 2796e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // be handled. The default is REMOVE_DUPLICATES. 2806e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) DuplicateHandling duplicate_policy; 2816e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2826e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Helpers to get the effective parameters values, since a value of 0 means 2836e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // "unspecified". 2846e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) int EffectiveMaxCount() const; 2856e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) int64 EffectiveBeginTime() const; 2866e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) int64 EffectiveEndTime() const; 2876e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}; 2886e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2891320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// QueryURLResult ------------------------------------------------------------- 2901320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 2911320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// QueryURLResult encapsulates the result of a call to HistoryBackend::QueryURL. 2921320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccistruct QueryURLResult { 2931320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci QueryURLResult(); 2941320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ~QueryURLResult(); 2951320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 2961320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // Indicates whether the call to HistoryBackend::QueryURL was successfull 2971320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // or not. If false, then both |row| and |visits| fields are undefined. 2981320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci bool success; 2991320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci URLRow row; 3001320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci VisitVector visits; 3011320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}; 3021320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 3036e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// VisibleVisitCountToHostResult ---------------------------------------------- 3046e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 3056e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// VisibleVisitCountToHostResult encapsulates the result of a call to 3066e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// HistoryBackend::GetVisibleVisitCountToHost. 3076e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)struct VisibleVisitCountToHostResult { 3086e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Indicates whether the call to HistoryBackend::GetVisibleVisitCountToHost 3096e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // was successfull or not. If false, then both |count| and |first_visit| are 3106e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // undefined. 3116e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) bool success; 3126e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) int count; 3136e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::Time first_visit; 3146e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}; 3156e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 3166e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// MostVisitedURL -------------------------------------------------------------- 3176e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 3186e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Holds the per-URL information of the most visited query. 3196e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)struct MostVisitedURL { 3206e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) MostVisitedURL(); 3216e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) MostVisitedURL(const GURL& url, const base::string16& title); 3226e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) MostVisitedURL(const GURL& url, 3236e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const base::string16& title, 3246e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const base::Time& last_forced_time); 3256e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) ~MostVisitedURL(); 3266e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 3276e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) GURL url; 3286e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::string16 title; 3296e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 3306e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // If this is a URL for which we want to force a thumbnail, records the last 3316e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // time it was forced so we can evict it when more recent URLs are requested. 3326e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // If it's not a forced thumbnail, keep a time of 0. 3336e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::Time last_forced_time; 3346e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 3356e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) RedirectList redirects; 3366e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 3376e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) bool operator==(const MostVisitedURL& other) { 3386e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) return url == other.url; 3396e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) } 3406e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}; 3416e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 3426e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// FilteredURL ----------------------------------------------------------------- 3436e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 3446e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Holds the per-URL information of the filterd url query. 3456e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)struct FilteredURL { 3466e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) struct ExtendedInfo { 3476e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) ExtendedInfo(); 3486e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // The absolute number of visits. 3496e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) unsigned int total_visits; 3506e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // The number of visits, as seen by the Most Visited NTP pane. 3516e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) unsigned int visits; 3526e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // The total number of seconds that the page was open. 3536e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) int64 duration_opened; 3546e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // The time when the page was last visited. 3556e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::Time last_visit_time; 3566e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) }; 3576e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 3586e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) FilteredURL(); 3596e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) explicit FilteredURL(const PageUsageData& data); 3606e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) ~FilteredURL(); 3616e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 3626e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) GURL url; 3636e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::string16 title; 3646e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) double score; 3656e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) ExtendedInfo extended_info; 3666e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}; 3676e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 3681320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Navigation ----------------------------------------------------------------- 3691320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 3701320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Marshalling structure for AddPage. 3711320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccistruct HistoryAddPageArgs { 3721320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // The default constructor is equivalent to: 3731320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // 3741320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // HistoryAddPageArgs( 3751320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // GURL(), base::Time(), NULL, 0, GURL(), 3761320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // history::RedirectList(), ui::PAGE_TRANSITION_LINK, 3771320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // SOURCE_BROWSED, false) 3781320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci HistoryAddPageArgs(); 3791320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci HistoryAddPageArgs(const GURL& url, 3801320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci base::Time time, 3811320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ContextID context_id, 3821320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci int32 page_id, 3831320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci const GURL& referrer, 3841320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci const history::RedirectList& redirects, 3851320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ui::PageTransition transition, 3861320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci VisitSource source, 3871320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci bool did_replace_entry); 3881320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ~HistoryAddPageArgs(); 3891320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 3901320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci GURL url; 3911320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci base::Time time; 3921320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 3931320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ContextID context_id; 3941320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci int32 page_id; 3951320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 3961320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci GURL referrer; 3971320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci history::RedirectList redirects; 3981320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ui::PageTransition transition; 3991320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci VisitSource visit_source; 4001320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci bool did_replace_entry; 4011320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}; 4021320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 4036e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// TopSites ------------------------------------------------------------------- 4046e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4056e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)typedef std::vector<MostVisitedURL> MostVisitedURLList; 4066e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)typedef std::vector<FilteredURL> FilteredURLList; 4076e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4086e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Used by TopSites to store the thumbnails. 4096e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)struct Images { 4106e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) Images(); 4116e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) ~Images(); 4126e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4136e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) scoped_refptr<base::RefCountedMemory> thumbnail; 4146e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) ThumbnailScore thumbnail_score; 4156e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4166e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // TODO(brettw): this will eventually store the favicon. 4176e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // scoped_refptr<base::RefCountedBytes> favicon; 4186e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}; 4196e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4206e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)struct MostVisitedURLWithRank { 4216e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) MostVisitedURL url; 4226e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) int rank; 4236e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}; 4246e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4256e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)typedef std::vector<MostVisitedURLWithRank> MostVisitedURLWithRankList; 4266e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4276e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)struct TopSitesDelta { 4286e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) TopSitesDelta(); 4296e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) ~TopSitesDelta(); 4306e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4316e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) MostVisitedURLList deleted; 4326e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) MostVisitedURLWithRankList added; 4336e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) MostVisitedURLWithRankList moved; 4346e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}; 4356e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4366e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)typedef std::map<GURL, scoped_refptr<base::RefCountedBytes> > URLToThumbnailMap; 4376e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4386e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Used when migrating most visited thumbnails out of history and into topsites. 4396e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)struct ThumbnailMigration { 4406e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) ThumbnailMigration(); 4416e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) ~ThumbnailMigration(); 4426e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4436e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) MostVisitedURLList most_visited; 4446e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) URLToThumbnailMap url_to_thumbnail_map; 4456e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}; 4466e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4476e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)typedef std::map<GURL, Images> URLToImagesMap; 4486e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4496e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)class MostVisitedThumbnails 4506e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) : public base::RefCountedThreadSafe<MostVisitedThumbnails> { 4516e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) public: 4526e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) MostVisitedThumbnails(); 4536e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4546e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) MostVisitedURLList most_visited; 4556e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) URLToImagesMap url_to_images_map; 4566e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4576e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) private: 4586e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) friend class base::RefCountedThreadSafe<MostVisitedThumbnails>; 4596e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) virtual ~MostVisitedThumbnails(); 4606e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4616e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(MostVisitedThumbnails); 4626e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}; 4636e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4646e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Favicons ------------------------------------------------------------------- 4656e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4666e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Used for the mapping between the page and icon. 4676e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)struct IconMapping { 4686e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) IconMapping(); 4696e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) ~IconMapping(); 4706e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4716e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // The unique id of the mapping. 4726e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) IconMappingID mapping_id; 4736e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4746e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // The url of a web page. 4756e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) GURL page_url; 4766e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4776e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // The unique id of the icon. 4786e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) favicon_base::FaviconID icon_id; 4796e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4806e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // The url of the icon. 4816e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) GURL icon_url; 4826e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4836e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // The type of icon. 4846e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) favicon_base::IconType icon_type; 4856e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}; 4866e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4876e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Defines a favicon bitmap and its associated pixel size. 4886e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)struct FaviconBitmapIDSize { 4896e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) FaviconBitmapIDSize(); 4906e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) ~FaviconBitmapIDSize(); 4916e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4926e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // The unique id of the favicon bitmap. 4936e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) FaviconBitmapID bitmap_id; 4946e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4956e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // The pixel dimensions of the associated bitmap. 4966e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) gfx::Size pixel_size; 4976e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}; 4986e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4996e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Defines a favicon bitmap stored in the history backend. 5006e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)struct FaviconBitmap { 5016e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) FaviconBitmap(); 5026e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) ~FaviconBitmap(); 5036e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 5046e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // The unique id of the bitmap. 5056e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) FaviconBitmapID bitmap_id; 5066e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 5076e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // The id of the favicon to which the bitmap belongs to. 5086e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) favicon_base::FaviconID icon_id; 5096e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 5106e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Time at which |bitmap_data| was last updated. 5116e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::Time last_updated; 5126e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 5136e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // The bits of the bitmap. 5146e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) scoped_refptr<base::RefCountedMemory> bitmap_data; 5156e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 5166e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // The pixel dimensions of bitmap_data. 5176e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) gfx::Size pixel_size; 5186e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}; 5196e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 5201320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Abbreviated information about a visit. 5211320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccistruct BriefVisitInfo { 5221320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci URLID url_id; 5231320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci base::Time time; 5241320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ui::PageTransition transition; 5251320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}; 5261320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 5271320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// An observer of VisitDatabase. 5281320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass VisitDatabaseObserver { 5291320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci public: 5301320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual ~VisitDatabaseObserver(); 5311320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual void OnAddVisit(const BriefVisitInfo& info) = 0; 5321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}; 5331320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 5346e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)struct ExpireHistoryArgs { 5356e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) ExpireHistoryArgs(); 5366e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) ~ExpireHistoryArgs(); 5376e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 5386e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Sets |begin_time| and |end_time| to the beginning and end of the day (in 5396e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // local time) on which |time| occurs. 5406e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) void SetTimeRangeForOneDay(base::Time time); 5416e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 5426e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) std::set<GURL> urls; 5436e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::Time begin_time; 5446e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::Time end_time; 5456e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}; 5466e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 5476e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)} // namespace history 5486e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 5496e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_TYPES_H_ 550