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