Home | History | Annotate | Download | only in history
      1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_TYPES_H_
      6 #define CHROME_BROWSER_HISTORY_HISTORY_TYPES_H_
      7 
      8 #include <deque>
      9 #include <map>
     10 #include <set>
     11 #include <string>
     12 #include <vector>
     13 
     14 #include "base/basictypes.h"
     15 #include "base/containers/stack_container.h"
     16 #include "base/memory/ref_counted_memory.h"
     17 #include "base/memory/scoped_vector.h"
     18 #include "base/strings/string16.h"
     19 #include "base/time/time.h"
     20 #include "chrome/browser/history/snippet.h"
     21 #include "chrome/browser/search_engines/template_url_id.h"
     22 #include "chrome/common/favicon/favicon_types.h"
     23 #include "chrome/common/ref_counted_util.h"
     24 #include "chrome/common/thumbnail_score.h"
     25 #include "content/public/common/page_transition_types.h"
     26 #include "ui/gfx/image/image.h"
     27 #include "ui/gfx/size.h"
     28 #include "url/gurl.h"
     29 
     30 class PageUsageData;
     31 
     32 namespace history {
     33 
     34 // Forward declaration for friend statements.
     35 class HistoryBackend;
     36 class URLDatabase;
     37 
     38 // Structure to hold redirect lists for URLs.  For a redirect chain
     39 // A -> B -> C, and entry in the map would look like "A => {B -> C}".
     40 typedef std::map<GURL, scoped_refptr<RefCountedVector<GURL> > > RedirectMap;
     41 
     42 // Container for a list of URLs.
     43 typedef std::vector<GURL> RedirectList;
     44 
     45 typedef int64 FaviconBitmapID; // Identifier for a bitmap in a favicon.
     46 typedef int64 SegmentID;  // URL segments for the most visited view.
     47 typedef int64 SegmentDurationID;  // Unique identifier for segment_duration.
     48 typedef int64 IconMappingID; // For page url and icon mapping.
     49 
     50 // URLRow ---------------------------------------------------------------------
     51 
     52 typedef int64 URLID;
     53 
     54 // Holds all information globally associated with one URL (one row in the
     55 // URL table).
     56 //
     57 // This keeps track of dirty bits, which are currently unused:
     58 //
     59 // TODO(brettw) the dirty bits are broken in a number of respects. First, the
     60 // database will want to update them on a const object, so they need to be
     61 // mutable.
     62 //
     63 // Second, there is a problem copying. If you make a copy of this structure
     64 // (as we allow since we put this into vectors in various places) then the
     65 // dirty bits will not be in sync for these copies.
     66 class URLRow {
     67  public:
     68   URLRow();
     69 
     70   explicit URLRow(const GURL& url);
     71 
     72   // We need to be able to set the id of a URLRow that's being passed through
     73   // an IPC message.  This constructor should probably not be used otherwise.
     74   URLRow(const GURL& url, URLID id);
     75 
     76   virtual ~URLRow();
     77   URLRow& operator=(const URLRow& other);
     78 
     79   URLID id() const { return id_; }
     80 
     81   // Sets the id of the row. The id should only be manually set when a row has
     82   // been retrieved from the history database or other dataset based on criteria
     83   // other than its id (i.e. by URL) and when the id has not yet been set in the
     84   // row.
     85   void set_id(URLID id) { id_ = id; }
     86 
     87   const GURL& url() const { return url_; }
     88 
     89   const string16& title() const {
     90     return title_;
     91   }
     92   void set_title(const string16& title) {
     93     // The title is frequently set to the same thing, so we don't bother
     94     // updating unless the string has changed.
     95     if (title != title_) {
     96       title_ = title;
     97     }
     98   }
     99 
    100   // The number of times this URL has been visited. This will often match the
    101   // number of entries in the visit table for this URL, but won't always. It's
    102   // really designed for autocomplete ranking, so some "useless" transitions
    103   // from the visit table aren't counted in this tally.
    104   int visit_count() const {
    105     return visit_count_;
    106   }
    107   void set_visit_count(int visit_count) {
    108     visit_count_ = visit_count;
    109   }
    110 
    111   // Number of times the URL was typed in the Omnibox. This "should" match
    112   // the number of TYPED transitions in the visit table. It's used primarily
    113   // for faster autocomplete ranking. If you need to know the actual number of
    114   // TYPED transitions, you should query the visit table since there could be
    115   // something out of sync.
    116   int typed_count() const {
    117     return typed_count_;
    118   }
    119   void set_typed_count(int typed_count) {
    120     typed_count_ = typed_count;
    121   }
    122 
    123   base::Time last_visit() const {
    124     return last_visit_;
    125   }
    126   void set_last_visit(base::Time last_visit) {
    127     last_visit_ = last_visit;
    128   }
    129 
    130   // If this is set, we won't autocomplete this URL.
    131   bool hidden() const {
    132     return hidden_;
    133   }
    134   void set_hidden(bool hidden) {
    135     hidden_ = hidden;
    136   }
    137 
    138   // Helper functor that determines if an URLRow refers to a given URL.
    139   class URLRowHasURL {
    140    public:
    141     explicit URLRowHasURL(const GURL& url) : url_(url) {}
    142 
    143     bool operator()(const URLRow& row) {
    144       return row.url() == url_;
    145     }
    146 
    147    private:
    148     const GURL& url_;
    149   };
    150 
    151  protected:
    152   // Swaps the contents of this URLRow with another, which allows it to be
    153   // destructively copied without memory allocations.
    154   void Swap(URLRow* other);
    155 
    156  private:
    157   // This class writes directly into this structure and clears our dirty bits
    158   // when reading out of the DB.
    159   friend class URLDatabase;
    160   friend class HistoryBackend;
    161 
    162   // Initializes all values that need initialization to their defaults.
    163   // This excludes objects which autoinitialize such as strings.
    164   void Initialize();
    165 
    166   // The row ID of this URL from the history database. This is immutable except
    167   // when retrieving the row from the database or when determining if the URL
    168   // referenced by the URLRow already exists in the database.
    169   URLID id_;
    170 
    171   // The URL of this row. Immutable except for the database which sets it
    172   // when it pulls them out. If clients want to change it, they must use
    173   // the constructor to make a new one.
    174   GURL url_;
    175 
    176   string16 title_;
    177 
    178   // Total number of times this URL has been visited.
    179   int visit_count_;
    180 
    181   // Number of times this URL has been manually entered in the URL bar.
    182   int typed_count_;
    183 
    184   // The date of the last visit of this URL, which saves us from having to
    185   // loop up in the visit table for things like autocomplete and expiration.
    186   base::Time last_visit_;
    187 
    188   // Indicates this entry should now be shown in typical UI or queries, this
    189   // is usually for subframes.
    190   bool hidden_;
    191 
    192   // We support the implicit copy constuctor and operator=.
    193 };
    194 typedef std::vector<URLRow> URLRows;
    195 
    196 // The enumeration of all possible sources of visits is listed below.
    197 // The source will be propagated along with a URL or a visit item
    198 // and eventually be stored in the history database,
    199 // visit_source table specifically.
    200 // Different from page transition types, they describe the origins of visits.
    201 // (Warning): Please don't change any existing values while it is ok to add
    202 // new values when needed.
    203 enum VisitSource {
    204   SOURCE_SYNCED = 0,         // Synchronized from somewhere else.
    205   SOURCE_BROWSED = 1,        // User browsed.
    206   SOURCE_EXTENSION = 2,      // Added by an extension.
    207   SOURCE_FIREFOX_IMPORTED = 3,
    208   SOURCE_IE_IMPORTED = 4,
    209   SOURCE_SAFARI_IMPORTED = 5,
    210 };
    211 
    212 typedef int64 VisitID;
    213 // Structure to hold the mapping between each visit's id and its source.
    214 typedef std::map<VisitID, VisitSource> VisitSourceMap;
    215 
    216 // VisitRow -------------------------------------------------------------------
    217 
    218 // Holds all information associated with a specific visit. A visit holds time
    219 // and referrer information for one time a URL is visited.
    220 class VisitRow {
    221  public:
    222   VisitRow();
    223   VisitRow(URLID arg_url_id,
    224            base::Time arg_visit_time,
    225            VisitID arg_referring_visit,
    226            content::PageTransition arg_transition,
    227            SegmentID arg_segment_id);
    228   ~VisitRow();
    229 
    230   // ID of this row (visit ID, used a a referrer for other visits).
    231   VisitID visit_id;
    232 
    233   // Row ID into the URL table of the URL that this page is.
    234   URLID url_id;
    235 
    236   base::Time visit_time;
    237 
    238   // Indicates another visit that was the referring page for this one.
    239   // 0 indicates no referrer.
    240   VisitID referring_visit;
    241 
    242   // A combination of bits from PageTransition.
    243   content::PageTransition transition;
    244 
    245   // The segment id (see visitsegment_database.*).
    246   // If 0, the segment id is null in the table.
    247   SegmentID segment_id;
    248 
    249   // Record how much time a user has this visit starting from the user
    250   // opened this visit to the user closed or ended this visit.
    251   // This includes both active and inactive time as long as
    252   // the visit was present.
    253   base::TimeDelta visit_duration;
    254 
    255   // Compares two visits based on dates, for sorting.
    256   bool operator<(const VisitRow& other) {
    257     return visit_time < other.visit_time;
    258   }
    259 
    260   // We allow the implicit copy constuctor and operator=.
    261 };
    262 
    263 // We pass around vectors of visits a lot
    264 typedef std::vector<VisitRow> VisitVector;
    265 
    266 // The basic information associated with a visit (timestamp, type of visit),
    267 // used by HistoryBackend::AddVisits() to create new visits for a URL.
    268 typedef std::pair<base::Time, content::PageTransition> VisitInfo;
    269 
    270 // PageVisit ------------------------------------------------------------------
    271 
    272 // Represents a simplified version of a visit for external users. Normally,
    273 // views are only interested in the time, and not the other information
    274 // associated with a VisitRow.
    275 struct PageVisit {
    276   URLID page_id;
    277   base::Time visit_time;
    278 };
    279 
    280 // URLResult -------------------------------------------------------------------
    281 
    282 class URLResult : public URLRow {
    283  public:
    284   URLResult();
    285   URLResult(const GURL& url, base::Time visit_time);
    286   // Constructor that create a URLResult from the specified URL and title match
    287   // positions from title_matches.
    288   URLResult(const GURL& url, const Snippet::MatchPositions& title_matches);
    289   explicit URLResult(const URLRow& url_row);
    290   virtual ~URLResult();
    291 
    292   base::Time visit_time() const { return visit_time_; }
    293   void set_visit_time(base::Time visit_time) { visit_time_ = visit_time; }
    294 
    295   const Snippet& snippet() const { return snippet_; }
    296 
    297   bool blocked_visit() const { return blocked_visit_; }
    298   void set_blocked_visit(bool blocked_visit) {
    299     blocked_visit_ = blocked_visit;
    300   }
    301 
    302   // If this is a title match, title_match_positions contains an entry for
    303   // every word in the title that matched one of the query parameters. Each
    304   // entry contains the start and end of the match.
    305   const Snippet::MatchPositions& title_match_positions() const {
    306     return title_match_positions_;
    307   }
    308 
    309   void SwapResult(URLResult* other);
    310 
    311   static bool CompareVisitTime(const URLResult& lhs, const URLResult& rhs);
    312 
    313  private:
    314   friend class HistoryBackend;
    315 
    316   // The time that this result corresponds to.
    317   base::Time visit_time_;
    318 
    319   // These values are typically set by HistoryBackend.
    320   Snippet snippet_;
    321   Snippet::MatchPositions title_match_positions_;
    322 
    323   // Whether a managed user was blocked when attempting to visit this URL.
    324   bool blocked_visit_;
    325 
    326   // We support the implicit copy constructor and operator=.
    327 };
    328 
    329 // QueryResults ----------------------------------------------------------------
    330 
    331 // Encapsulates the results of a history query. It supports an ordered list of
    332 // URLResult objects, plus an efficient way of looking up the index of each time
    333 // a given URL appears in those results.
    334 class QueryResults {
    335  public:
    336   typedef std::vector<URLResult*> URLResultVector;
    337 
    338   QueryResults();
    339   ~QueryResults();
    340 
    341   // Indicates the first time that the query includes results for (queries are
    342   // clipped at the beginning, so it will always include to the end of the time
    343   // queried).
    344   //
    345   // If the number of results was clipped as a result of the max count, this
    346   // will be the time of the first query returned. If there were fewer results
    347   // than we were allowed to return, this represents the first date considered
    348   // in the query (this will be before the first result if there was time
    349   // queried with no results).
    350   //
    351   // TODO(brettw): bug 1203054: This field is not currently set properly! Do
    352   // not use until the bug is fixed.
    353   base::Time first_time_searched() const { return first_time_searched_; }
    354   void set_first_time_searched(base::Time t) { first_time_searched_ = t; }
    355   // Note: If you need end_time_searched, it can be added.
    356 
    357   void set_reached_beginning(bool reached) { reached_beginning_ = reached; }
    358   bool reached_beginning() { return reached_beginning_; }
    359 
    360   size_t size() const { return results_.size(); }
    361   bool empty() const { return results_.empty(); }
    362 
    363   URLResult& back() { return *results_.back(); }
    364   const URLResult& back() const { return *results_.back(); }
    365 
    366   URLResult& operator[](size_t i) { return *results_[i]; }
    367   const URLResult& operator[](size_t i) const { return *results_[i]; }
    368 
    369   URLResultVector::const_iterator begin() const { return results_.begin(); }
    370   URLResultVector::const_iterator end() const { return results_.end(); }
    371   URLResultVector::const_reverse_iterator rbegin() const {
    372     return results_.rbegin();
    373   }
    374   URLResultVector::const_reverse_iterator rend() const {
    375     return results_.rend();
    376   }
    377 
    378   // Returns a pointer to the beginning of an array of all matching indices
    379   // for entries with the given URL. The array will be |*num_matches| long.
    380   // |num_matches| can be NULL if the caller is not interested in the number of
    381   // results (commonly it will only be interested in the first one and can test
    382   // the pointer for NULL).
    383   //
    384   // When there is no match, it will return NULL and |*num_matches| will be 0.
    385   const size_t* MatchesForURL(const GURL& url, size_t* num_matches) const;
    386 
    387   // Swaps the current result with another. This allows ownership to be
    388   // efficiently transferred without copying.
    389   void Swap(QueryResults* other);
    390 
    391   // Adds the given result to the map, using swap() on the members to avoid
    392   // copying (there are a lot of strings and vectors). This means the parameter
    393   // object will be cleared after this call.
    394   void AppendURLBySwapping(URLResult* result);
    395 
    396   // Removes all instances of the given URL from the result set.
    397   void DeleteURL(const GURL& url);
    398 
    399   // Deletes the given range of items in the result set.
    400   void DeleteRange(size_t begin, size_t end);
    401 
    402  private:
    403   // Maps the given URL to a list of indices into results_ which identify each
    404   // time an entry with that URL appears. Normally, each URL will have one or
    405   // very few indices after it, so we optimize this to use statically allocated
    406   // memory when possible.
    407   typedef std::map<GURL, base::StackVector<size_t, 4> > URLToResultIndices;
    408 
    409   // Inserts an entry into the |url_to_results_| map saying that the given URL
    410   // is at the given index in the results_.
    411   void AddURLUsageAtIndex(const GURL& url, size_t index);
    412 
    413   // Adds |delta| to each index in url_to_results_ in the range [begin,end]
    414   // (this is inclusive). This is used when inserting or deleting.
    415   void AdjustResultMap(size_t begin, size_t end, ptrdiff_t delta);
    416 
    417   base::Time first_time_searched_;
    418 
    419   // Whether the query reaches the beginning of the database.
    420   bool reached_beginning_;
    421 
    422   // The ordered list of results. The pointers inside this are owned by this
    423   // QueryResults object.
    424   ScopedVector<URLResult> results_;
    425 
    426   // Maps URLs to entries in results_.
    427   URLToResultIndices url_to_results_;
    428 
    429   DISALLOW_COPY_AND_ASSIGN(QueryResults);
    430 };
    431 
    432 // QueryOptions ----------------------------------------------------------------
    433 
    434 struct QueryOptions {
    435   QueryOptions();
    436 
    437   // The time range to search for matches in. The beginning is inclusive and
    438   // the ending is exclusive. Either one (or both) may be null.
    439   //
    440   // This will match only the one recent visit of a URL. For text search
    441   // queries, if the URL was visited in the given time period, but has also
    442   // been visited more recently than that, it will not be returned. When the
    443   // text query is empty, this will return the most recent visit within the
    444   // time range.
    445   base::Time begin_time;
    446   base::Time end_time;
    447 
    448   // Sets the query time to the last |days_ago| days to the present time.
    449   void SetRecentDayRange(int days_ago);
    450 
    451   // The maximum number of results to return. The results will be sorted with
    452   // the most recent first, so older results may not be returned if there is not
    453   // enough room. When 0, this will return everything (the default).
    454   int max_count;
    455 
    456   enum DuplicateHandling {
    457     // Omit visits for which there is a more recent visit to the same URL.
    458     // Each URL in the results will appear only once.
    459     REMOVE_ALL_DUPLICATES,
    460 
    461     // Omit visits for which there is a more recent visit to the same URL on
    462     // the same day. Each URL will appear no more than once per day, where the
    463     // day is defined by the local timezone.
    464     REMOVE_DUPLICATES_PER_DAY,
    465 
    466     // Return all visits without deduping.
    467     KEEP_ALL_DUPLICATES
    468   };
    469 
    470   // Allows the caller to specify how duplicate URLs in the result set should
    471   // be handled. The default is REMOVE_DUPLICATES.
    472   DuplicateHandling duplicate_policy;
    473 
    474   // Helpers to get the effective parameters values, since a value of 0 means
    475   // "unspecified".
    476   int EffectiveMaxCount() const;
    477   int64 EffectiveBeginTime() const;
    478   int64 EffectiveEndTime() const;
    479 };
    480 
    481 // KeywordSearchTermVisit -----------------------------------------------------
    482 
    483 // KeywordSearchTermVisit is returned from GetMostRecentKeywordSearchTerms. It
    484 // gives the time and search term of the keyword visit.
    485 struct KeywordSearchTermVisit {
    486   KeywordSearchTermVisit();
    487   ~KeywordSearchTermVisit();
    488 
    489   string16 term;    // The search term that was used.
    490   int visits;       // The visit count.
    491   base::Time time;  // The time of the most recent visit.
    492 };
    493 
    494 // KeywordSearchTermRow --------------------------------------------------------
    495 
    496 // Used for URLs that have a search term associated with them.
    497 struct KeywordSearchTermRow {
    498   KeywordSearchTermRow();
    499   ~KeywordSearchTermRow();
    500 
    501   TemplateURLID keyword_id;  // ID of the keyword.
    502   URLID url_id;              // ID of the url.
    503   string16 term;             // The search term that was used.
    504 };
    505 
    506 // MostVisitedURL --------------------------------------------------------------
    507 
    508 // Holds the per-URL information of the most visited query.
    509 struct MostVisitedURL {
    510   MostVisitedURL();
    511   MostVisitedURL(const GURL& url, const string16& title);
    512   ~MostVisitedURL();
    513 
    514   GURL url;
    515   string16 title;
    516 
    517   RedirectList redirects;
    518 
    519   bool operator==(const MostVisitedURL& other) {
    520     return url == other.url;
    521   }
    522 };
    523 
    524 // FilteredURL -----------------------------------------------------------------
    525 
    526 // Holds the per-URL information of the filterd url query.
    527 struct FilteredURL {
    528   struct ExtendedInfo {
    529     ExtendedInfo();
    530     // The absolute number of visits.
    531     unsigned int total_visits;
    532     // The number of visits, as seen by the Most Visited NTP pane.
    533     unsigned int visits;
    534     // The total number of seconds that the page was open.
    535     int64 duration_opened;
    536     // The time when the page was last visited.
    537     base::Time last_visit_time;
    538   };
    539 
    540   FilteredURL();
    541   explicit FilteredURL(const PageUsageData& data);
    542   ~FilteredURL();
    543 
    544   GURL url;
    545   string16 title;
    546   double score;
    547   ExtendedInfo extended_info;
    548 };
    549 
    550 // Navigation -----------------------------------------------------------------
    551 
    552 // Marshalling structure for AddPage.
    553 struct HistoryAddPageArgs {
    554   // The default constructor is equivalent to:
    555   //
    556   //   HistoryAddPageArgs(
    557   //       GURL(), base::Time(), NULL, 0, GURL(),
    558   //       history::RedirectList(), content::PAGE_TRANSITION_LINK,
    559   //       SOURCE_BROWSED, false)
    560   HistoryAddPageArgs();
    561   HistoryAddPageArgs(const GURL& url,
    562                      base::Time time,
    563                      const void* id_scope,
    564                      int32 page_id,
    565                      const GURL& referrer,
    566                      const history::RedirectList& redirects,
    567                      content::PageTransition transition,
    568                      VisitSource source,
    569                      bool did_replace_entry);
    570   ~HistoryAddPageArgs();
    571 
    572   GURL url;
    573   base::Time time;
    574 
    575   const void* id_scope;
    576   int32 page_id;
    577 
    578   GURL referrer;
    579   history::RedirectList redirects;
    580   content::PageTransition transition;
    581   VisitSource visit_source;
    582   bool did_replace_entry;
    583 };
    584 
    585 // TopSites -------------------------------------------------------------------
    586 
    587 typedef std::vector<MostVisitedURL> MostVisitedURLList;
    588 typedef std::vector<FilteredURL> FilteredURLList;
    589 
    590 // Used by TopSites to store the thumbnails.
    591 struct Images {
    592   Images();
    593   ~Images();
    594 
    595   scoped_refptr<base::RefCountedMemory> thumbnail;
    596   ThumbnailScore thumbnail_score;
    597 
    598   // TODO(brettw): this will eventually store the favicon.
    599   // scoped_refptr<base::RefCountedBytes> favicon;
    600 };
    601 
    602 struct MostVisitedURLWithRank {
    603   MostVisitedURL url;
    604   int rank;
    605 };
    606 
    607 typedef std::vector<MostVisitedURLWithRank> MostVisitedURLWithRankList;
    608 
    609 struct TopSitesDelta {
    610   TopSitesDelta();
    611   ~TopSitesDelta();
    612 
    613   MostVisitedURLList deleted;
    614   MostVisitedURLWithRankList added;
    615   MostVisitedURLWithRankList moved;
    616 };
    617 
    618 typedef std::map<GURL, scoped_refptr<base::RefCountedBytes> > URLToThumbnailMap;
    619 
    620 // Used when migrating most visited thumbnails out of history and into topsites.
    621 struct ThumbnailMigration {
    622   ThumbnailMigration();
    623   ~ThumbnailMigration();
    624 
    625   MostVisitedURLList most_visited;
    626   URLToThumbnailMap url_to_thumbnail_map;
    627 };
    628 
    629 typedef std::map<GURL, Images> URLToImagesMap;
    630 
    631 class MostVisitedThumbnails
    632     : public base::RefCountedThreadSafe<MostVisitedThumbnails> {
    633  public:
    634   MostVisitedThumbnails();
    635 
    636   MostVisitedURLList most_visited;
    637   URLToImagesMap url_to_images_map;
    638 
    639  private:
    640   friend class base::RefCountedThreadSafe<MostVisitedThumbnails>;
    641   virtual ~MostVisitedThumbnails();
    642 
    643   DISALLOW_COPY_AND_ASSIGN(MostVisitedThumbnails);
    644 };
    645 
    646 // Autocomplete thresholds -----------------------------------------------------
    647 
    648 // Constants which specify, when considered altogether, 'significant'
    649 // history items. These are used to filter out insignificant items
    650 // for consideration as autocomplete candidates.
    651 extern const int kLowQualityMatchTypedLimit;
    652 extern const int kLowQualityMatchVisitLimit;
    653 extern const int kLowQualityMatchAgeLimitInDays;
    654 
    655 // Returns the date threshold for considering an history item as significant.
    656 base::Time AutocompleteAgeThreshold();
    657 
    658 // Return true if |row| qualifies as an autocomplete candidate. If |time_cache|
    659 // is_null() then this function determines a new time threshold each time it is
    660 // called. Since getting system time can be costly (such as for cases where
    661 // this function will be called in a loop over many history items), you can
    662 // provide a non-null |time_cache| by simply initializing |time_cache| with
    663 // AutocompleteAgeThreshold() (or any other desired time in the past).
    664 bool RowQualifiesAsSignificant(const URLRow& row, const base::Time& threshold);
    665 
    666 // Favicons -------------------------------------------------------------------
    667 
    668 // Used for the mapping between the page and icon.
    669 struct IconMapping {
    670   IconMapping();
    671   ~IconMapping();
    672 
    673   // The unique id of the mapping.
    674   IconMappingID mapping_id;
    675 
    676   // The url of a web page.
    677   GURL page_url;
    678 
    679   // The unique id of the icon.
    680   chrome::FaviconID icon_id;
    681 
    682   // The url of the icon.
    683   GURL icon_url;
    684 
    685   // The type of icon.
    686   chrome::IconType icon_type;
    687 };
    688 
    689 // Defines a favicon bitmap and its associated pixel size.
    690 struct FaviconBitmapIDSize {
    691   FaviconBitmapIDSize();
    692   ~FaviconBitmapIDSize();
    693 
    694   // The unique id of the favicon bitmap.
    695   FaviconBitmapID bitmap_id;
    696 
    697   // The pixel dimensions of the associated bitmap.
    698   gfx::Size pixel_size;
    699 };
    700 
    701 // Defines a favicon bitmap stored in the history backend.
    702 struct FaviconBitmap {
    703   FaviconBitmap();
    704   ~FaviconBitmap();
    705 
    706   // The unique id of the bitmap.
    707   FaviconBitmapID bitmap_id;
    708 
    709   // The id of the favicon to which the bitmap belongs to.
    710   chrome::FaviconID icon_id;
    711 
    712   // Time at which |bitmap_data| was last updated.
    713   base::Time last_updated;
    714 
    715   // The bits of the bitmap.
    716   scoped_refptr<base::RefCountedMemory> bitmap_data;
    717 
    718   // The pixel dimensions of bitmap_data.
    719   gfx::Size pixel_size;
    720 };
    721 
    722 // Abbreviated information about a visit.
    723 struct BriefVisitInfo {
    724   URLID url_id;
    725   base::Time time;
    726   content::PageTransition transition;
    727 };
    728 
    729 // An observer of VisitDatabase.
    730 class VisitDatabaseObserver {
    731  public:
    732   virtual ~VisitDatabaseObserver();
    733   virtual void OnAddVisit(const BriefVisitInfo& info) = 0;
    734 };
    735 
    736 struct ExpireHistoryArgs {
    737   ExpireHistoryArgs();
    738   ~ExpireHistoryArgs();
    739 
    740   // Sets |begin_time| and |end_time| to the beginning and end of the day (in
    741   // local time) on which |time| occurs.
    742   void SetTimeRangeForOneDay(base::Time time);
    743 
    744   std::set<GURL> urls;
    745   base::Time begin_time;
    746   base::Time end_time;
    747 };
    748 
    749 }  // namespace history
    750 
    751 #endif  // CHROME_BROWSER_HISTORY_HISTORY_TYPES_H_
    752