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

Unified Diff: chrome/browser/favicon/favicon_service.cc

Issue 10857037: Make FaviconService a ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the tests 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/favicon/favicon_service.cc
diff --git a/chrome/browser/favicon/favicon_service.cc b/chrome/browser/favicon/favicon_service.cc
index 6c55b307fd75475ad91d8a8448a4aa5aa5b421dd..0a23d139925894d86155de205c5cef8d5cc03eae 100644
--- a/chrome/browser/favicon/favicon_service.cc
+++ b/chrome/browser/favicon/favicon_service.cc
@@ -6,12 +6,13 @@
#include "chrome/browser/history/history.h"
#include "chrome/browser/history/history_backend.h"
-#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/profile.h"
joth 2012/08/16 21:57:52 as you don't use the profile (just pass it around)
andreip3000 2012/08/17 09:34:57 Done.
#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
#include "chrome/common/url_constants.h"
-FaviconService::FaviconService(Profile* profile) : profile_(profile) {
+FaviconService::FaviconService(scoped_refptr<HistoryService> hs,
+ Profile* profile)
+ : history_service_(hs), profile_(profile) {
}
FaviconService::Handle FaviconService::GetFavicon(
@@ -21,10 +22,8 @@ FaviconService::Handle FaviconService::GetFavicon(
const FaviconDataCallback& callback) {
GetFaviconRequest* request = new GetFaviconRequest(callback);
AddRequest(request, consumer);
- HistoryService* hs =
- HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
- if (hs)
- hs->GetFavicon(request, icon_url, icon_type);
+ if (history_service_)
+ history_service_->GetFavicon(request, icon_url, icon_type);
else
ForwardEmptyResultAsync(request);
return request->handle();
@@ -38,10 +37,9 @@ FaviconService::Handle FaviconService::UpdateFaviconMappingAndFetch(
const FaviconDataCallback& callback) {
GetFaviconRequest* request = new GetFaviconRequest(callback);
AddRequest(request, consumer);
- HistoryService* hs =
- HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
- if (hs)
- hs->UpdateFaviconMappingAndFetch(request, page_url, icon_url, icon_type);
+ if (history_service_)
+ history_service_->UpdateFaviconMappingAndFetch(
+ request, page_url, icon_url, icon_type);
else
ForwardEmptyResultAsync(request);
return request->handle();
@@ -60,10 +58,8 @@ FaviconService::Handle FaviconService::GetFaviconForURL(
ChromeWebUIControllerFactory::GetInstance()->GetFaviconForURL(
profile_, request, page_url);
} else {
- HistoryService* hs = HistoryServiceFactory::GetForProfile(
- profile_, Profile::EXPLICIT_ACCESS);
- if (hs)
- hs->GetFaviconForURL(request, page_url, icon_types);
+ if (history_service_)
+ history_service_->GetFaviconForURL(request, page_url, icon_types);
else
ForwardEmptyResultAsync(request);
}
@@ -79,10 +75,8 @@ FaviconService::Handle FaviconService::GetFaviconForID(
GetFaviconRequest* request = new GetFaviconRequest(callback);
AddRequest(request, consumer);
FaviconService::Handle handle = request->handle();
- HistoryService* hs =
- HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
- if (hs)
- hs->GetFaviconForID(request, favicon_id);
+ if (history_service_)
+ history_service_->GetFaviconForID(request, favicon_id);
else
ForwardEmptyResultAsync(request);
@@ -91,36 +85,28 @@ FaviconService::Handle FaviconService::GetFaviconForID(
void FaviconService::SetFaviconOutOfDateForPage(const GURL& page_url) {
- HistoryService* hs =
- HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
- if (hs)
- hs->SetFaviconOutOfDateForPage(page_url);
+ if (history_service_)
+ history_service_->SetFaviconOutOfDateForPage(page_url);
}
void FaviconService::CloneFavicon(const GURL& old_page_url,
const GURL& new_page_url) {
- HistoryService* hs =
- HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
- if (hs)
- hs->CloneFavicon(old_page_url, new_page_url);
+ if (history_service_)
+ history_service_->CloneFavicon(old_page_url, new_page_url);
}
void FaviconService::SetImportedFavicons(
const std::vector<history::ImportedFaviconUsage>& favicon_usage) {
- HistoryService* hs =
- HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
- if (hs)
- hs->SetImportedFavicons(favicon_usage);
+ if (history_service_)
+ history_service_->SetImportedFavicons(favicon_usage);
}
void FaviconService::SetFavicon(const GURL& page_url,
const GURL& icon_url,
const std::vector<unsigned char>& image_data,
history::IconType icon_type) {
- HistoryService* hs =
- HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
- if (hs)
- hs->SetFavicon(page_url, icon_url, image_data, icon_type);
+ if (history_service_)
+ history_service_->SetFavicon(page_url, icon_url, image_data, icon_type);
}
FaviconService::~FaviconService() {

Powered by Google App Engine
This is Rietveld 408576698