OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "net/test/embedded_test_server/simple_connection_listener.h" | |
6 | |
7 #include "base/location.h" | |
8 #include "base/sequenced_task_runner.h" | |
9 #include "base/threading/thread_task_runner_handle.h" | |
10 #include "testing/gtest/include/gtest/gtest.h" | |
11 | |
12 namespace net { | |
13 namespace test_server { | |
14 | |
15 SimpleConnectionListener::SimpleConnectionListener( | |
16 int expected_connections, | |
17 AllowAdditionalConnections allow_additional_connections) | |
18 : expected_connections_(expected_connections), | |
19 allow_additional_connections_(allow_additional_connections), | |
20 run_loop_task_runner_(base::ThreadTaskRunnerHandle::Get()) {} | |
21 | |
22 SimpleConnectionListener::~SimpleConnectionListener() {} | |
23 | |
24 void SimpleConnectionListener::AcceptedSocket(const StreamSocket& socket) { | |
25 ++seen_connections_; | |
26 if (allow_additional_connections_ != ALLOW_ADDITIONAL_CONNECTIONS) | |
27 EXPECT_LE(seen_connections_, expected_connections_); | |
28 if (seen_connections_ == expected_connections_) | |
29 run_loop_task_runner_->PostTask(FROM_HERE, run_loop_.QuitClosure()); | |
30 } | |
31 | |
32 void SimpleConnectionListener::ReadFromSocket(const StreamSocket& socket, | |
33 int rv) {} | |
34 | |
35 void SimpleConnectionListener::WaitForConnections() { | |
36 EXPECT_TRUE(run_loop_task_runner_->RunsTasksOnCurrentThread()); | |
37 run_loop_.Run(); | |
38 } | |
39 | |
40 } // test_server | |
41 } // net | |
eroman
2017/05/16 20:21:20
ditto, unless the style has changed.
mmenke
2017/05/17 02:29:58
Done.
| |
OLD | NEW |