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

Side by Side Diff: chrome/browser/history/history_backend.h

Issue 10802066: Adds support for saving favicon size into history database. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes as requested by Sky and stevenjb Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_
6 #define CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ 6 #define CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_
7 7
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 // 241 //
242 // Exposed for testing reasons. 242 // Exposed for testing reasons.
243 void GetPageThumbnailDirectly( 243 void GetPageThumbnailDirectly(
244 const GURL& page_url, 244 const GURL& page_url,
245 scoped_refptr<base::RefCountedBytes>* data); 245 scoped_refptr<base::RefCountedBytes>* data);
246 246
247 void MigrateThumbnailsDatabase(); 247 void MigrateThumbnailsDatabase();
248 248
249 // Favicon ------------------------------------------------------------------- 249 // Favicon -------------------------------------------------------------------
250 250
251 void GetFavicon(scoped_refptr<GetFaviconRequest> request, 251 void GetFaviconClosestToSize(scoped_refptr<GetFaviconRequest> request,
252 const GURL& icon_url, 252 const GURL& icon_url,
253 int icon_types); 253 int icon_types,
254 const gfx::Size& pixel_size);
254 255
255 void GetFaviconForURL(scoped_refptr<GetFaviconRequest> request, 256 void GetFavicons(scoped_refptr<GetFaviconRequest> request,
256 const GURL& page_url, 257 const std::vector<GURL>& icon_urls,
257 int icon_types); 258 int icon_types);
258 259
259 void GetFaviconForID(scoped_refptr<GetFaviconRequest> request, FaviconID id); 260 void GetFaviconForURLClosestToSize(scoped_refptr<GetFaviconRequest> request,
261 const GURL& page_url,
262 int icon_types,
263 const gfx::Size& pixel_size);
260 264
261 void SetFavicon(const GURL& page_url, 265 void GetFaviconsForURL(scoped_refptr<GetFaviconRequest> request,
262 const GURL& icon_url, 266 const GURL& page_url,
263 scoped_refptr<base::RefCountedMemory> data, 267 int icon_types);
264 IconType icon_type);
265 268
266 void UpdateFaviconMappingAndFetch(scoped_refptr<GetFaviconRequest> request, 269 void UpdateFaviconMappingsAndFetch(scoped_refptr<GetFaviconRequest> request,
267 const GURL& page_url, 270 const GURL& page_url,
268 const GURL& icon_url, 271 const std::vector<GURL>& icon_urls,
269 IconType icon_type); 272 IconType icon_type);
270 273
271 void SetFaviconOutOfDateForPage(const GURL& page_url); 274 void AddFavicons(const GURL& page_url,
275 IconType icon_type,
276 const std::vector<FaviconDataElement>& elements);
277
278 void SetFavicons(const GURL& page_url,
279 IconType icon_type,
280 const std::vector<FaviconDataElement>& elements,
281 const IconURLSizesMap& icon_url_sizes);
282
283 void SetFaviconsOutOfDateForPage(const GURL& page_url);
272 284
273 void CloneFavicon(const GURL& old_page_url, const GURL& new_page_url); 285 void CloneFavicon(const GURL& old_page_url, const GURL& new_page_url);
274 286
275 void SetImportedFavicons( 287 void SetImportedFavicons(
276 const std::vector<ImportedFaviconUsage>& favicon_usage); 288 const std::vector<ImportedFaviconUsage>& favicon_usage);
277 289
278 // Downloads ----------------------------------------------------------------- 290 // Downloads -----------------------------------------------------------------
279 291
280 void GetNextDownloadId(scoped_refptr<DownloadNextIdRequest> request); 292 void GetNextDownloadId(scoped_refptr<DownloadNextIdRequest> request);
281 void QueryDownloads(scoped_refptr<DownloadQueryRequest> request); 293 void QueryDownloads(scoped_refptr<DownloadQueryRequest> request);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, URLsNoLongerBookmarked); 468 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, URLsNoLongerBookmarked);
457 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, StripUsernamePasswordTest); 469 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, StripUsernamePasswordTest);
458 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteThumbnailsDatabaseTest); 470 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteThumbnailsDatabaseTest);
459 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddPageVisitSource); 471 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddPageVisitSource);
460 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddPageArgsSource); 472 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddPageArgsSource);
461 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddVisitsSource); 473 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddVisitsSource);
462 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, RemoveVisitsSource); 474 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, RemoveVisitsSource);
463 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, RemoveVisitsTransitions); 475 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, RemoveVisitsTransitions);
464 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MigrationVisitSource); 476 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MigrationVisitSource);
465 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MigrationIconMapping); 477 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MigrationIconMapping);
466 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, SetFaviconMapping); 478 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
467 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddOrUpdateIconMapping); 479 SetFaviconMappingsForPageAndRedirects);
480 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
481 SetFaviconMappingsForPageDuplicates);
482 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, SetFavicons);
483 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, SetFaviconsDeleteBitmaps);
484 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, SetFaviconsReplaceBitmapData);
468 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetMostRecentVisits); 485 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetMostRecentVisits);
469 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconForURL); 486 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDB);
487 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBExpired);
488 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBDesiredSize);
489 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBIconType);
490 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBEmpty);
470 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 491 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
471 CloneFaviconIsRestrictedToSameDomain); 492 CloneFaviconIsRestrictedToSameDomain);
472 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, QueryFilteredURLs); 493 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, QueryFilteredURLs);
473 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, UpdateVisitDuration); 494 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, UpdateVisitDuration);
474 495
475 friend class ::TestingProfile; 496 friend class ::TestingProfile;
476 497
477 // Computes the name of the specified database on disk. 498 // Computes the name of the specified database on disk.
478 FilePath GetThumbnailFileName() const; 499 FilePath GetThumbnailFileName() const;
479 500
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 // Update the segment information. This is called internally when a page is 592 // Update the segment information. This is called internally when a page is
572 // added. Return the segment id of the segment that has been updated. 593 // added. Return the segment id of the segment that has been updated.
573 SegmentID UpdateSegments(const GURL& url, 594 SegmentID UpdateSegments(const GURL& url,
574 VisitID from_visit, 595 VisitID from_visit,
575 VisitID visit_id, 596 VisitID visit_id,
576 content::PageTransition transition_type, 597 content::PageTransition transition_type,
577 const base::Time ts); 598 const base::Time ts);
578 599
579 // Favicons ------------------------------------------------------------------ 600 // Favicons ------------------------------------------------------------------
580 601
581 // Used by both UpdateFaviconMappingAndFetch and GetFavicon. 602 // Used by UpdateFaviconMappingsAndFetch, GetFavicons and
582 // If page_url is non-null and SetFavicon has previously been invoked for 603 // GetFaviconClosestToSize.
583 // icon_url the favicon url for page_url (and all redirects) is set to 604 // If |page_url| is non-null, the icon urls for |page_url| (and all
584 // icon_url. 605 // redirects) are set to the subset of |icon_urls| for which icons are
606 // already stored in the database.
585 // Only a single type can be given in icon_type when page_url is specified. 607 // Only a single type can be given in icon_type when page_url is specified.
586 void UpdateFaviconMappingAndFetchImpl( 608 void UpdateFaviconMappingsAndFetchImpl(
587 const GURL* page_url, 609 const GURL* page_url,
588 const GURL& icon_url, 610 const std::vector<GURL>& icon_urls,
589 scoped_refptr<GetFaviconRequest> request, 611 scoped_refptr<GetFaviconRequest> request,
590 int icon_type); 612 int icon_types,
613 const gfx::Size* desired_pixel_size);
stevenjb 2012/08/15 22:59:18 Why a const* here instead of a const&?
591 614
592 // Sets the favicon url id for page_url to id. This will also broadcast 615 // Set the favicon bitmaps for the favicon at |icon_id|.
593 // notifications as necessary. 616 void SetFaviconBitmaps(FaviconID icon_id,
594 void SetFaviconMapping(const GURL& page_url, 617 const std::vector<FaviconDataElement>& elements);
595 FaviconID id,
596 IconType icon_type);
597 618
598 // Updates the FaviconID associated with the url of a page. If there is an 619 // Returns true if the params passed to SetFavicons: |elements| and
599 // existing mapping between |page_url| and |id| this does nothing and returns 620 // |icon_url_sizes| are valid.
600 // false. If the mapping needs to be added or updated, true is returned. If 621 bool ValidateSetFaviconsParams(
601 // there is an existing mapping but it does not map to |id|, then the |id| of 622 const std::vector<FaviconDataElement>& elements,
602 // the replaced FaviconID is set in |replaced_icon_id|. 623 const IconURLSizesMap& icon_url_sizes) const;
603 bool AddOrUpdateIconMapping(const GURL& page_url, 624
604 FaviconID id, 625 // Sets the sizes that the thumbnail database knows that the favicon at
605 IconType icon_type, 626 // |icon_id| is available at from the web. See history_types for a more
606 FaviconID* replaced_icon_id); 627 // in depth discussion about FaviconSizes.
628 void SetFaviconSizes(FaviconID icon_id,
629 const FaviconSizes& sizes);
630
631 // If there are favicons for |page_url| and one of the types in
632 // |icon_types|, |favicon_data| is set appropriately and true is returned.
633 // If |desired_pixel_size| is non NULL, |favicon_data| is set to the favicon
634 // bitmap which most closely matches |desired_pixel_size|.
635 bool GetFaviconsFromDB(const GURL& page_url,
636 int icon_types,
637 const gfx::Size* desired_pixel_size,
638 FaviconData* favicon_data);
639
640 // Add data for the favicon at |favicon_id| to |favicon_data|.
641 // As FaviconData only contains FaviconDataElements for a single IconType,
642 // the IconType of the favicon at favicon_id must match that of previous
643 // |FaviconData::elements|.
644 // Returns true on success.
645 bool AddToFaviconData(FaviconID favicon_id,
646 const gfx::Size* desired_pixel_size,
647 FaviconData* favicon_data);
648
649 // Returns index of the element in |elements| whose pixel size most closely
650 // matches |desired_pixel_size|.
651 int GetBestElementForSizeIndex(
652 const std::vector<FaviconDataElement>& elements,
653 const gfx::Size& desired_pixel_size) const;
654
655 // Define type used solely in SetFaviconMappingsForPageAndRedirects.
656 typedef std::map<GURL, FaviconID> IconURLFaviconIDMap;
657
658 // Updates the favicon ids for |icon_type| and |page_url| (including any
659 // redirects) to the favicon ids in |icon_url_id_map|. This will also
660 // broadcast notifications as necessary.
661 void SetFaviconMappingsForPageAndRedirects(
662 const GURL& page_url,
663 const IconType icon_type,
664 const IconURLFaviconIDMap& icon_url_id_map);
665
666 // Updates the favicon ids for |icon_type| and |page_url| to the ids in
667 // |icon_url_id_map|.
668 bool SetFaviconMappingsForPage(const GURL& page_url,
669 IconType icon_type,
670 const IconURLFaviconIDMap& icon_url_id_map);
607 671
608 // Generic stuff ------------------------------------------------------------- 672 // Generic stuff -------------------------------------------------------------
609 673
610 // Processes the next scheduled HistoryDBTask, scheduling this method 674 // Processes the next scheduled HistoryDBTask, scheduling this method
611 // to be invoked again if there are more tasks that need to run. 675 // to be invoked again if there are more tasks that need to run.
612 void ProcessDBTaskImpl(); 676 void ProcessDBTaskImpl();
613 677
614 // Release all tasks in history_db_tasks_ and clears it. 678 // Release all tasks in history_db_tasks_ and clears it.
615 void ReleaseDBTasks(); 679 void ReleaseDBTasks();
616 680
(...skipping 23 matching lines...) Expand all
640 // set of URLs in the URL table (these should correspond to the bookmarked 704 // set of URLs in the URL table (these should correspond to the bookmarked
641 // URLs). 705 // URLs).
642 // 706 //
643 // The IDs of the URLs may change. 707 // The IDs of the URLs may change.
644 bool ClearAllMainHistory(const URLRows& kept_urls); 708 bool ClearAllMainHistory(const URLRows& kept_urls);
645 709
646 // Returns the BookmarkService, blocking until it is loaded. This may return 710 // Returns the BookmarkService, blocking until it is loaded. This may return
647 // NULL during testing. 711 // NULL during testing.
648 BookmarkService* GetBookmarkService(); 712 BookmarkService* GetBookmarkService();
649 713
650 // If there is a favicon for |page_url| and one of the types in |icon_types|,
651 // |favicon| is set appropriately and true is returned.
652 bool GetFaviconFromDB(const GURL& page_url,
653 int icon_types,
654 FaviconData* favicon);
655
656 // Get favicon by the given |favicon_id|, the |favicon| is set appropriately
657 // and true if returned on success, otherwise false is returned.
658 bool GetFaviconFromDB(FaviconID favicon_id, FaviconData* favicon);
659
660 // Notify any observers of an addition to the visit database. 714 // Notify any observers of an addition to the visit database.
661 void NotifyVisitObservers(const VisitRow& visit); 715 void NotifyVisitObservers(const VisitRow& visit);
662 716
663 // Data ---------------------------------------------------------------------- 717 // Data ----------------------------------------------------------------------
664 718
665 // Delegate. See the class definition above for more information. This will 719 // Delegate. See the class definition above for more information. This will
666 // be NULL before Init is called and after Cleanup, but is guaranteed 720 // be NULL before Init is called and after Cleanup, but is guaranteed
667 // non-NULL in between. 721 // non-NULL in between.
668 scoped_ptr<Delegate> delegate_; 722 scoped_ptr<Delegate> delegate_;
669 723
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 // Used to provide the Android ContentProvider APIs. 809 // Used to provide the Android ContentProvider APIs.
756 scoped_ptr<AndroidProviderBackend> android_provider_backend_; 810 scoped_ptr<AndroidProviderBackend> android_provider_backend_;
757 #endif 811 #endif
758 812
759 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); 813 DISALLOW_COPY_AND_ASSIGN(HistoryBackend);
760 }; 814 };
761 815
762 } // namespace history 816 } // namespace history
763 817
764 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ 818 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698