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

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

Issue 1823273002: Send the value of google_brand::GetBrand in component update checks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor unit test improvement. Created 4 years, 9 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
10 #include <algorithm>
9 #include <cmath> 11 #include <cmath>
10 #include <cstring> 12 #include <cstring>
11 #include <vector> 13 #include <vector>
12 14
13 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
14 #include "base/files/file_util.h" 16 #include "base/files/file_util.h"
15 #include "base/files/memory_mapped_file.h" 17 #include "base/files/memory_mapped_file.h"
16 #include "base/guid.h" 18 #include "base/guid.h"
17 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/string_piece.h" 20 #include "base/strings/string_piece.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 221
220 uint8_t actual_hash[crypto::kSHA256Length] = {0}; 222 uint8_t actual_hash[crypto::kSHA256Length] = {0};
221 scoped_ptr<crypto::SecureHash> hasher( 223 scoped_ptr<crypto::SecureHash> hasher(
222 crypto::SecureHash::Create(crypto::SecureHash::SHA256)); 224 crypto::SecureHash::Create(crypto::SecureHash::SHA256));
223 hasher->Update(mmfile.data(), mmfile.length()); 225 hasher->Update(mmfile.data(), mmfile.length());
224 hasher->Finish(actual_hash, sizeof(actual_hash)); 226 hasher->Finish(actual_hash, sizeof(actual_hash));
225 227
226 return memcmp(actual_hash, &expected_hash[0], sizeof(actual_hash)) == 0; 228 return memcmp(actual_hash, &expected_hash[0], sizeof(actual_hash)) == 0;
227 } 229 }
228 230
231 bool IsValidBrand(const std::string& brand) {
232 const size_t kMaxBrandSize = 4;
233 if (brand.size() > kMaxBrandSize)
234 return false;
235
236 return std::find_if_not(brand.begin(), brand.end(), [](char ch) {
237 return base::IsAsciiAlpha(ch);
238 }) == brand.end();
239 }
240
229 } // namespace update_client 241 } // 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