Commit fa4053cc authored by kerz's avatar kerz Committed by Commit bot

Revert of ChromeBrowserProvider shouldn't own the FaviconService (patchset #1...

Revert of ChromeBrowserProvider shouldn't own the FaviconService (patchset #1 id:1 of https://codereview.chromium.org/731873003/)

Reason for revert:
Broke the branch build. https://uberchromegw.corp.google.com/i/chrome.mobile/builders/arm%20stable/builds/7097

Original issue's description:
> ChromeBrowserProvider shouldn't own the FaviconService
>
> As FaviconService is KeyedService and will be deleted along with profile.
>
> BUG=411435
> TBR=Tedchoc
>
> Review URL: https://codereview.chromium.org/739713002
>
> Cr-Commit-Position: refs/heads/master@{#304690}
>
> Committed: https://chromium.googlesource.com/chromium/src/+/8c5b8c707daa9c026540a63f6f1e1c5981f5909c

TBR=michaelbai@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=411435

Review URL: https://codereview.chromium.org/740853002

Cr-Commit-Position: refs/heads/master@{#304979}
parent 493f2aae
......@@ -650,12 +650,10 @@ class AsyncServiceRequest : protected BlockingUIThreadAsyncRequest {
// Base class for all asynchronous blocking tasks that use the favicon service.
class FaviconServiceTask : public AsyncServiceRequest<FaviconService> {
public:
FaviconServiceTask(base::CancelableTaskTracker* cancelable_tracker,
FaviconServiceTask(FaviconService* service,
base::CancelableTaskTracker* cancelable_tracker,
Profile* profile)
: AsyncServiceRequest<FaviconService>(
FaviconServiceFactory::GetForProfile(profile,
Profile::EXPLICIT_ACCESS),
cancelable_tracker),
: AsyncServiceRequest<FaviconService>(service, cancelable_tracker),
profile_(profile) {}
Profile* profile() const { return profile_; }
......@@ -669,18 +667,15 @@ class FaviconServiceTask : public AsyncServiceRequest<FaviconService> {
// Retrieves the favicon or touch icon for a URL from the FaviconService.
class BookmarkIconFetchTask : public FaviconServiceTask {
public:
BookmarkIconFetchTask(base::CancelableTaskTracker* cancelable_tracker,
BookmarkIconFetchTask(FaviconService* favicon_service,
base::CancelableTaskTracker* cancelable_tracker,
Profile* profile)
: FaviconServiceTask(cancelable_tracker, profile) {}
: FaviconServiceTask(favicon_service, 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()),
......@@ -1167,6 +1162,8 @@ 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);
......@@ -1553,7 +1550,8 @@ ScopedJavaLocalRef<jbyteArray> ChromeBrowserProvider::GetFaviconOrTouchIcon(
return ScopedJavaLocalRef<jbyteArray>();
GURL url = GURL(ConvertJavaStringToUTF16(env, jurl));
BookmarkIconFetchTask favicon_task(&cancelable_task_tracker_, profile_);
BookmarkIconFetchTask favicon_task(
favicon_service_.get(), &cancelable_task_tracker_, profile_);
favicon_base::FaviconRawBitmapResult bitmap_result = favicon_task.Run(url);
if (!bitmap_result.is_valid() || !bitmap_result.bitmap_data.get())
......
......@@ -209,6 +209,7 @@ class ChromeBrowserProvider : public BaseBookmarkModelObserver,
history::TopSites* top_sites_;
scoped_ptr<AndroidHistoryProviderService> service_;
scoped_ptr<FaviconService> favicon_service_;
base::CancelableTaskTracker cancelable_task_tracker_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment