| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_WEBSOCKETS_WEBSOCKET_STREAM_CREATE_TEST_BASE_H_ | 5 #ifndef NET_WEBSOCKETS_WEBSOCKET_STREAM_CREATE_TEST_BASE_H_ |
| 6 #define NET_WEBSOCKETS_WEBSOCKET_STREAM_CREATE_TEST_BASE_H_ | 6 #define NET_WEBSOCKETS_WEBSOCKET_STREAM_CREATE_TEST_BASE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/timer/timer.h" | 15 #include "base/timer/timer.h" |
| 16 #include "net/base/net_export.h" | 16 #include "net/base/net_export.h" |
| 17 #include "net/socket/socket_test_util.h" | 17 #include "net/socket/socket_test_util.h" |
| 18 #include "net/ssl/ssl_info.h" | 18 #include "net/ssl/ssl_info.h" |
| 19 #include "net/websockets/websocket_event_interface.h" | 19 #include "net/websockets/websocket_event_interface.h" |
| 20 #include "net/websockets/websocket_test_util.h" | 20 #include "net/websockets/websocket_test_util.h" |
| 21 | 21 |
| 22 class GURL; |
| 23 |
| 22 namespace net { | 24 namespace net { |
| 23 | 25 |
| 24 class HttpRequestHeaders; | 26 class HttpRequestHeaders; |
| 25 class HttpResponseHeaders; | 27 class HttpResponseHeaders; |
| 26 class WebSocketStream; | 28 class WebSocketStream; |
| 27 class WebSocketStreamRequest; | 29 class WebSocketStreamRequest; |
| 28 struct WebSocketHandshakeRequestInfo; | 30 struct WebSocketHandshakeRequestInfo; |
| 29 struct WebSocketHandshakeResponseInfo; | 31 struct WebSocketHandshakeResponseInfo; |
| 30 | 32 |
| 31 class WebSocketStreamCreateTestBase { | 33 class WebSocketStreamCreateTestBase { |
| 32 public: | 34 public: |
| 33 using HeaderKeyValuePair = std::pair<std::string, std::string>; | 35 using HeaderKeyValuePair = std::pair<std::string, std::string>; |
| 34 | 36 |
| 35 WebSocketStreamCreateTestBase(); | 37 WebSocketStreamCreateTestBase(); |
| 36 virtual ~WebSocketStreamCreateTestBase(); | 38 virtual ~WebSocketStreamCreateTestBase(); |
| 37 | 39 |
| 38 // A wrapper for CreateAndConnectStreamForTesting that knows about our default | 40 // A wrapper for CreateAndConnectStreamForTesting that knows about our default |
| 39 // parameters. | 41 // parameters. |
| 40 void CreateAndConnectStream(const std::string& socket_url, | 42 void CreateAndConnectStream(const GURL& socket_url, |
| 41 const std::vector<std::string>& sub_protocols, | 43 const std::vector<std::string>& sub_protocols, |
| 42 const url::Origin& origin, | 44 const url::Origin& origin, |
| 45 const GURL& first_party_for_cookies, |
| 43 const std::string& additional_headers, | 46 const std::string& additional_headers, |
| 44 std::unique_ptr<base::Timer> timer); | 47 std::unique_ptr<base::Timer> timer); |
| 45 | 48 |
| 46 static std::vector<HeaderKeyValuePair> RequestHeadersToVector( | 49 static std::vector<HeaderKeyValuePair> RequestHeadersToVector( |
| 47 const HttpRequestHeaders& headers); | 50 const HttpRequestHeaders& headers); |
| 48 static std::vector<HeaderKeyValuePair> ResponseHeadersToVector( | 51 static std::vector<HeaderKeyValuePair> ResponseHeadersToVector( |
| 49 const HttpResponseHeaders& headers); | 52 const HttpResponseHeaders& headers); |
| 50 | 53 |
| 51 const std::string& failure_message() const { return failure_message_; } | 54 const std::string& failure_message() const { return failure_message_; } |
| 52 bool has_failed() const { return has_failed_; } | 55 bool has_failed() const { return has_failed_; } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 80 base::RunLoop connect_run_loop_; | 83 base::RunLoop connect_run_loop_; |
| 81 | 84 |
| 82 private: | 85 private: |
| 83 class TestConnectDelegate; | 86 class TestConnectDelegate; |
| 84 DISALLOW_COPY_AND_ASSIGN(WebSocketStreamCreateTestBase); | 87 DISALLOW_COPY_AND_ASSIGN(WebSocketStreamCreateTestBase); |
| 85 }; | 88 }; |
| 86 | 89 |
| 87 } // namespace net | 90 } // namespace net |
| 88 | 91 |
| 89 #endif // NET_WEBSOCKETS_WEBSOCKET_STREAM_CREATE_TEST_BASE_H_ | 92 #endif // NET_WEBSOCKETS_WEBSOCKET_STREAM_CREATE_TEST_BASE_H_ |
| OLD | NEW |