| Index: chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc
|
| diff --git a/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc b/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc
|
| index 41f846b3dd459183c4c582764fe1ee6fedb68d9a..4e31565c909d2fabbdc0af12c90faf790e31dcd0 100644
|
| --- a/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc
|
| +++ b/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc
|
| @@ -9,11 +9,7 @@
|
| #include "base/bind.h"
|
| #include "base/location.h"
|
| #include "base/metrics/user_metrics.h"
|
| -#include "base/strings/string16.h"
|
| -#include "base/task_runner_util.h"
|
| -#include "base/threading/sequenced_worker_pool.h"
|
| -#include "chrome/browser/android/offline_pages/offline_page_utils.h"
|
| -#include "chrome/browser/android/shortcut_helper.h"
|
| +#include "base/task_scheduler/post_task.h"
|
| #include "chrome/browser/android/webapk/webapk_web_manifest_checker.h"
|
| #include "chrome/browser/favicon/favicon_service_factory.h"
|
| #include "chrome/browser/installable/installable_manager.h"
|
| @@ -28,7 +24,6 @@
|
| #include "content/public/browser/manifest_icon_selector.h"
|
| #include "content/public/browser/render_frame_host.h"
|
| #include "content/public/browser/web_contents.h"
|
| -#include "content/public/browser/web_contents_observer.h"
|
| #include "content/public/common/manifest.h"
|
| #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScreenOrientationLockType.h"
|
| #include "ui/gfx/codec/png_codec.h"
|
| @@ -77,11 +72,7 @@ AddToHomescreenDataFetcher::AddToHomescreenDataFetcher(
|
| int badge_size_in_px,
|
| bool check_webapk_compatibility,
|
| Observer* observer)
|
| - : WebContentsObserver(web_contents),
|
| - background_task_runner_(
|
| - content::BrowserThread::GetBlockingPool()
|
| - ->GetTaskRunnerWithShutdownBehavior(
|
| - base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)),
|
| + : content::WebContentsObserver(web_contents),
|
| weak_observer_(observer),
|
| shortcut_info_(GetShortcutUrl(web_contents->GetBrowserContext(),
|
| web_contents->GetLastCommittedURL())),
|
| @@ -290,16 +281,23 @@ void AddToHomescreenDataFetcher::FetchFavicon() {
|
|
|
| void AddToHomescreenDataFetcher::OnFaviconFetched(
|
| const favicon_base::FaviconRawBitmapResult& bitmap_result) {
|
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| +
|
| if (!web_contents() || !weak_observer_ || is_icon_saved_)
|
| return;
|
|
|
| - base::PostTaskAndReplyWithResult(
|
| - background_task_runner_.get(), FROM_HERE,
|
| - base::Bind(&AddToHomescreenDataFetcher::
|
| - CreateLauncherIconFromFaviconInBackground,
|
| - base::Unretained(this), bitmap_result),
|
| - base::Bind(&AddToHomescreenDataFetcher::NotifyObserver,
|
| - base::RetainedRef(this)));
|
| + // The user is waiting for the icon to be processed before they can proceed
|
| + // with add to homescreen. But if we shut down, there's no point starting the
|
| + // image processing. Use USER_VISIBLE with MayBlock and SKIP_ON_SHUTDOWN.
|
| + base::PostTaskWithTraitsAndReplyWithResult(
|
| + FROM_HERE,
|
| + {base::MayBlock(), base::TaskPriority::USER_VISIBLE,
|
| + base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN},
|
| + base::BindOnce(&AddToHomescreenDataFetcher::
|
| + CreateLauncherIconFromFaviconInBackground,
|
| + base::Unretained(this), bitmap_result),
|
| + base::BindOnce(&AddToHomescreenDataFetcher::NotifyObserver,
|
| + base::RetainedRef(this)));
|
| }
|
|
|
| SkBitmap AddToHomescreenDataFetcher::CreateLauncherIconFromFaviconInBackground(
|
| @@ -318,12 +316,19 @@ SkBitmap AddToHomescreenDataFetcher::CreateLauncherIconFromFaviconInBackground(
|
|
|
| void AddToHomescreenDataFetcher::CreateLauncherIcon(const SkBitmap& raw_icon) {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| - base::PostTaskAndReplyWithResult(
|
| - background_task_runner_.get(), FROM_HERE,
|
| - base::Bind(&AddToHomescreenDataFetcher::CreateLauncherIconInBackground,
|
| - base::Unretained(this), raw_icon),
|
| - base::Bind(&AddToHomescreenDataFetcher::NotifyObserver,
|
| - base::RetainedRef(this)));
|
| +
|
| + // The user is waiting for the icon to be processed before they can proceed
|
| + // with add to homescreen. But if we shut down, there's no point starting the
|
| + // image processing. Use USER_VISIBLE with MayBlock and SKIP_ON_SHUTDOWN.
|
| + base::PostTaskWithTraitsAndReplyWithResult(
|
| + FROM_HERE,
|
| + {base::MayBlock(), base::TaskPriority::USER_VISIBLE,
|
| + base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN},
|
| + base::BindOnce(
|
| + &AddToHomescreenDataFetcher::CreateLauncherIconInBackground,
|
| + base::Unretained(this), raw_icon),
|
| + base::BindOnce(&AddToHomescreenDataFetcher::NotifyObserver,
|
| + base::RetainedRef(this)));
|
| }
|
|
|
| SkBitmap AddToHomescreenDataFetcher::CreateLauncherIconInBackground(
|
|
|