Commit 5017f22c authored by Sorin Jianu's avatar Sorin Jianu Committed by Commit Bot

Create a Finch experiment to turn on JSON in the update client.

Bug: 881076
Change-Id: I9f9739197c903cce7b0814b54df4314d2917b6eb
Reviewed-on: https://chromium-review.googlesource.com/c/1334969Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
Commit-Queue: Sorin Jianu <sorin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608432}
parent 07930c24
......@@ -20,4 +20,10 @@ const char kUpdaterDefaultUrl[] =
const char kUpdaterFallbackUrl[] =
"http://update.googleapis.com/service/update2";
extern const char kUpdaterJSONDefaultUrl[] =
"https://update.googleapis.com/service/update2/json";
extern const char kUpdaterJSONFallbackUrl[] =
"http://update.googleapis.com/service/update2/json";
} // namespace component_updater
......@@ -7,9 +7,14 @@
namespace component_updater {
// Xml endpoints.
extern const char kUpdaterDefaultUrl[];
extern const char kUpdaterFallbackUrl[];
// JSON endpoints.
extern const char kUpdaterJSONDefaultUrl[];
extern const char kUpdaterJSONFallbackUrl[];
} // namespace component_updater
#endif // COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_URL_CONSTANTS_H_
......@@ -8,6 +8,7 @@
#include <algorithm>
#include "base/feature_list.h"
#include "base/stl_util.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
......@@ -32,6 +33,13 @@ namespace {
const int kDelayOneMinute = 60;
const int kDelayOneHour = kDelayOneMinute * 60;
// Enables using JSON as an update client protocol encoding instead of XML.
//
// The JSON implementation is available behind a flag:
// --enable-features=UpdateClientUseJSON
const base::Feature kFeatureUpdateClientUseJSON{
"UpdateClientUseJSON", base::FEATURE_DISABLED_BY_DEFAULT};
} // namespace
ConfiguratorImpl::ConfiguratorImpl(
......@@ -69,11 +77,15 @@ int ConfiguratorImpl::UpdateDelay() const {
}
std::vector<GURL> ConfiguratorImpl::UpdateUrl() const {
if (url_source_override_.is_valid()) {
if (url_source_override_.is_valid())
return {GURL(url_source_override_)};
}
std::vector<GURL> urls{GURL(kUpdaterDefaultUrl), GURL(kUpdaterFallbackUrl)};
std::vector<GURL> urls =
base::FeatureList::IsEnabled(kFeatureUpdateClientUseJSON)
? std::vector<GURL>{GURL(kUpdaterJSONDefaultUrl),
GURL(kUpdaterJSONFallbackUrl)}
: std::vector<GURL>{GURL(kUpdaterDefaultUrl),
GURL(kUpdaterFallbackUrl)};
if (require_encryption_)
update_client::RemoveUnsecureUrls(&urls);
......@@ -133,6 +145,8 @@ std::string ConfiguratorImpl::GetAppGuid() const {
std::unique_ptr<update_client::ProtocolHandlerFactory>
ConfiguratorImpl::GetProtocolHandlerFactory() const {
if (base::FeatureList::IsEnabled(kFeatureUpdateClientUseJSON))
return std::make_unique<update_client::ProtocolHandlerFactoryJSON>();
return std::make_unique<update_client::ProtocolHandlerFactoryXml>();
}
......
......@@ -4981,6 +4981,26 @@
]
}
],
"UpdateClientUseJSON": [
{
"platforms": [
"android",
"chromeos",
"linux",
"mac",
"windows",
"ios"
],
"experiments": [
{
"name": "UpdateClientUseJSON",
"enable_features": [
"UpdateClientUseJSON"
]
}
]
}
],
"UpdateMenuItem": [
{
"platforms": [
......
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