OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 CHROME_TEST_CHROMEDRIVER_NET_TEST_HTTP_SERVER_H_ | 5 #ifndef CHROME_TEST_CHROMEDRIVER_NET_TEST_HTTP_SERVER_H_ |
6 #define CHROME_TEST_CHROMEDRIVER_NET_TEST_HTTP_SERVER_H_ | 6 #define CHROME_TEST_CHROMEDRIVER_NET_TEST_HTTP_SERVER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // Sets the action to perform when receiving a WebSocket connect request. | 54 // Sets the action to perform when receiving a WebSocket connect request. |
55 void SetRequestAction(WebSocketRequestAction action); | 55 void SetRequestAction(WebSocketRequestAction action); |
56 | 56 |
57 // Sets the action to perform when receiving a WebSocket message. | 57 // Sets the action to perform when receiving a WebSocket message. |
58 void SetMessageAction(WebSocketMessageAction action); | 58 void SetMessageAction(WebSocketMessageAction action); |
59 | 59 |
60 // Returns the web socket URL that points to the server. | 60 // Returns the web socket URL that points to the server. |
61 GURL web_socket_url() const; | 61 GURL web_socket_url() const; |
62 | 62 |
63 // Overridden from net::HttpServer::Delegate: | 63 // Overridden from net::HttpServer::Delegate: |
64 virtual void OnConnect(int connection_id) OVERRIDE; | 64 virtual void OnConnect(int connection_id) override; |
65 virtual void OnHttpRequest(int connection_id, | 65 virtual void OnHttpRequest(int connection_id, |
66 const net::HttpServerRequestInfo& info) OVERRIDE {} | 66 const net::HttpServerRequestInfo& info) override {} |
67 virtual void OnWebSocketRequest( | 67 virtual void OnWebSocketRequest( |
68 int connection_id, | 68 int connection_id, |
69 const net::HttpServerRequestInfo& info) OVERRIDE; | 69 const net::HttpServerRequestInfo& info) override; |
70 virtual void OnWebSocketMessage(int connection_id, | 70 virtual void OnWebSocketMessage(int connection_id, |
71 const std::string& data) OVERRIDE; | 71 const std::string& data) override; |
72 virtual void OnClose(int connection_id) OVERRIDE; | 72 virtual void OnClose(int connection_id) override; |
73 | 73 |
74 private: | 74 private: |
75 void StartOnServerThread(bool* success, base::WaitableEvent* event); | 75 void StartOnServerThread(bool* success, base::WaitableEvent* event); |
76 void StopOnServerThread(base::WaitableEvent* event); | 76 void StopOnServerThread(base::WaitableEvent* event); |
77 | 77 |
78 base::Thread thread_; | 78 base::Thread thread_; |
79 | 79 |
80 // Access only on the server thread. | 80 // Access only on the server thread. |
81 scoped_ptr<net::HttpServer> server_; | 81 scoped_ptr<net::HttpServer> server_; |
82 | 82 |
83 // Access only on the server thread. | 83 // Access only on the server thread. |
84 std::set<int> connections_; | 84 std::set<int> connections_; |
85 | 85 |
86 base::WaitableEvent all_closed_event_; | 86 base::WaitableEvent all_closed_event_; |
87 | 87 |
88 // Protects |web_socket_url_|. | 88 // Protects |web_socket_url_|. |
89 mutable base::Lock url_lock_; | 89 mutable base::Lock url_lock_; |
90 GURL web_socket_url_; | 90 GURL web_socket_url_; |
91 | 91 |
92 // Protects the action flags. | 92 // Protects the action flags. |
93 base::Lock action_lock_; | 93 base::Lock action_lock_; |
94 WebSocketRequestAction request_action_; | 94 WebSocketRequestAction request_action_; |
95 WebSocketMessageAction message_action_; | 95 WebSocketMessageAction message_action_; |
96 | 96 |
97 DISALLOW_COPY_AND_ASSIGN(TestHttpServer); | 97 DISALLOW_COPY_AND_ASSIGN(TestHttpServer); |
98 }; | 98 }; |
99 | 99 |
100 #endif // CHROME_TEST_CHROMEDRIVER_NET_TEST_HTTP_SERVER_H_ | 100 #endif // CHROME_TEST_CHROMEDRIVER_NET_TEST_HTTP_SERVER_H_ |
OLD | NEW |