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

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

Issue 10802066: Adds support for saving favicon size into history database. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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_H_ 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_H_
6 #define CHROME_BROWSER_HISTORY_HISTORY_H_ 6 #define CHROME_BROWSER_HISTORY_HISTORY_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 682
683 // Favicon ------------------------------------------------------------------- 683 // Favicon -------------------------------------------------------------------
684 684
685 // These favicon methods are exposed to the FaviconService. Instead of calling 685 // These favicon methods are exposed to the FaviconService. Instead of calling
686 // these methods directly you should call the respective method on the 686 // these methods directly you should call the respective method on the
687 // FaviconService. 687 // FaviconService.
688 688
689 // Used by the FaviconService to get a favicon from the history backend. 689 // Used by the FaviconService to get a favicon from the history backend.
690 void GetFavicon(FaviconService::GetFaviconRequest* request, 690 void GetFavicon(FaviconService::GetFaviconRequest* request,
691 const GURL& icon_url, 691 const GURL& icon_url,
692 const gfx::Size& pixel_size,
692 history::IconType icon_type); 693 history::IconType icon_type);
693 694
694 // Used by the FaviconService to update the favicon mappings on the history 695 // Used by the FaviconService to update the favicon mappings on the history
695 // backend. 696 // backend.
696 void UpdateFaviconMappingAndFetch(FaviconService::GetFaviconRequest* request, 697 void UpdateFaviconMappingAndFetch(FaviconService::GetFaviconRequest* request,
697 const GURL& page_url, 698 const GURL& page_url,
698 const GURL& icon_url, 699 const GURL& icon_url,
700 const gfx::Size& pixel_size,
699 history::IconType icon_type); 701 history::IconType icon_type);
700 702
701 // Used by the FaviconService to get a favicon from the history backend. 703 // Used by the FaviconService to get a favicon from the history backend.
702 void GetFaviconForURL(FaviconService::GetFaviconRequest* request, 704 void GetFaviconForURL(FaviconService::GetFaviconRequest* request,
703 const GURL& page_url, 705 const GURL& page_url,
706 const gfx::Size& pixel_size,
704 int icon_types); 707 int icon_types);
705 708
706 // Used by the FaviconService to get a favicon from the history backend. 709 // Used by the FaviconService to get a favicon from the history backend.
707 void GetFaviconForID(FaviconService::GetFaviconRequest* request, 710 void GetFaviconForID(FaviconService::GetFaviconRequest* request,
708 history::FaviconID id); 711 history::FaviconID id);
709 712
710 // Used by the FaviconService to mark the favicon for the page as being out 713 // Used by the FaviconService to mark the favicon for the page as being out
711 // of date. 714 // of date.
712 void SetFaviconOutOfDateForPage(const GURL& page_url); 715 void SetFaviconOutOfDateForPage(const GURL& page_url);
713 716
714 // Used by the FaviconService to clone favicons from one page to another, 717 // Used by the FaviconService to clone favicons from one page to another,
715 // provided that other page does not already have favicons. 718 // provided that other page does not already have favicons.
716 void CloneFavicon(const GURL& old_page_url, const GURL& new_page_url); 719 void CloneFavicon(const GURL& old_page_url, const GURL& new_page_url);
717 720
718 // Used by the FaviconService for importing many favicons for many pages at 721 // Used by the FaviconService for importing many favicons for many pages at
719 // once. The pages must exist, any favicon sets for unknown pages will be 722 // once. The pages must exist, any favicon sets for unknown pages will be
720 // discarded. Existing favicons will not be overwritten. 723 // discarded. Existing favicons will not be overwritten.
721 void SetImportedFavicons( 724 void SetImportedFavicons(
722 const std::vector<history::ImportedFaviconUsage>& favicon_usage); 725 const std::vector<history::ImportedFaviconUsage>& favicon_usage);
723 726
724 // Used by the FaviconService to set the favicon for a page on the history 727 // Used by the FaviconService to set the favicon for a page on the history
725 // backend. 728 // backend.
729 // |requested size| is the size which was used to search for |image_data|
730 // for which |image_data| is the best match from |page_url|'s favicons.
731 // This does not necessarily correspond to the favicon's pixel size.
732 // For instance, if the ideal favicon size is 16x16 but the best match is
733 // a 10x16 favicon, |requested_size| is 16x16.
734 // TODO(pkotwicz): Add a parameter for the favicon's pixel size.
726 void SetFavicon(const GURL& page_url, 735 void SetFavicon(const GURL& page_url,
727 const GURL& icon_url, 736 const GURL& icon_url,
728 const std::vector<unsigned char>& image_data, 737 const std::vector<unsigned char>& image_data,
738 const gfx::Size& requested_size,
729 history::IconType icon_type); 739 history::IconType icon_type);
730 740
731
732 // Sets the in-memory URL database. This is called by the backend once the 741 // Sets the in-memory URL database. This is called by the backend once the
733 // database is loaded to make it available. 742 // database is loaded to make it available.
734 void SetInMemoryBackend(int backend_id, 743 void SetInMemoryBackend(int backend_id,
735 history::InMemoryHistoryBackend* mem_backend); 744 history::InMemoryHistoryBackend* mem_backend);
736 745
737 // Called by our BackendDelegate when there is a problem reading the database. 746 // Called by our BackendDelegate when there is a problem reading the database.
738 void NotifyProfileError(int backend_id, sql::InitStatus init_status); 747 void NotifyProfileError(int backend_id, sql::InitStatus init_status);
739 748
740 // Call to schedule a given task for running on the history thread with the 749 // Call to schedule a given task for running on the history thread with the
741 // specified priority. The task will have ownership taken. 750 // specified priority. The task will have ownership taken.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 LoadBackendIfNecessary(); 847 LoadBackendIfNecessary();
839 if (consumer) 848 if (consumer)
840 AddRequest(request, consumer); 849 AddRequest(request, consumer);
841 ScheduleTask(priority, 850 ScheduleTask(priority,
842 base::Bind(func, history_backend_.get(), 851 base::Bind(func, history_backend_.get(),
843 scoped_refptr<RequestType>(request), 852 scoped_refptr<RequestType>(request),
844 a, b, c, d)); 853 a, b, c, d));
845 return request->handle(); 854 return request->handle();
846 } 855 }
847 856
857 template<typename BackendFunc,
858 class RequestType, // Descendant of CancelableRequstBase.
859 typename ArgA,
860 typename ArgB,
861 typename ArgC,
862 typename ArgD,
863 typename ArgE>
864 Handle Schedule(SchedulePriority priority,
865 BackendFunc func, // Function to call on the HistoryBackend.
866 CancelableRequestConsumerBase* consumer,
867 RequestType* request,
868 const ArgA& a,
869 const ArgB& b,
870 const ArgC& c,
871 const ArgD& d,
872 const ArgE& e) {
873 DCHECK(thread_) << "History service being called after cleanup";
874 LoadBackendIfNecessary();
875 if (consumer)
876 AddRequest(request, consumer);
877 ScheduleTask(priority,
878 base::Bind(func, history_backend_.get(),
879 scoped_refptr<RequestType>(request),
880 a, b, c, d, e));
881 return request->handle();
882 }
883
848 // ScheduleAndForget --------------------------------------------------------- 884 // ScheduleAndForget ---------------------------------------------------------
849 // 885 //
850 // Functions for scheduling operations on the history thread that do not need 886 // Functions for scheduling operations on the history thread that do not need
851 // any callbacks and are not cancelable. 887 // any callbacks and are not cancelable.
852 888
853 template<typename BackendFunc> 889 template<typename BackendFunc>
854 void ScheduleAndForget(SchedulePriority priority, 890 void ScheduleAndForget(SchedulePriority priority,
855 BackendFunc func) { // Function to call on backend. 891 BackendFunc func) { // Function to call on backend.
856 DCHECK(thread_) << "History service being called after cleanup"; 892 DCHECK(thread_) << "History service being called after cleanup";
857 LoadBackendIfNecessary(); 893 LoadBackendIfNecessary();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 const ArgA& a, 934 const ArgA& a,
899 const ArgB& b, 935 const ArgB& b,
900 const ArgC& c, 936 const ArgC& c,
901 const ArgD& d) { 937 const ArgD& d) {
902 DCHECK(thread_) << "History service being called after cleanup"; 938 DCHECK(thread_) << "History service being called after cleanup";
903 LoadBackendIfNecessary(); 939 LoadBackendIfNecessary();
904 ScheduleTask(priority, base::Bind(func, history_backend_.get(), 940 ScheduleTask(priority, base::Bind(func, history_backend_.get(),
905 a, b, c, d)); 941 a, b, c, d));
906 } 942 }
907 943
944 template<typename BackendFunc,
945 typename ArgA,
946 typename ArgB,
947 typename ArgC,
948 typename ArgD,
949 typename ArgE>
950 void ScheduleAndForget(SchedulePriority priority,
951 BackendFunc func, // Function to call on backend.
952 const ArgA& a,
953 const ArgB& b,
954 const ArgC& c,
955 const ArgD& d,
956 const ArgE& e) {
957 DCHECK(thread_) << "History service being called after cleanup";
958 LoadBackendIfNecessary();
959 ScheduleTask(priority, base::Bind(func, history_backend_.get(),
960 a, b, c, d, e));
961 }
962
908 content::NotificationRegistrar registrar_; 963 content::NotificationRegistrar registrar_;
909 964
910 // Some void primitives require some internal processing in the main thread 965 // Some void primitives require some internal processing in the main thread
911 // when done. We use this internal consumer for this purpose. 966 // when done. We use this internal consumer for this purpose.
912 CancelableRequestConsumer internal_consumer_; 967 CancelableRequestConsumer internal_consumer_;
913 968
914 // The thread used by the history service to run complicated operations. 969 // The thread used by the history service to run complicated operations.
915 // |thread_| is NULL once |Cleanup| is NULL. 970 // |thread_| is NULL once |Cleanup| is NULL.
916 base::Thread* thread_; 971 base::Thread* thread_;
917 972
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 // The index used for quick history lookups. 1005 // The index used for quick history lookups.
951 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; 1006 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_;
952 1007
953 scoped_refptr<ObserverListThreadSafe<history::VisitDatabaseObserver> > 1008 scoped_refptr<ObserverListThreadSafe<history::VisitDatabaseObserver> >
954 visit_database_observers_; 1009 visit_database_observers_;
955 1010
956 DISALLOW_COPY_AND_ASSIGN(HistoryService); 1011 DISALLOW_COPY_AND_ASSIGN(HistoryService);
957 }; 1012 };
958 1013
959 #endif // CHROME_BROWSER_HISTORY_HISTORY_H_ 1014 #endif // CHROME_BROWSER_HISTORY_HISTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698