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 void OnConnect(int connection_id) override; |
65 virtual void OnHttpRequest(int connection_id, | 65 void OnHttpRequest(int connection_id, |
66 const net::HttpServerRequestInfo& info) override {} | 66 const net::HttpServerRequestInfo& info) override {} |
67 virtual void OnWebSocketRequest( | 67 void OnWebSocketRequest(int connection_id, |
68 int connection_id, | 68 const net::HttpServerRequestInfo& info) override; |
69 const net::HttpServerRequestInfo& info) override; | 69 void OnWebSocketMessage(int connection_id, const std::string& data) override; |
70 virtual void OnWebSocketMessage(int connection_id, | 70 void OnClose(int connection_id) override; |
71 const std::string& data) override; | |
72 virtual void OnClose(int connection_id) override; | |
73 | 71 |
74 private: | 72 private: |
75 void StartOnServerThread(bool* success, base::WaitableEvent* event); | 73 void StartOnServerThread(bool* success, base::WaitableEvent* event); |
76 void StopOnServerThread(base::WaitableEvent* event); | 74 void StopOnServerThread(base::WaitableEvent* event); |
77 | 75 |
78 base::Thread thread_; | 76 base::Thread thread_; |
79 | 77 |
80 // Access only on the server thread. | 78 // Access only on the server thread. |
81 scoped_ptr<net::HttpServer> server_; | 79 scoped_ptr<net::HttpServer> server_; |
82 | 80 |
83 // Access only on the server thread. | 81 // Access only on the server thread. |
84 std::set<int> connections_; | 82 std::set<int> connections_; |
85 | 83 |
86 base::WaitableEvent all_closed_event_; | 84 base::WaitableEvent all_closed_event_; |
87 | 85 |
88 // Protects |web_socket_url_|. | 86 // Protects |web_socket_url_|. |
89 mutable base::Lock url_lock_; | 87 mutable base::Lock url_lock_; |
90 GURL web_socket_url_; | 88 GURL web_socket_url_; |
91 | 89 |
92 // Protects the action flags. | 90 // Protects the action flags. |
93 base::Lock action_lock_; | 91 base::Lock action_lock_; |
94 WebSocketRequestAction request_action_; | 92 WebSocketRequestAction request_action_; |
95 WebSocketMessageAction message_action_; | 93 WebSocketMessageAction message_action_; |
96 | 94 |
97 DISALLOW_COPY_AND_ASSIGN(TestHttpServer); | 95 DISALLOW_COPY_AND_ASSIGN(TestHttpServer); |
98 }; | 96 }; |
99 | 97 |
100 #endif // CHROME_TEST_CHROMEDRIVER_NET_TEST_HTTP_SERVER_H_ | 98 #endif // CHROME_TEST_CHROMEDRIVER_NET_TEST_HTTP_SERVER_H_ |
OLD | NEW |