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/update_client/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" | |
20 #include "components/component_updater/crx_update_item.h" | |
21 #include "components/crx_file/id_util.h" | 19 #include "components/crx_file/id_util.h" |
| 20 #include "components/update_client/configurator.h" |
| 21 #include "components/update_client/crx_update_item.h" |
| 22 #include "components/update_client/update_client.h" |
22 #include "components/update_client/update_query_params.h" | 23 #include "components/update_client/update_query_params.h" |
23 #include "net/base/load_flags.h" | 24 #include "net/base/load_flags.h" |
24 #include "net/url_request/url_fetcher.h" | 25 #include "net/url_request/url_fetcher.h" |
25 #include "net/url_request/url_request_context_getter.h" | 26 #include "net/url_request/url_request_context_getter.h" |
26 #include "net/url_request/url_request_status.h" | 27 #include "net/url_request/url_request_status.h" |
27 | 28 |
28 using update_client::UpdateQueryParams; | 29 namespace update_client { |
29 | |
30 namespace component_updater { | |
31 | 30 |
32 namespace { | 31 namespace { |
33 | 32 |
34 // Returns the amount of physical memory in GB, rounded to the nearest GB. | 33 // Returns the amount of physical memory in GB, rounded to the nearest GB. |
35 int GetPhysicalMemoryGB() { | 34 int GetPhysicalMemoryGB() { |
36 const double kOneGB = 1024 * 1024 * 1024; | 35 const double kOneGB = 1024 * 1024 * 1024; |
37 const int64_t phys_mem = base::SysInfo::AmountOfPhysicalMemory(); | 36 const int64_t phys_mem = base::SysInfo::AmountOfPhysicalMemory(); |
38 return static_cast<int>(std::floor(0.5 + phys_mem / kOneGB)); | 37 return static_cast<int>(std::floor(0.5 + phys_mem / kOneGB)); |
39 } | 38 } |
40 | 39 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 UpdateQueryParams::GetNaclArch()); // "nacl_arch" | 92 UpdateQueryParams::GetNaclArch()); // "nacl_arch" |
94 #if defined(OS_WIN) | 93 #if defined(OS_WIN) |
95 const bool is_wow64(base::win::OSInfo::GetInstance()->wow64_status() == | 94 const bool is_wow64(base::win::OSInfo::GetInstance()->wow64_status() == |
96 base::win::OSInfo::WOW64_ENABLED); | 95 base::win::OSInfo::WOW64_ENABLED); |
97 if (is_wow64) | 96 if (is_wow64) |
98 base::StringAppendF(&request, " wow64=\"1\""); | 97 base::StringAppendF(&request, " wow64=\"1\""); |
99 #endif | 98 #endif |
100 base::StringAppendF(&request, ">"); | 99 base::StringAppendF(&request, ">"); |
101 | 100 |
102 // HW platform information. | 101 // HW platform information. |
103 base::StringAppendF(&request, | 102 base::StringAppendF(&request, "<hw physmemory=\"%d\"/>", |
104 "<hw physmemory=\"%d\"/>", | |
105 GetPhysicalMemoryGB()); // "physmem" in GB. | 103 GetPhysicalMemoryGB()); // "physmem" in GB. |
106 | 104 |
107 // OS version and platform information. | 105 // OS version and platform information. |
108 base::StringAppendF( | 106 base::StringAppendF( |
109 &request, | 107 &request, "<os platform=\"%s\" version=\"%s\" arch=\"%s\"/>", |
110 "<os platform=\"%s\" version=\"%s\" arch=\"%s\"/>", | |
111 os_long_name.c_str(), // "platform" | 108 os_long_name.c_str(), // "platform" |
112 base::SysInfo().OperatingSystemVersion().c_str(), // "version" | 109 base::SysInfo().OperatingSystemVersion().c_str(), // "version" |
113 base::SysInfo().OperatingSystemArchitecture().c_str()); // "arch" | 110 base::SysInfo().OperatingSystemArchitecture().c_str()); // "arch" |
114 | 111 |
115 // The actual payload of the request. | 112 // The actual payload of the request. |
116 base::StringAppendF(&request, "%s</request>", request_body.c_str()); | 113 base::StringAppendF(&request, "%s</request>", request_body.c_str()); |
117 | 114 |
118 return request; | 115 return request; |
119 } | 116 } |
120 | 117 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 return base::DeleteFile(dirname, false); | 185 return base::DeleteFile(dirname, false); |
189 } | 186 } |
190 | 187 |
191 std::string GetCrxComponentID(const CrxComponent& component) { | 188 std::string GetCrxComponentID(const CrxComponent& component) { |
192 const size_t kCrxIdSize = 16; | 189 const size_t kCrxIdSize = 16; |
193 CHECK_GE(component.pk_hash.size(), kCrxIdSize); | 190 CHECK_GE(component.pk_hash.size(), kCrxIdSize); |
194 return HexStringToID(base::StringToLowerASCII( | 191 return HexStringToID(base::StringToLowerASCII( |
195 base::HexEncode(&component.pk_hash[0], kCrxIdSize))); | 192 base::HexEncode(&component.pk_hash[0], kCrxIdSize))); |
196 } | 193 } |
197 | 194 |
198 } // namespace component_updater | 195 } // namespace update_client |
OLD | NEW |