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

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

Issue 5239001: [Sync] Make sync integration tests use local xmpp servers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed unneeded switch Created 10 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 | Annotate | Revision Log
« no previous file with comments | « net/test/test_server.h ('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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/test_server.h" 5 #include "net/test/test_server.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 182 }
183 183
184 return ret; 184 return ret;
185 } 185 }
186 186
187 const HostPortPair& TestServer::host_port_pair() const { 187 const HostPortPair& TestServer::host_port_pair() const {
188 DCHECK(started_); 188 DCHECK(started_);
189 return host_port_pair_; 189 return host_port_pair_;
190 } 190 }
191 191
192 const DictionaryValue& TestServer::server_data() const {
193 DCHECK(started_);
194 return *server_data_;
195 }
196
192 std::string TestServer::GetScheme() const { 197 std::string TestServer::GetScheme() const {
193 switch (type_) { 198 switch (type_) {
194 case TYPE_FTP: 199 case TYPE_FTP:
195 return "ftp"; 200 return "ftp";
196 case TYPE_HTTP: 201 case TYPE_HTTP:
197 case TYPE_SYNC: 202 case TYPE_SYNC:
198 return "http"; 203 return "http";
199 case TYPE_HTTPS: 204 case TYPE_HTTPS:
200 return "https"; 205 return "https";
201 default: 206 default:
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 bool TestServer::ParseServerData(const std::string& server_data) { 389 bool TestServer::ParseServerData(const std::string& server_data) {
385 VLOG(1) << "Server data: " << server_data; 390 VLOG(1) << "Server data: " << server_data;
386 base::JSONReader json_reader; 391 base::JSONReader json_reader;
387 scoped_ptr<Value> value(json_reader.JsonToValue(server_data, true, false)); 392 scoped_ptr<Value> value(json_reader.JsonToValue(server_data, true, false));
388 if (!value.get() || 393 if (!value.get() ||
389 !value->IsType(Value::TYPE_DICTIONARY)) { 394 !value->IsType(Value::TYPE_DICTIONARY)) {
390 LOG(ERROR) << "Could not parse server data: " 395 LOG(ERROR) << "Could not parse server data: "
391 << json_reader.GetErrorMessage(); 396 << json_reader.GetErrorMessage();
392 return false; 397 return false;
393 } 398 }
394 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); 399 server_data_.reset(static_cast<DictionaryValue*>(value.release()));
395 int port = 0; 400 int port = 0;
396 if (!dict->GetInteger("port", &port)) { 401 if (!server_data_->GetInteger("port", &port)) {
397 LOG(ERROR) << "Could not find port value"; 402 LOG(ERROR) << "Could not find port value";
398 return false; 403 return false;
399 } 404 }
400 if ((port <= 0) || (port >= kuint16max)) { 405 if ((port <= 0) || (port >= kuint16max)) {
401 LOG(ERROR) << "Invalid port value: " << port; 406 LOG(ERROR) << "Invalid port value: " << port;
402 return false; 407 return false;
403 } 408 }
404 host_port_pair_.set_port(port); 409 host_port_pair_.set_port(port);
405 return true; 410 return true;
406 } 411 }
407 412
408 } // namespace net 413 } // namespace net
OLDNEW
« no previous file with comments | « net/test/test_server.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698