summaryrefslogtreecommitdiffstats
path: root/chrome_frame/test
diff options
context:
space:
mode:
authorrkn@chromium.org <rkn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-23 20:30:33 +0000
committerrkn@chromium.org <rkn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-23 20:30:33 +0000
commitff04c53708ec68d1f6b1aefa2d44df1725cdf7eb (patch)
treeb0b3dc40223111a4440a56b5d3b279e5b92bd310 /chrome_frame/test
parentfd0719894fe7432eec3155bd23cfab4bb22d4595 (diff)
downloadchromium_src-ff04c53708ec68d1f6b1aefa2d44df1725cdf7eb.zip
chromium_src-ff04c53708ec68d1f6b1aefa2d44df1725cdf7eb.tar.gz
chromium_src-ff04c53708ec68d1f6b1aefa2d44df1725cdf7eb.tar.bz2
Moved the ListenSocket class (found in net/base/listen_socket.h) to the net namespace.
BUG=87032 TEST=None Review URL: http://codereview.chromium.org/7190041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90257 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/test')
-rw-r--r--chrome_frame/test/test_server.cc28
-rw-r--r--chrome_frame/test/test_server.h52
-rw-r--r--chrome_frame/test/test_with_web_server.cc4
3 files changed, 45 insertions, 39 deletions
diff --git a/chrome_frame/test/test_server.cc b/chrome_frame/test/test_server.cc
index 2a6c0a5..c43c5ef 100644
--- a/chrome_frame/test/test_server.cc
+++ b/chrome_frame/test/test_server.cc
@@ -97,7 +97,7 @@ bool FileResponse::GetContentType(std::string* content_type) const {
return content_type->length() > 0;
}
-void FileResponse::WriteContents(ListenSocket* socket) const {
+void FileResponse::WriteContents(net::ListenSocket* socket) const {
DCHECK(file_.get());
if (file_.get()) {
socket->Send(reinterpret_cast<const char*>(file_->data()),
@@ -130,7 +130,7 @@ SimpleWebServer::SimpleWebServer(int port) {
CHECK(MessageLoop::current()) << "SimpleWebServer requires a message loop";
net::EnsureWinsockInit();
AddResponse(&quit_);
- server_ = ListenSocket::Listen("127.0.0.1", port, this);
+ server_ = net::ListenSocket::Listen("127.0.0.1", port, this);
DCHECK(server_.get() != NULL);
}
@@ -165,7 +165,8 @@ Response* SimpleWebServer::FindResponse(const Request& request) const {
return NULL;
}
-Connection* SimpleWebServer::FindConnection(const ListenSocket* socket) const {
+Connection* SimpleWebServer::FindConnection(
+ const net::ListenSocket* socket) const {
ConnectionList::const_iterator it;
for (it = connections_.begin(); it != connections_.end(); it++) {
if ((*it)->IsSame(socket)) {
@@ -175,12 +176,12 @@ Connection* SimpleWebServer::FindConnection(const ListenSocket* socket) const {
return NULL;
}
-void SimpleWebServer::DidAccept(ListenSocket* server,
- ListenSocket* connection) {
+void SimpleWebServer::DidAccept(net::ListenSocket* server,
+ net::ListenSocket* connection) {
connections_.push_back(new Connection(connection));
}
-void SimpleWebServer::DidRead(ListenSocket* connection,
+void SimpleWebServer::DidRead(net::ListenSocket* connection,
const char* data,
int len) {
Connection* c = FindConnection(connection);
@@ -217,7 +218,7 @@ void SimpleWebServer::DidRead(ListenSocket* connection,
}
}
-void SimpleWebServer::DidClose(ListenSocket* sock) {
+void SimpleWebServer::DidClose(net::ListenSocket* sock) {
// To keep the historical list of connections reasonably tidy, we delete
// 404's when the connection ends.
Connection* c = FindConnection(sock);
@@ -233,7 +234,7 @@ HTTPTestServer::HTTPTestServer(int port, const std::wstring& address,
FilePath root_dir)
: port_(port), address_(address), root_dir_(root_dir) {
net::EnsureWinsockInit();
- server_ = ListenSocket::Listen(WideToUTF8(address), port, this);
+ server_ = net::ListenSocket::Listen(WideToUTF8(address), port, this);
}
HTTPTestServer::~HTTPTestServer() {
@@ -241,7 +242,7 @@ HTTPTestServer::~HTTPTestServer() {
}
std::list<scoped_refptr<ConfigurableConnection>>::iterator
-HTTPTestServer::FindConnection(const ListenSocket* socket) {
+HTTPTestServer::FindConnection(const net::ListenSocket* socket) {
ConnectionList::iterator it;
for (it = connection_list_.begin(); it != connection_list_.end(); ++it) {
if ((*it)->socket_ == socket) {
@@ -253,18 +254,19 @@ HTTPTestServer::FindConnection(const ListenSocket* socket) {
}
scoped_refptr<ConfigurableConnection> HTTPTestServer::ConnectionFromSocket(
- const ListenSocket* socket) {
+ const net::ListenSocket* socket) {
ConnectionList::iterator it = FindConnection(socket);
if (it != connection_list_.end())
return *it;
return NULL;
}
-void HTTPTestServer::DidAccept(ListenSocket* server, ListenSocket* socket) {
+void HTTPTestServer::DidAccept(net::ListenSocket* server,
+ net::ListenSocket* socket) {
connection_list_.push_back(new ConfigurableConnection(socket));
}
-void HTTPTestServer::DidRead(ListenSocket* socket,
+void HTTPTestServer::DidRead(net::ListenSocket* socket,
const char* data,
int len) {
scoped_refptr<ConfigurableConnection> connection =
@@ -282,7 +284,7 @@ void HTTPTestServer::DidRead(ListenSocket* socket,
}
}
-void HTTPTestServer::DidClose(ListenSocket* socket) {
+void HTTPTestServer::DidClose(net::ListenSocket* socket) {
ConnectionList::iterator it = FindConnection(socket);
DCHECK(it != connection_list_.end());
connection_list_.erase(it);
diff --git a/chrome_frame/test/test_server.h b/chrome_frame/test/test_server.h
index 2b8454a..50ba5da 100644
--- a/chrome_frame/test/test_server.h
+++ b/chrome_frame/test/test_server.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -105,13 +105,13 @@ class Request {
// shut down.
class Connection {
public:
- explicit Connection(ListenSocket* sock) : socket_(sock) {
+ explicit Connection(net::ListenSocket* sock) : socket_(sock) {
}
~Connection() {
}
- bool IsSame(const ListenSocket* socket) const {
+ bool IsSame(const net::ListenSocket* socket) const {
return socket_ == socket;
}
@@ -124,7 +124,7 @@ class Connection {
}
protected:
- scoped_refptr<ListenSocket> socket_;
+ scoped_refptr<net::ListenSocket> socket_;
Request request_;
private:
@@ -160,7 +160,7 @@ class Response {
return 0;
}
- virtual void WriteContents(ListenSocket* socket) const {
+ virtual void WriteContents(net::ListenSocket* socket) const {
}
virtual void IncrementAccessCounter() {
@@ -211,7 +211,7 @@ class SimpleResponse : public ResponseForPath {
: ResponseForPath(request_path), contents_(contents) {
}
- virtual void WriteContents(ListenSocket* socket) const {
+ virtual void WriteContents(net::ListenSocket* socket) const {
socket->Send(contents_.c_str(), contents_.length(), false);
}
@@ -237,7 +237,7 @@ class FileResponse : public ResponseForPath {
}
virtual bool GetContentType(std::string* content_type) const;
- virtual void WriteContents(ListenSocket* socket) const;
+ virtual void WriteContents(net::ListenSocket* socket) const;
virtual size_t ContentLength() const;
protected:
@@ -271,7 +271,7 @@ typedef std::list<Connection*> ConnectionList;
// Implementation of a simple http server.
// Before creating an instance of the server, make sure the current thread
// has a message loop.
-class SimpleWebServer : public ListenSocket::ListenSocketDelegate {
+class SimpleWebServer : public net::ListenSocket::ListenSocketDelegate {
public:
explicit SimpleWebServer(int port);
virtual ~SimpleWebServer();
@@ -287,9 +287,12 @@ class SimpleWebServer : public ListenSocket::ListenSocketDelegate {
void DeleteAllResponses();
// ListenSocketDelegate overrides.
- virtual void DidAccept(ListenSocket* server, ListenSocket* connection);
- virtual void DidRead(ListenSocket* connection, const char* data, int len);
- virtual void DidClose(ListenSocket* sock);
+ virtual void DidAccept(net::ListenSocket* server,
+ net::ListenSocket* connection);
+ virtual void DidRead(net::ListenSocket* connection,
+ const char* data,
+ int len);
+ virtual void DidClose(net::ListenSocket* sock);
const ConnectionList& connections() const {
return connections_;
@@ -302,17 +305,17 @@ class SimpleWebServer : public ListenSocket::ListenSocketDelegate {
: SimpleResponse("/quit", "So long and thanks for all the fish.") {
}
- virtual void QuitResponse::WriteContents(ListenSocket* socket) const {
+ virtual void QuitResponse::WriteContents(net::ListenSocket* socket) const {
SimpleResponse::WriteContents(socket);
MessageLoop::current()->Quit();
}
};
Response* FindResponse(const Request& request) const;
- Connection* FindConnection(const ListenSocket* socket) const;
+ Connection* FindConnection(const net::ListenSocket* socket) const;
protected:
- scoped_refptr<ListenSocket> server_;
+ scoped_refptr<net::ListenSocket> server_;
ConnectionList connections_;
std::list<Response*> responses_;
QuitResponse quit_;
@@ -337,8 +340,9 @@ class ConfigurableConnection : public base::RefCounted<ConfigurableConnection> {
int64 timeout_;
};
- explicit ConfigurableConnection(ListenSocket* sock)
- : socket_(sock), cur_pos_(0) { }
+ explicit ConfigurableConnection(net::ListenSocket* sock)
+ : socket_(sock),
+ cur_pos_(0) {}
// Send HTTP response with provided |headers| and |content|. Appends
// "Context-Length:" header if the |content| is not empty.
@@ -356,7 +360,7 @@ class ConfigurableConnection : public base::RefCounted<ConfigurableConnection> {
// next chunk of |data_|.
void SendChunk();
- scoped_refptr<ListenSocket> socket_;
+ scoped_refptr<net::ListenSocket> socket_;
Request r_;
SendOptions options_;
std::string data_;
@@ -368,7 +372,7 @@ class ConfigurableConnection : public base::RefCounted<ConfigurableConnection> {
// Simple class used as a base class for mock webserver.
// Override virtual functions Get and Post and use passed ConfigurableConnection
// instance to send the response.
-class HTTPTestServer : public ListenSocket::ListenSocketDelegate {
+class HTTPTestServer : public net::ListenSocket::ListenSocketDelegate {
public:
explicit HTTPTestServer(int port, const std::wstring& address,
FilePath root_dir);
@@ -396,16 +400,16 @@ class HTTPTestServer : public ListenSocket::ListenSocketDelegate {
private:
typedef std::list<scoped_refptr<ConfigurableConnection> > ConnectionList;
- ConnectionList::iterator FindConnection(const ListenSocket* socket);
+ ConnectionList::iterator FindConnection(const net::ListenSocket* socket);
scoped_refptr<ConfigurableConnection> ConnectionFromSocket(
- const ListenSocket* socket);
+ const net::ListenSocket* socket);
// ListenSocketDelegate overrides.
- virtual void DidAccept(ListenSocket* server, ListenSocket* socket);
- virtual void DidRead(ListenSocket* socket, const char* data, int len);
- virtual void DidClose(ListenSocket* socket);
+ virtual void DidAccept(net::ListenSocket* server, net::ListenSocket* socket);
+ virtual void DidRead(net::ListenSocket* socket, const char* data, int len);
+ virtual void DidClose(net::ListenSocket* socket);
- scoped_refptr<ListenSocket> server_;
+ scoped_refptr<net::ListenSocket> server_;
ConnectionList connection_list_;
DISALLOW_COPY_AND_ASSIGN(HTTPTestServer);
diff --git a/chrome_frame/test/test_with_web_server.cc b/chrome_frame/test/test_with_web_server.cc
index 4399ac3..c759815 100644
--- a/chrome_frame/test/test_with_web_server.cc
+++ b/chrome_frame/test/test_with_web_server.cc
@@ -1114,7 +1114,7 @@ class UaTemplateFileResponse : public test_server::FileResponse {
return content_.length();
}
- virtual void WriteContents(ListenSocket* socket) const {
+ virtual void WriteContents(net::ListenSocket* socket) const {
DCHECK(content_.length());
socket->Send(content_.c_str(), content_.length(), false);
request_id_++;
@@ -1240,7 +1240,7 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_TestDownloadFromForm) {
return match;
}
- virtual void WriteContents(ListenSocket* socket) const {
+ virtual void WriteContents(net::ListenSocket* socket) const {
if (is_post_) {
socket->Send(kText, sizeof(kText) - 1, false);
} else {