Chromium Code Reviews| 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> |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 #include "components/update_client/configurator.h" | 27 #include "components/update_client/configurator.h" |
| 28 #include "components/update_client/crx_update_item.h" | 28 #include "components/update_client/crx_update_item.h" |
| 29 #include "components/update_client/update_client.h" | 29 #include "components/update_client/update_client.h" |
| 30 #include "components/update_client/update_query_params.h" | 30 #include "components/update_client/update_query_params.h" |
| 31 #include "crypto/secure_hash.h" | 31 #include "crypto/secure_hash.h" |
| 32 #include "crypto/sha2.h" | 32 #include "crypto/sha2.h" |
| 33 #include "net/base/load_flags.h" | 33 #include "net/base/load_flags.h" |
| 34 #include "net/url_request/url_fetcher.h" | 34 #include "net/url_request/url_fetcher.h" |
| 35 #include "net/url_request/url_request_context_getter.h" | 35 #include "net/url_request/url_request_context_getter.h" |
| 36 #include "net/url_request/url_request_status.h" | 36 #include "net/url_request/url_request_status.h" |
| 37 #include "url/gurl.h" | |
| 37 | 38 |
| 38 namespace update_client { | 39 namespace update_client { |
| 39 | 40 |
| 40 namespace { | 41 namespace { |
| 41 | 42 |
| 42 // Returns the amount of physical memory in GB, rounded to the nearest GB. | 43 // Returns the amount of physical memory in GB, rounded to the nearest GB. |
| 43 int GetPhysicalMemoryGB() { | 44 int GetPhysicalMemoryGB() { |
| 44 const double kOneGB = 1024 * 1024 * 1024; | 45 const double kOneGB = 1024 * 1024 * 1024; |
| 45 const int64_t phys_mem = base::SysInfo::AmountOfPhysicalMemory(); | 46 const int64_t phys_mem = base::SysInfo::AmountOfPhysicalMemory(); |
| 46 return static_cast<int>(std::floor(0.5 + phys_mem / kOneGB)); | 47 return static_cast<int>(std::floor(0.5 + phys_mem / kOneGB)); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 bool IsValidBrand(const std::string& brand) { | 232 bool IsValidBrand(const std::string& brand) { |
| 232 const size_t kMaxBrandSize = 4; | 233 const size_t kMaxBrandSize = 4; |
| 233 if (brand.size() > kMaxBrandSize) | 234 if (brand.size() > kMaxBrandSize) |
| 234 return false; | 235 return false; |
| 235 | 236 |
| 236 return std::find_if_not(brand.begin(), brand.end(), [](char ch) { | 237 return std::find_if_not(brand.begin(), brand.end(), [](char ch) { |
| 237 return base::IsAsciiAlpha(ch); | 238 return base::IsAsciiAlpha(ch); |
| 238 }) == brand.end(); | 239 }) == brand.end(); |
| 239 } | 240 } |
| 240 | 241 |
| 242 void RemoveUnsecureUrls(std::vector<GURL>* urls) { | |
|
waffles
2016/04/04 17:44:44
It might be worth calling this "RemoveEncryptedUrl
Sorin Jianu
2016/04/04 18:01:40
Acknowledged.
| |
| 243 DCHECK(urls); | |
| 244 urls->erase(std::remove_if( | |
| 245 urls->begin(), urls->end(), | |
| 246 [](const GURL& url) { return !url.SchemeIsCryptographic(); }), | |
| 247 urls->end()); | |
| 248 } | |
| 249 | |
| 241 } // namespace update_client | 250 } // namespace update_client |
| OLD | NEW |