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

Side by Side Diff: net/tools/flip_server/flip_config.cc

Issue 93793004: Format and Refactor Flip Server. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 7 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
« no previous file with comments | « net/tools/flip_server/flip_config.h ('k') | net/tools/flip_server/flip_in_mem_edsm_server.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/tools/flip_server/flip_config.h" 5 #include "net/tools/flip_server/flip_config.h"
6 6
7 #include <unistd.h> 7 #include <unistd.h>
8 8
9 namespace net { 9 namespace net {
10 10
11 FlipAcceptor::FlipAcceptor(enum FlipHandlerType flip_handler_type, 11 FlipAcceptor::FlipAcceptor(enum FlipHandlerType flip_handler_type,
12 std::string listen_ip, 12 std::string listen_ip,
13 std::string listen_port, 13 std::string listen_port,
14 std::string ssl_cert_filename, 14 std::string ssl_cert_filename,
15 std::string ssl_key_filename, 15 std::string ssl_key_filename,
16 std::string http_server_ip, 16 std::string http_server_ip,
17 std::string http_server_port, 17 std::string http_server_port,
18 std::string https_server_ip, 18 std::string https_server_ip,
19 std::string https_server_port, 19 std::string https_server_port,
20 int spdy_only, 20 int spdy_only,
21 int accept_backlog_size, 21 int accept_backlog_size,
22 bool disable_nagle, 22 bool disable_nagle,
23 int accepts_per_wake, 23 int accepts_per_wake,
24 bool reuseport, 24 bool reuseport,
25 bool wait_for_iface, 25 bool wait_for_iface,
26 void *memory_cache) 26 void* memory_cache)
27 : flip_handler_type_(flip_handler_type), 27 : flip_handler_type_(flip_handler_type),
28 listen_ip_(listen_ip), 28 listen_ip_(listen_ip),
29 listen_port_(listen_port), 29 listen_port_(listen_port),
30 ssl_cert_filename_(ssl_cert_filename), 30 ssl_cert_filename_(ssl_cert_filename),
31 ssl_key_filename_(ssl_key_filename), 31 ssl_key_filename_(ssl_key_filename),
32 http_server_ip_(http_server_ip), 32 http_server_ip_(http_server_ip),
33 http_server_port_(http_server_port), 33 http_server_port_(http_server_port),
34 https_server_ip_(https_server_ip), 34 https_server_ip_(https_server_ip),
35 https_server_port_(https_server_port), 35 https_server_port_(https_server_port),
36 spdy_only_(spdy_only), 36 spdy_only_(spdy_only),
(...skipping 14 matching lines...) Expand all
51 while (1) { 51 while (1) {
52 int ret = CreateListeningSocket(listen_ip_, 52 int ret = CreateListeningSocket(listen_ip_,
53 listen_port_, 53 listen_port_,
54 true, 54 true,
55 accept_backlog_size_, 55 accept_backlog_size_,
56 true, 56 true,
57 reuseport, 57 reuseport,
58 wait_for_iface, 58 wait_for_iface,
59 disable_nagle_, 59 disable_nagle_,
60 &listen_fd_); 60 &listen_fd_);
61 if ( ret == 0 ) { 61 if (ret == 0) {
62 break; 62 break;
63 } else if ( ret == -3 && wait_for_iface ) { 63 } else if (ret == -3 && wait_for_iface) {
64 // Binding error EADDRNOTAVAIL was encounted. We need 64 // Binding error EADDRNOTAVAIL was encounted. We need
65 // to wait for the interfaces to raised. try again. 65 // to wait for the interfaces to raised. try again.
66 usleep(200000); 66 usleep(200000);
67 } else { 67 } else {
68 LOG(ERROR) << "Unable to create listening socket for: ret = " << ret 68 LOG(ERROR) << "Unable to create listening socket for: ret = " << ret
69 << ": " << listen_ip_.c_str() << ":" 69 << ": " << listen_ip_.c_str() << ":" << listen_port_.c_str();
70 << listen_port_.c_str();
71 return; 70 return;
72 } 71 }
73 } 72 }
74 73
75 FlipSetNonBlocking(listen_fd_); 74 FlipSetNonBlocking(listen_fd_);
76 VLOG(1) << "Listening on socket: "; 75 VLOG(1) << "Listening on socket: ";
77 if (flip_handler_type == FLIP_HANDLER_PROXY) 76 if (flip_handler_type == FLIP_HANDLER_PROXY)
78 VLOG(1) << "\tType : Proxy"; 77 VLOG(1) << "\tType : Proxy";
79 else if (FLIP_HANDLER_SPDY_SERVER) 78 else if (FLIP_HANDLER_SPDY_SERVER)
80 VLOG(1) << "\tType : SPDY Server"; 79 VLOG(1) << "\tType : SPDY Server";
81 else if (FLIP_HANDLER_HTTP_SERVER) 80 else if (FLIP_HANDLER_HTTP_SERVER)
82 VLOG(1) << "\tType : HTTP Server"; 81 VLOG(1) << "\tType : HTTP Server";
83 VLOG(1) << "\tIP : " << listen_ip_; 82 VLOG(1) << "\tIP : " << listen_ip_;
84 VLOG(1) << "\tPort : " << listen_port_; 83 VLOG(1) << "\tPort : " << listen_port_;
85 VLOG(1) << "\tHTTP Server : " << http_server_ip_ << ":" 84 VLOG(1) << "\tHTTP Server : " << http_server_ip_ << ":" << http_server_port_;
86 << http_server_port_;
87 VLOG(1) << "\tHTTPS Server : " << https_server_ip_ << ":" 85 VLOG(1) << "\tHTTPS Server : " << https_server_ip_ << ":"
88 << https_server_port_; 86 << https_server_port_;
89 VLOG(1) << "\tSSL : " 87 VLOG(1) << "\tSSL : " << (ssl_cert_filename.size() ? "true"
90 << (ssl_cert_filename.size()?"true":"false"); 88 : "false");
91 VLOG(1) << "\tCertificate : " << ssl_cert_filename; 89 VLOG(1) << "\tCertificate : " << ssl_cert_filename;
92 VLOG(1) << "\tKey : " << ssl_key_filename; 90 VLOG(1) << "\tKey : " << ssl_key_filename;
93 VLOG(1) << "\tSpdy Only : " << (spdy_only?"true":"false"); 91 VLOG(1) << "\tSpdy Only : " << (spdy_only ? "true" : "false");
94 } 92 }
95 93
96 FlipAcceptor::~FlipAcceptor() {} 94 FlipAcceptor::~FlipAcceptor() {}
97 95
98 FlipConfig::FlipConfig() 96 FlipConfig::FlipConfig()
99 : server_think_time_in_s_(0), 97 : server_think_time_in_s_(0),
100 log_destination_(logging::LOG_TO_SYSTEM_DEBUG_LOG), 98 log_destination_(logging::LOG_TO_SYSTEM_DEBUG_LOG),
101 wait_for_iface_(false) { 99 wait_for_iface_(false) {}
102 }
103 100
104 FlipConfig::~FlipConfig() {} 101 FlipConfig::~FlipConfig() {}
105 102
106 void FlipConfig::AddAcceptor(enum FlipHandlerType flip_handler_type, 103 void FlipConfig::AddAcceptor(enum FlipHandlerType flip_handler_type,
107 std::string listen_ip, 104 std::string listen_ip,
108 std::string listen_port, 105 std::string listen_port,
109 std::string ssl_cert_filename, 106 std::string ssl_cert_filename,
110 std::string ssl_key_filename, 107 std::string ssl_key_filename,
111 std::string http_server_ip, 108 std::string http_server_ip,
112 std::string http_server_port, 109 std::string http_server_port,
113 std::string https_server_ip, 110 std::string https_server_ip,
114 std::string https_server_port, 111 std::string https_server_port,
115 int spdy_only, 112 int spdy_only,
116 int accept_backlog_size, 113 int accept_backlog_size,
117 bool disable_nagle, 114 bool disable_nagle,
118 int accepts_per_wake, 115 int accepts_per_wake,
119 bool reuseport, 116 bool reuseport,
120 bool wait_for_iface, 117 bool wait_for_iface,
121 void *memory_cache) { 118 void* memory_cache) {
122 // TODO(mbelshe): create a struct FlipConfigArgs{} for the arguments. 119 // TODO(mbelshe): create a struct FlipConfigArgs{} for the arguments.
123 acceptors_.push_back(new FlipAcceptor(flip_handler_type, 120 acceptors_.push_back(new FlipAcceptor(flip_handler_type,
124 listen_ip, 121 listen_ip,
125 listen_port, 122 listen_port,
126 ssl_cert_filename, 123 ssl_cert_filename,
127 ssl_key_filename, 124 ssl_key_filename,
128 http_server_ip, 125 http_server_ip,
129 http_server_port, 126 http_server_port,
130 https_server_ip, 127 https_server_ip,
131 https_server_port, 128 https_server_port,
132 spdy_only, 129 spdy_only,
133 accept_backlog_size, 130 accept_backlog_size,
134 disable_nagle, 131 disable_nagle,
135 accepts_per_wake, 132 accepts_per_wake,
136 reuseport, 133 reuseport,
137 wait_for_iface, 134 wait_for_iface,
138 memory_cache)); 135 memory_cache));
139 } 136 }
140 137
141 } // namespace 138 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/flip_server/flip_config.h ('k') | net/tools/flip_server/flip_in_mem_edsm_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698