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

Side by Side Diff: net/test/spawned_test_server/base_test_server.cc

Issue 1893083002: Change scoped_ptr to std::unique_ptr in //net. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptr-net-all: iwyu 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "net/test/spawned_test_server/base_test_server.h" 5 #include "net/test/spawned_test_server/base_test_server.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 107 }
108 108
109 base::FilePath src_dir; 109 base::FilePath src_dir;
110 if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)) 110 if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_dir))
111 return false; 111 return false;
112 112
113 *local_certificates_dir = src_dir.Append(certificates_dir); 113 *local_certificates_dir = src_dir.Append(certificates_dir);
114 return true; 114 return true;
115 } 115 }
116 116
117 scoped_ptr<base::ListValue> GetTokenBindingParams(std::vector<int> params) { 117 std::unique_ptr<base::ListValue> GetTokenBindingParams(
118 scoped_ptr<base::ListValue> values(new base::ListValue()); 118 std::vector<int> params) {
119 std::unique_ptr<base::ListValue> values(new base::ListValue());
119 for (int param : params) { 120 for (int param : params) {
120 values->Append(new base::FundamentalValue(param)); 121 values->Append(new base::FundamentalValue(param));
121 } 122 }
122 return values; 123 return values;
123 } 124 }
124 125
125 } // namespace 126 } // namespace
126 127
127 BaseTestServer::SSLOptions::SSLOptions() 128 BaseTestServer::SSLOptions::SSLOptions()
128 : server_certificate(CERT_OK), 129 : server_certificate(CERT_OK),
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 case TYPE_UDP_ECHO: 259 case TYPE_UDP_ECHO:
259 default: 260 default:
260 NOTREACHED(); 261 NOTREACHED();
261 } 262 }
262 return std::string(); 263 return std::string();
263 } 264 }
264 265
265 bool BaseTestServer::GetAddressList(AddressList* address_list) const { 266 bool BaseTestServer::GetAddressList(AddressList* address_list) const {
266 DCHECK(address_list); 267 DCHECK(address_list);
267 268
268 scoped_ptr<HostResolver> resolver(HostResolver::CreateDefaultResolver(NULL)); 269 std::unique_ptr<HostResolver> resolver(
270 HostResolver::CreateDefaultResolver(NULL));
269 HostResolver::RequestInfo info(host_port_pair_); 271 HostResolver::RequestInfo info(host_port_pair_);
270 // Limit the lookup to IPv4. When started with the default 272 // Limit the lookup to IPv4. When started with the default
271 // address of kLocalhost, testserver.py only supports IPv4. 273 // address of kLocalhost, testserver.py only supports IPv4.
272 // If a custom hostname is used, it's possible that the test 274 // If a custom hostname is used, it's possible that the test
273 // server will listen on both IPv4 and IPv6, so this will 275 // server will listen on both IPv4 and IPv6, so this will
274 // still work. The testserver does not support explicit 276 // still work. The testserver does not support explicit
275 // IPv6 literal hostnames. 277 // IPv6 literal hostnames.
276 info.set_address_family(ADDRESS_FAMILY_IPV4); 278 info.set_address_family(ADDRESS_FAMILY_IPV4);
277 TestCompletionCallback callback; 279 TestCompletionCallback callback;
278 int rv = resolver->Resolve(info, 280 int rv = resolver->Resolve(info,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 // This method shouldn't get called twice. 401 // This method shouldn't get called twice.
400 DCHECK(certificates_dir_.empty()); 402 DCHECK(certificates_dir_.empty());
401 document_root_ = document_root; 403 document_root_ = document_root;
402 certificates_dir_ = certificates_dir; 404 certificates_dir_ = certificates_dir;
403 DCHECK(!certificates_dir_.empty()); 405 DCHECK(!certificates_dir_.empty());
404 } 406 }
405 407
406 bool BaseTestServer::ParseServerData(const std::string& server_data) { 408 bool BaseTestServer::ParseServerData(const std::string& server_data) {
407 VLOG(1) << "Server data: " << server_data; 409 VLOG(1) << "Server data: " << server_data;
408 base::JSONReader json_reader; 410 base::JSONReader json_reader;
409 scoped_ptr<base::Value> value(json_reader.ReadToValue(server_data)); 411 std::unique_ptr<base::Value> value(json_reader.ReadToValue(server_data));
410 if (!value.get() || !value->IsType(base::Value::TYPE_DICTIONARY)) { 412 if (!value.get() || !value->IsType(base::Value::TYPE_DICTIONARY)) {
411 LOG(ERROR) << "Could not parse server data: " 413 LOG(ERROR) << "Could not parse server data: "
412 << json_reader.GetErrorMessage(); 414 << json_reader.GetErrorMessage();
413 return false; 415 return false;
414 } 416 }
415 417
416 server_data_.reset(static_cast<base::DictionaryValue*>(value.release())); 418 server_data_.reset(static_cast<base::DictionaryValue*>(value.release()));
417 int port = 0; 419 int port = 0;
418 if (!server_data_->GetInteger("port", &port)) { 420 if (!server_data_->GetInteger("port", &port)) {
419 LOG(ERROR) << "Could not find port value"; 421 LOG(ERROR) << "Could not find port value";
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 LOG(ERROR) << "Certificate path " << certificate_path.value() 485 LOG(ERROR) << "Certificate path " << certificate_path.value()
484 << " doesn't exist. Can't launch https server."; 486 << " doesn't exist. Can't launch https server.";
485 return false; 487 return false;
486 } 488 }
487 arguments->SetString("cert-and-key-file", certificate_path.value()); 489 arguments->SetString("cert-and-key-file", certificate_path.value());
488 } 490 }
489 491
490 // Check the client certificate related arguments. 492 // Check the client certificate related arguments.
491 if (ssl_options_.request_client_certificate) 493 if (ssl_options_.request_client_certificate)
492 arguments->Set("ssl-client-auth", base::Value::CreateNullValue()); 494 arguments->Set("ssl-client-auth", base::Value::CreateNullValue());
493 scoped_ptr<base::ListValue> ssl_client_certs(new base::ListValue()); 495 std::unique_ptr<base::ListValue> ssl_client_certs(new base::ListValue());
494 496
495 std::vector<base::FilePath>::const_iterator it; 497 std::vector<base::FilePath>::const_iterator it;
496 for (it = ssl_options_.client_authorities.begin(); 498 for (it = ssl_options_.client_authorities.begin();
497 it != ssl_options_.client_authorities.end(); ++it) { 499 it != ssl_options_.client_authorities.end(); ++it) {
498 if (it->IsAbsolute() && !base::PathExists(*it)) { 500 if (it->IsAbsolute() && !base::PathExists(*it)) {
499 LOG(ERROR) << "Client authority path " << it->value() 501 LOG(ERROR) << "Client authority path " << it->value()
500 << " doesn't exist. Can't launch https server."; 502 << " doesn't exist. Can't launch https server.";
501 return false; 503 return false;
502 } 504 }
503 ssl_client_certs->Append(new base::StringValue(it->value())); 505 ssl_client_certs->Append(new base::StringValue(it->value()));
504 } 506 }
505 507
506 if (ssl_client_certs->GetSize()) 508 if (ssl_client_certs->GetSize())
507 arguments->Set("ssl-client-ca", ssl_client_certs.release()); 509 arguments->Set("ssl-client-ca", ssl_client_certs.release());
508 510
509 scoped_ptr<base::ListValue> client_cert_types(new base::ListValue()); 511 std::unique_ptr<base::ListValue> client_cert_types(new base::ListValue());
510 for (size_t i = 0; i < ssl_options_.client_cert_types.size(); i++) { 512 for (size_t i = 0; i < ssl_options_.client_cert_types.size(); i++) {
511 client_cert_types->Append(new base::StringValue( 513 client_cert_types->Append(new base::StringValue(
512 GetClientCertType(ssl_options_.client_cert_types[i]))); 514 GetClientCertType(ssl_options_.client_cert_types[i])));
513 } 515 }
514 if (client_cert_types->GetSize()) 516 if (client_cert_types->GetSize())
515 arguments->Set("ssl-client-cert-type", client_cert_types.release()); 517 arguments->Set("ssl-client-cert-type", client_cert_types.release());
516 } 518 }
517 519
518 if (type_ == TYPE_HTTPS) { 520 if (type_ == TYPE_HTTPS) {
519 arguments->Set("https", base::Value::CreateNullValue()); 521 arguments->Set("https", base::Value::CreateNullValue());
520 522
521 std::string ocsp_arg = ssl_options_.GetOCSPArgument(); 523 std::string ocsp_arg = ssl_options_.GetOCSPArgument();
522 if (!ocsp_arg.empty()) 524 if (!ocsp_arg.empty())
523 arguments->SetString("ocsp", ocsp_arg); 525 arguments->SetString("ocsp", ocsp_arg);
524 526
525 if (ssl_options_.cert_serial != 0) { 527 if (ssl_options_.cert_serial != 0) {
526 arguments->SetInteger("cert-serial", ssl_options_.cert_serial); 528 arguments->SetInteger("cert-serial", ssl_options_.cert_serial);
527 } 529 }
528 530
529 // Check key exchange argument. 531 // Check key exchange argument.
530 scoped_ptr<base::ListValue> key_exchange_values(new base::ListValue()); 532 std::unique_ptr<base::ListValue> key_exchange_values(new base::ListValue());
531 GetKeyExchangesList(ssl_options_.key_exchanges, key_exchange_values.get()); 533 GetKeyExchangesList(ssl_options_.key_exchanges, key_exchange_values.get());
532 if (key_exchange_values->GetSize()) 534 if (key_exchange_values->GetSize())
533 arguments->Set("ssl-key-exchange", key_exchange_values.release()); 535 arguments->Set("ssl-key-exchange", key_exchange_values.release());
534 // Check bulk cipher argument. 536 // Check bulk cipher argument.
535 scoped_ptr<base::ListValue> bulk_cipher_values(new base::ListValue()); 537 std::unique_ptr<base::ListValue> bulk_cipher_values(new base::ListValue());
536 GetCiphersList(ssl_options_.bulk_ciphers, bulk_cipher_values.get()); 538 GetCiphersList(ssl_options_.bulk_ciphers, bulk_cipher_values.get());
537 if (bulk_cipher_values->GetSize()) 539 if (bulk_cipher_values->GetSize())
538 arguments->Set("ssl-bulk-cipher", bulk_cipher_values.release()); 540 arguments->Set("ssl-bulk-cipher", bulk_cipher_values.release());
539 if (ssl_options_.record_resume) 541 if (ssl_options_.record_resume)
540 arguments->Set("https-record-resume", base::Value::CreateNullValue()); 542 arguments->Set("https-record-resume", base::Value::CreateNullValue());
541 if (ssl_options_.tls_intolerant != SSLOptions::TLS_INTOLERANT_NONE) { 543 if (ssl_options_.tls_intolerant != SSLOptions::TLS_INTOLERANT_NONE) {
542 arguments->SetInteger("tls-intolerant", ssl_options_.tls_intolerant); 544 arguments->SetInteger("tls-intolerant", ssl_options_.tls_intolerant);
543 arguments->Set("tls-intolerance-type", GetTLSIntoleranceType( 545 arguments->Set("tls-intolerance-type", GetTLSIntoleranceType(
544 ssl_options_.tls_intolerance_type)); 546 ssl_options_.tls_intolerance_type));
545 } 547 }
546 if (ssl_options_.fallback_scsv_enabled) 548 if (ssl_options_.fallback_scsv_enabled)
547 arguments->Set("fallback-scsv", base::Value::CreateNullValue()); 549 arguments->Set("fallback-scsv", base::Value::CreateNullValue());
548 if (!ssl_options_.signed_cert_timestamps_tls_ext.empty()) { 550 if (!ssl_options_.signed_cert_timestamps_tls_ext.empty()) {
549 std::string b64_scts_tls_ext; 551 std::string b64_scts_tls_ext;
550 base::Base64Encode(ssl_options_.signed_cert_timestamps_tls_ext, 552 base::Base64Encode(ssl_options_.signed_cert_timestamps_tls_ext,
551 &b64_scts_tls_ext); 553 &b64_scts_tls_ext);
552 arguments->SetString("signed-cert-timestamps-tls-ext", b64_scts_tls_ext); 554 arguments->SetString("signed-cert-timestamps-tls-ext", b64_scts_tls_ext);
553 } 555 }
554 if (ssl_options_.staple_ocsp_response) 556 if (ssl_options_.staple_ocsp_response)
555 arguments->Set("staple-ocsp-response", base::Value::CreateNullValue()); 557 arguments->Set("staple-ocsp-response", base::Value::CreateNullValue());
556 if (ssl_options_.ocsp_server_unavailable) { 558 if (ssl_options_.ocsp_server_unavailable) {
557 arguments->Set("ocsp-server-unavailable", 559 arguments->Set("ocsp-server-unavailable",
558 base::Value::CreateNullValue()); 560 base::Value::CreateNullValue());
559 } 561 }
560 if (!ssl_options_.npn_protocols.empty()) { 562 if (!ssl_options_.npn_protocols.empty()) {
561 scoped_ptr<base::ListValue> npn_protocols(new base::ListValue()); 563 std::unique_ptr<base::ListValue> npn_protocols(new base::ListValue());
562 for (const std::string& proto : ssl_options_.npn_protocols) { 564 for (const std::string& proto : ssl_options_.npn_protocols) {
563 npn_protocols->Append(new base::StringValue(proto)); 565 npn_protocols->Append(new base::StringValue(proto));
564 } 566 }
565 arguments->Set("npn-protocols", std::move(npn_protocols)); 567 arguments->Set("npn-protocols", std::move(npn_protocols));
566 } 568 }
567 if (ssl_options_.alert_after_handshake) 569 if (ssl_options_.alert_after_handshake)
568 arguments->Set("alert-after-handshake", base::Value::CreateNullValue()); 570 arguments->Set("alert-after-handshake", base::Value::CreateNullValue());
569 571
570 if (ssl_options_.disable_channel_id) 572 if (ssl_options_.disable_channel_id)
571 arguments->Set("disable-channel-id", base::Value::CreateNullValue()); 573 arguments->Set("disable-channel-id", base::Value::CreateNullValue());
572 if (ssl_options_.disable_extended_master_secret) { 574 if (ssl_options_.disable_extended_master_secret) {
573 arguments->Set("disable-extended-master-secret", 575 arguments->Set("disable-extended-master-secret",
574 base::Value::CreateNullValue()); 576 base::Value::CreateNullValue());
575 } 577 }
576 if (!ssl_options_.supported_token_binding_params.empty()) { 578 if (!ssl_options_.supported_token_binding_params.empty()) {
577 scoped_ptr<base::ListValue> token_binding_params(new base::ListValue()); 579 std::unique_ptr<base::ListValue> token_binding_params(
580 new base::ListValue());
578 arguments->Set( 581 arguments->Set(
579 "token-binding-params", 582 "token-binding-params",
580 GetTokenBindingParams(ssl_options_.supported_token_binding_params)); 583 GetTokenBindingParams(ssl_options_.supported_token_binding_params));
581 } 584 }
582 } 585 }
583 586
584 return GenerateAdditionalArguments(arguments); 587 return GenerateAdditionalArguments(arguments);
585 } 588 }
586 589
587 bool BaseTestServer::GenerateAdditionalArguments( 590 bool BaseTestServer::GenerateAdditionalArguments(
588 base::DictionaryValue* arguments) const { 591 base::DictionaryValue* arguments) const {
589 return true; 592 return true;
590 } 593 }
591 594
592 } // namespace net 595 } // namespace net
OLDNEW
« no previous file with comments | « net/test/spawned_test_server/base_test_server.h ('k') | net/test/spawned_test_server/remote_test_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698