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

Side by Side Diff: net/tools/quic/test_tools/server_thread.h

Issue 330333006: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix linus_tsan error - reverted the change to ConnectionMigrationClientPortChanged unitttest 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 | Annotate | Revision Log
OLDNEW
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"
11 #include "net/tools/quic/quic_server.h" 11 #include "net/tools/quic/quic_server.h"
12 12
13 namespace net { 13 namespace net {
14 namespace tools { 14 namespace tools {
15 namespace test { 15 namespace test {
16 16
17 // Simple wrapper class to run server in a thread. 17 // Simple wrapper class to run server in a thread.
18 class ServerThread : public base::SimpleThread { 18 class ServerThread : public base::SimpleThread {
19 public: 19 public:
20 ServerThread(IPEndPoint address, 20 ServerThread(QuicServer* server,
21 const QuicConfig& config, 21 IPEndPoint address,
22 const QuicVersionVector& supported_versions, 22 bool strike_register_no_startup_period);
23 bool strike_register_no_startup_period,
24 uint32 server_initial_flow_control_receive_window);
25 23
26 virtual ~ServerThread(); 24 virtual ~ServerThread();
27 25
28 // Prepares the server, but does not start accepting connections. Useful for 26 // Prepares the server, but does not start accepting connections. Useful for
29 // injecting mocks. 27 // injecting mocks.
30 void Initialize(); 28 void Initialize();
31 29
32 // Runs the event loop. Will initialize if necessary. 30 // Runs the event loop. Will initialize if necessary.
33 virtual void Run() OVERRIDE; 31 virtual void Run() OVERRIDE;
34 32
35 // 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.
36 void WaitForCryptoHandshakeConfirmed(); 34 void WaitForCryptoHandshakeConfirmed();
37 35
38 // Pauses execution of the server until Resume() is called. May only be 36 // Pauses execution of the server until Resume() is called. May only be
39 // called once. 37 // called once.
40 void Pause(); 38 void Pause();
41 39
42 // Resumes execution of the server after Pause() has been called. May only 40 // Resumes execution of the server after Pause() has been called. May only
43 // be called once. 41 // be called once.
44 void Resume(); 42 void Resume();
45 43
46 // Stops the server from executing and shuts it down, destroying all 44 // Stops the server from executing and shuts it down, destroying all
47 // server objects. 45 // server objects.
48 void Quit(); 46 void Quit();
49 47
50 // Returns the underlying server. Care must be taken to avoid data races 48 // Returns the underlying server. Care must be taken to avoid data races
51 // when accessing the server. It is always safe to access the server 49 // when accessing the server. It is always safe to access the server
52 // after calling Pause() and before calling Resume(). 50 // after calling Pause() and before calling Resume().
53 QuicServer* server() { return &server_; } 51 QuicServer* server() { return server_.get(); }
54 52
55 // Returns the port that the server is listening on. 53 // Returns the port that the server is listening on.
56 int GetPort(); 54 int GetPort();
57 55
58 private: 56 private:
59 void MaybeNotifyOfHandshakeConfirmation(); 57 void MaybeNotifyOfHandshakeConfirmation();
60 58
61 base::WaitableEvent confirmed_; // Notified when the first handshake is 59 base::WaitableEvent confirmed_; // Notified when the first handshake is
62 // confirmed. 60 // confirmed.
63 base::WaitableEvent pause_; // Notified when the server should pause. 61 base::WaitableEvent pause_; // Notified when the server should pause.
64 base::WaitableEvent paused_; // Notitied when the server has paused 62 base::WaitableEvent paused_; // Notitied when the server has paused
65 base::WaitableEvent resume_; // Notified when the server should resume. 63 base::WaitableEvent resume_; // Notified when the server should resume.
66 base::WaitableEvent quit_; // Notified when the server should quit. 64 base::WaitableEvent quit_; // Notified when the server should quit.
67 65
68 tools::QuicServer server_; 66 scoped_ptr<QuicServer> server_;
69 IPEndPoint address_; 67 IPEndPoint address_;
70 base::Lock port_lock_; 68 base::Lock port_lock_;
71 int port_; 69 int port_;
72 70
73 bool initialized_; 71 bool initialized_;
74 72
75 DISALLOW_COPY_AND_ASSIGN(ServerThread); 73 DISALLOW_COPY_AND_ASSIGN(ServerThread);
76 }; 74 };
77 75
78 } // namespace test 76 } // namespace test
79 } // namespace tools 77 } // namespace tools
80 } // namespace net 78 } // namespace net
81 79
82 #endif // NET_TOOLS_QUIC_SERVER_THREAD_H_ 80 #endif // NET_TOOLS_QUIC_SERVER_THREAD_H_
OLDNEW
« no previous file with comments | « net/tools/quic/test_tools/quic_test_utils.cc ('k') | net/tools/quic/test_tools/server_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698