summaryrefslogtreecommitdiffstats
path: root/chrome/browser/favicon
diff options
context:
space:
mode:
authoracolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-07 23:45:35 +0000
committeracolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-07 23:45:35 +0000
commit2f0158e718ff28a6884ffed00fc740a771e7929f (patch)
tree94e900a0a0be8f5cb20cd76eabfe73dfc1634437 /chrome/browser/favicon
parentfdd84dc3a652c41a5f4e27a2363221c7a215f4f3 (diff)
downloadchromium_src-2f0158e718ff28a6884ffed00fc740a771e7929f.zip
chromium_src-2f0158e718ff28a6884ffed00fc740a771e7929f.tar.gz
chromium_src-2f0158e718ff28a6884ffed00fc740a771e7929f.tar.bz2
Revert 104597 - base::Bind: Complete cleanup of history/.
Breaks Linux Touch. BUG=none TEST=none R=csilv@chromium.org Review URL: http://codereview.chromium.org/8163005 TBR=jhawkins@chromium.org Review URL: http://codereview.chromium.org/8207012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104604 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/favicon')
-rw-r--r--chrome/browser/favicon/favicon_handler.cc15
-rw-r--r--chrome/browser/favicon/favicon_handler.h6
-rw-r--r--chrome/browser/favicon/favicon_handler_unittest.cc33
-rw-r--r--chrome/browser/favicon/favicon_service.cc9
-rw-r--r--chrome/browser/favicon/favicon_service.h15
-rw-r--r--chrome/browser/favicon/favicon_tab_helper.h2
6 files changed, 40 insertions, 40 deletions
diff --git a/chrome/browser/favicon/favicon_handler.cc b/chrome/browser/favicon/favicon_handler.cc
index 9385c39..b14bf9b 100644
--- a/chrome/browser/favicon/favicon_handler.cc
+++ b/chrome/browser/favicon/favicon_handler.cc
@@ -8,8 +8,6 @@
#include <vector>
-#include "base/bind.h"
-#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/memory/ref_counted_memory.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
@@ -103,8 +101,7 @@ void FaviconHandler::FetchFavicon(const GURL& url) {
// available.
if (GetFaviconService()) {
GetFaviconForURL(url_, icon_types_, &cancelable_consumer_,
- base::Bind(&FaviconHandler::OnFaviconDataForInitialURL,
- base::Unretained(this)));
+ NewCallback(this, &FaviconHandler::OnFaviconDataForInitialURL));
}
}
@@ -270,7 +267,7 @@ void FaviconHandler::UpdateFaviconMappingAndFetch(
const GURL& icon_url,
history::IconType icon_type,
CancelableRequestConsumerBase* consumer,
- const FaviconService::FaviconDataCallback& callback) {
+ FaviconService::FaviconDataCallback* callback) {
GetFaviconService()->UpdateFaviconMappingAndFetch(page_url, icon_url,
icon_type, consumer, callback);
}
@@ -279,7 +276,7 @@ void FaviconHandler::GetFavicon(
const GURL& icon_url,
history::IconType icon_type,
CancelableRequestConsumerBase* consumer,
- const FaviconService::FaviconDataCallback& callback) {
+ FaviconService::FaviconDataCallback* callback) {
GetFaviconService()->GetFavicon(icon_url, icon_type, consumer, callback);
}
@@ -287,7 +284,7 @@ void FaviconHandler::GetFaviconForURL(
const GURL& page_url,
int icon_types,
CancelableRequestConsumerBase* consumer,
- const FaviconService::FaviconDataCallback& callback) {
+ FaviconService::FaviconDataCallback* callback) {
GetFaviconService()->GetFaviconForURL(page_url, icon_types, consumer,
callback);
}
@@ -371,7 +368,7 @@ void FaviconHandler::DownloadFaviconOrAskHistory(
// favicon given the favicon URL.
if (profile_->IsOffTheRecord()) {
GetFavicon(icon_url, icon_type, &cancelable_consumer_,
- base::Bind(&FaviconHandler::OnFaviconData, base::Unretained(this)));
+ NewCallback(this, &FaviconHandler::OnFaviconData));
} else {
// Ask the history service for the icon. This does two things:
// 1. Attempts to fetch the favicon data from the database.
@@ -381,7 +378,7 @@ void FaviconHandler::DownloadFaviconOrAskHistory(
// Issue the request and associate the current page ID with it.
UpdateFaviconMappingAndFetch(page_url, icon_url, icon_type,
&cancelable_consumer_,
- base::Bind(&FaviconHandler::OnFaviconData, base::Unretained(this)));
+ NewCallback(this, &FaviconHandler::OnFaviconData));
}
}
}
diff --git a/chrome/browser/favicon/favicon_handler.h b/chrome/browser/favicon/favicon_handler.h
index da979f9..ccdae05 100644
--- a/chrome/browser/favicon/favicon_handler.h
+++ b/chrome/browser/favicon/favicon_handler.h
@@ -127,19 +127,19 @@ class FaviconHandler {
const GURL& icon_url,
history::IconType icon_type,
CancelableRequestConsumerBase* consumer,
- const FaviconService::FaviconDataCallback& callback);
+ FaviconService::FaviconDataCallback* callback);
virtual void GetFavicon(
const GURL& icon_url,
history::IconType icon_type,
CancelableRequestConsumerBase* consumer,
- const FaviconService::FaviconDataCallback& callback);
+ FaviconService::FaviconDataCallback* callback);
virtual void GetFaviconForURL(
const GURL& page_url,
int icon_types,
CancelableRequestConsumerBase* consumer,
- const FaviconService::FaviconDataCallback& callback);
+ FaviconService::FaviconDataCallback* callback);
virtual void SetHistoryFavicon(const GURL& page_url,
const GURL& icon_url,
diff --git a/chrome/browser/favicon/favicon_handler_unittest.cc b/chrome/browser/favicon/favicon_handler_unittest.cc
index bdf05d8..3eba39a 100644
--- a/chrome/browser/favicon/favicon_handler_unittest.cc
+++ b/chrome/browser/favicon/favicon_handler_unittest.cc
@@ -86,7 +86,7 @@ class HistoryRequestHandler {
HistoryRequestHandler(const GURL& page_url,
const GURL& icon_url,
int icon_type,
- const FaviconService::FaviconDataCallback& callback)
+ FaviconService::FaviconDataCallback* callback)
: page_url_(page_url),
icon_url_(icon_url),
icon_type_(icon_type),
@@ -97,7 +97,7 @@ class HistoryRequestHandler {
const GURL& icon_url,
int icon_type,
const std::vector<unsigned char>& image_data,
- const FaviconService::FaviconDataCallback& callback)
+ FaviconService::FaviconDataCallback* callback)
: page_url_(page_url),
icon_url_(icon_url),
icon_type_(icon_type),
@@ -105,7 +105,9 @@ class HistoryRequestHandler {
callback_(callback) {
}
- virtual ~HistoryRequestHandler() {}
+ virtual ~HistoryRequestHandler() {
+ delete callback_;
+ }
void InvokeCallback();
const GURL page_url_;
@@ -113,7 +115,7 @@ class HistoryRequestHandler {
const int icon_type_;
const std::vector<unsigned char> image_data_;
history::FaviconData favicon_data_;
- FaviconService::FaviconDataCallback callback_;
+ FaviconService::FaviconDataCallback* callback_;
private:
DISALLOW_COPY_AND_ASSIGN(HistoryRequestHandler);
@@ -217,7 +219,7 @@ class TestFaviconHandler : public FaviconHandler {
const GURL& icon_url,
history::IconType icon_type,
CancelableRequestConsumerBase* consumer,
- const FaviconService::FaviconDataCallback& callback) OVERRIDE {
+ FaviconService::FaviconDataCallback* callback) OVERRIDE {
history_handler_.reset(new HistoryRequestHandler(page_url, icon_url,
icon_type, callback));
}
@@ -226,7 +228,7 @@ class TestFaviconHandler : public FaviconHandler {
const GURL& icon_url,
history::IconType icon_type,
CancelableRequestConsumerBase* consumer,
- const FaviconService::FaviconDataCallback& callback) OVERRIDE {
+ FaviconService::FaviconDataCallback* callback) OVERRIDE {
history_handler_.reset(new HistoryRequestHandler(GURL(), icon_url,
icon_type, callback));
}
@@ -235,7 +237,7 @@ class TestFaviconHandler : public FaviconHandler {
const GURL& page_url,
int icon_types,
CancelableRequestConsumerBase* consumer,
- const FaviconService::FaviconDataCallback& callback) OVERRIDE {
+ FaviconService::FaviconDataCallback* callback) OVERRIDE {
history_handler_.reset(new HistoryRequestHandler(page_url, GURL(),
icon_types, callback));
}
@@ -251,9 +253,8 @@ class TestFaviconHandler : public FaviconHandler {
const GURL& icon_url,
const std::vector<unsigned char>& image_data,
history::IconType icon_type) OVERRIDE {
- history_handler_.reset(new HistoryRequestHandler(
- page_url, icon_url,icon_type, image_data,
- FaviconService::FaviconDataCallback()));
+ history_handler_.reset(new HistoryRequestHandler(page_url, icon_url,
+ icon_type, image_data, NULL));
}
virtual FaviconService* GetFaviconService() OVERRIDE {
@@ -301,7 +302,7 @@ void DownloadHandler::InvokeCallback() {
}
void HistoryRequestHandler::InvokeCallback() {
- callback_.Run(0, favicon_data_);
+ callback_->Run(0, favicon_data_);
}
class FaviconHandlerTest : public ChromeRenderViewHostTestHarness {
@@ -785,17 +786,19 @@ TEST_F(FaviconHandlerTest, UpdateDuringDownloading) {
// Reset the history_handler to verify whether favicon is request from
// history.
// Save the callback for late use.
- FaviconService::FaviconDataCallback callback = history_handler->callback_;
+ FaviconService::FaviconDataCallback* callback = history_handler->callback_;
+ // Prevent the callback from being released.
+ history_handler->callback_ = NULL;
helper.set_history_handler(NULL);
- // Simulates download succeed.
+ // Smulates download succeed.
download_handler->InvokeCallback();
- // The downloaded icon should be thrown away as there is favicon update.
+ // The downloaded icon should be thrown away as there is faviocn update.
EXPECT_FALSE(helper.history_handler());
helper.set_download_handler(NULL);
- // Simulates getting the icon from history.
+ // Smulates getting the icon from history.
scoped_ptr<HistoryRequestHandler> handler;
handler.reset(new HistoryRequestHandler(page_url, latest_icon_url,
history::TOUCH_ICON, callback));
diff --git a/chrome/browser/favicon/favicon_service.cc b/chrome/browser/favicon/favicon_service.cc
index 5efd081..a276c7c 100644
--- a/chrome/browser/favicon/favicon_service.cc
+++ b/chrome/browser/favicon/favicon_service.cc
@@ -17,7 +17,7 @@ FaviconService::Handle FaviconService::GetFavicon(
const GURL& icon_url,
history::IconType icon_type,
CancelableRequestConsumerBase* consumer,
- const FaviconDataCallback& callback) {
+ FaviconDataCallback* callback) {
GetFaviconRequest* request = new GetFaviconRequest(callback);
AddRequest(request, consumer);
HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
@@ -33,7 +33,7 @@ FaviconService::Handle FaviconService::UpdateFaviconMappingAndFetch(
const GURL& icon_url,
history::IconType icon_type,
CancelableRequestConsumerBase* consumer,
- const FaviconDataCallback& callback) {
+ FaviconService::FaviconDataCallback* callback) {
GetFaviconRequest* request = new GetFaviconRequest(callback);
AddRequest(request, consumer);
HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
@@ -48,7 +48,7 @@ FaviconService::Handle FaviconService::GetFaviconForURL(
const GURL& page_url,
int icon_types,
CancelableRequestConsumerBase* consumer,
- const FaviconDataCallback& callback) {
+ FaviconDataCallback* callback) {
GetFaviconRequest* request = new GetFaviconRequest(callback);
AddRequest(request, consumer);
FaviconService::Handle handle = request->handle();
@@ -92,5 +92,6 @@ FaviconService::~FaviconService() {
}
void FaviconService::ForwardEmptyResultAsync(GetFaviconRequest* request) {
- request->ForwardResultAsync(request->handle(), history::FaviconData());
+ request->ForwardResultAsync(FaviconDataCallback::TupleType(
+ request->handle(), history::FaviconData()));
}
diff --git a/chrome/browser/favicon/favicon_service.h b/chrome/browser/favicon/favicon_service.h
index 4fb313b..2062239 100644
--- a/chrome/browser/favicon/favicon_service.h
+++ b/chrome/browser/favicon/favicon_service.h
@@ -8,7 +8,7 @@
#include <vector>
-#include "base/callback.h"
+#include "base/callback_old.h"
#include "base/memory/ref_counted.h"
#include "base/memory/ref_counted_memory.h"
#include "base/task.h"
@@ -40,10 +40,9 @@ class FaviconService : public CancelableRequestProvider {
// opposed to not knowing anything). |expired| will be set to true if we
// refreshed the favicon "too long" ago and should be updated if the page
// is visited again.
- typedef base::Callback<
- void(Handle, // handle
- history::FaviconData)> // the type of favicon
- FaviconDataCallback;
+ typedef Callback2<Handle, // handle
+ history::FaviconData>::Type // the type of favicon
+ FaviconDataCallback;
typedef CancelableRequest<FaviconDataCallback> GetFaviconRequest;
@@ -53,7 +52,7 @@ class FaviconService : public CancelableRequestProvider {
Handle GetFavicon(const GURL& icon_url,
history::IconType icon_type,
CancelableRequestConsumerBase* consumer,
- const FaviconDataCallback& callback);
+ FaviconDataCallback* callback);
// Fetches the |icon_type| of favicon at |icon_url|, sending the results to
// the given |callback|. If the favicon has previously been set via
@@ -64,7 +63,7 @@ class FaviconService : public CancelableRequestProvider {
const GURL& icon_url,
history::IconType icon_type,
CancelableRequestConsumerBase* consumer,
- const FaviconDataCallback& callback);
+ FaviconDataCallback* callback);
// Requests any |icon_types| of favicon for a web page URL. |consumer| is
// notified when the bits have been fetched. |icon_types| can be any
@@ -77,7 +76,7 @@ class FaviconService : public CancelableRequestProvider {
Handle GetFaviconForURL(const GURL& page_url,
int icon_types,
CancelableRequestConsumerBase* consumer,
- const FaviconDataCallback& callback);
+ FaviconDataCallback* callback);
// Marks all types of favicon for the page as being out of date.
void SetFaviconOutOfDateForPage(const GURL& page_url);
diff --git a/chrome/browser/favicon/favicon_tab_helper.h b/chrome/browser/favicon/favicon_tab_helper.h
index 97e8d63..c236f75 100644
--- a/chrome/browser/favicon/favicon_tab_helper.h
+++ b/chrome/browser/favicon/favicon_tab_helper.h
@@ -7,7 +7,7 @@
#pragma once
#include "base/basictypes.h"
-#include "base/callback_old.h"
+#include "base/callback.h"
#include "chrome/browser/favicon/favicon_handler_delegate.h"
#include "chrome/browser/favicon/favicon_service.h"
#include "chrome/common/favicon_url.h"