Index: chrome/browser/android/provider/chrome_browser_provider.cc |
diff --git a/chrome/browser/android/provider/chrome_browser_provider.cc b/chrome/browser/android/provider/chrome_browser_provider.cc |
index 6031f00267536badbf9e5fc0241debafa7b58e02..1db116610cc6996a40da880c31ba051aa2966d10 100644 |
--- a/chrome/browser/android/provider/chrome_browser_provider.cc |
+++ b/chrome/browser/android/provider/chrome_browser_provider.cc |
@@ -649,10 +649,12 @@ class AsyncServiceRequest : protected BlockingUIThreadAsyncRequest { |
// Base class for all asynchronous blocking tasks that use the favicon service. |
class FaviconServiceTask : public AsyncServiceRequest<FaviconService> { |
public: |
- FaviconServiceTask(FaviconService* service, |
- base::CancelableTaskTracker* cancelable_tracker, |
+ FaviconServiceTask(base::CancelableTaskTracker* cancelable_tracker, |
Profile* profile) |
- : AsyncServiceRequest<FaviconService>(service, cancelable_tracker), |
+ : AsyncServiceRequest<FaviconService>( |
+ FaviconServiceFactory::GetForProfile(profile, |
+ Profile::EXPLICIT_ACCESS), |
+ cancelable_tracker), |
profile_(profile) {} |
Profile* profile() const { return profile_; } |
@@ -666,15 +668,18 @@ class FaviconServiceTask : public AsyncServiceRequest<FaviconService> { |
// Retrieves the favicon or touch icon for a URL from the FaviconService. |
class BookmarkIconFetchTask : public FaviconServiceTask { |
public: |
- BookmarkIconFetchTask(FaviconService* favicon_service, |
- base::CancelableTaskTracker* cancelable_tracker, |
+ BookmarkIconFetchTask(base::CancelableTaskTracker* cancelable_tracker, |
Profile* profile) |
- : FaviconServiceTask(favicon_service, cancelable_tracker, profile) {} |
+ : FaviconServiceTask(cancelable_tracker, profile) {} |
favicon_base::FaviconRawBitmapResult Run(const GURL& url) { |
float max_scale = ui::GetScaleForScaleFactor( |
ResourceBundle::GetSharedInstance().GetMaxScaleFactor()); |
int desired_size_in_pixel = std::ceil(gfx::kFaviconSize * max_scale); |
+ |
+ if (service() == NULL) |
+ return favicon_base::FaviconRawBitmapResult(); |
+ |
RunAsyncRequestOnUIThreadBlocking( |
base::Bind(&FaviconService::GetRawFaviconForPageURL, |
base::Unretained(service()), |
@@ -1160,8 +1165,6 @@ ChromeBrowserProvider::ChromeBrowserProvider(JNIEnv* env, jobject obj) |
bookmark_model_ = BookmarkModelFactory::GetForProfile(profile_); |
top_sites_ = profile_->GetTopSites(); |
service_.reset(new AndroidHistoryProviderService(profile_)); |
- favicon_service_.reset(FaviconServiceFactory::GetForProfile(profile_, |
- Profile::EXPLICIT_ACCESS)); |
// Registers the notifications we are interested. |
bookmark_model_->AddObserver(this); |
@@ -1548,8 +1551,7 @@ ScopedJavaLocalRef<jbyteArray> ChromeBrowserProvider::GetFaviconOrTouchIcon( |
return ScopedJavaLocalRef<jbyteArray>(); |
GURL url = GURL(ConvertJavaStringToUTF16(env, jurl)); |
- BookmarkIconFetchTask favicon_task( |
- favicon_service_.get(), &cancelable_task_tracker_, profile_); |
+ BookmarkIconFetchTask favicon_task(&cancelable_task_tracker_, profile_); |
favicon_base::FaviconRawBitmapResult bitmap_result = favicon_task.Run(url); |
if (!bitmap_result.is_valid() || !bitmap_result.bitmap_data.get()) |