Reformat the WebRTC code base
Running clang-format with chromium's style guide. The goal is n-fold: * providing consistency and readability (that's what code guidelines are for) * preventing noise with presubmit checks and git cl format * building on the previous point: making it easier to automatically fix format issues * you name it Please consider using git-hyper-blame to ignore this commit. Bug: webrtc:9340 Change-Id: I694567c4cdf8cee2860958cfe82bfaf25848bb87 Reviewed-on: https://webrtc-review.googlesource.com/81185 Reviewed-by: Patrik Höglund <phoglund@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23660}
This commit is contained in:
@ -17,59 +17,56 @@ using namespace webrtc::testing;
|
||||
namespace rtc {
|
||||
|
||||
namespace {
|
||||
const char* const kRequest =
|
||||
const char* const kRequest =
|
||||
"GET /index.html HTTP/1.1\r\n"
|
||||
"Host: localhost\r\n"
|
||||
"\r\n";
|
||||
|
||||
struct HttpServerMonitor : public sigslot::has_slots<> {
|
||||
HttpServerTransaction* transaction;
|
||||
bool server_closed, connection_closed;
|
||||
struct HttpServerMonitor : public sigslot::has_slots<> {
|
||||
HttpServerTransaction* transaction;
|
||||
bool server_closed, connection_closed;
|
||||
|
||||
HttpServerMonitor(HttpServer* server)
|
||||
: transaction(nullptr), server_closed(false), connection_closed(false) {
|
||||
server->SignalCloseAllComplete.connect(this,
|
||||
&HttpServerMonitor::OnClosed);
|
||||
server->SignalHttpRequest.connect(this, &HttpServerMonitor::OnRequest);
|
||||
server->SignalHttpRequestComplete.connect(this,
|
||||
&HttpServerMonitor::OnRequestComplete);
|
||||
server->SignalConnectionClosed.connect(this,
|
||||
&HttpServerMonitor::OnConnectionClosed);
|
||||
}
|
||||
void OnRequest(HttpServer*, HttpServerTransaction* t) {
|
||||
ASSERT_FALSE(transaction);
|
||||
transaction = t;
|
||||
transaction->response.set_success();
|
||||
transaction->response.setHeader(HH_CONNECTION, "Close");
|
||||
}
|
||||
void OnRequestComplete(HttpServer*, HttpServerTransaction* t, int) {
|
||||
ASSERT_EQ(transaction, t);
|
||||
transaction = nullptr;
|
||||
}
|
||||
void OnClosed(HttpServer*) {
|
||||
server_closed = true;
|
||||
}
|
||||
void OnConnectionClosed(HttpServer*, int, StreamInterface* stream) {
|
||||
connection_closed = true;
|
||||
delete stream;
|
||||
}
|
||||
};
|
||||
|
||||
void CreateClientConnection(HttpServer& server,
|
||||
HttpServerMonitor& monitor,
|
||||
bool send_request) {
|
||||
StreamSource* client = new StreamSource;
|
||||
client->SetState(SS_OPEN);
|
||||
server.HandleConnection(client);
|
||||
EXPECT_FALSE(monitor.server_closed);
|
||||
EXPECT_FALSE(monitor.transaction);
|
||||
|
||||
if (send_request) {
|
||||
// Simulate a request
|
||||
client->QueueString(kRequest);
|
||||
EXPECT_FALSE(monitor.server_closed);
|
||||
}
|
||||
HttpServerMonitor(HttpServer* server)
|
||||
: transaction(nullptr), server_closed(false), connection_closed(false) {
|
||||
server->SignalCloseAllComplete.connect(this, &HttpServerMonitor::OnClosed);
|
||||
server->SignalHttpRequest.connect(this, &HttpServerMonitor::OnRequest);
|
||||
server->SignalHttpRequestComplete.connect(
|
||||
this, &HttpServerMonitor::OnRequestComplete);
|
||||
server->SignalConnectionClosed.connect(
|
||||
this, &HttpServerMonitor::OnConnectionClosed);
|
||||
}
|
||||
void OnRequest(HttpServer*, HttpServerTransaction* t) {
|
||||
ASSERT_FALSE(transaction);
|
||||
transaction = t;
|
||||
transaction->response.set_success();
|
||||
transaction->response.setHeader(HH_CONNECTION, "Close");
|
||||
}
|
||||
void OnRequestComplete(HttpServer*, HttpServerTransaction* t, int) {
|
||||
ASSERT_EQ(transaction, t);
|
||||
transaction = nullptr;
|
||||
}
|
||||
void OnClosed(HttpServer*) { server_closed = true; }
|
||||
void OnConnectionClosed(HttpServer*, int, StreamInterface* stream) {
|
||||
connection_closed = true;
|
||||
delete stream;
|
||||
}
|
||||
};
|
||||
|
||||
void CreateClientConnection(HttpServer& server,
|
||||
HttpServerMonitor& monitor,
|
||||
bool send_request) {
|
||||
StreamSource* client = new StreamSource;
|
||||
client->SetState(SS_OPEN);
|
||||
server.HandleConnection(client);
|
||||
EXPECT_FALSE(monitor.server_closed);
|
||||
EXPECT_FALSE(monitor.transaction);
|
||||
|
||||
if (send_request) {
|
||||
// Simulate a request
|
||||
client->QueueString(kRequest);
|
||||
EXPECT_FALSE(monitor.server_closed);
|
||||
}
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
TEST(HttpServer, DoesNotSignalCloseUnlessCloseAllIsCalled) {
|
||||
@ -127,4 +124,4 @@ TEST(HttpServer, SignalsCloseAfterForcedCloseAll) {
|
||||
EXPECT_TRUE(monitor.connection_closed);
|
||||
}
|
||||
|
||||
} // namespace rtc
|
||||
} // namespace rtc
|
||||
|
Reference in New Issue
Block a user