summaryrefslogtreecommitdiffstats
path: root/chrome/browser/favicon/favicon_service.h
diff options
context:
space:
mode:
authorkaiwang@chromium.org <kaiwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-07 01:32:01 +0000
committerkaiwang@chromium.org <kaiwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-07 01:32:01 +0000
commit0ea3db50aa19bcc15dcf15fcf4e7b20be3b004fb (patch)
tree972c588c6b25ddbbcce41e50193c4346993f496e /chrome/browser/favicon/favicon_service.h
parent2494ceabbea6b78e7b5dda93717dcbcfbb1bc5a4 (diff)
downloadchromium_src-0ea3db50aa19bcc15dcf15fcf4e7b20be3b004fb.zip
chromium_src-0ea3db50aa19bcc15dcf15fcf4e7b20be3b004fb.tar.gz
chromium_src-0ea3db50aa19bcc15dcf15fcf4e7b20be3b004fb.tar.bz2
Convert some FaviconService functions to use New CancelableTaskTracker
This CL converts: FaviconService::GetFaviconImageForURL FaviconService::GetRawFaviconForURL FaviconService::GetFaviconForURL ---------- They depends on --------- HistoryService::GetFaviconsForURL ---------- which depends on -------- HistoryBackend::GetFaviconsForURL So please review above changes first. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ FaviconService::GetFaviconImageForURL ---------- is used by -------------- bookmarks/bookmark_model.cc ui/intents/web_intent_icon_loader.cc ui/cocoa/history_menu_bridge.mm ui/toolbar/recent_tabs_sub_menu_model.cc ui/toolbar/back_forward_menu_model.cc ui/webui/ntp/app_launcher_handler.cc jumplist_win.cc FaviconService::GetRawFaviconForURL ---------- is used by -------------- android/provider/chrome_browser_provider.cc bookmarks/bookmark_html_writer.cc sync/glue/session_model_associator.cc ui/webui/extensions/extension_icon_source.cc ui/webui/favicon_source.cc ui/webui/ntp/android/bookmarks_handler.cc ui/webui/ntp/favicon_webui_handler.cc FaviconService::GetFaviconForURL ---------- is used by -------------- favicon/favicon_handler.h BUG=155883 Review URL: https://chromiumcodereview.appspot.com/11421188 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171675 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/favicon/favicon_service.h')
-rw-r--r--chrome/browser/favicon/favicon_service.h93
1 files changed, 65 insertions, 28 deletions
diff --git a/chrome/browser/favicon/favicon_service.h b/chrome/browser/favicon/favicon_service.h
index e6f71a3..baef869 100644
--- a/chrome/browser/favicon/favicon_service.h
+++ b/chrome/browser/favicon/favicon_service.h
@@ -12,6 +12,7 @@
#include "chrome/browser/common/cancelable_request.h"
#include "chrome/browser/history/history_types.h"
#include "chrome/browser/profiles/profile_keyed_service.h"
+#include "chrome/common/cancelable_task_tracker.h"
#include "chrome/common/ref_counted_util.h"
#include "ui/base/layout.h"
@@ -36,20 +37,16 @@ class FaviconService : public CancelableRequestProvider,
FaviconForURLParams(Profile* profile,
const GURL& page_url,
int icon_types,
- int desired_size_in_dip,
- CancelableRequestConsumerBase* consumer)
+ int desired_size_in_dip)
: profile(profile),
page_url(page_url),
icon_types(icon_types),
- desired_size_in_dip(desired_size_in_dip),
- consumer(consumer) {
- }
+ desired_size_in_dip(desired_size_in_dip) {}
Profile* profile;
GURL page_url;
int icon_types;
int desired_size_in_dip;
- CancelableRequestConsumerBase* consumer;
};
// Callback for GetFaviconImage() and GetFaviconImageForURL().
@@ -63,6 +60,8 @@ class FaviconService : public CancelableRequestProvider,
// icon URLs.
typedef base::Callback<void(Handle, const history::FaviconImageResult&)>
FaviconImageCallback;
+ typedef base::Callback<void(const history::FaviconImageResult&)>
+ FaviconImageCallback2;
// Callback for GetRawFavicon() and GetRawFaviconForURL().
// FaviconBitmapResult::bitmap_data is the bitmap in the thumbnail database
@@ -71,6 +70,8 @@ class FaviconService : public CancelableRequestProvider,
// invalid history::FaviconBitmapResult if there are no matches.
typedef base::Callback<void(Handle, const history::FaviconBitmapResult&)>
FaviconRawCallback;
+ typedef base::Callback<void(const history::FaviconBitmapResult&)>
+ FaviconRawCallback2;
// Callback for GetFavicon() and GetFaviconForURL().
//
@@ -100,6 +101,18 @@ class FaviconService : public CancelableRequestProvider,
typedef CancelableRequest<FaviconResultsCallback> GetFaviconRequest;
+ typedef base::Callback<
+ void(const std::vector<history::FaviconBitmapResult>&,
+ const history::IconURLSizesMap&)>
+ FaviconResultsCallback2;
+
+ // We usually pass parameters with pointer to avoid copy. This function is a
+ // helper to run FaviconResultsCallback2 with pointer parameters.
+ static void FaviconResultsCallbackRunner(
+ const FaviconResultsCallback2& callback,
+ const std::vector<history::FaviconBitmapResult>* results,
+ const history::IconURLSizesMap* size_map);
+
// Requests the favicon at |icon_url| of |icon_type| whose size most closely
// matches |desired_size_in_dip|. If |desired_size_in_dip| is 0, the largest
// favicon bitmap at |icon_url| is returned. |consumer| is notified when the
@@ -158,23 +171,29 @@ class FaviconService : public CancelableRequestProvider,
// Requests the favicons of any of |icon_types| whose pixel sizes most
// closely match |desired_size_in_dip| and desired scale factors for a web
// page URL. If |desired_size_in_dip| is 0, the largest favicon for the web
- // page URL is returned. |consumer| is notified when the bits have been
- // fetched. |icon_types| can be any combination of IconType value, but only
- // one icon will be returned in the priority of TOUCH_PRECOMPOSED_ICON,
- // TOUCH_ICON and FAVICON. Each of the three methods below differs in the
- // format of the callback and the requested scale factors. All of the scale
- // factors supported by the current platform (eg MacOS) are requested for
+ // page URL is returned. |callback| is run when the bits have been fetched.
+ // |icon_types| can be any combination of IconType value, but only one icon
+ // will be returned in the priority of TOUCH_PRECOMPOSED_ICON, TOUCH_ICON and
+ // FAVICON. Each of the three methods below differs in the format of the
+ // callback and the requested scale factors. All of the scale factors
+ // supported by the current platform (eg MacOS) are requested for
// GetFaviconImageForURL().
- Handle GetFaviconImageForURL(const FaviconForURLParams& params,
- const FaviconImageCallback& callback);
+ // Note. |callback| is always run asynchronously.
+ CancelableTaskTracker::TaskId GetFaviconImageForURL(
+ const FaviconForURLParams& params,
+ const FaviconImageCallback2& callback,
+ CancelableTaskTracker* tracker);
- Handle GetRawFaviconForURL(const FaviconForURLParams& params,
- ui::ScaleFactor desired_scale_factor,
- const FaviconRawCallback& callback);
+ CancelableTaskTracker::TaskId GetRawFaviconForURL(
+ const FaviconForURLParams& params,
+ ui::ScaleFactor desired_scale_factor,
+ const FaviconRawCallback2& callback,
+ CancelableTaskTracker* tracker);
- Handle GetFaviconForURL(
+ CancelableTaskTracker::TaskId GetFaviconForURL(
const FaviconForURLParams& params,
- const FaviconResultsCallback& callback);
+ const FaviconResultsCallback2& callback,
+ CancelableTaskTracker* tracker);
// Used to request a bitmap for the favicon with |favicon_id| which is not
// resized from the size it is stored at in the database. If there are
@@ -230,37 +249,55 @@ class FaviconService : public CancelableRequestProvider,
private:
HistoryService* history_service_;
- // Helper to forward an empty result if we cannot get the history service.
- void ForwardEmptyResultAsync(GetFaviconRequest* request);
-
// Helper function for GetFaviconImageForURL(), GetRawFaviconForURL() and
// GetFaviconForURL().
- Handle GetFaviconForURLImpl(
+ CancelableTaskTracker::TaskId GetFaviconForURLImpl(
const FaviconForURLParams& params,
const std::vector<ui::ScaleFactor>& desired_scale_factors,
- GetFaviconRequest* request);
+ const FaviconResultsCallback2& callback,
+ CancelableTaskTracker* tracker);
// Intermediate callback for GetFaviconImage() and GetFaviconImageForURL()
// so that history service can deal solely with FaviconResultsCallback.
// Builds history::FaviconImageResult from |favicon_bitmap_results| and runs
// |callback|.
- void GetFaviconImageCallback(
- int desired_size_in_dip,
+ void RunFaviconImageCallbackWithBitmapResults(
FaviconImageCallback callback,
+ int desired_size_in_dip,
Handle handle,
std::vector<history::FaviconBitmapResult> favicon_bitmap_results,
history::IconURLSizesMap icon_url_sizes_map);
+ void RunFaviconImageCallbackWithBitmapResults2(
+ const FaviconImageCallback2& callback,
+ int desired_size_in_dip,
+ const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results,
+ const history::IconURLSizesMap& icon_url_sizes_map);
// Intermediate callback for GetRawFavicon() and GetRawFaviconForURL()
// so that history service can deal solely with FaviconResultsCallback.
// Resizes history::FaviconBitmapResult if necessary and runs |callback|.
- void GetRawFaviconCallback(
+ void RunFaviconRawCallbackWithBitmapResults(
+ FaviconRawCallback callback,
int desired_size_in_dip,
ui::ScaleFactor desired_scale_factor,
- FaviconRawCallback callback,
Handle handle,
std::vector<history::FaviconBitmapResult> favicon_bitmap_results,
history::IconURLSizesMap icon_url_sizes_map);
+ void RunFaviconRawCallbackWithBitmapResults2(
+ const FaviconRawCallback2& callback,
+ int desired_size_in_dip,
+ ui::ScaleFactor desired_scale_factor,
+ const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results,
+ const history::IconURLSizesMap& icon_url_sizes_map);
+
+ // Helper to forward an empty result if we cannot get the history service.
+ void ForwardEmptyResultAsync(GetFaviconRequest* request);
+
+ // Helper to run callback with empty results if we cannot get the history
+ // service.
+ CancelableTaskTracker::TaskId RunWithEmptyResultAsync(
+ const FaviconResultsCallback2& callback,
+ CancelableTaskTracker* tracker);
DISALLOW_COPY_AND_ASSIGN(FaviconService);
};