Commit 021b9e2d authored by sorin@chromium.org's avatar sorin@chromium.org

Added "os" attribute in the component updater update requests.

In order to be compatible with the v2 version of the update protocol and
existing update configuration files, the "os" attribute (and fwiw, "arch")
must be serialized as part of the <request> element.

BUG=332551

Review URL: https://codereview.chromium.org/130543002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243809 0039d316-1c4b-4281-b951-d872f2087c98
parent 57df66c0
...@@ -42,11 +42,13 @@ std::string BuildProtocolRequest(const std::string& request_body, ...@@ -42,11 +42,13 @@ std::string BuildProtocolRequest(const std::string& request_body,
base::StringAppendF( base::StringAppendF(
&request, &request,
"version=\"%s-%s\" prodversion=\"%s\" " "version=\"%s-%s\" prodversion=\"%s\" "
"requestid=\"{%s}\" updaterchannel=\"%s\" arch=\"%s\" nacl_arch=\"%s\"", "requestid=\"{%s}\" updaterchannel=\"%s\" "
"os=\"%s\" arch=\"%s\" nacl_arch=\"%s\"",
prod_id.c_str(), chrome_version.c_str(), // "version" prod_id.c_str(), chrome_version.c_str(), // "version"
chrome_version.c_str(), // "prodversion" chrome_version.c_str(), // "prodversion"
base::GenerateGUID().c_str(), // "requestid" base::GenerateGUID().c_str(), // "requestid"
chrome::OmahaQueryParams::GetChannelString(), // "updaterchannel" chrome::OmahaQueryParams::GetChannelString(), // "updaterchannel"
chrome::OmahaQueryParams::getOS(), // "os"
chrome::OmahaQueryParams::getArch(), // "arch" chrome::OmahaQueryParams::getArch(), // "arch"
chrome::OmahaQueryParams::getNaclArch()); // "nacl_arch" chrome::OmahaQueryParams::getNaclArch()); // "nacl_arch"
#if defined(OS_WIN) #if defined(OS_WIN)
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/path_service.h" #include "base/path_service.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/component_updater/component_updater_utils.h" #include "chrome/browser/component_updater/component_updater_utils.h"
...@@ -471,6 +472,21 @@ TEST_F(ComponentUpdaterTest, InstallCrx) { ...@@ -471,6 +472,21 @@ TEST_F(ComponentUpdaterTest, InstallCrx) {
"request protocol=\"3.0\" extra=\"foo\"")) "request protocol=\"3.0\" extra=\"foo\""))
<< post_interceptor_->GetRequestsAsString(); << post_interceptor_->GetRequestsAsString();
// Tokenize the request string to look for specific attributes, which
// are important for backward compatibility with the version v2 of the update
// protocol. In this case, inspect the <request>, which is the first element
// after the xml declaration of the update request body.
// Expect to find the |os| and the |arch| attributes:
// <?xml version="1.0" encoding="UTF-8"?>
// <request...os=...arch=...>
// ...
// </request>
const std::string update_request(post_interceptor_->GetRequests()[0]);
std::vector<base::StringPiece> elements;
Tokenize(update_request, "<>", &elements);
EXPECT_NE(string::npos, elements[1].find("os="));
EXPECT_NE(string::npos, elements[1].find("arch="));
component_updater()->Stop(); component_updater()->Stop();
} }
......
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