summaryrefslogtreecommitdiffstats
path: root/sync/test
diff options
context:
space:
mode:
authorpvalenzuela@chromium.org <pvalenzuela@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-02 00:10:19 +0000
committerpvalenzuela@chromium.org <pvalenzuela@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-02 00:10:19 +0000
commitf635e0b4eb22336ede68f0a34b967bd4ef819512 (patch)
tree9a33276de94aa3dd2829f2d93f3646ae1a4352a8 /sync/test
parent15c75ce84bcf5dbf03034ed52da0f310fa2193a1 (diff)
downloadchromium_src-f635e0b4eb22336ede68f0a34b967bd4ef819512.zip
chromium_src-f635e0b4eb22336ede68f0a34b967bd4ef819512.tar.gz
chromium_src-f635e0b4eb22336ede68f0a34b967bd4ef819512.tar.bz2
Remove Sync FakeServer standalone executable
This code was created with the intention of being used in Android tests, but it has gone unused to this point. This qualifies as dead code right now, but we may bring it back in the future. BUG=NONE Review URL: https://codereview.chromium.org/264773007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267686 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/test')
-rw-r--r--sync/test/fake_server/fake_sync_server_http_handler.cc77
-rw-r--r--sync/test/fake_server/fake_sync_server_http_handler.h54
-rw-r--r--sync/test/fake_server/run_sync_fake_server.cc61
3 files changed, 0 insertions, 192 deletions
diff --git a/sync/test/fake_server/fake_sync_server_http_handler.cc b/sync/test/fake_server/fake_sync_server_http_handler.cc
deleted file mode 100644
index 4438e4db..0000000
--- a/sync/test/fake_server/fake_sync_server_http_handler.cc
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright 2014 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.
-
-#include <iostream>
-
-#include "base/strings/string_util.h"
-#include "base/strings/stringprintf.h"
-#include "net/base/ip_endpoint.h"
-#include "net/base/net_errors.h"
-#include "net/server/http_server_request_info.h"
-#include "net/server/http_server_response_info.h"
-#include "net/socket/tcp_listen_socket.h"
-#include "sync/test/fake_server/fake_sync_server_http_handler.h"
-
-namespace fake_server {
-
-FakeSyncServerHttpHandler::FakeSyncServerHttpHandler() : requested_port_(0) {}
-
-FakeSyncServerHttpHandler::FakeSyncServerHttpHandler(int port)
- : requested_port_(port) {}
-
-FakeSyncServerHttpHandler::~FakeSyncServerHttpHandler() {}
-
-// Note that this must be called from within an IO MessageLoop because it
-// initializes a net::HttpServer.
-void FakeSyncServerHttpHandler::Start() {
- VLOG(1) << "Starting web server";
- net::TCPListenSocketFactory factory("0.0.0.0", requested_port_);
- server_ = new net::HttpServer(factory, this);
- net::IPEndPoint address;
- int error = server_->GetLocalAddress(&address);
- CHECK_EQ(net::OK, error) << base::StringPrintf(
- "Error %d while trying to choose a port: %s",
- error,
- net::ErrorToString(error));
-
- LOG(INFO) << base::StringPrintf("Listening on port %d", address.port());
-}
-
-void FakeSyncServerHttpHandler::OnHttpRequest(
- int connection_id,
- const net::HttpServerRequestInfo& info) {
-
- // Hand http requests over to the sync FakeServer implementation to process
- VLOG(1) << "Request path: " << info.path;
- int response_code = -1;
- std::string response;
- int server_return_value = fake_sync_server_.HandleCommand(info.data,
- &response_code,
- &response);
- if (server_return_value == 0) {
- // A '0' error code indicates a successful request to FakeServer
- server_->Send(connection_id, net::HttpStatusCode(response_code),
- response, "text/html");
- VLOG(1) << "Sync response sent: " << response;
- } else {
- // The FakeServer returned a non-0 error code.
- std::string error_message = base::StringPrintf(
- "Error processing sync request: error code %d. (%s)",
- server_return_value,
- net::ErrorToString(server_return_value));
- server_->Send500(connection_id, error_message);
- LOG(ERROR) << error_message;
- }
-}
-
-void FakeSyncServerHttpHandler::OnWebSocketRequest(
- int connection_id,
- const net::HttpServerRequestInfo& info) {}
-
-void FakeSyncServerHttpHandler::OnWebSocketMessage(int connection_id,
- const std::string& data) {}
-
-void FakeSyncServerHttpHandler::OnClose(int connection_id) {}
-
-} // namespace fake_server
diff --git a/sync/test/fake_server/fake_sync_server_http_handler.h b/sync/test/fake_server/fake_sync_server_http_handler.h
deleted file mode 100644
index ef5ecb51..0000000
--- a/sync/test/fake_server/fake_sync_server_http_handler.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2014 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.
-
-#ifndef SYNC_TEST_FAKE_SERVER_FAKE_SERVER_HTTP_HANDLER_H_
-#define SYNC_TEST_FAKE_SERVER_FAKE_SERVER_HTTP_HANDLER_H_
-
-#include "net/server/http_server.h"
-#include "sync/test/fake_server/fake_server.h"
-
-namespace fake_server {
-
-// An HTTP server that forwards requests to FakeServer, providing a quick way
-// to test Sync client code.
-class FakeSyncServerHttpHandler : public net::HttpServer::Delegate {
- public:
- // Creates a fake sync server that listens on an available port.
- FakeSyncServerHttpHandler();
-
- // Creates a fake sync server that listens on a specified port.
- explicit FakeSyncServerHttpHandler(int port);
-
- virtual ~FakeSyncServerHttpHandler();
-
- // Begin accepting HTTP requests. Must be called from an IO MessageLoop.
- void Start();
-
- // Overridden from net::HttpServer::Delegate.
- // HTTP requests are processed and WebSocket requests are currently
- // unimplemented.
- virtual void OnHttpRequest(int connection_id,
- const net::HttpServerRequestInfo& info) OVERRIDE;
- virtual void OnWebSocketRequest(
- int connection_id,
- const net::HttpServerRequestInfo& info) OVERRIDE;
-
- virtual void OnWebSocketMessage(int connection_id,
- const std::string& data) OVERRIDE;
-
- virtual void OnClose(int connection_id) OVERRIDE;
-
- private:
- int requested_port_;
-
- scoped_refptr<net::HttpServer> server_;
-
- fake_server::FakeServer fake_sync_server_;
-
- DISALLOW_COPY_AND_ASSIGN(FakeSyncServerHttpHandler);
-};
-
-} // namespace fake_server
-
-#endif // SYNC_TEST_FAKE_SERVER_FAKE_SERVER_HTTP_HANDLER_H_
diff --git a/sync/test/fake_server/run_sync_fake_server.cc b/sync/test/fake_server/run_sync_fake_server.cc
deleted file mode 100644
index 9ded029..0000000
--- a/sync/test/fake_server/run_sync_fake_server.cc
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2014 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.
-
-#include <iostream>
-
-#include "base/at_exit.h"
-#include "base/bind.h"
-#include "base/command_line.h"
-#include "base/message_loop/message_loop.h"
-#include "base/message_loop/message_loop_proxy.h"
-#include "base/strings/string_number_conversions.h"
-#include "sync/test/fake_server/fake_sync_server_http_handler.h"
-
-const char kPortNumberSwitch[] = "port";
-
-// This runs a FakeSyncServerHttpHandler as a command-line app.
-int main(int argc, char* argv[]) {
- using fake_server::FakeSyncServerHttpHandler;
-
- CommandLine::Init(argc, argv);
- CommandLine* command_line = CommandLine::ForCurrentProcess();
- logging::LoggingSettings settings;
- settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
- logging::InitLogging(settings);
-
- FakeSyncServerHttpHandler* server;
-
- // Check if a port was specified on the command line
- if (command_line->HasSwitch(kPortNumberSwitch)) {
- std::string requested_port =
- command_line->GetSwitchValueASCII(kPortNumberSwitch);
- int port;
- if (!base::StringToInt(requested_port, &port)) {
- LOG(ERROR) << "Invalid --" << kPortNumberSwitch << " specified: \""
- << requested_port << "\"";
- return -1;
- }
-
- server = new FakeSyncServerHttpHandler(port);
- } else {
- LOG(INFO) << "Selecting an avilable port. Pass --" << kPortNumberSwitch
- << "=<port number> to specify your own.";
- server = new FakeSyncServerHttpHandler();
- }
-
- base::WeakPtrFactory<FakeSyncServerHttpHandler> server_ptr_factory(server);
-
- // An HttpServer must be run on a IO MessageLoop.
- base::AtExitManager exit_manager; // Debug builds demand that ExitManager
- // be initialized before MessageLoop.
- base::MessageLoop message_loop(base::MessageLoop::TYPE_IO);
- bool posted = message_loop.current()->message_loop_proxy()->PostTask(
- FROM_HERE,
- base::Bind(&FakeSyncServerHttpHandler::Start,
- server_ptr_factory.GetWeakPtr()));
- CHECK(posted) << "Failed to start the HTTP server. PostTask returned false.";
- message_loop.current()->Run();
-
- return 0;
-}