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

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

Issue 12209080: Cleanup: Remove deprecated base::Value methods from net. Use base::Value too. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_session.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/base_test_server.h" 5 #include "net/test/base_test_server.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 24 matching lines...) Expand all
35 // Return a different hostname string that resolves to the same hostname. 35 // Return a different hostname string that resolves to the same hostname.
36 return "localhost"; 36 return "localhost";
37 } 37 }
38 38
39 // Use the 127.0.0.1 as default. 39 // Use the 127.0.0.1 as default.
40 return BaseTestServer::kLocalhost; 40 return BaseTestServer::kLocalhost;
41 } 41 }
42 42
43 void GetCiphersList(int cipher, base::ListValue* values) { 43 void GetCiphersList(int cipher, base::ListValue* values) {
44 if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_RC4) 44 if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_RC4)
45 values->Append(base::Value::CreateStringValue("rc4")); 45 values->Append(new base::StringValue("rc4"));
46 if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_AES128) 46 if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_AES128)
47 values->Append(base::Value::CreateStringValue("aes128")); 47 values->Append(new base::StringValue("aes128"));
48 if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_AES256) 48 if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_AES256)
49 values->Append(base::Value::CreateStringValue("aes256")); 49 values->Append(new base::StringValue("aes256"));
50 if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_3DES) 50 if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_3DES)
51 values->Append(base::Value::CreateStringValue("3des")); 51 values->Append(new base::StringValue("3des"));
52 } 52 }
53 53
54 } // namespace 54 } // namespace
55 55
56 BaseTestServer::SSLOptions::SSLOptions() 56 BaseTestServer::SSLOptions::SSLOptions()
57 : server_certificate(CERT_OK), 57 : server_certificate(CERT_OK),
58 ocsp_status(OCSP_OK), 58 ocsp_status(OCSP_OK),
59 request_client_certificate(false), 59 request_client_certificate(false),
60 bulk_ciphers(SSLOptions::BULK_CIPHER_ANY), 60 bulk_ciphers(SSLOptions::BULK_CIPHER_ANY),
61 record_resume(false), 61 record_resume(false),
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 Init(GetHostname(type, ssl_options)); 129 Init(GetHostname(type, ssl_options));
130 } 130 }
131 131
132 BaseTestServer::~BaseTestServer() {} 132 BaseTestServer::~BaseTestServer() {}
133 133
134 const HostPortPair& BaseTestServer::host_port_pair() const { 134 const HostPortPair& BaseTestServer::host_port_pair() const {
135 DCHECK(started_); 135 DCHECK(started_);
136 return host_port_pair_; 136 return host_port_pair_;
137 } 137 }
138 138
139 const DictionaryValue& BaseTestServer::server_data() const { 139 const base::DictionaryValue& BaseTestServer::server_data() const {
140 DCHECK(started_); 140 DCHECK(started_);
141 DCHECK(server_data_.get()); 141 DCHECK(server_data_.get());
142 return *server_data_; 142 return *server_data_;
143 } 143 }
144 144
145 std::string BaseTestServer::GetScheme() const { 145 std::string BaseTestServer::GetScheme() const {
146 switch (type_) { 146 switch (type_) {
147 case TYPE_FTP: 147 case TYPE_FTP:
148 return "ftp"; 148 return "ftp";
149 case TYPE_HTTP: 149 case TYPE_HTTP:
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // This method shouldn't get called twice. 252 // This method shouldn't get called twice.
253 DCHECK(certificates_dir_.empty()); 253 DCHECK(certificates_dir_.empty());
254 document_root_ = document_root; 254 document_root_ = document_root;
255 certificates_dir_ = certificates_dir; 255 certificates_dir_ = certificates_dir;
256 DCHECK(!certificates_dir_.empty()); 256 DCHECK(!certificates_dir_.empty());
257 } 257 }
258 258
259 bool BaseTestServer::ParseServerData(const std::string& server_data) { 259 bool BaseTestServer::ParseServerData(const std::string& server_data) {
260 VLOG(1) << "Server data: " << server_data; 260 VLOG(1) << "Server data: " << server_data;
261 base::JSONReader json_reader; 261 base::JSONReader json_reader;
262 scoped_ptr<Value> value(json_reader.ReadToValue(server_data)); 262 scoped_ptr<base::Value> value(json_reader.ReadToValue(server_data));
263 if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) { 263 if (!value.get() || !value->IsType(base::Value::TYPE_DICTIONARY)) {
264 LOG(ERROR) << "Could not parse server data: " 264 LOG(ERROR) << "Could not parse server data: "
265 << json_reader.GetErrorMessage(); 265 << json_reader.GetErrorMessage();
266 return false; 266 return false;
267 } 267 }
268 268
269 server_data_.reset(static_cast<DictionaryValue*>(value.release())); 269 server_data_.reset(static_cast<base::DictionaryValue*>(value.release()));
270 int port = 0; 270 int port = 0;
271 if (!server_data_->GetInteger("port", &port)) { 271 if (!server_data_->GetInteger("port", &port)) {
272 LOG(ERROR) << "Could not find port value"; 272 LOG(ERROR) << "Could not find port value";
273 return false; 273 return false;
274 } 274 }
275 if ((port <= 0) || (port > kuint16max)) { 275 if ((port <= 0) || (port > kuint16max)) {
276 LOG(ERROR) << "Invalid port value: " << port; 276 LOG(ERROR) << "Invalid port value: " << port;
277 return false; 277 return false;
278 } 278 }
279 host_port_pair_.set_port(port); 279 host_port_pair_.set_port(port);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 scoped_ptr<base::ListValue> ssl_client_certs(new base::ListValue()); 354 scoped_ptr<base::ListValue> ssl_client_certs(new base::ListValue());
355 355
356 std::vector<FilePath>::const_iterator it; 356 std::vector<FilePath>::const_iterator it;
357 for (it = ssl_options_.client_authorities.begin(); 357 for (it = ssl_options_.client_authorities.begin();
358 it != ssl_options_.client_authorities.end(); ++it) { 358 it != ssl_options_.client_authorities.end(); ++it) {
359 if (it->IsAbsolute() && !file_util::PathExists(*it)) { 359 if (it->IsAbsolute() && !file_util::PathExists(*it)) {
360 LOG(ERROR) << "Client authority path " << it->value() 360 LOG(ERROR) << "Client authority path " << it->value()
361 << " doesn't exist. Can't launch https server."; 361 << " doesn't exist. Can't launch https server.";
362 return false; 362 return false;
363 } 363 }
364 ssl_client_certs->Append(base::Value::CreateStringValue(it->value())); 364 ssl_client_certs->Append(new base::StringValue(it->value()));
365 } 365 }
366 366
367 if (ssl_client_certs->GetSize()) 367 if (ssl_client_certs->GetSize())
368 arguments->Set("ssl-client-ca", ssl_client_certs.release()); 368 arguments->Set("ssl-client-ca", ssl_client_certs.release());
369 } 369 }
370 370
371 if (type_ == TYPE_HTTPS) { 371 if (type_ == TYPE_HTTPS) {
372 arguments->Set("https", base::Value::CreateNullValue()); 372 arguments->Set("https", base::Value::CreateNullValue());
373 373
374 std::string ocsp_arg = ssl_options_.GetOCSPArgument(); 374 std::string ocsp_arg = ssl_options_.GetOCSPArgument();
375 if (!ocsp_arg.empty()) 375 if (!ocsp_arg.empty())
376 arguments->SetString("ocsp", ocsp_arg); 376 arguments->SetString("ocsp", ocsp_arg);
377 377
378 // Check bulk cipher argument. 378 // Check bulk cipher argument.
379 scoped_ptr<base::ListValue> bulk_cipher_values(new base::ListValue()); 379 scoped_ptr<base::ListValue> bulk_cipher_values(new base::ListValue());
380 GetCiphersList(ssl_options_.bulk_ciphers, bulk_cipher_values.get()); 380 GetCiphersList(ssl_options_.bulk_ciphers, bulk_cipher_values.get());
381 if (bulk_cipher_values->GetSize()) 381 if (bulk_cipher_values->GetSize())
382 arguments->Set("ssl-bulk-cipher", bulk_cipher_values.release()); 382 arguments->Set("ssl-bulk-cipher", bulk_cipher_values.release());
383 if (ssl_options_.record_resume) 383 if (ssl_options_.record_resume)
384 arguments->Set("https-record-resume", base::Value::CreateNullValue()); 384 arguments->Set("https-record-resume", base::Value::CreateNullValue());
385 if (ssl_options_.tls_intolerant != SSLOptions::TLS_INTOLERANT_NONE) { 385 if (ssl_options_.tls_intolerant != SSLOptions::TLS_INTOLERANT_NONE) {
386 arguments->Set("tls-intolerant", 386 arguments->Set("tls-intolerant",
387 base::Value::CreateIntegerValue(ssl_options_.tls_intolerant)); 387 new base::FundamentalValue(ssl_options_.tls_intolerant));
388 } 388 }
389 } 389 }
390 390
391 return GenerateAdditionalArguments(arguments); 391 return GenerateAdditionalArguments(arguments);
392 } 392 }
393 393
394 bool BaseTestServer::GenerateAdditionalArguments( 394 bool BaseTestServer::GenerateAdditionalArguments(
395 base::DictionaryValue* arguments) const { 395 base::DictionaryValue* arguments) const {
396 return true; 396 return true;
397 } 397 }
398 398
399 } // namespace net 399 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698