OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef NET_TOOLS_QUIC_SERVER_THREAD_H_ | 5 #ifndef NET_TOOLS_QUIC_SERVER_THREAD_H_ |
6 #define NET_TOOLS_QUIC_SERVER_THREAD_H_ | 6 #define NET_TOOLS_QUIC_SERVER_THREAD_H_ |
7 | 7 |
8 #include "base/threading/simple_thread.h" | 8 #include "base/threading/simple_thread.h" |
9 #include "net/base/ip_endpoint.h" | 9 #include "net/base/ip_endpoint.h" |
10 #include "net/quic/quic_config.h" | 10 #include "net/quic/quic_config.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 // SimpleThread implementation. | 27 // SimpleThread implementation. |
28 virtual void Run() OVERRIDE; | 28 virtual void Run() OVERRIDE; |
29 | 29 |
30 // Waits until the server has started and is listening for requests. | 30 // Waits until the server has started and is listening for requests. |
31 void WaitForServerStartup(); | 31 void WaitForServerStartup(); |
32 | 32 |
33 // Waits for the handshake to be confirmed for the first session created. | 33 // Waits for the handshake to be confirmed for the first session created. |
34 void WaitForCryptoHandshakeConfirmed(); | 34 void WaitForCryptoHandshakeConfirmed(); |
35 | 35 |
36 // Pauses execution of the server until Resume() is called. May only be | 36 // Pauses execution of the server until Resume() is called. |
37 // called once. | |
38 void Pause(); | 37 void Pause(); |
39 | 38 |
40 // Resumes execution of the server after Pause() has been called. May only | 39 // Resumes execution of the server after Pause() has been called. |
41 // be called once. | |
42 void Resume(); | 40 void Resume(); |
43 | 41 |
44 // Stops the server from executing and shuts it down, destroying all | 42 // Stops the server from executing and shuts it down, destroying all |
45 // server objects. | 43 // server objects. |
46 void Quit(); | 44 void Quit(); |
47 | 45 |
48 // Returns the underlying server. Care must be taken to avoid data races | 46 // Returns the underlying server. Care must be taken to avoid data races |
49 // when accessing the server. It is always safe to access the server | 47 // when accessing the server. It is always safe to access the server |
50 // after calling Pause() and before calling Resume(). | 48 // after calling Pause() and before calling Resume(). |
51 QuicServer* server() { return &server_; } | 49 QuicServer* server() { return &server_; } |
52 | 50 |
53 // Returns the port that the server is listening on. | 51 // Returns the port that the server is listening on. |
54 int GetPort(); | 52 int GetPort(); |
55 | 53 |
56 private: | 54 private: |
57 void MaybeNotifyOfHandshakeConfirmation(); | 55 void MaybeNotifyOfHandshakeConfirmation(); |
58 | 56 |
| 57 base::Lock event_loop_mu_; // Held when the server is processing events. |
59 base::WaitableEvent listening_; // Notified when the server is listening. | 58 base::WaitableEvent listening_; // Notified when the server is listening. |
60 base::WaitableEvent confirmed_; // Notified when the first handshake is | 59 base::WaitableEvent confirmed_; // Notified when the first handshake is |
61 // confirmed. | 60 // confirmed. |
62 base::WaitableEvent pause_; // Notified when the server should pause. | |
63 base::WaitableEvent paused_; // Notitied when the server has paused | |
64 base::WaitableEvent resume_; // Notified when the server should resume. | |
65 base::WaitableEvent quit_; // Notified when the server should quit. | 61 base::WaitableEvent quit_; // Notified when the server should quit. |
66 | 62 |
67 tools::QuicServer server_; | 63 tools::QuicServer server_; |
68 IPEndPoint address_; | 64 IPEndPoint address_; |
69 base::Lock port_lock_; | 65 base::Lock port_lock_; |
70 int port_; | 66 int port_; |
71 | 67 |
72 DISALLOW_COPY_AND_ASSIGN(ServerThread); | 68 DISALLOW_COPY_AND_ASSIGN(ServerThread); |
73 }; | 69 }; |
74 | 70 |
75 } // namespace test | 71 } // namespace test |
76 } // namespace tools | 72 } // namespace tools |
77 } // namespace net | 73 } // namespace net |
78 | 74 |
79 #endif // NET_TOOLS_QUIC_SERVER_THREAD_H_ | 75 #endif // NET_TOOLS_QUIC_SERVER_THREAD_H_ |
OLD | NEW |