Commit d461ee46 authored by Min Qin's avatar Min Qin Committed by Commit Bot

Move parallel download feature to components/download

This feature is currently defined in content/.
This Cl moves it to components/download to remove download dependency on content/.

BUG=803135

Change-Id: Iabbc34eff56554722d4aa7bde1f461135984ac74
Reviewed-on: https://chromium-review.googlesource.com/955899
Commit-Queue: Min Qin <qinmin@chromium.org>
Reviewed-by: default avatarXing Liu <xingliu@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542199}
parent 4df819e3
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_features.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_features.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h"
#include "components/dom_distiller/core/dom_distiller_switches.h" #include "components/dom_distiller/core/dom_distiller_switches.h"
#include "components/download/public/common/download_features.h"
#include "components/error_page/common/error_page_switches.h" #include "components/error_page/common/error_page_switches.h"
#include "components/favicon/core/features.h" #include "components/favicon/core/features.h"
#include "components/feature_engagement/public/feature_constants.h" #include "components/feature_engagement/public/feature_constants.h"
...@@ -3490,7 +3491,7 @@ const FeatureEntry kFeatureEntries[] = { ...@@ -3490,7 +3491,7 @@ const FeatureEntry kFeatureEntries[] = {
{"enable-parallel-downloading", flag_descriptions::kParallelDownloadingName, {"enable-parallel-downloading", flag_descriptions::kParallelDownloadingName,
flag_descriptions::kParallelDownloadingDescription, kOsAll, flag_descriptions::kParallelDownloadingDescription, kOsAll,
FEATURE_VALUE_TYPE(features::kParallelDownloading)}, FEATURE_VALUE_TYPE(download::features::kParallelDownloading)},
{"enable-html-base-username-detector", {"enable-html-base-username-detector",
flag_descriptions::kHtmlBasedUsernameDetectorName, flag_descriptions::kHtmlBasedUsernameDetectorName,
......
...@@ -21,6 +21,8 @@ component("public") { ...@@ -21,6 +21,8 @@ component("public") {
"download_danger_type.h", "download_danger_type.h",
"download_destination_observer.cc", "download_destination_observer.cc",
"download_destination_observer.h", "download_destination_observer.h",
"download_features.cc",
"download_features.h",
"download_interrupt_reason_values.h", "download_interrupt_reason_values.h",
"download_interrupt_reasons.h", "download_interrupt_reasons.h",
"download_interrupt_reasons_utils.h", "download_interrupt_reasons_utils.h",
......
// Copyright 2018 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.
#include "components/download/public/common/download_features.h"
#include "build/build_config.h"
namespace download {
namespace features {
const base::Feature kParallelDownloading {
"ParallelDownloading",
#if defined(OS_ANDROID)
base::FEATURE_ENABLED_BY_DEFAULT
#else
base::FEATURE_DISABLED_BY_DEFAULT
#endif
};
} // namespace features
} // namespace download
// Copyright 2018 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.
#ifndef COMPONENTS_DOWNLOAD_PUBLIC_COMMON_DOWNLOAD_FEATURES_H_
#define COMPONENTS_DOWNLOAD_PUBLIC_COMMON_DOWNLOAD_FEATURES_H_
#include "base/feature_list.h"
#include "components/download/public/common/download_export.h"
namespace download {
namespace features {
// Whether a download can be handled by parallel jobs.
COMPONENTS_DOWNLOAD_EXPORT extern const base::Feature kParallelDownloading;
} // namespace features
} // namespace download
#endif // COMPONENTS_DOWNLOAD_PUBLIC_COMMON_DOWNLOAD_FEATURES_H_
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/download/public/common/download_danger_type.h" #include "components/download/public/common/download_danger_type.h"
#include "components/download/public/common/download_features.h"
#include "components/download/public/common/download_task_runner.h" #include "components/download/public/common/download_task_runner.h"
#include "content/browser/download/download_file_factory.h" #include "content/browser/download/download_file_factory.h"
#include "content/browser/download/download_file_impl.h" #include "content/browser/download/download_file_impl.h"
...@@ -42,7 +43,6 @@ ...@@ -42,7 +43,6 @@
#include "content/browser/web_contents/web_contents_impl.h" #include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/download_request_utils.h" #include "content/public/browser/download_request_utils.h"
#include "content/public/browser/resource_throttle.h" #include "content/public/browser/resource_throttle.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_paths.h" #include "content/public/common/content_paths.h"
#include "content/public/common/webplugininfo.h" #include "content/public/common/webplugininfo.h"
#include "content/public/test/browser_test_utils.h" #include "content/public/test/browser_test_utils.h"
...@@ -915,7 +915,7 @@ class ParallelDownloadTest : public DownloadContentTest { ...@@ -915,7 +915,7 @@ class ParallelDownloadTest : public DownloadContentTest {
{content::kParallelRequestDelayFinchKey, "0"}, {content::kParallelRequestDelayFinchKey, "0"},
{content::kParallelRequestRemainingTimeFinchKey, "0"}}; {content::kParallelRequestRemainingTimeFinchKey, "0"}};
scoped_feature_list_.InitAndEnableFeatureWithParameters( scoped_feature_list_.InitAndEnableFeatureWithParameters(
features::kParallelDownloading, params); download::features::kParallelDownloading, params);
} }
~ParallelDownloadTest() override {} ~ParallelDownloadTest() override {}
...@@ -971,7 +971,8 @@ class ParallelDownloadTest : public DownloadContentTest { ...@@ -971,7 +971,8 @@ class ParallelDownloadTest : public DownloadContentTest {
const download::DownloadItem::ReceivedSlices& received_slices, const download::DownloadItem::ReceivedSlices& received_slices,
int64_t total_length, int64_t total_length,
size_t expected_request_count) { size_t expected_request_count) {
EXPECT_TRUE(base::FeatureList::IsEnabled(features::kParallelDownloading)); EXPECT_TRUE(
base::FeatureList::IsEnabled(download::features::kParallelDownloading));
GURL url = TestDownloadHttpResponse::GetNextURLForDownload(); GURL url = TestDownloadHttpResponse::GetNextURLForDownload();
GURL server_url = embedded_test_server()->GetURL(url.host(), url.path()); GURL server_url = embedded_test_server()->GetURL(url.host(), url.path());
TestDownloadHttpResponse::Parameters parameters; TestDownloadHttpResponse::Parameters parameters;
...@@ -1007,7 +1008,8 @@ class ParallelDownloadTest : public DownloadContentTest { ...@@ -1007,7 +1008,8 @@ class ParallelDownloadTest : public DownloadContentTest {
// Verifies parallel download completion. // Verifies parallel download completion.
void RunCompletionTest(TestDownloadHttpResponse::Parameters& parameters) { void RunCompletionTest(TestDownloadHttpResponse::Parameters& parameters) {
EXPECT_TRUE(base::FeatureList::IsEnabled(features::kParallelDownloading)); EXPECT_TRUE(
base::FeatureList::IsEnabled(download::features::kParallelDownloading));
GURL url = TestDownloadHttpResponse::GetNextURLForDownload(); GURL url = TestDownloadHttpResponse::GetNextURLForDownload();
GURL server_url = embedded_test_server()->GetURL(url.host(), url.path()); GURL server_url = embedded_test_server()->GetURL(url.host(), url.path());
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
#include "base/metrics/field_trial_params.h" #include "base/metrics/field_trial_params.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "components/download/public/common/download_features.h"
#include "components/download/public/common/download_save_info.h" #include "components/download/public/common/download_save_info.h"
#include "content/public/common/content_features.h"
namespace content { namespace content {
...@@ -157,7 +157,7 @@ bool CanRecoverFromError( ...@@ -157,7 +157,7 @@ bool CanRecoverFromError(
int64_t GetMinSliceSizeConfig() { int64_t GetMinSliceSizeConfig() {
std::string finch_value = base::GetFieldTrialParamValueByFeature( std::string finch_value = base::GetFieldTrialParamValueByFeature(
features::kParallelDownloading, kMinSliceSizeFinchKey); download::features::kParallelDownloading, kMinSliceSizeFinchKey);
int64_t result; int64_t result;
return base::StringToInt64(finch_value, &result) return base::StringToInt64(finch_value, &result)
? result ? result
...@@ -166,7 +166,7 @@ int64_t GetMinSliceSizeConfig() { ...@@ -166,7 +166,7 @@ int64_t GetMinSliceSizeConfig() {
int GetParallelRequestCountConfig() { int GetParallelRequestCountConfig() {
std::string finch_value = base::GetFieldTrialParamValueByFeature( std::string finch_value = base::GetFieldTrialParamValueByFeature(
features::kParallelDownloading, kParallelRequestCountFinchKey); download::features::kParallelDownloading, kParallelRequestCountFinchKey);
int result; int result;
return base::StringToInt(finch_value, &result) ? result return base::StringToInt(finch_value, &result) ? result
: kParallelRequestCount; : kParallelRequestCount;
...@@ -174,7 +174,7 @@ int GetParallelRequestCountConfig() { ...@@ -174,7 +174,7 @@ int GetParallelRequestCountConfig() {
base::TimeDelta GetParallelRequestDelayConfig() { base::TimeDelta GetParallelRequestDelayConfig() {
std::string finch_value = base::GetFieldTrialParamValueByFeature( std::string finch_value = base::GetFieldTrialParamValueByFeature(
features::kParallelDownloading, kParallelRequestDelayFinchKey); download::features::kParallelDownloading, kParallelRequestDelayFinchKey);
int64_t time_ms = 0; int64_t time_ms = 0;
return base::StringToInt64(finch_value, &time_ms) return base::StringToInt64(finch_value, &time_ms)
? base::TimeDelta::FromMilliseconds(time_ms) ? base::TimeDelta::FromMilliseconds(time_ms)
...@@ -183,7 +183,8 @@ base::TimeDelta GetParallelRequestDelayConfig() { ...@@ -183,7 +183,8 @@ base::TimeDelta GetParallelRequestDelayConfig() {
base::TimeDelta GetParallelRequestRemainingTimeConfig() { base::TimeDelta GetParallelRequestRemainingTimeConfig() {
std::string finch_value = base::GetFieldTrialParamValueByFeature( std::string finch_value = base::GetFieldTrialParamValueByFeature(
features::kParallelDownloading, kParallelRequestRemainingTimeFinchKey); download::features::kParallelDownloading,
kParallelRequestRemainingTimeFinchKey);
int time_in_seconds = 0; int time_in_seconds = 0;
return base::StringToInt(finch_value, &time_in_seconds) return base::StringToInt(finch_value, &time_in_seconds)
? base::TimeDelta::FromSeconds(time_in_seconds) ? base::TimeDelta::FromSeconds(time_in_seconds)
...@@ -214,11 +215,12 @@ int64_t GetMaxContiguousDataBlockSizeFromBeginning( ...@@ -214,11 +215,12 @@ int64_t GetMaxContiguousDataBlockSizeFromBeginning(
bool IsParallelDownloadEnabled() { bool IsParallelDownloadEnabled() {
bool feature_enabled = bool feature_enabled =
base::FeatureList::IsEnabled(features::kParallelDownloading); base::FeatureList::IsEnabled(download::features::kParallelDownloading);
// Disabled when |kEnableParallelDownloadFinchKey| Finch config is set to // Disabled when |kEnableParallelDownloadFinchKey| Finch config is set to
// false. // false.
bool enabled_parameter = GetFieldTrialParamByFeatureAsBool( bool enabled_parameter = GetFieldTrialParamByFeatureAsBool(
features::kParallelDownloading, kEnableParallelDownloadFinchKey, true); download::features::kParallelDownloading, kEnableParallelDownloadFinchKey,
true);
return feature_enabled && enabled_parameter; return feature_enabled && enabled_parameter;
} }
......
...@@ -9,11 +9,11 @@ ...@@ -9,11 +9,11 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "components/download/public/common/download_features.h"
#include "components/download/public/common/download_save_info.h" #include "components/download/public/common/download_save_info.h"
#include "content/browser/byte_stream.h" #include "content/browser/byte_stream.h"
#include "content/browser/download/byte_stream_input_stream.h" #include "content/browser/download/byte_stream_input_stream.h"
#include "content/public/browser/download_manager.h" #include "content/public/browser/download_manager.h"
#include "content/public/common/content_features.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -203,7 +203,7 @@ TEST_F(ParallelDownloadUtilsTest, FinchConfigEnabled) { ...@@ -203,7 +203,7 @@ TEST_F(ParallelDownloadUtilsTest, FinchConfigEnabled) {
{content::kParallelRequestDelayFinchKey, "2000"}, {content::kParallelRequestDelayFinchKey, "2000"},
{content::kParallelRequestRemainingTimeFinchKey, "3"}}; {content::kParallelRequestRemainingTimeFinchKey, "3"}};
feature_list.InitAndEnableFeatureWithParameters( feature_list.InitAndEnableFeatureWithParameters(
features::kParallelDownloading, params); download::features::kParallelDownloading, params);
EXPECT_TRUE(IsParallelDownloadEnabled()); EXPECT_TRUE(IsParallelDownloadEnabled());
EXPECT_EQ(GetMinSliceSizeConfig(), 1234); EXPECT_EQ(GetMinSliceSizeConfig(), 1234);
EXPECT_EQ(GetParallelRequestCountConfig(), 6); EXPECT_EQ(GetParallelRequestCountConfig(), 6);
...@@ -216,7 +216,7 @@ TEST_F(ParallelDownloadUtilsTest, FinchConfigEnabled) { ...@@ -216,7 +216,7 @@ TEST_F(ParallelDownloadUtilsTest, FinchConfigEnabled) {
// feature. // feature.
TEST_F(ParallelDownloadUtilsTest, FinchConfigDisabled) { TEST_F(ParallelDownloadUtilsTest, FinchConfigDisabled) {
base::test::ScopedFeatureList feature_list; base::test::ScopedFeatureList feature_list;
feature_list.InitAndDisableFeature(features::kParallelDownloading); feature_list.InitAndDisableFeature(download::features::kParallelDownloading);
EXPECT_FALSE(IsParallelDownloadEnabled()); EXPECT_FALSE(IsParallelDownloadEnabled());
} }
...@@ -229,7 +229,7 @@ TEST_F(ParallelDownloadUtilsTest, FinchConfigDisabledWithParameter) { ...@@ -229,7 +229,7 @@ TEST_F(ParallelDownloadUtilsTest, FinchConfigDisabledWithParameter) {
{content::kMinSliceSizeFinchKey, "4321"}, {content::kMinSliceSizeFinchKey, "4321"},
{content::kEnableParallelDownloadFinchKey, "false"}}; {content::kEnableParallelDownloadFinchKey, "false"}};
feature_list.InitAndEnableFeatureWithParameters( feature_list.InitAndEnableFeatureWithParameters(
features::kParallelDownloading, params); download::features::kParallelDownloading, params);
// Use |enable_parallel_download| to disable parallel download in enabled // Use |enable_parallel_download| to disable parallel download in enabled
// experiment group. // experiment group.
EXPECT_FALSE(IsParallelDownloadEnabled()); EXPECT_FALSE(IsParallelDownloadEnabled());
...@@ -241,7 +241,7 @@ TEST_F(ParallelDownloadUtilsTest, FinchConfigDisabledWithParameter) { ...@@ -241,7 +241,7 @@ TEST_F(ParallelDownloadUtilsTest, FinchConfigDisabledWithParameter) {
{content::kMinSliceSizeFinchKey, "4321"}, {content::kMinSliceSizeFinchKey, "4321"},
{content::kEnableParallelDownloadFinchKey, "true"}}; {content::kEnableParallelDownloadFinchKey, "true"}};
feature_list.InitAndEnableFeatureWithParameters( feature_list.InitAndEnableFeatureWithParameters(
features::kParallelDownloading, params); download::features::kParallelDownloading, params);
// Disable only if |enable_parallel_download| sets to false. // Disable only if |enable_parallel_download| sets to false.
EXPECT_TRUE(IsParallelDownloadEnabled()); EXPECT_TRUE(IsParallelDownloadEnabled());
EXPECT_EQ(GetMinSliceSizeConfig(), 4321); EXPECT_EQ(GetMinSliceSizeConfig(), 4321);
...@@ -251,7 +251,7 @@ TEST_F(ParallelDownloadUtilsTest, FinchConfigDisabledWithParameter) { ...@@ -251,7 +251,7 @@ TEST_F(ParallelDownloadUtilsTest, FinchConfigDisabledWithParameter) {
std::map<std::string, std::string> params = { std::map<std::string, std::string> params = {
{content::kMinSliceSizeFinchKey, "4321"}}; {content::kMinSliceSizeFinchKey, "4321"}};
feature_list.InitAndEnableFeatureWithParameters( feature_list.InitAndEnableFeatureWithParameters(
features::kParallelDownloading, params); download::features::kParallelDownloading, params);
// Empty |enable_parallel_download| in an enabled experiment group will have // Empty |enable_parallel_download| in an enabled experiment group will have
// no impact. // no impact.
EXPECT_TRUE(IsParallelDownloadEnabled()); EXPECT_TRUE(IsParallelDownloadEnabled());
......
...@@ -238,16 +238,6 @@ const base::Feature kOriginManifest{"OriginManifest", ...@@ -238,16 +238,6 @@ const base::Feature kOriginManifest{"OriginManifest",
const base::Feature kOriginTrials{"OriginTrials", const base::Feature kOriginTrials{"OriginTrials",
base::FEATURE_ENABLED_BY_DEFAULT}; base::FEATURE_ENABLED_BY_DEFAULT};
// Whether a download can be handled by parallel jobs.
const base::Feature kParallelDownloading {
"ParallelDownloading",
#if defined(OS_ANDROID)
base::FEATURE_ENABLED_BY_DEFAULT
#else
base::FEATURE_DISABLED_BY_DEFAULT
#endif
};
// Whether document level event listeners should default 'passive' to true. // Whether document level event listeners should default 'passive' to true.
const base::Feature kPassiveDocumentEventListeners{ const base::Feature kPassiveDocumentEventListeners{
"PassiveDocumentEventListeners", base::FEATURE_ENABLED_BY_DEFAULT}; "PassiveDocumentEventListeners", base::FEATURE_ENABLED_BY_DEFAULT};
......
...@@ -64,7 +64,6 @@ CONTENT_EXPORT extern const base::Feature kNotificationContentImage; ...@@ -64,7 +64,6 @@ CONTENT_EXPORT extern const base::Feature kNotificationContentImage;
CONTENT_EXPORT extern const base::Feature kNotificationsWithMojo; CONTENT_EXPORT extern const base::Feature kNotificationsWithMojo;
CONTENT_EXPORT extern const base::Feature kOriginManifest; CONTENT_EXPORT extern const base::Feature kOriginManifest;
CONTENT_EXPORT extern const base::Feature kOriginTrials; CONTENT_EXPORT extern const base::Feature kOriginTrials;
CONTENT_EXPORT extern const base::Feature kParallelDownloading;
CONTENT_EXPORT extern const base::Feature kPassiveDocumentEventListeners; CONTENT_EXPORT extern const base::Feature kPassiveDocumentEventListeners;
CONTENT_EXPORT extern const base::Feature kPassiveEventListenersDueToFling; CONTENT_EXPORT extern const base::Feature kPassiveEventListenersDueToFling;
CONTENT_EXPORT extern const base::Feature kPdfIsolation; CONTENT_EXPORT extern const base::Feature kPdfIsolation;
......
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