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

Unified 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: Changes as requested Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/history/history.h
diff --git a/chrome/browser/history/history.h b/chrome/browser/history/history.h
index 20a7ec1084248b63c71c59ae1880440b22032bfd..f2c0cd810aa695c746c2d0be73cd5706641da906 100644
--- a/chrome/browser/history/history.h
+++ b/chrome/browser/history/history.h
@@ -25,6 +25,7 @@
#include "content/public/browser/notification_registrar.h"
#include "content/public/common/page_transition_types.h"
#include "sql/init_status.h"
+#include "ui/base/layout.h"
#if defined(OS_ANDROID)
#include "chrome/browser/history/android/android_history_provider_service.h"
@@ -689,34 +690,79 @@ class HistoryService : public CancelableRequestProvider,
// these methods directly you should call the respective method on the
// FaviconService.
+ // Used by FaviconService to get all the favicon bitmaps from the history
+ // backend for the favicons at |icon_urls|.
+ void GetFavicons(FaviconService::GetFaviconRequest* request,
+ const std::vector<GURL>& icon_urls,
+ int icon_types,
+ int desired_size_in_dip,
+ const std::vector<ui::ScaleFactor>& desired_scale_factors);
+
+ // Used by the FaviconService to get all the favicons mapped to |page_url|
+ // from the history backend.
michaelbai 2012/09/04 21:18:53 From the comments it is not clear to me that, how
pkotwicz 2012/09/04 22:40:54 You cannot get all of the favicon bitmaps from thi
+ void GetFaviconsForURL(
+ FaviconService::GetFaviconRequest* request,
+ const GURL& page_url,
+ int icon_types,
+ int desired_size_in_dip,
+ const std::vector<ui::ScaleFactor>& desired_scale_factors);
+
// Used by the FaviconService to get a favicon from the history backend.
- void GetFavicon(FaviconService::GetFaviconRequest* request,
- const GURL& icon_url,
- history::IconType icon_type);
+ void GetFaviconForID(FaviconService::GetFaviconRequest* request,
+ history::FaviconID id,
+ int desired_size_in_dip,
+ ui::ScaleFactor desired_scale_facot);
// Used by the FaviconService to update the favicon mappings on the history
+ // backend for favicons of type FAVICON.
+ // |icon_urls| is a list of all the favicon URLs known for |page_url|. It is
+ // important for this list to be complete as any favicons mapped to
+ // |page_url| whose icon URL is not in |icon_urls| will be deleted.
michaelbai 2012/09/04 21:18:53 The comment didn't say how the parameters icon_typ
pkotwicz 2012/09/04 22:40:54 I have updated the comments in this file in patch
+ void UpdateFaviconMappingsAndFetch(
+ FaviconService::GetFaviconRequest* request,
+ const GURL& page_url,
+ const std::vector<GURL>& icon_urls,
+ int icon_types,
+ int desired_size_in_dip,
+ const std::vector<ui::ScaleFactor>& desired_scale_factors);
+
+ // Used by the FaviconService to add favicons for a page on the history
+ // backend. This method queries for the IconURLSizesMap from |page_url|. If
+ // unavailable, a guess at what IconURLSizesMap should be is used. This
+ // function is inefficient. Do not use if at all possible.
+ // TODO(pkotwicz): Remove this function once it is no longer required by
+ // sync.
+ void MergeFavicon(
+ const GURL& page_url,
+ const GURL& icon_url,
+ history::IconType icon_type,
+ scoped_refptr<base::RefCountedMemory> bitmap_data,
+ const gfx::Size& pixel_size);
+
+ // Used by the FaviconService to set the favicons for a page on the history
// backend.
- void UpdateFaviconMappingAndFetch(FaviconService::GetFaviconRequest* request,
- const GURL& page_url,
- const GURL& icon_url,
- history::IconType icon_type);
-
- // Used by the FaviconService to get a favicon from the history backend.
- void GetFaviconForURL(FaviconService::GetFaviconRequest* request,
- const GURL& page_url,
- int icon_types);
-
- // Used by the FaviconService to get a favicon from the history backend.
- void GetFaviconForID(FaviconService::GetFaviconRequest* request,
- history::FaviconID id);
+ // |elements| is a listing of additional favicon bitmaps to store for
michaelbai 2012/09/04 21:18:53 There is no elements argument in method's definiti
+ // |page_url|.
+ // |icon_url_sizes| is a mapping of all the icon urls of favicons available
+ // for |page_url| to the sizes that those favicons are available at from the
+ // web. |elements| does not need to have entries for all the icon urls or
+ // sizes listed in |icon_url_sizes|. However, the icon urls and sizes in
+ // |elements| must be a subset of |icon_url_sizes|. It is important that
+ // |icon_url_sizes| be complete as mappings to favicons whose icon url or
+ // pixel size is not in |icon_url_sizes| will be deleted.
+ void SetFavicons(
+ const GURL& page_url,
+ history::IconType icon_type,
+ const std::vector<history::FaviconBitmapData>& favicon_bitmap_data,
+ const history::IconURLSizesMap& icon_url_sizes);
// Used by the FaviconService to mark the favicon for the page as being out
// of date.
- void SetFaviconOutOfDateForPage(const GURL& page_url);
+ void SetFaviconsOutOfDateForPage(const GURL& page_url);
// Used by the FaviconService to clone favicons from one page to another,
// provided that other page does not already have favicons.
- void CloneFavicon(const GURL& old_page_url, const GURL& new_page_url);
+ void CloneFavicons(const GURL& old_page_url, const GURL& new_page_url);
// Used by the FaviconService for importing many favicons for many pages at
// once. The pages must exist, any favicon sets for unknown pages will be
@@ -724,14 +770,6 @@ class HistoryService : public CancelableRequestProvider,
void SetImportedFavicons(
const std::vector<history::ImportedFaviconUsage>& favicon_usage);
- // Used by the FaviconService to set the favicon for a page on the history
- // backend.
- void SetFavicon(const GURL& page_url,
- const GURL& icon_url,
- const std::vector<unsigned char>& image_data,
- history::IconType icon_type);
-
-
// Sets the in-memory URL database. This is called by the backend once the
// database is loaded to make it available.
void SetInMemoryBackend(int backend_id,
@@ -848,6 +886,33 @@ class HistoryService : public CancelableRequestProvider,
return request->handle();
}
+ template<typename BackendFunc,
+ class RequestType, // Descendant of CancelableRequstBase.
+ typename ArgA,
+ typename ArgB,
+ typename ArgC,
+ typename ArgD,
+ typename ArgE>
+ Handle Schedule(SchedulePriority priority,
+ BackendFunc func, // Function to call on the HistoryBackend.
+ CancelableRequestConsumerBase* consumer,
+ RequestType* request,
+ const ArgA& a,
+ const ArgB& b,
+ const ArgC& c,
+ const ArgD& d,
+ const ArgE& e) {
+ DCHECK(thread_) << "History service being called after cleanup";
+ LoadBackendIfNecessary();
+ if (consumer)
+ AddRequest(request, consumer);
+ ScheduleTask(priority,
+ base::Bind(func, history_backend_.get(),
+ scoped_refptr<RequestType>(request),
+ a, b, c, d, e));
+ return request->handle();
+ }
+
// ScheduleAndForget ---------------------------------------------------------
//
// Functions for scheduling operations on the history thread that do not need
@@ -908,6 +973,25 @@ class HistoryService : public CancelableRequestProvider,
a, b, c, d));
}
+ template<typename BackendFunc,
+ typename ArgA,
+ typename ArgB,
+ typename ArgC,
+ typename ArgD,
+ typename ArgE>
+ void ScheduleAndForget(SchedulePriority priority,
+ BackendFunc func, // Function to call on backend.
+ const ArgA& a,
+ const ArgB& b,
+ const ArgC& c,
+ const ArgD& d,
+ const ArgE& e) {
+ DCHECK(thread_) << "History service being called after cleanup";
+ LoadBackendIfNecessary();
+ ScheduleTask(priority, base::Bind(func, history_backend_.get(),
+ a, b, c, d, e));
+ }
+
content::NotificationRegistrar registrar_;
// Some void primitives require some internal processing in the main thread

Powered by Google App Engine
This is Rietveld 408576698