OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/component_updater/component_updater_utils.h" | 5 #include "components/component_updater/component_updater_utils.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
12 #include "base/guid.h" | 12 #include "base/guid.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
17 #include "base/sys_info.h" | 17 #include "base/sys_info.h" |
18 #include "base/win/windows_version.h" | 18 #include "base/win/windows_version.h" |
19 #include "components/component_updater/component_updater_configurator.h" | 19 #include "components/component_updater/component_updater_configurator.h" |
20 #include "components/component_updater/crx_update_item.h" | 20 #include "components/component_updater/crx_update_item.h" |
21 #include "components/crx_file/id_util.h" | 21 #include "components/crx_file/id_util.h" |
22 #include "components/omaha_client/omaha_query_params.h" | 22 #include "components/update_client/update_query_params.h" |
23 #include "net/base/load_flags.h" | 23 #include "net/base/load_flags.h" |
24 #include "net/url_request/url_fetcher.h" | 24 #include "net/url_request/url_fetcher.h" |
25 #include "net/url_request/url_request_context_getter.h" | 25 #include "net/url_request/url_request_context_getter.h" |
26 #include "net/url_request/url_request_status.h" | 26 #include "net/url_request/url_request_status.h" |
27 | 27 |
28 using omaha_client::OmahaQueryParams; | 28 using update_client::UpdateQueryParams; |
29 | 29 |
30 namespace component_updater { | 30 namespace component_updater { |
31 | 31 |
32 namespace { | 32 namespace { |
33 | 33 |
34 // Returns the amount of physical memory in GB, rounded to the nearest GB. | 34 // Returns the amount of physical memory in GB, rounded to the nearest GB. |
35 int GetPhysicalMemoryGB() { | 35 int GetPhysicalMemoryGB() { |
36 const double kOneGB = 1024 * 1024 * 1024; | 36 const double kOneGB = 1024 * 1024 * 1024; |
37 const int64_t phys_mem = base::SysInfo::AmountOfPhysicalMemory(); | 37 const int64_t phys_mem = base::SysInfo::AmountOfPhysicalMemory(); |
38 return static_cast<int>(std::floor(0.5 + phys_mem / kOneGB)); | 38 return static_cast<int>(std::floor(0.5 + phys_mem / kOneGB)); |
(...skipping 20 matching lines...) Expand all Loading... |
59 | 59 |
60 } // namespace | 60 } // namespace |
61 | 61 |
62 std::string BuildProtocolRequest(const std::string& browser_version, | 62 std::string BuildProtocolRequest(const std::string& browser_version, |
63 const std::string& channel, | 63 const std::string& channel, |
64 const std::string& lang, | 64 const std::string& lang, |
65 const std::string& os_long_name, | 65 const std::string& os_long_name, |
66 const std::string& request_body, | 66 const std::string& request_body, |
67 const std::string& additional_attributes) { | 67 const std::string& additional_attributes) { |
68 const std::string prod_id( | 68 const std::string prod_id( |
69 OmahaQueryParams::GetProdIdString(OmahaQueryParams::CHROME)); | 69 UpdateQueryParams::GetProdIdString(UpdateQueryParams::CHROME)); |
70 | 70 |
71 std::string request( | 71 std::string request( |
72 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 72 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" |
73 "<request protocol=\"3.0\" "); | 73 "<request protocol=\"3.0\" "); |
74 | 74 |
75 if (!additional_attributes.empty()) | 75 if (!additional_attributes.empty()) |
76 base::StringAppendF(&request, "%s ", additional_attributes.c_str()); | 76 base::StringAppendF(&request, "%s ", additional_attributes.c_str()); |
77 | 77 |
78 // Chrome version and platform information. | 78 // Chrome version and platform information. |
79 base::StringAppendF( | 79 base::StringAppendF( |
80 &request, | 80 &request, |
81 "version=\"%s-%s\" prodversion=\"%s\" " | 81 "version=\"%s-%s\" prodversion=\"%s\" " |
82 "requestid=\"{%s}\" lang=\"%s\" updaterchannel=\"%s\" prodchannel=\"%s\" " | 82 "requestid=\"{%s}\" lang=\"%s\" updaterchannel=\"%s\" prodchannel=\"%s\" " |
83 "os=\"%s\" arch=\"%s\" nacl_arch=\"%s\"", | 83 "os=\"%s\" arch=\"%s\" nacl_arch=\"%s\"", |
84 prod_id.c_str(), | 84 prod_id.c_str(), |
85 browser_version.c_str(), // "version" | 85 browser_version.c_str(), // "version" |
86 browser_version.c_str(), // "prodversion" | 86 browser_version.c_str(), // "prodversion" |
87 base::GenerateGUID().c_str(), // "requestid" | 87 base::GenerateGUID().c_str(), // "requestid" |
88 lang.c_str(), // "lang", | 88 lang.c_str(), // "lang", |
89 channel.c_str(), // "updaterchannel" | 89 channel.c_str(), // "updaterchannel" |
90 channel.c_str(), // "prodchannel" | 90 channel.c_str(), // "prodchannel" |
91 OmahaQueryParams::GetOS(), // "os" | 91 UpdateQueryParams::GetOS(), // "os" |
92 OmahaQueryParams::GetArch(), // "arch" | 92 UpdateQueryParams::GetArch(), // "arch" |
93 OmahaQueryParams::GetNaclArch()); // "nacl_arch" | 93 UpdateQueryParams::GetNaclArch()); // "nacl_arch" |
94 #if defined(OS_WIN) | 94 #if defined(OS_WIN) |
95 const bool is_wow64(base::win::OSInfo::GetInstance()->wow64_status() == | 95 const bool is_wow64(base::win::OSInfo::GetInstance()->wow64_status() == |
96 base::win::OSInfo::WOW64_ENABLED); | 96 base::win::OSInfo::WOW64_ENABLED); |
97 if (is_wow64) | 97 if (is_wow64) |
98 base::StringAppendF(&request, " wow64=\"1\""); | 98 base::StringAppendF(&request, " wow64=\"1\""); |
99 #endif | 99 #endif |
100 base::StringAppendF(&request, ">"); | 100 base::StringAppendF(&request, ">"); |
101 | 101 |
102 // HW platform information. | 102 // HW platform information. |
103 base::StringAppendF(&request, | 103 base::StringAppendF(&request, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 } | 189 } |
190 | 190 |
191 std::string GetCrxComponentID(const CrxComponent& component) { | 191 std::string GetCrxComponentID(const CrxComponent& component) { |
192 const size_t kCrxIdSize = 16; | 192 const size_t kCrxIdSize = 16; |
193 CHECK_GE(component.pk_hash.size(), kCrxIdSize); | 193 CHECK_GE(component.pk_hash.size(), kCrxIdSize); |
194 return HexStringToID(base::StringToLowerASCII( | 194 return HexStringToID(base::StringToLowerASCII( |
195 base::HexEncode(&component.pk_hash[0], kCrxIdSize))); | 195 base::HexEncode(&component.pk_hash[0], kCrxIdSize))); |
196 } | 196 } |
197 | 197 |
198 } // namespace component_updater | 198 } // namespace component_updater |
OLD | NEW |