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

Side by Side Diff: net/tools/quic/quic_server_bin.cc

Issue 340433002: Port QuicServer to Chrome network stack (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix invalid memory access + blocked writers Created 6 years, 6 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
« net/quic/quic_server_test.cc ('K') | « net/quic/quic_server_test.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // A binary wrapper for QuicServer. It listens forever on --port 5 // A binary wrapper for QuicServer. It listens forever on --port
6 // (default 6121) until it's killed or ctrl-cd to death. 6 // (default 6121) until it's killed or ctrl-cd to death.
7 7
8 #include <iostream> 8 #include <iostream>
9 9
10 #include "base/at_exit.h" 10 #include "base/at_exit.h"
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/run_loop.h"
14 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
15 #include "net/base/ip_endpoint.h" 16 #include "net/base/ip_endpoint.h"
16 #include "net/tools/quic/quic_in_memory_cache.h" 17 #include "net/quic/quic_in_memory_cache.h"
17 #include "net/tools/quic/quic_server.h" 18 #include "net/quic/quic_server.h"
19
20 const uint32 kServerInitialFlowControlWindow = 100 * net::kMaxPacketSize;
wtc 2014/06/18 02:04:47 This is a very non-obvious constant. Can we get th
dmziegler 2014/06/18 20:13:42 It used to live in quic_server.cc with no explanat
18 21
19 // The port the quic server will listen on. 22 // The port the quic server will listen on.
20
21 int32 FLAGS_port = 6121; 23 int32 FLAGS_port = 6121;
22 24
23 int main(int argc, char *argv[]) { 25 int main(int argc, char *argv[]) {
24 base::CommandLine::Init(argc, argv); 26 base::CommandLine::Init(argc, argv);
25 base::CommandLine* line = base::CommandLine::ForCurrentProcess(); 27 base::CommandLine* line = base::CommandLine::ForCurrentProcess();
26 28
27 logging::LoggingSettings settings; 29 logging::LoggingSettings settings;
28 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; 30 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
29 CHECK(logging::InitLogging(settings)); 31 CHECK(logging::InitLogging(settings));
30 32
31 if (line->HasSwitch("h") || line->HasSwitch("help")) { 33 if (line->HasSwitch("h") || line->HasSwitch("help")) {
32 const char* help_str = 34 const char* help_str =
33 "Usage: quic_server [options]\n" 35 "Usage: quic_server [options]\n"
34 "\n" 36 "\n"
35 "Options:\n" 37 "Options:\n"
36 "-h, --help show this help message and exit\n" 38 "-h, --help show this help message and exit\n"
37 "--port=<port> specify the port to listen on\n" 39 "--port=<port> specify the port to listen on\n"
38 "--quic_in_memory_cache_dir directory containing response data\n" 40 "--quic_in_memory_cache_dir directory containing response data\n"
39 " to load\n"; 41 " to load\n";
40 std::cout << help_str; 42 std::cout << help_str;
41 exit(0); 43 exit(0);
42 } 44 }
43 45
44 if (line->HasSwitch("quic_in_memory_cache_dir")) { 46 if (line->HasSwitch("quic_in_memory_cache_dir")) {
45 net::tools::FLAGS_quic_in_memory_cache_dir = 47 net::g_quic_in_memory_cache_dir = base::FilePath::FromUTF8Unsafe(
wtc 2014/06/18 02:04:47 It may be better to provide a setter function. See
dmziegler 2014/06/18 20:13:42 Do you want me to make this better now, or should
46 line->GetSwitchValueASCII("quic_in_memory_cache_dir"); 48 line->GetSwitchValueASCII("quic_in_memory_cache_dir"));
47 } 49 }
48 50
49 if (line->HasSwitch("port")) { 51 if (line->HasSwitch("port")) {
50 int port; 52 int port;
51 if (base::StringToInt(line->GetSwitchValueASCII("port"), &port)) { 53 if (base::StringToInt(line->GetSwitchValueASCII("port"), &port)) {
52 FLAGS_port = port; 54 FLAGS_port = port;
53 } 55 }
54 } 56 }
55 57
56 base::AtExitManager exit_manager; 58 base::AtExitManager exit_manager;
57 59
60 base::MessageLoopForIO messageLoop;
wtc 2014/06/18 02:04:47 This variable should be named "message_loop". But
dmziegler 2014/06/18 20:13:42 Yes, it initializes the message loop on the thread
61
58 net::IPAddressNumber ip; 62 net::IPAddressNumber ip;
59 CHECK(net::ParseIPLiteralToNumber("::", &ip)); 63 CHECK(net::ParseIPLiteralToNumber("::", &ip));
60 64
61 net::tools::QuicServer server; 65 net::QuicConfig config;
66 config.SetDefaults();
67
68 net::QuicVersionVector versions;
69 versions.push_back(net::QUIC_VERSION_19);
70 versions.push_back(net::QUIC_VERSION_18);
71 versions.push_back(net::QUIC_VERSION_17);
72 versions.push_back(net::QUIC_VERSION_16);
73 versions.push_back(net::QUIC_VERSION_15);
wtc 2014/06/18 02:04:48 There should be a function that returns all the su
dmziegler 2014/06/18 20:13:42 Yes, replaced.
74
75 net::QuicServer server(config, versions, kServerInitialFlowControlWindow);
62 76
63 if (!server.Listen(net::IPEndPoint(ip, FLAGS_port))) { 77 if (!server.Listen(net::IPEndPoint(ip, FLAGS_port))) {
64 return 1; 78 return 1;
65 } 79 }
66 80
67 while (1) { 81 base::RunLoop().Run();
68 server.WaitForEvents();
69 }
70 82
71 return 0; 83 return 0;
72 } 84 }
OLDNEW
« net/quic/quic_server_test.cc ('K') | « net/quic/quic_server_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698