Commit 4f2e41be authored by Etienne Pierre-doray's avatar Etienne Pierre-doray Committed by Commit Bot

[TaskScheduler]: Use AssertLongCPUWorkAllowed to better match intent in chrome/browser/android

Instead of ScopedBlockingCall or AssertBlockingAllowed(),
AssertLongCPUWorkAllowed is used in FinalizeLauncherIconInBackground()
and in CreateLauncherIconFromFaviconInBackground().

Original CL intention was:
This CL uses ScopedBlockingCall to mark blocking calls in /chrome/browser/android/webapps.

This CL was created by replacing calls to AssertBlockingAllowed()
with instantiations of ScopedBlockingCall(MAY_BLOCK).
I kindly ask the reviewer to make sure of the following:
  - ScopedBlockingCall is instantiated in a scope with minimal CPU usage.
    If this is not the case, ScopedBlockingCall should be instantiated
    closer to the blocking call. See scoped_blocking_call.h for more
    info. Please let me know when/where the blocking call happens if this needs
    to be changed.
  - Parameter |blocking_type| matches expectation (MAY_BLOCK/WILL_BLOCK). See
    BlockingType for more info. While I assumed MAY_BLOCK by default, that might
    not be the best fit if we know that this callsite is guaranteed to block.
  - The ScopedBlockingCall's scope covers the entirety of the blocking operation
    previously asserted against by the AssertBlockingAllowed().

This CL was uploaded by git cl split.

R=dominickn@chromium.org

Bug: 874080
Change-Id: I31ed4164dbd93d424b7a3a69f833519d13c6fbf1
Reviewed-on: https://chromium-review.googlesource.com/1191185Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593708}
parent d572ce1d
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "base/optional.h" #include "base/optional.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/threading/scoped_blocking_call.h" #include "base/threading/thread_restrictions.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/android/color_helpers.h" #include "chrome/browser/android/color_helpers.h"
#include "chrome/browser/android/webapk/chrome_webapk_host.h" #include "chrome/browser/android/webapk/chrome_webapk_host.h"
...@@ -257,7 +257,7 @@ SkBitmap ShortcutHelper::FinalizeLauncherIconInBackground( ...@@ -257,7 +257,7 @@ SkBitmap ShortcutHelper::FinalizeLauncherIconInBackground(
const SkBitmap& bitmap, const SkBitmap& bitmap,
const GURL& url, const GURL& url,
bool* is_generated) { bool* is_generated) {
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK); base::AssertLongCPUWorkAllowed();
JNIEnv* env = base::android::AttachCurrentThread(); JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jobject> result; ScopedJavaLocalRef<jobject> result;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h" #include "base/metrics/user_metrics.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/android/shortcut_helper.h" #include "chrome/browser/android/shortcut_helper.h"
#include "chrome/browser/android/webapk/chrome_webapk_host.h" #include "chrome/browser/android/webapk/chrome_webapk_host.h"
#include "chrome/browser/android/webapk/webapk_web_manifest_checker.h" #include "chrome/browser/android/webapk/webapk_web_manifest_checker.h"
...@@ -67,8 +68,6 @@ InstallableParams ParamsToPerformInstallableCheck() { ...@@ -67,8 +68,6 @@ InstallableParams ParamsToPerformInstallableCheck() {
// - whether |icon| was used in generating the launcher icon // - whether |icon| was used in generating the launcher icon
std::pair<SkBitmap, bool> CreateLauncherIconInBackground(const GURL& start_url, std::pair<SkBitmap, bool> CreateLauncherIconInBackground(const GURL& start_url,
const SkBitmap& icon) { const SkBitmap& icon) {
base::AssertBlockingAllowed();
bool is_generated = false; bool is_generated = false;
SkBitmap primary_icon = ShortcutHelper::FinalizeLauncherIconInBackground( SkBitmap primary_icon = ShortcutHelper::FinalizeLauncherIconInBackground(
icon, start_url, &is_generated); icon, start_url, &is_generated);
...@@ -84,10 +83,9 @@ std::pair<SkBitmap, bool> CreateLauncherIconInBackground(const GURL& start_url, ...@@ -84,10 +83,9 @@ std::pair<SkBitmap, bool> CreateLauncherIconInBackground(const GURL& start_url,
std::pair<SkBitmap, bool> CreateLauncherIconFromFaviconInBackground( std::pair<SkBitmap, bool> CreateLauncherIconFromFaviconInBackground(
const GURL& start_url, const GURL& start_url,
const favicon_base::FaviconRawBitmapResult& bitmap_result) { const favicon_base::FaviconRawBitmapResult& bitmap_result) {
base::AssertBlockingAllowed();
SkBitmap decoded; SkBitmap decoded;
if (bitmap_result.is_valid()) { if (bitmap_result.is_valid()) {
base::AssertLongCPUWorkAllowed();
gfx::PNGCodec::Decode(bitmap_result.bitmap_data->front(), gfx::PNGCodec::Decode(bitmap_result.bitmap_data->front(),
bitmap_result.bitmap_data->size(), &decoded); bitmap_result.bitmap_data->size(), &decoded);
} }
......
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