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

Side by Side Diff: chrome/browser/policy/test/local_policy_test_server.cc

Issue 1452853002: Convert vector_as_array to vector::data in //chrome{,cast,os}. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@vector-data
Patch Set: Created 5 years, 1 month 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 "chrome/browser/policy/test/local_policy_test_server.h" 5 #include "chrome/browser/policy/test/local_policy_test_server.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/base_paths.h" 12 #include "base/base_paths.h"
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
15 #include "base/path_service.h" 15 #include "base/path_service.h"
16 #include "base/stl_util.h"
17 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
18 #include "components/policy/core/common/cloud/cloud_policy_constants.h" 17 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
19 #include "crypto/rsa_private_key.h" 18 #include "crypto/rsa_private_key.h"
20 #include "net/test/python_utils.h" 19 #include "net/test/python_utils.h"
21 #include "net/test/spawned_test_server/base_test_server.h" 20 #include "net/test/spawned_test_server/base_test_server.h"
22 21
23 namespace policy { 22 namespace policy {
24 23
25 namespace { 24 namespace {
26 25
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 bool LocalPolicyTestServer::SetSigningKeyAndSignature( 89 bool LocalPolicyTestServer::SetSigningKeyAndSignature(
91 const crypto::RSAPrivateKey* key, const std::string& signature) { 90 const crypto::RSAPrivateKey* key, const std::string& signature) {
92 CHECK(server_data_dir_.IsValid()); 91 CHECK(server_data_dir_.IsValid());
93 92
94 std::vector<uint8> signing_key_bits; 93 std::vector<uint8> signing_key_bits;
95 if (!key->ExportPrivateKey(&signing_key_bits)) 94 if (!key->ExportPrivateKey(&signing_key_bits))
96 return false; 95 return false;
97 96
98 policy_key_ = server_data_dir_.path().Append(kSigningKeyFileName); 97 policy_key_ = server_data_dir_.path().Append(kSigningKeyFileName);
99 int bytes_written = base::WriteFile( 98 int bytes_written = base::WriteFile(
100 policy_key_, 99 policy_key_, reinterpret_cast<const char*>(signing_key_bits.data()),
101 reinterpret_cast<const char*>(vector_as_array(&signing_key_bits)),
102 signing_key_bits.size()); 100 signing_key_bits.size());
103 101
104 if (bytes_written != static_cast<int>(signing_key_bits.size())) 102 if (bytes_written != static_cast<int>(signing_key_bits.size()))
105 return false; 103 return false;
106 104
107 // Write the signature data. 105 // Write the signature data.
108 base::FilePath signature_file = server_data_dir_.path().Append( 106 base::FilePath signature_file = server_data_dir_.path().Append(
109 kSigningKeySignatureFileName); 107 kSigningKeySignatureFileName);
110 bytes_written = base::WriteFile( 108 bytes_written = base::WriteFile(
111 signature_file, 109 signature_file,
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 std::string LocalPolicyTestServer::GetSelector(const std::string& type, 255 std::string LocalPolicyTestServer::GetSelector(const std::string& type,
258 const std::string& entity_id) { 256 const std::string& entity_id) {
259 std::string selector = type; 257 std::string selector = type;
260 if (!entity_id.empty()) 258 if (!entity_id.empty())
261 selector = base::StringPrintf("%s/%s", type.c_str(), entity_id.c_str()); 259 selector = base::StringPrintf("%s/%s", type.c_str(), entity_id.c_str());
262 std::replace_if(selector.begin(), selector.end(), IsUnsafeCharacter, '_'); 260 std::replace_if(selector.begin(), selector.end(), IsUnsafeCharacter, '_');
263 return selector; 261 return selector;
264 } 262 }
265 263
266 } // namespace policy 264 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698