Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(445)

Unified Diff: components/download/internal/config.cc

Issue 2895953004: Add initial Controller to DownloadService (Closed)
Patch Set: Rebased Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/download/internal/config.h ('k') | components/download/internal/controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/download/internal/config.cc
diff --git a/components/download/internal/config.cc b/components/download/internal/config.cc
index 564da91b881af7e4a18e860cdb1024aeb694659b..264add3a90a8dcbb068ca99be9bd73b289f73745 100644
--- a/components/download/internal/config.cc
+++ b/components/download/internal/config.cc
@@ -16,29 +16,29 @@ namespace download {
namespace {
// Default value for max concurrent downloads configuration.
-const int kDefaultMaxConcurrentDownloads = 4;
+const uint32_t kDefaultMaxConcurrentDownloads = 4;
// Default value for maximum running downloads of the download service.
-const int kDefaultMaxRunningDownloads = 1;
+const uint32_t kDefaultMaxRunningDownloads = 1;
// Default value for maximum scheduled downloads.
-const int kDefaultMaxScheduledDownloads = 15;
+const uint32_t kDefaultMaxScheduledDownloads = 15;
// Default value for maximum retry count.
-const int kDefaultMaxRetryCount = 5;
+const uint32_t kDefaultMaxRetryCount = 5;
// Default value for file keep alive time in minutes, keep the file alive for
// 12 hours by default.
-const int kDefaultFileKeepAliveTimeMinutes = 12 * 60;
+const uint32_t kDefaultFileKeepAliveTimeMinutes = 12 * 60;
// Helper routine to get Finch experiment parameter. If no Finch seed was found,
// use the |default_value|. The |name| should match an experiment
// parameter in Finch server configuration.
-int GetFinchConfigInt(const std::string& name, int default_value) {
+uint32_t GetFinchConfigUInt(const std::string& name, uint32_t default_value) {
std::string finch_value =
base::GetFieldTrialParamValueByFeature(kDownloadServiceFeature, name);
- int result;
- return base::StringToInt(finch_value, &result) ? result : default_value;
+ uint32_t result;
+ return base::StringToUint(finch_value, &result) ? result : default_value;
}
} // namespace
@@ -46,16 +46,17 @@ int GetFinchConfigInt(const std::string& name, int default_value) {
// static
std::unique_ptr<Configuration> Configuration::CreateFromFinch() {
std::unique_ptr<Configuration> config(new Configuration());
- config->max_concurrent_downloads = GetFinchConfigInt(
+ config->max_concurrent_downloads = GetFinchConfigUInt(
kMaxConcurrentDownloadsConfig, kDefaultMaxConcurrentDownloads);
- config->max_running_downloads = GetFinchConfigInt(
+ config->max_running_downloads = GetFinchConfigUInt(
kMaxRunningDownloadsConfig, kDefaultMaxRunningDownloads);
- config->max_scheduled_downloads = GetFinchConfigInt(
+ config->max_scheduled_downloads = GetFinchConfigUInt(
kMaxScheduledDownloadsConfig, kDefaultMaxScheduledDownloads);
config->max_retry_count =
- GetFinchConfigInt(kMaxRetryCountConfig, kDefaultMaxRetryCount);
- config->file_keep_alive_time = base::TimeDelta::FromMinutes(GetFinchConfigInt(
- kFileKeepAliveTimeMinutesConfig, kDefaultFileKeepAliveTimeMinutes));
+ GetFinchConfigUInt(kMaxRetryCountConfig, kDefaultMaxRetryCount);
+ config->file_keep_alive_time =
+ base::TimeDelta::FromMinutes(base::saturated_cast<int>(GetFinchConfigUInt(
+ kFileKeepAliveTimeMinutesConfig, kDefaultFileKeepAliveTimeMinutes)));
return config;
}
@@ -64,7 +65,7 @@ Configuration::Configuration()
max_running_downloads(kDefaultMaxRunningDownloads),
max_scheduled_downloads(kDefaultMaxScheduledDownloads),
max_retry_count(kDefaultMaxRetryCount),
- file_keep_alive_time(
- base::TimeDelta::FromMinutes(kDefaultFileKeepAliveTimeMinutes)) {}
+ file_keep_alive_time(base::TimeDelta::FromMinutes(
+ base::saturated_cast<int>(kDefaultFileKeepAliveTimeMinutes))) {}
} // namespace download
« no previous file with comments | « components/download/internal/config.h ('k') | components/download/internal/controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698