Commit 58ddc78c authored by sorin@chromium.org's avatar sorin@chromium.org

The component update checks should include the amount of installed memory.

BUG=371655

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269606 0039d316-1c4b-4281-b951-d872f2087c98
parent 496cbfbe
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "chrome/browser/component_updater/component_updater_utils.h" #include "chrome/browser/component_updater/component_updater_utils.h"
#include <cmath>
#include "base/file_util.h" #include "base/file_util.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/guid.h" #include "base/guid.h"
...@@ -25,6 +27,17 @@ ...@@ -25,6 +27,17 @@
namespace component_updater { namespace component_updater {
namespace {
// Returns the amount of physical memory in GB, rounded to the nearest GB.
int GetPhysicalMemoryGB() {
const double kOneGB = 1024 * 1024 * 1024;
const int64 phys_mem = base::SysInfo::AmountOfPhysicalMemory();
return static_cast<int>(std::floor(0.5 + phys_mem / kOneGB));
}
} // namespace
std::string BuildProtocolRequest(const std::string& request_body, std::string BuildProtocolRequest(const std::string& request_body,
const std::string& additional_attributes) { const std::string& additional_attributes) {
const std::string prod_id(chrome::OmahaQueryParams::GetProdIdString( const std::string prod_id(chrome::OmahaQueryParams::GetProdIdString(
...@@ -63,6 +76,11 @@ std::string BuildProtocolRequest(const std::string& request_body, ...@@ -63,6 +76,11 @@ std::string BuildProtocolRequest(const std::string& request_body,
#endif #endif
base::StringAppendF(&request, ">"); base::StringAppendF(&request, ">");
// HW platform information.
base::StringAppendF(&request,
"<hw physmemory=\"%d\"/>",
GetPhysicalMemoryGB()); // "physmem" in GB.
// OS version and platform information. // OS version and platform information.
base::StringAppendF( base::StringAppendF(
&request, &request,
......
...@@ -34,6 +34,7 @@ struct CrxUpdateItem; ...@@ -34,6 +34,7 @@ struct CrxUpdateItem;
// requestid="{7383396D-B4DD-46E1-9104-AAC6B918E792}" // requestid="{7383396D-B4DD-46E1-9104-AAC6B918E792}"
// updaterchannel="canary" arch="x86" nacl_arch="x86-64" // updaterchannel="canary" arch="x86" nacl_arch="x86-64"
// ADDITIONAL ATTRIBUTES> // ADDITIONAL ATTRIBUTES>
// <hw physmemory="16"/>
// <os platform="win" version="6.1" arch="x86"/> // <os platform="win" version="6.1" arch="x86"/>
// ... REQUEST BODY ... // ... REQUEST BODY ...
// </request> // </request>
......
...@@ -192,6 +192,9 @@ TEST_F(UpdateCheckerTest, UpdateCheckSuccess) { ...@@ -192,6 +192,9 @@ TEST_F(UpdateCheckerTest, UpdateCheckSuccess) {
"app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\">" "app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\">"
"<updatecheck /><packages><package fp=\"fp1\"/></packages></app>")); "<updatecheck /><packages><package fp=\"fp1\"/></packages></app>"));
EXPECT_NE(string::npos,
post_interceptor_->GetRequests()[0].find("<hw physmemory="));
// Sanity check the arguments of the callback after parsing. // Sanity check the arguments of the callback after parsing.
EXPECT_EQ(0, error_); EXPECT_EQ(0, error_);
EXPECT_TRUE(error_message_.empty()); EXPECT_TRUE(error_message_.empty());
......
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