Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1586)

Side by Side Diff: components/update_client/utils.cc

Issue 1740333002: Allow fallback from https to http for component update checks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/update_client/utils.h ('k') | components/update_client/utils_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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) {
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
OLDNEW
« no previous file with comments | « components/update_client/utils.h ('k') | components/update_client/utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698