Commit ff672925 authored by Alexander Alekseev's avatar Alexander Alekseev Committed by Commit Bot

ChromeOS: use GoogleUpdateSettings::GetCollectStatsConsent on blocking thread.

This is an update to https://chromium-review.googlesource.com/783707 that
ensures that blocking GetCollectStatsConsent is used only on a blocking thread.

Bug: 782641
Change-Id: I5629e00616f1ab24b4a63f1c3433f683370c3239
Reviewed-on: https://chromium-review.googlesource.com/802764
Commit-Queue: Alexander Alekseev <alemate@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521055}
parent e6fdd3c6
......@@ -216,6 +216,11 @@ bool IsOnline(NetworkPortalDetector::CaptivePortalStatus status) {
return status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE;
}
void GetVersionAndConsent(std::string* out_version, bool* out_consent) {
*out_version = version_loader::GetVersion(version_loader::VERSION_SHORT);
*out_consent = GoogleUpdateSettings::GetCollectStatsConsent();
}
} // namespace
// A class that's used to specify the way how Gaia should be loaded.
......@@ -293,16 +298,24 @@ void GaiaScreenHandler::DisableRestrictiveProxyCheckForTest() {
}
void GaiaScreenHandler::LoadGaia(const GaiaContext& context) {
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
base::Bind(&version_loader::GetVersion, version_loader::VERSION_SHORT),
base::Bind(&GaiaScreenHandler::LoadGaiaWithVersion,
weak_factory_.GetWeakPtr(), context));
}
void GaiaScreenHandler::LoadGaiaWithVersion(
std::unique_ptr<std::string> version = std::make_unique<std::string>();
std::unique_ptr<bool> consent = std::make_unique<bool>();
base::OnceClosure get_version_and_consent =
base::BindOnce(&GetVersionAndConsent, base::Unretained(version.get()),
base::Unretained(consent.get()));
base::OnceClosure load_gaia = base::BindOnce(
&GaiaScreenHandler::LoadGaiaWithVersionAndConsent,
weak_factory_.GetWeakPtr(), context, base::Owned(version.release()),
base::Owned(consent.release()));
base::PostTaskWithTraitsAndReply(
FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
std::move(get_version_and_consent), std::move(load_gaia));
}
void GaiaScreenHandler::LoadGaiaWithVersionAndConsent(
const GaiaContext& context,
const std::string& platform_version) {
const std::string* platform_version,
const bool* collect_stats_consent) {
// Start a new session with SigninPartitionManager, generating a a unique
// StoragePartition.
login::SigninPartitionManager* signin_partition_manager =
......@@ -359,8 +372,8 @@ void GaiaScreenHandler::LoadGaiaWithVersion(
params.SetString("clientId",
GaiaUrls::GetInstance()->oauth2_chrome_client_id());
params.SetString("clientVersion", version_info::GetVersionNumber());
if (!platform_version.empty())
params.SetString("platformVersion", platform_version);
if (!platform_version->empty())
params.SetString("platformVersion", *platform_version);
params.SetString("releaseChannel", chrome::GetChannelString());
params.SetString("endpointGen", kEndpointGen);
......@@ -383,7 +396,7 @@ void GaiaScreenHandler::LoadGaiaWithVersion(
}
// We only send |chromeos_board| Gaia URL parameter if user has opted into
// sending device statistics.
if (GoogleUpdateSettings::GetCollectStatsConsent())
if (*collect_stats_consent)
params.SetString("lsbReleaseBoard", base::SysInfo::GetLsbReleaseBoard());
params.SetString("webviewPartitionName",
signin_partition_manager->GetCurrentStoragePartitionName());
......
......@@ -58,9 +58,11 @@ class GaiaScreenHandler : public BaseScreenHandler,
void LoadGaia(const GaiaContext& context);
// Callback that loads GAIA after version information has been retrieved.
void LoadGaiaWithVersion(const GaiaContext& context,
const std::string& platform_version);
// Callback that loads GAIA after version and stat consent information has
// been retrieved.
void LoadGaiaWithVersionAndConsent(const GaiaContext& context,
const std::string* platform_version,
const bool* collect_stats_consent);
// Sends request to reload Gaia. If |force_reload| is true, request
// will be sent in any case, otherwise it will be sent only when Gaia is
......
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