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/update_client/utils.h" | 5 #include "components/update_client/utils.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <cmath> | 11 #include <cmath> |
12 #include <cstring> | 12 #include <cstring> |
13 #include <map> | 13 #include <map> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/callback.h" | 16 #include "base/callback.h" |
17 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
18 #include "base/files/file_util.h" | 18 #include "base/files/file_util.h" |
19 #include "base/files/memory_mapped_file.h" | 19 #include "base/files/memory_mapped_file.h" |
20 #include "base/guid.h" | 20 #include "base/guid.h" |
21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
22 #include "base/strings/string_piece.h" | 22 #include "base/strings/string_piece.h" |
23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
24 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
25 #include "base/sys_info.h" | 25 #include "base/sys_info.h" |
26 #include "base/win/windows_version.h" | |
27 #include "build/build_config.h" | 26 #include "build/build_config.h" |
28 #include "components/crx_file/id_util.h" | 27 #include "components/crx_file/id_util.h" |
29 #include "components/data_use_measurement/core/data_use_user_data.h" | 28 #include "components/data_use_measurement/core/data_use_user_data.h" |
30 #include "components/update_client/configurator.h" | 29 #include "components/update_client/configurator.h" |
31 #include "components/update_client/crx_update_item.h" | 30 #include "components/update_client/crx_update_item.h" |
32 #include "components/update_client/update_client.h" | 31 #include "components/update_client/update_client.h" |
33 #include "components/update_client/update_client_errors.h" | 32 #include "components/update_client/update_client_errors.h" |
34 #include "components/update_client/update_query_params.h" | 33 #include "components/update_client/update_query_params.h" |
35 #include "components/update_client/updater_state.h" | 34 #include "components/update_client/updater_state.h" |
36 #include "crypto/secure_hash.h" | 35 #include "crypto/secure_hash.h" |
37 #include "crypto/sha2.h" | 36 #include "crypto/sha2.h" |
38 #include "net/base/load_flags.h" | 37 #include "net/base/load_flags.h" |
39 #include "net/url_request/url_fetcher.h" | 38 #include "net/url_request/url_fetcher.h" |
40 #include "net/url_request/url_request_context_getter.h" | 39 #include "net/url_request/url_request_context_getter.h" |
41 #include "net/url_request/url_request_status.h" | 40 #include "net/url_request/url_request_status.h" |
42 #include "url/gurl.h" | 41 #include "url/gurl.h" |
43 | 42 |
| 43 #if defined(OS_WIN) |
| 44 #include "base/win/windows_version.h" |
| 45 #endif |
| 46 |
44 namespace update_client { | 47 namespace update_client { |
45 | 48 |
46 namespace { | 49 namespace { |
47 | 50 |
48 // Returns the amount of physical memory in GB, rounded to the nearest GB. | 51 // Returns the amount of physical memory in GB, rounded to the nearest GB. |
49 int GetPhysicalMemoryGB() { | 52 int GetPhysicalMemoryGB() { |
50 const double kOneGB = 1024 * 1024 * 1024; | 53 const double kOneGB = 1024 * 1024 * 1024; |
51 const int64_t phys_mem = base::SysInfo::AmountOfPhysicalMemory(); | 54 const int64_t phys_mem = base::SysInfo::AmountOfPhysicalMemory(); |
52 return static_cast<int>(std::floor(0.5 + phys_mem / kOneGB)); | 55 return static_cast<int>(std::floor(0.5 + phys_mem / kOneGB)); |
53 } | 56 } |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 [](const GURL& url) { return !url.SchemeIsCryptographic(); }), | 339 [](const GURL& url) { return !url.SchemeIsCryptographic(); }), |
337 urls->end()); | 340 urls->end()); |
338 } | 341 } |
339 | 342 |
340 CrxInstaller::Result InstallFunctionWrapper(base::Callback<bool()> callback) { | 343 CrxInstaller::Result InstallFunctionWrapper(base::Callback<bool()> callback) { |
341 return CrxInstaller::Result(callback.Run() ? InstallError::NONE | 344 return CrxInstaller::Result(callback.Run() ? InstallError::NONE |
342 : InstallError::GENERIC_ERROR); | 345 : InstallError::GENERIC_ERROR); |
343 } | 346 } |
344 | 347 |
345 } // namespace update_client | 348 } // namespace update_client |
OLD | NEW |