diff options
Diffstat (limited to 'chrome/browser/favicon_service.cc')
-rw-r--r-- | chrome/browser/favicon_service.cc | 43 |
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) |