From 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 6 Oct 2020 12:48:11 +0200 Subject: BASELINE: Update Chromium to 84.0.4147.141 Change-Id: Ib85eb4cfa1cbe2b2b81e5022c8cad5c493969535 Reviewed-by: Allan Sandfeld Jensen --- .../components/background_task_scheduler/BUILD.gn | 36 ++++++++++++---------- .../BackgroundTaskSchedulerExternalUma.java | 8 ++++- .../background_task_scheduler/background_task.h | 27 ++++++++-------- .../background_task_scheduler_factory.cc | 11 ++++++- .../internal/BackgroundTaskSchedulerPrefs.java | 15 +++++---- .../internal/BackgroundTaskSchedulerUmaTest.java | 6 +++- .../background_task_scheduler/task_ids.h | 2 ++ .../background_task_scheduler/task_info.h | 1 + 8 files changed, 67 insertions(+), 39 deletions(-) (limited to 'chromium/components/background_task_scheduler') diff --git a/chromium/components/background_task_scheduler/BUILD.gn b/chromium/components/background_task_scheduler/BUILD.gn index 642bd4ad27e..8a71072bceb 100644 --- a/chromium/components/background_task_scheduler/BUILD.gn +++ b/chromium/components/background_task_scheduler/BUILD.gn @@ -18,11 +18,10 @@ if (is_android) { } group("background_task_scheduler") { - public_deps = [ ":public" ] - - if (is_android) { - deps = [ ":factory" ] - } + public_deps = [ + ":factory", + ":public", + ] } static_library("public") { @@ -39,23 +38,23 @@ static_library("public") { public_deps = [ "//base", "//components/keyed_service/core", - "//content/public/browser", ] } -if (is_android) { - static_library("factory") { - sources = [ - "background_task_scheduler_factory.cc", - "background_task_scheduler_factory.h", - ] +static_library("factory") { + sources = [ + "background_task_scheduler_factory.cc", + "background_task_scheduler_factory.h", + ] - deps = [ - ":public", - "internal:native_task", - ] + deps = [ ":public" ] + + if (is_android) { + deps += [ "internal:native_task" ] } +} +if (is_android) { # This is shared between WebView and Chrome. We do not want to add GCM # related permissions for WebView while still wanting to avoid collision # between WebView and Chrome. @@ -99,7 +98,10 @@ if (is_android) { ] } - junit_binary("components_background_task_scheduler_junit_tests") { + java_library("components_background_task_scheduler_junit_tests") { + # Platform checks are broken for Robolectric. See https://crbug.com/1071638. + bypass_platform_checks = true + testonly = true sources = [ "internal/android/junit/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskGcmTaskServiceTest.java", "internal/android/junit/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskJobServiceTest.java", diff --git a/chromium/components/background_task_scheduler/android/java/src/org/chromium/components/background_task_scheduler/BackgroundTaskSchedulerExternalUma.java b/chromium/components/background_task_scheduler/android/java/src/org/chromium/components/background_task_scheduler/BackgroundTaskSchedulerExternalUma.java index 1f232a32272..b09fdbccfa7 100644 --- a/chromium/components/background_task_scheduler/android/java/src/org/chromium/components/background_task_scheduler/BackgroundTaskSchedulerExternalUma.java +++ b/chromium/components/background_task_scheduler/android/java/src/org/chromium/components/background_task_scheduler/BackgroundTaskSchedulerExternalUma.java @@ -35,8 +35,10 @@ public abstract class BackgroundTaskSchedulerExternalUma { public static final int BACKGROUND_TASK_NOTIFICATION_SCHEDULER = 20; public static final int BACKGROUND_TASK_NOTIFICATION_TRIGGER = 21; public static final int BACKGROUND_TASK_PERIODIC_SYNC_WAKE_UP = 22; + public static final int BACKGROUND_TASK_QUERY_TILE = 23; + public static final int BACKGROUND_TASK_FEEDV2_REFRESH = 24; // Keep this one at the end and increment appropriately when adding new tasks. - public static final int BACKGROUND_TASK_COUNT = 23; + public static final int BACKGROUND_TASK_COUNT = 25; protected BackgroundTaskSchedulerExternalUma() {} @@ -141,6 +143,10 @@ public abstract class BackgroundTaskSchedulerExternalUma { return BACKGROUND_TASK_NOTIFICATION_TRIGGER; case TaskIds.PERIODIC_BACKGROUND_SYNC_CHROME_WAKEUP_TASK_JOB_ID: return BACKGROUND_TASK_PERIODIC_SYNC_WAKE_UP; + case TaskIds.QUERY_TILE_JOB_ID: + return BACKGROUND_TASK_QUERY_TILE; + case TaskIds.FEEDV2_REFRESH_JOB_ID: + return BACKGROUND_TASK_FEEDV2_REFRESH; default: assert false; } diff --git a/chromium/components/background_task_scheduler/background_task.h b/chromium/components/background_task_scheduler/background_task.h index 811c99159c8..1ecdd147dd6 100644 --- a/chromium/components/background_task_scheduler/background_task.h +++ b/chromium/components/background_task_scheduler/background_task.h @@ -9,7 +9,10 @@ #include "base/macros.h" #include "components/background_task_scheduler/task_parameters.h" #include "components/keyed_service/core/simple_factory_key.h" -#include "content/public/browser/browser_context.h" + +namespace content { +class BrowserContext; +} // namespace content namespace background_task { @@ -22,16 +25,12 @@ class BackgroundTask { public: // The following two methods represent the callback from // BackgroundTaskScheduler when your task should start processing. It is - // invoked on the main thread, and if your task finishes quickly, you should - // return false from this method when you are done processing. If this is a - // long-running task, you should return true from this method, and instead - // invoke the |callback| when the processing is finished on some other thread. - // While this method is running the system holds a wakelock. If false is - // returned from this method, the wakelock is immediately released, but if - // this method returns true, the wakelock is not released until either the - // |callback| is invoked, or the system calls onStopTask. Depending on whether - // Chrome is running in service manager only mode or full browser mode, one or - // both of the following two methods are invoked. + // invoked on the main thread, and after your task finishes, you should + // run the |callback|. While this method is running the system holds a + // wakelock and the wakelock is not released until either the |callback| is + // invoked, or the system calls onStopTask. Depending on whether Chrome is + // running in service manager only mode or full browser mode, one or both of + // the following methods are invoked. // Callback invoked when chrome is running in service manager only mode. User // can start executing the task here or save the params and wait till full @@ -41,7 +40,7 @@ class BackgroundTask { SimpleFactoryKey* key) {} // Callback invoked when Chrome is running in full browser mode. This is - // invoked only if the chrome was started in reduced mode. + // invoked only if the chrome was started in full browser mode. virtual void OnStartTaskWithFullBrowser( const TaskParameters& task_params, TaskFinishedCallback callback, @@ -56,7 +55,9 @@ class BackgroundTask { // TaskFinishedCallback has been invoked. This will typically happen whenever // the required conditions for the task are no longer met. See TaskInfo for // more details. A wakelock is held by the system while this callback is - // invoked, and immediately released after this method returns. + // invoked, and immediately released after this method returns. If true is + // returned from this method, the task will be rescheduled, for false, the + // task will not be rescheduled. virtual bool OnStopTask(const TaskParameters& task_params) = 0; // Destructor. diff --git a/chromium/components/background_task_scheduler/background_task_scheduler_factory.cc b/chromium/components/background_task_scheduler/background_task_scheduler_factory.cc index 42e291cd7e6..a1de62fa760 100644 --- a/chromium/components/background_task_scheduler/background_task_scheduler_factory.cc +++ b/chromium/components/background_task_scheduler/background_task_scheduler_factory.cc @@ -7,9 +7,14 @@ #include #include "base/memory/singleton.h" -#include "components/background_task_scheduler/internal/android/native_task_scheduler.h" +#include "build/build_config.h" +#include "components/background_task_scheduler/background_task_scheduler.h" #include "components/keyed_service/core/simple_dependency_manager.h" +#if defined(OS_ANDROID) +#include "components/background_task_scheduler/internal/android/native_task_scheduler.h" +#endif + namespace background_task { // static @@ -33,7 +38,11 @@ BackgroundTaskSchedulerFactory::~BackgroundTaskSchedulerFactory() = default; std::unique_ptr BackgroundTaskSchedulerFactory::BuildServiceInstanceFor( SimpleFactoryKey* key) const { +#if defined(OS_ANDROID) return std::make_unique(); +#else + return nullptr; +#endif } SimpleFactoryKey* BackgroundTaskSchedulerFactory::GetKeyToUse( diff --git a/chromium/components/background_task_scheduler/internal/android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerPrefs.java b/chromium/components/background_task_scheduler/internal/android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerPrefs.java index f7fd0bcf63f..bedf11cb0dc 100644 --- a/chromium/components/background_task_scheduler/internal/android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerPrefs.java +++ b/chromium/components/background_task_scheduler/internal/android/java/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerPrefs.java @@ -16,6 +16,7 @@ import com.google.protobuf.InvalidProtocolBufferException; import org.chromium.base.ContextUtils; import org.chromium.base.Log; +import org.chromium.base.StrictModeContext; import org.chromium.base.TraceEvent; import org.chromium.components.background_task_scheduler.TaskInfo; @@ -143,12 +144,14 @@ public class BackgroundTaskSchedulerPrefs { @Override public void visit(TaskInfo.OneOffInfo oneOffInfo) { - ScheduledTaskProto.ScheduledTask scheduledTask = - ScheduledTaskProto.ScheduledTask.newBuilder() - .setType(ScheduledTaskProto.ScheduledTask.Type.ONE_OFF) - .build(); - mSerializedScheduledTask = - Base64.encodeToString(scheduledTask.toByteArray(), Base64.DEFAULT); + try (StrictModeContext ignored = StrictModeContext.allowDiskReads()) { + ScheduledTaskProto.ScheduledTask scheduledTask = + ScheduledTaskProto.ScheduledTask.newBuilder() + .setType(ScheduledTaskProto.ScheduledTask.Type.ONE_OFF) + .build(); + mSerializedScheduledTask = + Base64.encodeToString(scheduledTask.toByteArray(), Base64.DEFAULT); + } } @Override diff --git a/chromium/components/background_task_scheduler/internal/android/junit/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerUmaTest.java b/chromium/components/background_task_scheduler/internal/android/junit/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerUmaTest.java index b0fd24c6e97..923cbeebedc 100644 --- a/chromium/components/background_task_scheduler/internal/android/junit/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerUmaTest.java +++ b/chromium/components/background_task_scheduler/internal/android/junit/src/org/chromium/components/background_task_scheduler/internal/BackgroundTaskSchedulerUmaTest.java @@ -119,7 +119,11 @@ public class BackgroundTaskSchedulerUmaTest { assertEquals(BackgroundTaskSchedulerUma.BACKGROUND_TASK_PERIODIC_SYNC_WAKE_UP, BackgroundTaskSchedulerUma.toUmaEnumValueFromTaskId( TaskIds.PERIODIC_BACKGROUND_SYNC_CHROME_WAKEUP_TASK_JOB_ID)); - assertEquals(BackgroundTaskSchedulerUma.BACKGROUND_TASK_COUNT, 23); + assertEquals(BackgroundTaskSchedulerUma.BACKGROUND_TASK_QUERY_TILE, + BackgroundTaskSchedulerUma.toUmaEnumValueFromTaskId(TaskIds.QUERY_TILE_JOB_ID)); + assertEquals(BackgroundTaskSchedulerUma.BACKGROUND_TASK_FEEDV2_REFRESH, + BackgroundTaskSchedulerUma.toUmaEnumValueFromTaskId(TaskIds.FEEDV2_REFRESH_JOB_ID)); + assertEquals(BackgroundTaskSchedulerUma.BACKGROUND_TASK_COUNT, 25); } @Test diff --git a/chromium/components/background_task_scheduler/task_ids.h b/chromium/components/background_task_scheduler/task_ids.h index a565fe8ce94..78b491ab4e9 100644 --- a/chromium/components/background_task_scheduler/task_ids.h +++ b/chromium/components/background_task_scheduler/task_ids.h @@ -45,6 +45,8 @@ enum class TaskIds { NOTIFICATION_SCHEDULER_JOB_ID = 103, NOTIFICATION_TRIGGER_JOB_ID = 104, PERIODIC_BACKGROUND_SYNC_CHROME_WAKEUP_TASK_JOB_ID = 105, + QUERY_TILE_JOB_ID = 106, + FEEDV2_REFRESH_JOB_ID = 107, }; } // namespace background_task diff --git a/chromium/components/background_task_scheduler/task_info.h b/chromium/components/background_task_scheduler/task_info.h index 66145a5877f..795be73b4f0 100644 --- a/chromium/components/background_task_scheduler/task_info.h +++ b/chromium/components/background_task_scheduler/task_info.h @@ -6,6 +6,7 @@ #define COMPONENTS_BACKGROUND_TASK_SCHEDULER_TASK_INFO_H_ #include +#include #include "base/macros.h" #include "base/optional.h" -- cgit v1.2.1