summaryrefslogtreecommitdiff
path: root/chromium/components/update_client
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-12-10 16:19:40 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-12-10 16:01:50 +0000
commit51f6c2793adab2d864b3d2b360000ef8db1d3e92 (patch)
tree835b3b4446b012c75e80177cef9fbe6972cc7dbe /chromium/components/update_client
parent6036726eb981b6c4b42047513b9d3f4ac865daac (diff)
downloadqtwebengine-chromium-51f6c2793adab2d864b3d2b360000ef8db1d3e92.tar.gz
BASELINE: Update Chromium to 71.0.3578.93
Change-Id: I6a32086c33670e1b033f8b10e6bf1fd4da1d105d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/components/update_client')
-rw-r--r--chromium/components/update_client/BUILD.gn1
-rw-r--r--chromium/components/update_client/DEPS1
-rw-r--r--chromium/components/update_client/configurator.h7
-rw-r--r--chromium/components/update_client/ping_manager_unittest.cc108
-rw-r--r--chromium/components/update_client/protocol_builder.cc17
-rw-r--r--chromium/components/update_client/protocol_builder.h7
-rw-r--r--chromium/components/update_client/protocol_builder_unittest.cc10
-rw-r--r--chromium/components/update_client/request_sender.cc2
-rw-r--r--chromium/components/update_client/request_sender.h15
-rw-r--r--chromium/components/update_client/request_sender_unittest.cc2
-rw-r--r--chromium/components/update_client/test_configurator.cc5
-rw-r--r--chromium/components/update_client/test_configurator.h3
-rw-r--r--chromium/components/update_client/update_checker.cc26
-rw-r--r--chromium/components/update_client/update_checker.h16
-rw-r--r--chromium/components/update_client/update_checker_unittest.cc65
-rw-r--r--chromium/components/update_client/update_client_unittest.cc274
-rw-r--r--chromium/components/update_client/utils.cc4
-rw-r--r--chromium/components/update_client/utils.h5
18 files changed, 307 insertions, 261 deletions
diff --git a/chromium/components/update_client/BUILD.gn b/chromium/components/update_client/BUILD.gn
index 966e7346891..0c6ef0f6082 100644
--- a/chromium/components/update_client/BUILD.gn
+++ b/chromium/components/update_client/BUILD.gn
@@ -185,5 +185,6 @@ source_set("unit_tests") {
"//testing/gmock",
"//testing/gtest",
"//third_party/libxml",
+ "//third_party/re2",
]
}
diff --git a/chromium/components/update_client/DEPS b/chromium/components/update_client/DEPS
index 11fec055972..7beeb7b82cb 100644
--- a/chromium/components/update_client/DEPS
+++ b/chromium/components/update_client/DEPS
@@ -15,5 +15,6 @@ include_rules = [
"+services/network/test",
"+services/service_manager/public",
"+third_party/libxml",
+ "+third_party/re2",
"+third_party/zlib",
]
diff --git a/chromium/components/update_client/configurator.h b/chromium/components/update_client/configurator.h
index db2762fe4f1..347813e4832 100644
--- a/chromium/components/update_client/configurator.h
+++ b/chromium/components/update_client/configurator.h
@@ -9,6 +9,7 @@
#include <string>
#include <vector>
+#include "base/containers/flat_map.h"
#include "base/memory/ref_counted.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
@@ -82,9 +83,9 @@ class Configurator : public base::RefCountedThreadSafe<Configurator> {
virtual std::string GetOSLongName() const = 0;
// Parameters added to each url request. It can be empty if none are needed.
- // The return string must be safe for insertion as an attribute in an
- // XML element.
- virtual std::string ExtraRequestParams() const = 0;
+ // Returns a map of name-value pairs that match ^[-_a-zA-Z0-9]$ regex.
+ virtual base::flat_map<std::string, std::string> ExtraRequestParams()
+ const = 0;
// Provides a hint for the server to control the order in which multiple
// download urls are returned. The hint may or may not be honored in the
diff --git a/chromium/components/update_client/ping_manager_unittest.cc b/chromium/components/update_client/ping_manager_unittest.cc
index 3e0b9db9142..0ac9f80b475 100644
--- a/chromium/components/update_client/ping_manager_unittest.cc
+++ b/chromium/components/update_client/ping_manager_unittest.cc
@@ -22,6 +22,7 @@
#include "components/update_client/url_loader_post_interceptor.h"
#include "net/url_request/url_request_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/re2/src/re2/re2.h"
using std::string;
@@ -123,13 +124,22 @@ TEST_F(PingManagerTest, SendPing) {
RunThreads();
EXPECT_EQ(1, interceptor->GetCount()) << interceptor->GetRequestsAsString();
- EXPECT_NE(string::npos,
- interceptor->GetRequestBody(0).find(
- "<app appid=\"abc\">"
- "<event eventtype=\"3\" eventresult=\"1\" "
- "previousversion=\"1.0\" nextversion=\"2.0\"/></app>"))
- << interceptor->GetRequestsAsString();
- EXPECT_NE(string::npos, interceptor->GetRequestBody(0).find(" sessionid="));
+ const auto msg = interceptor->GetRequestBody(0);
+ constexpr char regex[] =
+ R"(<\?xml version="1\.0" encoding="UTF-8"\?>)"
+ R"(<request protocol="3\.1" )"
+ R"(dedup="cr" acceptformat="crx2,crx3" )"
+ R"(sessionid="{[-\w]{36}}" requestid="{[-\w]{36}}" )"
+ R"(updater="fake_prodid" updaterversion="30\.0" prodversion="30\.0" )"
+ R"(lang="fake_lang" updaterchannel="fake_channel_string" )"
+ R"(prodchannel="fake_channel_string" )"
+ R"(os="\w+" arch="\w+" nacl_arch="[-\w]+"( wow64="1")?>)"
+ R"(<hw physmemory="\d+"/>)"
+ R"(<os platform="Fake Operating System" arch="[,-.\w]+" )"
+ R"(version="[-.\w]+"( sp="[\s\w]+")?/>)"
+ R"(<app appid="abc"><event eventtype="3" eventresult="1" )"
+ R"(previousversion="1\.0" nextversion="2\.0"/></app></request>)";
+ EXPECT_TRUE(RE2::FullMatch(msg, regex)) << msg;
// Check the ping request does not carry the specific extra request headers.
EXPECT_FALSE(std::get<1>(interceptor->GetRequests()[0])
@@ -157,12 +167,11 @@ TEST_F(PingManagerTest, SendPing) {
RunThreads();
EXPECT_EQ(1, interceptor->GetCount()) << interceptor->GetRequestsAsString();
- EXPECT_NE(string::npos,
- interceptor->GetRequestBody(0).find(
- "<app appid=\"abc\">"
- "<event eventtype=\"3\" eventresult=\"0\" "
- "previousversion=\"1.0\" nextversion=\"2.0\"/></app>"))
- << interceptor->GetRequestsAsString();
+ const auto msg = interceptor->GetRequestBody(0);
+ constexpr char regex[] =
+ R"(<app appid="abc"><event eventtype="3" eventresult="0" )"
+ R"(previousversion="1\.0" nextversion="2\.0"/></app>)";
+ EXPECT_TRUE(RE2::PartialMatch(msg, regex)) << msg;
interceptor->Reset();
}
@@ -190,16 +199,16 @@ TEST_F(PingManagerTest, SendPing) {
RunThreads();
EXPECT_EQ(1, interceptor->GetCount()) << interceptor->GetRequestsAsString();
- EXPECT_NE(string::npos,
- interceptor->GetRequestBody(0).find(
- "<app appid=\"abc\">"
- "<event eventtype=\"3\" eventresult=\"0\" errorcat=\"1\" "
- "errorcode=\"2\" extracode1=\"-1\" diffresult=\"0\" "
- "differrorcat=\"4\" "
- "differrorcode=\"20\" diffextracode1=\"-10\" "
- "previousfp=\"prev fp\" nextfp=\"next fp\" "
- "previousversion=\"1.0\" nextversion=\"2.0\"/></app>"))
- << interceptor->GetRequestsAsString();
+ const auto msg = interceptor->GetRequestBody(0);
+ constexpr char regex[] =
+ R"(<app appid="abc">)"
+ R"(<event eventtype="3" eventresult="0" errorcat="1" )"
+ R"(errorcode="2" extracode1="-1" diffresult="0" )"
+ R"(differrorcat="4" differrorcode="20" diffextracode1="-10" )"
+ R"(previousfp="prev fp" nextfp="next fp" )"
+ R"(previousversion="1\.0" nextversion="2\.0"/></app>)";
+ EXPECT_TRUE(RE2::PartialMatch(msg, regex)) << msg;
+
interceptor->Reset();
}
@@ -218,11 +227,12 @@ TEST_F(PingManagerTest, SendPing) {
RunThreads();
EXPECT_EQ(1, interceptor->GetCount()) << interceptor->GetRequestsAsString();
- EXPECT_NE(string::npos,
- interceptor->GetRequestBody(0).find(
- "<app appid=\"abc\"><event eventtype=\"3\" eventresult=\"0\" "
- "previousversion=\"1.0\"/></app>"))
- << interceptor->GetRequestsAsString();
+ const auto msg = interceptor->GetRequestBody(0);
+ constexpr char regex[] =
+ R"(<app appid="abc"><event eventtype="3" eventresult="0" )"
+ R"(previousversion="1\.0"/></app>)";
+ EXPECT_TRUE(RE2::PartialMatch(msg, regex)) << msg;
+
interceptor->Reset();
}
@@ -239,12 +249,12 @@ TEST_F(PingManagerTest, SendPing) {
RunThreads();
EXPECT_EQ(1, interceptor->GetCount()) << interceptor->GetRequestsAsString();
- EXPECT_NE(string::npos,
- interceptor->GetRequestBody(0).find(
- "<app appid=\"abc\">"
- "<event eventtype=\"4\" eventresult=\"1\" "
- "previousversion=\"1.2.3.4\" nextversion=\"0\"/></app>"))
- << interceptor->GetRequestsAsString();
+ const auto msg = interceptor->GetRequestBody(0);
+ constexpr char regex[] =
+ R"(<app appid="abc"><event eventtype="4" eventresult="1" )"
+ R"(previousversion="1\.2\.3\.4" nextversion="0"/></app>)";
+ EXPECT_TRUE(RE2::PartialMatch(msg, regex)) << msg;
+
interceptor->Reset();
}
@@ -282,21 +292,21 @@ TEST_F(PingManagerTest, SendPing) {
RunThreads();
EXPECT_EQ(1, interceptor->GetCount()) << interceptor->GetRequestsAsString();
- EXPECT_NE(
- string::npos,
- interceptor->GetRequestBody(0).find(
- "<app appid=\"abc\">"
- "<event eventtype=\"3\" eventresult=\"1\" previousversion=\"1.0\" "
- "nextversion=\"2.0\"/>"
- "<event eventtype=\"14\" eventresult=\"0\" downloader=\"direct\" "
- "errorcode=\"-1\" url=\"http://host1/path1\" downloaded=\"123\" "
- "total=\"456\" download_time_ms=\"987\" previousversion=\"1.0\" "
- "nextversion=\"2.0\"/>"
- "<event eventtype=\"14\" eventresult=\"1\" downloader=\"bits\" "
- "url=\"http://host2/path2\" downloaded=\"1230\" total=\"4560\" "
- "download_time_ms=\"9870\" previousversion=\"1.0\" "
- "nextversion=\"2.0\"/></app>"))
- << interceptor->GetRequestsAsString();
+ const auto msg = interceptor->GetRequestBody(0);
+ constexpr char regex[] =
+ R"(<app appid="abc">)"
+ R"(<event eventtype="3" eventresult="1" )"
+ R"(previousversion="1\.0" nextversion="2\.0"/>)"
+ R"(<event eventtype="14" eventresult="0" downloader="direct" )"
+ R"(errorcode="-1" url="http://host1/path1" downloaded="123" )"
+ R"(total="456" download_time_ms="987" previousversion="1\.0" )"
+ R"(nextversion="2\.0"/>)"
+ R"(<event eventtype="14" eventresult="1" downloader="bits" )"
+ R"(url="http://host2/path2" downloaded="1230" total="4560" )"
+ R"(download_time_ms="9870" previousversion="1\.0" )"
+ R"(nextversion="2\.0"/></app>)";
+ EXPECT_TRUE(RE2::PartialMatch(msg, regex)) << msg;
+
interceptor->Reset();
}
}
diff --git a/chromium/components/update_client/protocol_builder.cc b/chromium/components/update_client/protocol_builder.cc
index 54a172e1c50..0bcda6736ac 100644
--- a/chromium/components/update_client/protocol_builder.cc
+++ b/chromium/components/update_client/protocol_builder.cc
@@ -211,15 +211,18 @@ std::string BuildProtocolRequest(
const std::string& os_long_name,
const std::string& download_preference,
const std::string& request_body,
- const std::string& additional_attributes,
+ const base::flat_map<std::string, std::string>& additional_attributes,
const std::unique_ptr<UpdaterState::Attributes>& updater_state_attributes) {
std::string request = base::StringPrintf(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<request protocol=\"%s\" ",
kProtocolVersion);
- if (!additional_attributes.empty())
- base::StringAppendF(&request, "%s ", additional_attributes.c_str());
+ if (!additional_attributes.empty()) {
+ for (const auto& attr : additional_attributes)
+ base::StringAppendF(&request, "%s=\"%s\" ", attr.first.c_str(),
+ attr.second.c_str());
+ }
// Constant information for this updater.
base::StringAppendF(&request, "dedup=\"cr\" acceptformat=\"crx2,crx3\" ");
@@ -301,7 +304,7 @@ std::string BuildProtocolRequest(
return request;
}
-std::map<std::string, std::string> BuildUpdateCheckExtraRequestHeaders(
+base::flat_map<std::string, std::string> BuildUpdateCheckExtraRequestHeaders(
scoped_refptr<Configurator> config,
const std::vector<std::string>& ids,
bool is_foreground) {
@@ -312,7 +315,7 @@ std::map<std::string, std::string> BuildUpdateCheckExtraRequestHeaders(
? ids
: std::vector<std::string>(ids.cbegin(),
ids.cbegin() + maxExtensionCount);
- return std::map<std::string, std::string>{
+ return {
{"X-Goog-Update-Updater",
base::StringPrintf("%s-%s", config->GetProdId().c_str(),
config->GetBrowserVersion().GetString().c_str())},
@@ -327,7 +330,7 @@ std::string BuildUpdateCheckRequest(
const std::vector<std::string>& ids_checked,
const IdToComponentPtrMap& components,
PersistedData* metadata,
- const std::string& additional_attributes,
+ const base::flat_map<std::string, std::string>& additional_attributes,
bool enabled_component_updates,
const std::unique_ptr<UpdaterState::Attributes>& updater_state_attributes) {
const std::string brand(SanitizeBrand(config.GetBrand()));
@@ -442,7 +445,7 @@ std::string BuildEventPingRequest(const Configurator& config,
config.GetBrowserVersion().GetString(),
config.GetChannel(), config.GetLang(),
config.GetOSLongName(),
- config.GetDownloadPreference(), app, "", nullptr);
+ config.GetDownloadPreference(), app, {}, nullptr);
}
} // namespace update_client
diff --git a/chromium/components/update_client/protocol_builder.h b/chromium/components/update_client/protocol_builder.h
index e323c82aad4..d00bf0c0fc9 100644
--- a/chromium/components/update_client/protocol_builder.h
+++ b/chromium/components/update_client/protocol_builder.h
@@ -10,6 +10,7 @@
#include <string>
#include <vector>
+#include "base/containers/flat_map.h"
#include "components/update_client/component.h"
#include "components/update_client/crx_downloader.h"
#include "components/update_client/updater_state.h"
@@ -22,7 +23,7 @@ class PersistedData;
// Creates the values for the DDOS extra request headers sent with the update
// check. These headers include "X-Goog-Update-Updater",
// "X-Goog-Update-AppId", and "X-Goog-Update-Interactivity".
-std::map<std::string, std::string> BuildUpdateCheckExtraRequestHeaders(
+base::flat_map<std::string, std::string> BuildUpdateCheckExtraRequestHeaders(
scoped_refptr<Configurator> config,
const std::vector<std::string>& ids_checked,
bool is_foreground);
@@ -48,7 +49,7 @@ std::string BuildUpdateCheckRequest(
const std::vector<std::string>& ids_checked,
const IdToComponentPtrMap& components,
PersistedData* metadata,
- const std::string& additional_attributes,
+ const base::flat_map<std::string, std::string>& additional_attributes,
bool enabled_component_updates,
const std::unique_ptr<UpdaterState::Attributes>& updater_state_attributes);
@@ -120,7 +121,7 @@ std::string BuildProtocolRequest(
const std::string& os_long_name,
const std::string& download_preference,
const std::string& request_body,
- const std::string& additional_attributes,
+ const base::flat_map<std::string, std::string>& additional_attributes,
const std::unique_ptr<UpdaterState::Attributes>& updater_state_attributes);
} // namespace update_client
diff --git a/chromium/components/update_client/protocol_builder_unittest.cc b/chromium/components/update_client/protocol_builder_unittest.cc
index 0570e70e4f2..206959b2701 100644
--- a/chromium/components/update_client/protocol_builder_unittest.cc
+++ b/chromium/components/update_client/protocol_builder_unittest.cc
@@ -23,7 +23,7 @@ TEST(BuildProtocolRequest, SessionIdProdIdVersion) {
// Verifies that |session_id|, |prod_id| and |version| are serialized.
const string request = BuildProtocolRequest(
"15160585-8ADE-4D3C-839B-1281A6035D1F", "some_prod_id", "1.0", "", "", "",
- "", "", "", nullptr);
+ "", "", {}, nullptr);
EXPECT_NE(
string::npos,
request.find(" sessionid=\"{15160585-8ADE-4D3C-839B-1281A6035D1F}\" "));
@@ -35,12 +35,12 @@ TEST(BuildProtocolRequest, SessionIdProdIdVersion) {
TEST(BuildProtocolRequest, DownloadPreference) {
// Verifies that an empty |download_preference| is not serialized.
const string request_no_dlpref =
- BuildProtocolRequest("1", "", "", "", "", "", "", "", "", nullptr);
+ BuildProtocolRequest("1", "", "", "", "", "", "", "", {}, nullptr);
EXPECT_EQ(string::npos, request_no_dlpref.find(" dlpref="));
// Verifies that |download_preference| is serialized.
const string request_with_dlpref = BuildProtocolRequest(
- "1", "", "", "", "", "", "some pref", "", "", nullptr);
+ "1", "", "", "", "", "", "some pref", "", {}, nullptr);
EXPECT_NE(string::npos, request_with_dlpref.find(" dlpref=\"some pref\""));
}
@@ -48,7 +48,7 @@ TEST(BuildProtocolRequest, UpdaterStateAttributes) {
// When no updater state is provided, then check that the elements and
// attributes related to the updater state are not serialized.
std::string request =
- BuildProtocolRequest("1", "", "", "", "", "", "", "", "", nullptr);
+ BuildProtocolRequest("1", "", "", "", "", "", "", "", {}, nullptr);
EXPECT_EQ(std::string::npos, request.find(" domainjoined"));
EXPECT_EQ(std::string::npos, request.find("<updater"));
@@ -62,7 +62,7 @@ TEST(BuildProtocolRequest, UpdaterStateAttributes) {
attributes["autoupdatecheckenabled"] = "0";
attributes["updatepolicy"] = "-1";
request = BuildProtocolRequest(
- "1", "", "", "", "", "", "", "", "",
+ "1", "", "", "", "", "", "", "", {},
std::make_unique<UpdaterState::Attributes>(attributes));
EXPECT_NE(std::string::npos, request.find(" domainjoined=\"1\""));
const std::string updater_element =
diff --git a/chromium/components/update_client/request_sender.cc b/chromium/components/update_client/request_sender.cc
index be6e856db2b..b6657163b72 100644
--- a/chromium/components/update_client/request_sender.cc
+++ b/chromium/components/update_client/request_sender.cc
@@ -60,7 +60,7 @@ RequestSender::~RequestSender() {
void RequestSender::Send(
const std::vector<GURL>& urls,
- const std::map<std::string, std::string>& request_extra_headers,
+ const base::flat_map<std::string, std::string>& request_extra_headers,
const std::string& request_body,
bool use_signing,
RequestSenderCallback request_sender_callback) {
diff --git a/chromium/components/update_client/request_sender.h b/chromium/components/update_client/request_sender.h
index 10722312152..2ffdd62bd57 100644
--- a/chromium/components/update_client/request_sender.h
+++ b/chromium/components/update_client/request_sender.h
@@ -7,12 +7,12 @@
#include <stdint.h>
-#include <map>
#include <memory>
#include <string>
#include <vector>
#include "base/callback.h"
+#include "base/containers/flat_map.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/threading/thread_checker.h"
@@ -54,11 +54,12 @@ class RequestSender {
// If this optional parameter is set, the values of "fg" or "bg" are sent
// for true or false values of this parameter. Otherwise the header is not
// sent at all.
- void Send(const std::vector<GURL>& urls,
- const std::map<std::string, std::string>& request_extra_headers,
- const std::string& request_body,
- bool use_signing,
- RequestSenderCallback request_sender_callback);
+ void Send(
+ const std::vector<GURL>& urls,
+ const base::flat_map<std::string, std::string>& request_extra_headers,
+ const std::string& request_body,
+ bool use_signing,
+ RequestSenderCallback request_sender_callback);
private:
// Combines the |url| and |query_params| parameters.
@@ -99,7 +100,7 @@ class RequestSender {
const scoped_refptr<Configurator> config_;
std::vector<GURL> urls_;
- std::map<std::string, std::string> request_extra_headers_;
+ base::flat_map<std::string, std::string> request_extra_headers_;
std::string request_body_;
bool use_signing_; // True if CUP signing is used.
RequestSenderCallback request_sender_callback_;
diff --git a/chromium/components/update_client/request_sender_unittest.cc b/chromium/components/update_client/request_sender_unittest.cc
index e2eb26316d8..aa9e4c93c12 100644
--- a/chromium/components/update_client/request_sender_unittest.cc
+++ b/chromium/components/update_client/request_sender_unittest.cc
@@ -229,7 +229,7 @@ TEST_F(RequestSenderTest, RequestSendFailedNoUrls) {
std::vector<GURL> urls;
request_sender_ = std::make_unique<RequestSender>(config_);
request_sender_->Send(
- urls, std::map<std::string, std::string>(), "test", false,
+ urls, {}, "test", false,
base::BindOnce(&RequestSenderTest::RequestSenderComplete,
base::Unretained(this)));
RunThreads();
diff --git a/chromium/components/update_client/test_configurator.cc b/chromium/components/update_client/test_configurator.cc
index be07318b6fe..da9f2ddcc85 100644
--- a/chromium/components/update_client/test_configurator.cc
+++ b/chromium/components/update_client/test_configurator.cc
@@ -108,8 +108,9 @@ std::string TestConfigurator::GetOSLongName() const {
return "Fake Operating System";
}
-std::string TestConfigurator::ExtraRequestParams() const {
- return "extra=\"foo\"";
+base::flat_map<std::string, std::string> TestConfigurator::ExtraRequestParams()
+ const {
+ return {{"extra", "foo"}};
}
std::string TestConfigurator::GetDownloadPreference() const {
diff --git a/chromium/components/update_client/test_configurator.h b/chromium/components/update_client/test_configurator.h
index 4868d734662..cf74358ac54 100644
--- a/chromium/components/update_client/test_configurator.h
+++ b/chromium/components/update_client/test_configurator.h
@@ -12,6 +12,7 @@
#include <utility>
#include <vector>
+#include "base/containers/flat_map.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "components/update_client/configurator.h"
@@ -84,7 +85,7 @@ class TestConfigurator : public Configurator {
std::string GetBrand() const override;
std::string GetLang() const override;
std::string GetOSLongName() const override;
- std::string ExtraRequestParams() const override;
+ base::flat_map<std::string, std::string> ExtraRequestParams() const override;
std::string GetDownloadPreference() const override;
scoped_refptr<network::SharedURLLoaderFactory> URLLoaderFactory()
const override;
diff --git a/chromium/components/update_client/update_checker.cc b/chromium/components/update_client/update_checker.cc
index d915d3834d4..a2ce8f4ad6f 100644
--- a/chromium/components/update_client/update_checker.cc
+++ b/chromium/components/update_client/update_checker.cc
@@ -55,19 +55,21 @@ class UpdateCheckerImpl : public UpdateChecker {
~UpdateCheckerImpl() override;
// Overrides for UpdateChecker.
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_checked,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override;
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_checked,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override;
private:
void ReadUpdaterStateAttributes();
- void CheckForUpdatesHelper(const std::string& session_id,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates);
+ void CheckForUpdatesHelper(
+ const std::string& session_id,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates);
void OnRequestSenderComplete(int error,
const std::string& response,
int retry_after_sec);
@@ -101,7 +103,7 @@ void UpdateCheckerImpl::CheckForUpdates(
const std::string& session_id,
const std::vector<std::string>& ids_checked,
const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
+ const base::flat_map<std::string, std::string>& additional_attributes,
bool enabled_component_updates,
UpdateCheckCallback update_check_callback) {
DCHECK(thread_checker_.CalledOnValidThread());
@@ -136,7 +138,7 @@ void UpdateCheckerImpl::ReadUpdaterStateAttributes() {
void UpdateCheckerImpl::CheckForUpdatesHelper(
const std::string& session_id,
const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
+ const base::flat_map<std::string, std::string>& additional_attributes,
bool enabled_component_updates) {
DCHECK(thread_checker_.CalledOnValidThread());
diff --git a/chromium/components/update_client/update_checker.h b/chromium/components/update_client/update_checker.h
index 241e3a0a73c..d5126e193d5 100644
--- a/chromium/components/update_client/update_checker.h
+++ b/chromium/components/update_client/update_checker.h
@@ -10,6 +10,7 @@
#include <vector>
#include "base/callback.h"
+#include "base/containers/flat_map.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/optional.h"
@@ -38,18 +39,17 @@ class UpdateChecker {
// Initiates an update check for the components specified by their ids.
// |additional_attributes| provides a way to customize the <request> element.
- // This value is inserted as-is, therefore it must be well-formed as an
- // XML attribute string.
// |is_foreground| controls the value of "X-Goog-Update-Interactivity"
// header which is sent with the update check.
// On completion, the state of |components| is mutated as required by the
// server response received.
- virtual void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) = 0;
+ virtual void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) = 0;
static std::unique_ptr<UpdateChecker> Create(
scoped_refptr<Configurator> config,
diff --git a/chromium/components/update_client/update_checker_unittest.cc b/chromium/components/update_client/update_checker_unittest.cc
index 8fc15dce703..266cfad3768 100644
--- a/chromium/components/update_client/update_checker_unittest.cc
+++ b/chromium/components/update_client/update_checker_unittest.cc
@@ -258,7 +258,7 @@ TEST_P(UpdateCheckerTest, UpdateCheckSuccess) {
update_checker_->CheckForUpdates(
update_context_->session_id, {kUpdateItemId}, components,
- "extra=\"params\"", true,
+ {{"extra", "params"}, {"testrequest", "1"}}, true,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -271,7 +271,8 @@ TEST_P(UpdateCheckerTest, UpdateCheckSuccess) {
// Sanity check the request.
const auto& request = post_interceptor_->GetRequestBody(0);
EXPECT_THAT(request,
- testing::HasSubstr(R"(request protocol="3.1" extra="params")"));
+ testing::HasSubstr(
+ R"(request protocol="3.1" extra="params" testrequest="1")"));
// The request must not contain any "dlpref" in the default case.
EXPECT_THAT(request, testing::Not(testing::HasSubstr(R"( dlpref=")")));
EXPECT_THAT(request,
@@ -347,7 +348,7 @@ TEST_F(UpdateCheckerTest, UpdateCheckInvalidAp) {
component->crx_component_->installer_attributes["ap"] = std::string(257, 'a');
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", true,
+ update_context_->session_id, {kUpdateItemId}, components, {}, true,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
@@ -375,7 +376,7 @@ TEST_F(UpdateCheckerTest, UpdateCheckSuccessNoBrand) {
components[kUpdateItemId] = MakeComponent();
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", true,
+ update_context_->session_id, {kUpdateItemId}, components, {}, true,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
@@ -403,7 +404,7 @@ TEST_F(UpdateCheckerTest, UpdateCheckError) {
components[kUpdateItemId] = MakeComponent();
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", true,
+ update_context_->session_id, {kUpdateItemId}, components, {}, true,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -432,7 +433,7 @@ TEST_F(UpdateCheckerTest, UpdateCheckDownloadPreference) {
update_checker_->CheckForUpdates(
update_context_->session_id, {kUpdateItemId}, components,
- "extra=\"params\"", true,
+ {{"extra", "params"}}, true,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -457,7 +458,7 @@ TEST_F(UpdateCheckerTest, UpdateCheckCupError) {
components[kUpdateItemId] = MakeComponent();
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", true,
+ update_context_->session_id, {kUpdateItemId}, components, {}, true,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
@@ -498,7 +499,7 @@ TEST_F(UpdateCheckerTest, UpdateCheckRequiresEncryptionError) {
component->crx_component_->requires_network_encryption = true;
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", true,
+ update_context_->session_id, {kUpdateItemId}, components, {}, true,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -527,7 +528,7 @@ TEST_F(UpdateCheckerTest, UpdateCheckLastRollCall) {
activity_data_service_->SetDaysSinceLastRollCall(kUpdateItemId, 5);
update_checker_->CheckForUpdates(
update_context_->session_id, {kUpdateItemId}, components,
- "extra=\"params\"", true,
+ {{"extra", "params"}}, true,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -535,7 +536,7 @@ TEST_F(UpdateCheckerTest, UpdateCheckLastRollCall) {
update_checker_ = UpdateChecker::Create(config_, metadata_.get());
update_checker_->CheckForUpdates(
update_context_->session_id, {kUpdateItemId}, components,
- "extra=\"params\"", true,
+ {{"extra", "params"}}, true,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -570,7 +571,7 @@ TEST_F(UpdateCheckerTest, UpdateCheckLastActive) {
activity_data_service_->SetDaysSinceLastActive(kUpdateItemId, 10);
update_checker_->CheckForUpdates(
update_context_->session_id, {kUpdateItemId}, components,
- "extra=\"params\"", true,
+ {{"extra", "params"}}, true,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -582,7 +583,7 @@ TEST_F(UpdateCheckerTest, UpdateCheckLastActive) {
update_checker_ = UpdateChecker::Create(config_, metadata_.get());
update_checker_->CheckForUpdates(
update_context_->session_id, {kUpdateItemId}, components,
- "extra=\"params\"", true,
+ {{"extra", "params"}}, true,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -593,7 +594,7 @@ TEST_F(UpdateCheckerTest, UpdateCheckLastActive) {
update_checker_ = UpdateChecker::Create(config_, metadata_.get());
update_checker_->CheckForUpdates(
update_context_->session_id, {kUpdateItemId}, components,
- "extra=\"params\"", true,
+ {{"extra", "params"}}, true,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -626,7 +627,7 @@ TEST_F(UpdateCheckerTest, UpdateCheckInstallSource) {
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.xml")));
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", false,
+ update_context_->session_id, {kUpdateItemId}, components, {}, false,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -639,7 +640,7 @@ TEST_F(UpdateCheckerTest, UpdateCheckInstallSource) {
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.xml")));
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", false,
+ update_context_->session_id, {kUpdateItemId}, components, {}, false,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -656,7 +657,7 @@ TEST_F(UpdateCheckerTest, UpdateCheckInstallSource) {
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.xml")));
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", false,
+ update_context_->session_id, {kUpdateItemId}, components, {}, false,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -673,7 +674,7 @@ TEST_F(UpdateCheckerTest, UpdateCheckInstallSource) {
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.xml")));
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", false,
+ update_context_->session_id, {kUpdateItemId}, components, {}, false,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -696,7 +697,7 @@ TEST_F(UpdateCheckerTest, ComponentDisabled) {
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.xml")));
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", false,
+ update_context_->session_id, {kUpdateItemId}, components, {}, false,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -712,7 +713,7 @@ TEST_F(UpdateCheckerTest, ComponentDisabled) {
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.xml")));
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", false,
+ update_context_->session_id, {kUpdateItemId}, components, {}, false,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -727,7 +728,7 @@ TEST_F(UpdateCheckerTest, ComponentDisabled) {
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.xml")));
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", false,
+ update_context_->session_id, {kUpdateItemId}, components, {}, false,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -743,7 +744,7 @@ TEST_F(UpdateCheckerTest, ComponentDisabled) {
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.xml")));
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", false,
+ update_context_->session_id, {kUpdateItemId}, components, {}, false,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -759,7 +760,7 @@ TEST_F(UpdateCheckerTest, ComponentDisabled) {
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.xml")));
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", false,
+ update_context_->session_id, {kUpdateItemId}, components, {}, false,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -777,7 +778,7 @@ TEST_F(UpdateCheckerTest, ComponentDisabled) {
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.xml")));
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", false,
+ update_context_->session_id, {kUpdateItemId}, components, {}, false,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -811,7 +812,7 @@ TEST_F(UpdateCheckerTest, UpdateCheckUpdateDisabled) {
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.xml")));
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", false,
+ update_context_->session_id, {kUpdateItemId}, components, {}, false,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -831,7 +832,7 @@ TEST_F(UpdateCheckerTest, UpdateCheckUpdateDisabled) {
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.xml")));
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", false,
+ update_context_->session_id, {kUpdateItemId}, components, {}, false,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -852,7 +853,7 @@ TEST_F(UpdateCheckerTest, UpdateCheckUpdateDisabled) {
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.xml")));
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", true,
+ update_context_->session_id, {kUpdateItemId}, components, {}, true,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -872,7 +873,7 @@ TEST_F(UpdateCheckerTest, UpdateCheckUpdateDisabled) {
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.xml")));
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", true,
+ update_context_->session_id, {kUpdateItemId}, components, {}, true,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -893,7 +894,7 @@ TEST_F(UpdateCheckerTest, NoUpdateActionRun) {
components[kUpdateItemId] = MakeComponent();
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", true,
+ update_context_->session_id, {kUpdateItemId}, components, {}, true,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -930,7 +931,7 @@ TEST_F(UpdateCheckerTest, UpdatePauseResume) {
components[kUpdateItemId] = MakeComponent();
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", true,
+ update_context_->session_id, {kUpdateItemId}, components, {}, true,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -964,7 +965,7 @@ TEST_F(UpdateCheckerTest, UpdateResetUpdateChecker) {
update_checker_ = UpdateChecker::Create(config_, metadata_.get());
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", true,
+ update_context_->session_id, {kUpdateItemId}, components, {}, true,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
runloop.Run();
@@ -983,7 +984,7 @@ TEST_F(UpdateCheckerTest, ParseErrorProtocolVersionMismatch) {
components[kUpdateItemId] = MakeComponent();
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", true,
+ update_context_->session_id, {kUpdateItemId}, components, {}, true,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
@@ -1012,7 +1013,7 @@ TEST_F(UpdateCheckerTest, ParseErrorAppStatusErrorUnknownApplication) {
components[kUpdateItemId] = MakeComponent();
update_checker_->CheckForUpdates(
- update_context_->session_id, {kUpdateItemId}, components, "", true,
+ update_context_->session_id, {kUpdateItemId}, components, {}, true,
base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete,
base::Unretained(this)));
RunThreads();
diff --git a/chromium/components/update_client/update_client_unittest.cc b/chromium/components/update_client/update_client_unittest.cc
index dc41bbd13b6..8f1da0f0367 100644
--- a/chromium/components/update_client/update_client_unittest.cc
+++ b/chromium/components/update_client/update_client_unittest.cc
@@ -6,6 +6,7 @@
#include <utility>
#include "base/bind.h"
+#include "base/containers/flat_map.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/location.h"
@@ -245,12 +246,13 @@ TEST_F(UpdateClientTest, OneCrxNoUpdate) {
return std::make_unique<MockUpdateChecker>();
}
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override {
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override {
EXPECT_FALSE(session_id.empty());
EXPECT_TRUE(enabled_component_updates);
EXPECT_EQ(1u, ids_to_check.size());
@@ -363,12 +365,13 @@ TEST_F(UpdateClientTest, TwoCrxUpdateNoUpdate) {
return std::make_unique<MockUpdateChecker>();
}
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override {
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override {
/*
Mock the following response:
@@ -579,12 +582,13 @@ TEST_F(UpdateClientTest, TwoCrxUpdateFirstServerIgnoresSecond) {
return std::make_unique<MockUpdateChecker>();
}
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override {
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override {
/*
Mock the following response:
@@ -786,12 +790,13 @@ TEST_F(UpdateClientTest, TwoCrxUpdateNoCrxComponentData) {
return std::make_unique<MockUpdateChecker>();
}
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override {
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override {
/*
Mock the following response:
@@ -974,12 +979,13 @@ TEST_F(UpdateClientTest, TwoCrxUpdateNoCrxComponentDataAtAll) {
return std::make_unique<MockUpdateChecker>();
}
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override {
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override {
NOTREACHED();
}
};
@@ -1080,12 +1086,13 @@ TEST_F(UpdateClientTest, TwoCrxUpdateDownloadTimeout) {
return std::make_unique<MockUpdateChecker>();
}
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override {
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override {
/*
Mock the following response:
@@ -1354,12 +1361,13 @@ TEST_F(UpdateClientTest, OneCrxDiffUpdate) {
return std::make_unique<MockUpdateChecker>();
}
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override {
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override {
EXPECT_FALSE(session_id.empty());
static int num_call = 0;
@@ -1682,12 +1690,13 @@ TEST_F(UpdateClientTest, OneCrxInstallError) {
return std::make_unique<MockUpdateChecker>();
}
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override {
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override {
/*
Mock the following response:
@@ -1873,12 +1882,13 @@ TEST_F(UpdateClientTest, OneCrxDiffUpdateFailsFullUpdateSucceeds) {
return std::make_unique<MockUpdateChecker>();
}
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override {
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override {
EXPECT_FALSE(session_id.empty());
static int num_call = 0;
@@ -2173,12 +2183,13 @@ TEST_F(UpdateClientTest, OneCrxNoUpdateQueuedCall) {
return std::make_unique<MockUpdateChecker>();
}
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override {
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override {
EXPECT_FALSE(session_id.empty());
EXPECT_TRUE(enabled_component_updates);
EXPECT_EQ(1u, ids_to_check.size());
@@ -2288,12 +2299,13 @@ TEST_F(UpdateClientTest, OneCrxInstall) {
return std::make_unique<MockUpdateChecker>();
}
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override {
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override {
/*
Mock the following response:
@@ -2466,12 +2478,13 @@ TEST_F(UpdateClientTest, OneCrxInstallNoCrxComponentData) {
return std::make_unique<MockUpdateChecker>();
}
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override {
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override {
NOTREACHED();
}
};
@@ -2580,12 +2593,13 @@ TEST_F(UpdateClientTest, ConcurrentInstallSameCRX) {
return std::make_unique<MockUpdateChecker>();
}
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override {
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override {
EXPECT_FALSE(session_id.empty());
EXPECT_TRUE(enabled_component_updates);
EXPECT_EQ(1u, ids_to_check.size());
@@ -2689,12 +2703,13 @@ TEST_F(UpdateClientTest, EmptyIdList) {
return std::make_unique<MockUpdateChecker>();
}
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override {
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override {
NOTREACHED();
}
};
@@ -2750,12 +2765,13 @@ TEST_F(UpdateClientTest, SendUninstallPing) {
return nullptr;
}
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override {
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override {
NOTREACHED();
}
};
@@ -2854,12 +2870,13 @@ TEST_F(UpdateClientTest, RetryAfter) {
return std::make_unique<MockUpdateChecker>();
}
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override {
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override {
EXPECT_FALSE(session_id.empty());
static int num_call = 0;
@@ -3036,12 +3053,13 @@ TEST_F(UpdateClientTest, TwoCrxUpdateOneUpdateDisabled) {
return std::make_unique<MockUpdateChecker>();
}
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override {
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override {
/*
Mock the following response:
@@ -3282,12 +3300,13 @@ TEST_F(UpdateClientTest, OneCrxUpdateCheckFails) {
return std::make_unique<MockUpdateChecker>();
}
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override {
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override {
EXPECT_FALSE(session_id.empty());
EXPECT_TRUE(enabled_component_updates);
EXPECT_EQ(1u, ids_to_check.size());
@@ -3422,12 +3441,13 @@ TEST_F(UpdateClientTest, OneCrxErrorUnknownApp) {
return std::make_unique<MockUpdateChecker>();
}
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override {
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override {
EXPECT_FALSE(session_id.empty());
EXPECT_TRUE(enabled_component_updates);
EXPECT_EQ(4u, ids_to_check.size());
@@ -3579,12 +3599,13 @@ TEST_F(UpdateClientTest, ActionRun_Install) {
return std::make_unique<MockUpdateChecker>();
}
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override {
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override {
/*
Mock the following response:
@@ -3743,12 +3764,13 @@ TEST_F(UpdateClientTest, ActionRun_NoUpdate) {
return std::make_unique<MockUpdateChecker>();
}
- void CheckForUpdates(const std::string& session_id,
- const std::vector<std::string>& ids_to_check,
- const IdToComponentPtrMap& components,
- const std::string& additional_attributes,
- bool enabled_component_updates,
- UpdateCheckCallback update_check_callback) override {
+ void CheckForUpdates(
+ const std::string& session_id,
+ const std::vector<std::string>& ids_to_check,
+ const IdToComponentPtrMap& components,
+ const base::flat_map<std::string, std::string>& additional_attributes,
+ bool enabled_component_updates,
+ UpdateCheckCallback update_check_callback) override {
/*
Mock the following response:
diff --git a/chromium/components/update_client/utils.cc b/chromium/components/update_client/utils.cc
index 131288f3ce7..fc2e42bd6e0 100644
--- a/chromium/components/update_client/utils.cc
+++ b/chromium/components/update_client/utils.cc
@@ -9,7 +9,6 @@
#include <algorithm>
#include <cmath>
#include <cstring>
-#include <map>
#include <vector>
#include "base/callback.h"
@@ -40,7 +39,8 @@ namespace update_client {
std::unique_ptr<network::SimpleURLLoader> SendProtocolRequest(
const GURL& url,
- const std::map<std::string, std::string>& protocol_request_extra_headers,
+ const base::flat_map<std::string, std::string>&
+ protocol_request_extra_headers,
const std::string& protocol_request,
network::SimpleURLLoader::BodyAsStringCallback callback,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) {
diff --git a/chromium/components/update_client/utils.h b/chromium/components/update_client/utils.h
index e8ec3b7247d..77fc76c178e 100644
--- a/chromium/components/update_client/utils.h
+++ b/chromium/components/update_client/utils.h
@@ -5,13 +5,13 @@
#ifndef COMPONENTS_UPDATE_CLIENT_UTILS_H_
#define COMPONENTS_UPDATE_CLIENT_UTILS_H_
-#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/callback_forward.h"
+#include "base/containers/flat_map.h"
#include "base/memory/ref_counted.h"
#include "components/update_client/update_client.h"
@@ -45,7 +45,8 @@ using LoadCompleteCallback =
// expected to contain XML data. The caller owns the returned object.
std::unique_ptr<network::SimpleURLLoader> SendProtocolRequest(
const GURL& url,
- const std::map<std::string, std::string>& protocol_request_extra_headers,
+ const base::flat_map<std::string, std::string>&
+ protocol_request_extra_headers,
const std::string& protocol_request,
LoadCompleteCallback callback,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory);