summaryrefslogtreecommitdiffstats
path: root/chrome/browser/favicon_service.cc
diff options
context:
space:
mode:
authorarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-17 20:19:57 +0000
committerarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-17 20:19:57 +0000
commit790879f7d6faea44ef0d13c2f7b44fe74edafa5e (patch)
tree6d0210a7594a265ba97425289f0a0ac44aabfb62 /chrome/browser/favicon_service.cc
parent36ea6c6f047abed672aa9af4f3071a7364142d64 (diff)
downloadchromium_src-790879f7d6faea44ef0d13c2f7b44fe74edafa5e.zip
chromium_src-790879f7d6faea44ef0d13c2f7b44fe74edafa5e.tar.gz
chromium_src-790879f7d6faea44ef0d13c2f7b44fe74edafa5e.tar.bz2
Change so that the extension favicon is read on the UI thread since extension objects should only be accessed on the UI thread.
This also fixes erg's todo to make favicons use RefCountedMemory instead of RefCountedBytes in all places. BUG=None TEST=None Review URL: http://codereview.chromium.org/1028001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41869 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/favicon_service.cc')
-rw-r--r--chrome/browser/favicon_service.cc43
1 files changed, 7 insertions, 36 deletions
diff --git a/chrome/browser/favicon_service.cc b/chrome/browser/favicon_service.cc
index 621d93b..0c24c80 100644
--- a/chrome/browser/favicon_service.cc
+++ b/chrome/browser/favicon_service.cc
@@ -49,12 +49,14 @@ FaviconService::Handle FaviconService::GetFaviconForURL(
FaviconDataCallback* callback) {
GetFaviconRequest* request = new GetFaviconRequest(callback);
AddRequest(request, consumer);
-
+ FaviconService::Handle handle = request->handle();
if (page_url.SchemeIs(chrome::kChromeUIScheme) ||
page_url.SchemeIs(chrome::kExtensionScheme)) {
- ChromeThread::PostTask(ChromeThread::FILE, FROM_HERE,
- NewRunnableMethod(this, &FaviconService::GetFaviconForDOMUIOnFileThread,
- request, page_url));
+ scoped_refptr<RefCountedMemory> icon_data =
+ DOMUIFactory::GetFaviconResourceBytes(profile_, page_url);
+ bool know_icon = icon_data.get() != NULL && icon_data->size() > 0;
+ request->ForwardResultAsync(FaviconDataCallback::TupleType(handle,
+ know_icon, icon_data, false, GURL()));
} else {
HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
if (hs)
@@ -62,40 +64,9 @@ FaviconService::Handle FaviconService::GetFaviconForURL(
else
ForwardEmptyResultAsync(request);
}
- return request->handle();
-}
-
-void FaviconService::GetFaviconForDOMUIOnFileThread(GetFaviconRequest* request,
- const GURL& page_url) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
- DCHECK(page_url.SchemeIs(chrome::kChromeUIScheme) ||
- page_url.SchemeIs(chrome::kExtensionScheme));
-
- // TODO(erg): For now, we're cheating here. DOMUIFactory returns the new
- // RefCountedMemory superclass, but consumers of favicon information are
- // still all hardcoded to use RefCountedBytes. For now, just copy the
- // favicon data in this case because the returned RefCountedMemory class is
- // the statically allocated memory one; not the vector backed
- // RefCountedBytes.
-
- scoped_refptr<RefCountedBytes> icon_data = NULL;
- scoped_refptr<RefCountedMemory> static_memory(
- DOMUIFactory::GetFaviconResourceBytes(profile_, page_url));
- bool know_icon = static_memory.get() != NULL;
-
- if (know_icon) {
- std::vector<unsigned char> bytes;
- bytes.insert(bytes.begin(),
- static_memory->front(),
- static_memory->front() + static_memory->size());
- icon_data = RefCountedBytes::TakeVector(&bytes);
- }
-
- request->ForwardResult(FaviconDataCallback::TupleType(request->handle(),
- know_icon, icon_data, false, GURL()));
+ return handle;
}
-
void FaviconService::SetFaviconOutOfDateForPage(const GURL& page_url) {
HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
if (hs)