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

Unified Diff: net/tools/fetch/fetch_server.cc

Issue 99333: A utility driver for doing client/server HTTP transaction... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/tools/fetch/fetch_client.cc ('k') | net/tools/fetch/http_listen_socket.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/fetch/fetch_server.cc
===================================================================
--- net/tools/fetch/fetch_server.cc (revision 0)
+++ net/tools/fetch/fetch_server.cc (revision 0)
@@ -0,0 +1,54 @@
+// Copyright (c) 2009 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 "base/at_exit.h"
+#include "base/command_line.h"
+#include "base/message_loop.h"
+#include "base/singleton.h"
+#include "base/stats_counters.h"
+#include "net/base/completion_callback.h"
+#include "net/base/io_buffer.h"
+#include "net/base/net_errors.h"
+#include "net/base/winsock_init.h"
+#include "net/http/http_network_layer.h"
+#include "net/http/http_request_info.h"
+#include "net/http/http_transaction.h"
+#include "net/proxy/proxy_service.h"
+#include "net/tools/fetch/http_server.h"
+
+void usage(const char* program_name) {
+ printf("usage: %s\n", program_name);
+ exit(-1);
+}
+
+int main(int argc, char**argv) {
+ base::AtExitManager exit;
+ StatsTable table("fetchserver", 50, 1000);
+ table.set_current(&table);
+
+ net::EnsureWinsockInit();
+
+ CommandLine::Init(0, NULL);
+ const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
+
+ // Do work here.
+ MessageLoop loop;
+ HttpServer server("", 80); // TODO(mbelshe): make port configurable
+ MessageLoop::current()->Run();
+
+ if (parsed_command_line.HasSwitch(L"stats")) {
+ // Dump the stats table.
+ printf("<stats>\n");
+ int counter_max = table.GetMaxCounters();
+ for (int index=0; index < counter_max; index++) {
+ std::string name(table.GetRowName(index));
+ if (name.length() > 0) {
+ int value = table.GetRowValue(index);
+ printf("%s:\t%d\n", name.c_str(), value);
+ }
+ }
+ printf("</stats>\n");
+ }
+
+}
« no previous file with comments | « net/tools/fetch/fetch_client.cc ('k') | net/tools/fetch/http_listen_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698