Moved download task scheduler out of background_service
Since both download service and auto-resumptions depend on task scheduler
and task manager, it would be ideal to move them out to a common directory.
This CL moves them out to //components/download/public/task
Bug: 920706
Change-Id: I81b06d9d4e4d577fed48ee8e9c57600ee7b4a793
Reviewed-on: https://chromium-review.googlesource.com/c/1405544
Reviewed-by: David Trainor <dtrainor@chromium.org>
Commit-Queue: Shakti Sahu <shaktisahu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#621826}
diff --git a/chrome/android/BUILD.gn b/chrome/android/BUILD.gn
index e05a263..d7aca3b1 100644
--- a/chrome/android/BUILD.gn
+++ b/chrome/android/BUILD.gn
@@ -294,8 +294,8 @@
"//components/dom_distiller/core/android:dom_distiller_core_java",
"//components/download/internal/background_service:internal_java",
"//components/download/network:network_java",
- "//components/download/public/background_service:public_java",
"//components/download/public/common:public_java",
+ "//components/download/public/task:public_java",
"//components/embedder_support/android:content_view_java",
"//components/embedder_support/android:web_contents_delegate_java",
"//components/feature_engagement:feature_engagement_java",
diff --git a/chrome/browser/android/download/service/download_task_scheduler.h b/chrome/browser/android/download/service/download_task_scheduler.h
index ec4624cc..cfa9005 100644
--- a/chrome/browser/android/download/service/download_task_scheduler.h
+++ b/chrome/browser/android/download/service/download_task_scheduler.h
@@ -10,8 +10,7 @@
#include <memory>
#include "base/macros.h"
-#include "components/download/public/background_service/download_task_types.h"
-#include "components/download/public/background_service/task_scheduler.h"
+#include "components/download/public/task/task_scheduler.h"
namespace download {
namespace android {
diff --git a/chrome/browser/download/download_service_factory.cc b/chrome/browser/download/download_service_factory.cc
index adc476f..42998a7 100644
--- a/chrome/browser/download/download_service_factory.cc
+++ b/chrome/browser/download/download_service_factory.cc
@@ -23,7 +23,7 @@
#include "components/download/public/background_service/clients.h"
#include "components/download/public/background_service/download_service.h"
#include "components/download/public/background_service/features.h"
-#include "components/download/public/background_service/task_scheduler.h"
+#include "components/download/public/task/task_scheduler.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/offline_pages/buildflags/buildflags.h"
#include "content/public/browser/browser_context.h"
diff --git a/chrome/browser/download/download_task_scheduler_impl.h b/chrome/browser/download/download_task_scheduler_impl.h
index 7f35d67..5385040e 100644
--- a/chrome/browser/download/download_task_scheduler_impl.h
+++ b/chrome/browser/download/download_task_scheduler_impl.h
@@ -11,7 +11,7 @@
#include "base/cancelable_callback.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "components/download/public/background_service/task_scheduler.h"
+#include "components/download/public/task/task_scheduler.h"
namespace content {
class BrowserContext;
diff --git a/components/download/BUILD.gn b/components/download/BUILD.gn
index d022618..a2a5342 100644
--- a/components/download/BUILD.gn
+++ b/components/download/BUILD.gn
@@ -12,7 +12,7 @@
"//components/download/database:unit_tests",
"//components/download/internal/background_service:unit_tests",
"//components/download/internal/common:unit_tests",
- "//components/download/public/background_service:unit_tests",
+ "//components/download/public/task:unit_tests",
"//components/download/quarantine:unit_tests",
]
}
diff --git a/components/download/content/factory/download_service_factory.cc b/components/download/content/factory/download_service_factory.cc
index 5dbbeceaf..d691b40 100644
--- a/components/download/content/factory/download_service_factory.cc
+++ b/components/download/content/factory/download_service_factory.cc
@@ -14,7 +14,6 @@
#include "components/download/internal/background_service/download_service_impl.h"
#include "components/download/internal/background_service/download_store.h"
#include "components/download/internal/background_service/empty_file_monitor.h"
-#include "components/download/internal/background_service/empty_task_scheduler.h"
#include "components/download/internal/background_service/file_monitor_impl.h"
#include "components/download/internal/background_service/in_memory_download_driver.h"
#include "components/download/internal/background_service/logger_impl.h"
@@ -22,6 +21,7 @@
#include "components/download/internal/background_service/noop_store.h"
#include "components/download/internal/background_service/proto/entry.pb.h"
#include "components/download/internal/background_service/scheduler/scheduler_impl.h"
+#include "components/download/public/task/empty_task_scheduler.h"
#include "components/leveldb_proto/proto_database_impl.h"
#include "content/public/browser/storage_partition.h"
diff --git a/components/download/internal/background_service/BUILD.gn b/components/download/internal/background_service/BUILD.gn
index 6034df5..83b9120 100644
--- a/components/download/internal/background_service/BUILD.gn
+++ b/components/download/internal/background_service/BUILD.gn
@@ -38,8 +38,6 @@
"driver_entry.h",
"empty_file_monitor.cc",
"empty_file_monitor.h",
- "empty_task_scheduler.cc",
- "empty_task_scheduler.h",
"entry.cc",
"entry.h",
"entry_utils.cc",
diff --git a/components/download/internal/background_service/controller.h b/components/download/internal/background_service/controller.h
index 6c35850..9b7f53f 100644
--- a/components/download/internal/background_service/controller.h
+++ b/components/download/internal/background_service/controller.h
@@ -10,7 +10,7 @@
#include "base/macros.h"
#include "components/download/public/background_service/clients.h"
#include "components/download/public/background_service/download_service.h"
-#include "components/download/public/background_service/download_task_types.h"
+#include "components/download/public/task/download_task_types.h"
namespace download {
diff --git a/components/download/internal/background_service/controller_impl.h b/components/download/internal/background_service/controller_impl.h
index d2476d5..7105d00 100644
--- a/components/download/internal/background_service/controller_impl.h
+++ b/components/download/internal/background_service/controller_impl.h
@@ -28,7 +28,7 @@
#include "components/download/public/background_service/client.h"
#include "components/download/public/background_service/download_params.h"
#include "components/download/public/background_service/navigation_monitor.h"
-#include "components/download/public/background_service/task_scheduler.h"
+#include "components/download/public/task/task_scheduler.h"
namespace download {
diff --git a/components/download/internal/background_service/scheduler/scheduler_impl.cc b/components/download/internal/background_service/scheduler/scheduler_impl.cc
index a47fe638..4976f10e 100644
--- a/components/download/internal/background_service/scheduler/scheduler_impl.cc
+++ b/components/download/internal/background_service/scheduler/scheduler_impl.cc
@@ -9,7 +9,7 @@
#include "components/download/internal/background_service/entry_utils.h"
#include "components/download/internal/background_service/scheduler/device_status.h"
#include "components/download/public/background_service/download_params.h"
-#include "components/download/public/background_service/task_scheduler.h"
+#include "components/download/public/task/task_scheduler.h"
namespace download {
diff --git a/components/download/internal/background_service/scheduler/scheduler_impl_unittest.cc b/components/download/internal/background_service/scheduler/scheduler_impl_unittest.cc
index 10b5faf..35eb57b 100644
--- a/components/download/internal/background_service/scheduler/scheduler_impl_unittest.cc
+++ b/components/download/internal/background_service/scheduler/scheduler_impl_unittest.cc
@@ -11,7 +11,7 @@
#include "components/download/internal/background_service/config.h"
#include "components/download/internal/background_service/entry.h"
#include "components/download/internal/background_service/scheduler/device_status.h"
-#include "components/download/public/background_service/task_scheduler.h"
+#include "components/download/public/task/task_scheduler.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/download/internal/background_service/stats.h b/components/download/internal/background_service/stats.h
index 7a0e40f..11100e1 100644
--- a/components/download/internal/background_service/stats.h
+++ b/components/download/internal/background_service/stats.h
@@ -13,7 +13,7 @@
#include "components/download/internal/background_service/entry.h"
#include "components/download/public/background_service/clients.h"
#include "components/download/public/background_service/download_params.h"
-#include "components/download/public/background_service/download_task_types.h"
+#include "components/download/public/task/download_task_types.h"
namespace download {
diff --git a/components/download/public/background_service/BUILD.gn b/components/download/public/background_service/BUILD.gn
index 4a91c71..424ed0b 100644
--- a/components/download/public/background_service/BUILD.gn
+++ b/components/download/public/background_service/BUILD.gn
@@ -16,15 +16,11 @@
"download_params.cc",
"download_params.h",
"download_service.h",
- "download_task_types.h",
"features.cc",
"features.h",
"logger.h",
"navigation_monitor.h",
"service_config.h",
- "task_manager.cc",
- "task_manager.h",
- "task_scheduler.h",
]
deps = [
@@ -39,41 +35,8 @@
public_deps = [
"//base",
+ "//components/download/public/task:public",
"//net",
"//url",
]
}
-
-if (is_android) {
- android_library("public_java") {
- srcjar_deps = [ ":jni_enums" ]
-
- deps = [
- "//base:base_java",
- "//third_party/android_deps:android_support_annotations_java",
- ]
- }
-
- java_cpp_enum("jni_enums") {
- visibility = [ "*" ]
-
- sources = [
- "download_task_types.h",
- ]
- }
-}
-
-source_set("unit_tests") {
- testonly = true
-
- sources = [
- "task_manager_unittest.cc",
- ]
-
- deps = [
- "//base/test:test_support",
- "//components/download/public/background_service:public",
- "//testing/gmock",
- "//testing/gtest",
- ]
-}
diff --git a/components/download/public/background_service/download_service.h b/components/download/public/background_service/download_service.h
index 736666e0..01168f7 100644
--- a/components/download/public/background_service/download_service.h
+++ b/components/download/public/background_service/download_service.h
@@ -13,7 +13,7 @@
#include "base/memory/ref_counted.h"
#include "base/sequenced_task_runner.h"
#include "components/download/public/background_service/clients.h"
-#include "components/download/public/background_service/download_task_types.h"
+#include "components/download/public/task/download_task_types.h"
#include "components/keyed_service/core/keyed_service.h"
namespace download {
diff --git a/components/download/public/common/auto_resumption_handler.cc b/components/download/public/common/auto_resumption_handler.cc
index 3e6dfa5..3e01c85 100644
--- a/components/download/public/common/auto_resumption_handler.cc
+++ b/components/download/public/common/auto_resumption_handler.cc
@@ -10,7 +10,7 @@
#include "base/metrics/field_trial_params.h"
#include "base/strings/string_number_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
-#include "components/download/public/background_service/task_scheduler.h"
+#include "components/download/public/task/task_scheduler.h"
#include "url/gurl.h"
namespace {
diff --git a/components/download/public/common/auto_resumption_handler.h b/components/download/public/common/auto_resumption_handler.h
index c0bb504..0f36597 100644
--- a/components/download/public/common/auto_resumption_handler.h
+++ b/components/download/public/common/auto_resumption_handler.h
@@ -13,9 +13,9 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "components/download/network/network_status_listener.h"
-#include "components/download/public/background_service/task_manager.h"
#include "components/download/public/common/download_export.h"
#include "components/download/public/common/download_item.h"
+#include "components/download/public/task/task_manager.h"
namespace download {
diff --git a/components/download/public/task/BUILD.gn b/components/download/public/task/BUILD.gn
new file mode 100644
index 0000000..33ccb4c
--- /dev/null
+++ b/components/download/public/task/BUILD.gn
@@ -0,0 +1,57 @@
+# Copyright 2019 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+if (is_android) {
+ import("//build/config/android/config.gni")
+ import("//build/config/android/rules.gni")
+}
+
+source_set("public") {
+ sources = [
+ "download_task_types.h",
+ "empty_task_scheduler.cc",
+ "empty_task_scheduler.h",
+ "task_manager.cc",
+ "task_manager.h",
+ "task_scheduler.h",
+ ]
+
+ public_deps = [
+ "//base",
+ ]
+}
+
+if (is_android) {
+ android_library("public_java") {
+ srcjar_deps = [ ":jni_enums" ]
+
+ deps = [
+ "//base:base_java",
+ "//third_party/android_deps:android_support_annotations_java",
+ ]
+ }
+
+ java_cpp_enum("jni_enums") {
+ visibility = [ "*" ]
+
+ sources = [
+ "download_task_types.h",
+ ]
+ }
+}
+
+source_set("unit_tests") {
+ testonly = true
+
+ sources = [
+ "task_manager_unittest.cc",
+ ]
+
+ deps = [
+ ":public",
+ "//base/test:test_support",
+ "//testing/gmock",
+ "//testing/gtest",
+ ]
+}
diff --git a/components/download/public/background_service/download_task_types.h b/components/download/public/task/download_task_types.h
similarity index 72%
rename from components/download/public/background_service/download_task_types.h
rename to components/download/public/task/download_task_types.h
index 5140f520..559ca79 100644
--- a/components/download/public/background_service/download_task_types.h
+++ b/components/download/public/task/download_task_types.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_DOWNLOAD_PUBLIC_BACKGROUND_SERVICE_DOWNLOAD_TASK_TYPES_H_
-#define COMPONENTS_DOWNLOAD_PUBLIC_BACKGROUND_SERVICE_DOWNLOAD_TASK_TYPES_H_
+#ifndef COMPONENTS_DOWNLOAD_PUBLIC_TASK_DOWNLOAD_TASK_TYPES_H_
+#define COMPONENTS_DOWNLOAD_PUBLIC_TASK_DOWNLOAD_TASK_TYPES_H_
namespace download {
@@ -22,4 +22,4 @@
} // namespace download
-#endif // COMPONENTS_DOWNLOAD_PUBLIC_BACKGROUND_SERVICE_DOWNLOAD_TASK_TYPES_H_
+#endif // COMPONENTS_DOWNLOAD_PUBLIC_TASK_DOWNLOAD_TASK_TYPES_H_
diff --git a/components/download/internal/background_service/empty_task_scheduler.cc b/components/download/public/task/empty_task_scheduler.cc
similarity index 90%
rename from components/download/internal/background_service/empty_task_scheduler.cc
rename to components/download/public/task/empty_task_scheduler.cc
index 445d622..ae59a0d 100644
--- a/components/download/internal/background_service/empty_task_scheduler.cc
+++ b/components/download/public/task/empty_task_scheduler.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/download/internal/background_service/empty_task_scheduler.h"
+#include "components/download/public/task/empty_task_scheduler.h"
namespace download {
diff --git a/components/download/internal/background_service/empty_task_scheduler.h b/components/download/public/task/empty_task_scheduler.h
similarity index 73%
rename from components/download/internal/background_service/empty_task_scheduler.h
rename to components/download/public/task/empty_task_scheduler.h
index 814ade7..4b452cc 100644
--- a/components/download/internal/background_service/empty_task_scheduler.h
+++ b/components/download/public/task/empty_task_scheduler.h
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_DOWNLOAD_INTERNAL_BACKGROUND_SERVICE_EMPTY_TASK_SCHEDULER_H_
-#define COMPONENTS_DOWNLOAD_INTERNAL_BACKGROUND_SERVICE_EMPTY_TASK_SCHEDULER_H_
+#ifndef COMPONENTS_DOWNLOAD_PUBLIC_TASK_EMPTY_TASK_SCHEDULER_H_
+#define COMPONENTS_DOWNLOAD_PUBLIC_TASK_EMPTY_TASK_SCHEDULER_H_
#include <stdint.h>
#include "base/macros.h"
-#include "components/download/public/background_service/task_scheduler.h"
+#include "components/download/public/task/task_scheduler.h"
namespace download {
@@ -33,4 +33,4 @@
} // namespace download
-#endif // COMPONENTS_DOWNLOAD_INTERNAL_BACKGROUND_SERVICE_EMPTY_TASK_SCHEDULER_H_
+#endif // COMPONENTS_DOWNLOAD_PUBLIC_TASK_EMPTY_TASK_SCHEDULER_H_
diff --git a/components/download/public/background_service/task_manager.cc b/components/download/public/task/task_manager.cc
similarity index 97%
rename from components/download/public/background_service/task_manager.cc
rename to components/download/public/task/task_manager.cc
index 085b77f..0ef808b 100644
--- a/components/download/public/background_service/task_manager.cc
+++ b/components/download/public/task/task_manager.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/download/public/background_service/task_manager.h"
+#include "components/download/public/task/task_manager.h"
namespace download {
namespace {
diff --git a/components/download/public/background_service/task_manager.h b/components/download/public/task/task_manager.h
similarity index 92%
rename from components/download/public/background_service/task_manager.h
rename to components/download/public/task/task_manager.h
index c0bf734..0808541 100644
--- a/components/download/public/background_service/task_manager.h
+++ b/components/download/public/task/task_manager.h
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_DOWNLOAD_PUBLIC_BACKGROUND_SERVICE_TASK_MANAGER_H_
-#define COMPONENTS_DOWNLOAD_PUBLIC_BACKGROUND_SERVICE_TASK_MANAGER_H_
+#ifndef COMPONENTS_DOWNLOAD_PUBLIC_TASK_TASK_MANAGER_H_
+#define COMPONENTS_DOWNLOAD_PUBLIC_TASK_TASK_MANAGER_H_
#include <stdint.h>
#include <map>
#include "base/callback.h"
-#include "components/download/public/background_service/task_scheduler.h"
+#include "components/download/public/task/task_scheduler.h"
namespace download {
@@ -89,4 +89,4 @@
} // namespace download
-#endif // COMPONENTS_DOWNLOAD_PUBLIC_BACKGROUND_SERVICE_TASK_MANAGER_H_
+#endif // COMPONENTS_DOWNLOAD_PUBLIC_TASK_TASK_MANAGER_H_
diff --git a/components/download/public/background_service/task_manager_unittest.cc b/components/download/public/task/task_manager_unittest.cc
similarity index 98%
rename from components/download/public/background_service/task_manager_unittest.cc
rename to components/download/public/task/task_manager_unittest.cc
index d2d34e8..c4c9daa 100644
--- a/components/download/public/background_service/task_manager_unittest.cc
+++ b/components/download/public/task/task_manager_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/download/public/background_service/task_manager.h"
+#include "components/download/public/task/task_manager.h"
#include <stdint.h>
#include <memory>
diff --git a/components/download/public/background_service/task_scheduler.h b/components/download/public/task/task_scheduler.h
similarity index 81%
rename from components/download/public/background_service/task_scheduler.h
rename to components/download/public/task/task_scheduler.h
index 409af4b..5d4af64 100644
--- a/components/download/public/background_service/task_scheduler.h
+++ b/components/download/public/task/task_scheduler.h
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_DOWNLOAD_PUBLIC_BACKGROUND_SERVICE_TASK_SCHEDULER_H_
-#define COMPONENTS_DOWNLOAD_PUBLIC_BACKGROUND_SERVICE_TASK_SCHEDULER_H_
+#ifndef COMPONENTS_DOWNLOAD_PUBLIC_TASK_TASK_SCHEDULER_H_
+#define COMPONENTS_DOWNLOAD_PUBLIC_TASK_TASK_SCHEDULER_H_
#include <stdint.h>
-#include "components/download/public/background_service/download_task_types.h"
+#include "components/download/public/task/download_task_types.h"
namespace download {
@@ -36,4 +36,4 @@
} // namespace download
-#endif // COMPONENTS_DOWNLOAD_PUBLIC_BACKGROUND_SERVICE_TASK_SCHEDULER_H_
+#endif // COMPONENTS_DOWNLOAD_PUBLIC_TASK_TASK_SCHEDULER_H_