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

Side by Side Diff: components/policy/core/common/cloud/resource_cache.cc

Issue 86913002: Make base::Base64Encode() return void (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: One more chromeos-specific fix. Created 7 years 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/policy/core/common/cloud/resource_cache.h" 5 #include "components/policy/core/common/cloud/resource_cache.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_enumerator.h" 10 #include "base/files/file_enumerator.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/safe_numerics.h" 12 #include "base/safe_numerics.h"
13 #include "base/sequenced_task_runner.h" 13 #include "base/sequenced_task_runner.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 15
16 namespace policy { 16 namespace policy {
17 17
18 namespace { 18 namespace {
19 19
20 // Verifies that |value| is not empty and encodes it into base64url format, 20 // Verifies that |value| is not empty and encodes it into base64url format,
21 // which is safe to use as a file name on all platforms. 21 // which is safe to use as a file name on all platforms.
22 bool Base64Encode(const std::string& value, std::string* encoded) { 22 bool Base64Encode(const std::string& value, std::string* encoded) {
23 DCHECK(!value.empty()); 23 DCHECK(!value.empty());
24 if (value.empty() || !base::Base64Encode(value, encoded)) 24 if (value.empty())
25 return false; 25 return false;
26 base::Base64Encode(value, encoded);
26 base::ReplaceChars(*encoded, "+", "-", encoded); 27 base::ReplaceChars(*encoded, "+", "-", encoded);
27 base::ReplaceChars(*encoded, "/", "_", encoded); 28 base::ReplaceChars(*encoded, "/", "_", encoded);
28 return true; 29 return true;
29 } 30 }
30 31
31 // Decodes all elements of |input| from base64url format and stores the decoded 32 // Decodes all elements of |input| from base64url format and stores the decoded
32 // elements in |output|. 33 // elements in |output|.
33 bool Base64Encode(const std::set<std::string>& input, 34 bool Base64Encode(const std::set<std::string>& input,
34 std::set<std::string>* output) { 35 std::set<std::string>* output) {
35 output->clear(); 36 output->clear();
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 if (!VerifyKeyPath(key, allow_create_key, &key_path) || 232 if (!VerifyKeyPath(key, allow_create_key, &key_path) ||
232 !Base64Encode(subkey, &encoded)) { 233 !Base64Encode(subkey, &encoded)) {
233 return false; 234 return false;
234 } 235 }
235 *path = key_path.AppendASCII(encoded); 236 *path = key_path.AppendASCII(encoded);
236 return true; 237 return true;
237 } 238 }
238 239
239 240
240 } // namespace policy 241 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/net/websocket.cc ('k') | content/browser/devtools/renderer_overrides_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698