| 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 NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ | 5 #ifndef NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ |
| 6 #define NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ | 6 #define NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "net/spdy/spdy_protocol.h" | 33 #include "net/spdy/spdy_protocol.h" |
| 34 #include "net/ssl/ssl_config_service_defaults.h" | 34 #include "net/ssl/ssl_config_service_defaults.h" |
| 35 #include "net/url_request/url_request_context.h" | 35 #include "net/url_request/url_request_context.h" |
| 36 #include "net/url_request/url_request_context_storage.h" | 36 #include "net/url_request/url_request_context_storage.h" |
| 37 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
| 38 | 38 |
| 39 class GURL; | 39 class GURL; |
| 40 | 40 |
| 41 namespace net { | 41 namespace net { |
| 42 | 42 |
| 43 class BoundNetLog; | 43 class NetLogWithSource; |
| 44 class CTVerifier; | 44 class CTVerifier; |
| 45 class CTPolicyEnforcer; | 45 class CTPolicyEnforcer; |
| 46 class HostPortPair; | 46 class HostPortPair; |
| 47 class SpdySession; | 47 class SpdySession; |
| 48 class SpdySessionKey; | 48 class SpdySessionKey; |
| 49 class SpdySessionPool; | 49 class SpdySessionPool; |
| 50 class SpdyStream; | 50 class SpdyStream; |
| 51 class SpdyStreamRequest; | 51 class SpdyStreamRequest; |
| 52 | 52 |
| 53 // Default upload data used by both, mock objects and framer when creating | 53 // Default upload data used by both, mock objects and framer when creating |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // and fills in |priority| on success. | 98 // and fills in |priority| on success. |
| 99 bool GetSpdyPriority(const SpdySerializedFrame& frame, SpdyPriority* priority); | 99 bool GetSpdyPriority(const SpdySerializedFrame& frame, SpdyPriority* priority); |
| 100 | 100 |
| 101 // Tries to create a stream in |session| synchronously. Returns NULL | 101 // Tries to create a stream in |session| synchronously. Returns NULL |
| 102 // on failure. | 102 // on failure. |
| 103 base::WeakPtr<SpdyStream> CreateStreamSynchronously( | 103 base::WeakPtr<SpdyStream> CreateStreamSynchronously( |
| 104 SpdyStreamType type, | 104 SpdyStreamType type, |
| 105 const base::WeakPtr<SpdySession>& session, | 105 const base::WeakPtr<SpdySession>& session, |
| 106 const GURL& url, | 106 const GURL& url, |
| 107 RequestPriority priority, | 107 RequestPriority priority, |
| 108 const BoundNetLog& net_log); | 108 const NetLogWithSource& net_log); |
| 109 | 109 |
| 110 // Helper class used by some tests to release a stream as soon as it's | 110 // Helper class used by some tests to release a stream as soon as it's |
| 111 // created. | 111 // created. |
| 112 class StreamReleaserCallback : public TestCompletionCallbackBase { | 112 class StreamReleaserCallback : public TestCompletionCallbackBase { |
| 113 public: | 113 public: |
| 114 StreamReleaserCallback(); | 114 StreamReleaserCallback(); |
| 115 | 115 |
| 116 ~StreamReleaserCallback() override; | 116 ~StreamReleaserCallback() override; |
| 117 | 117 |
| 118 // Returns a callback that releases |request|'s stream. | 118 // Returns a callback that releases |request|'s stream. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 SpdyURLRequestContext(); | 214 SpdyURLRequestContext(); |
| 215 ~SpdyURLRequestContext() override; | 215 ~SpdyURLRequestContext() override; |
| 216 | 216 |
| 217 MockClientSocketFactory& socket_factory() { return socket_factory_; } | 217 MockClientSocketFactory& socket_factory() { return socket_factory_; } |
| 218 | 218 |
| 219 private: | 219 private: |
| 220 MockClientSocketFactory socket_factory_; | 220 MockClientSocketFactory socket_factory_; |
| 221 URLRequestContextStorage storage_; | 221 URLRequestContextStorage storage_; |
| 222 }; | 222 }; |
| 223 | 223 |
| 224 // Equivalent to pool->GetIfExists(spdy_session_key, BoundNetLog()) != NULL. | 224 // Equivalent to pool->GetIfExists(spdy_session_key, NetLogWithSource()) != |
| 225 // NULL. |
| 225 bool HasSpdySession(SpdySessionPool* pool, const SpdySessionKey& key); | 226 bool HasSpdySession(SpdySessionPool* pool, const SpdySessionKey& key); |
| 226 | 227 |
| 227 // Creates a SPDY session for the given key and puts it in the SPDY | 228 // Creates a SPDY session for the given key and puts it in the SPDY |
| 228 // session pool in |http_session|. A SPDY session for |key| must not | 229 // session pool in |http_session|. A SPDY session for |key| must not |
| 229 // already exist. | 230 // already exist. |
| 230 base::WeakPtr<SpdySession> CreateInsecureSpdySession( | 231 base::WeakPtr<SpdySession> CreateInsecureSpdySession( |
| 231 HttpNetworkSession* http_session, | 232 HttpNetworkSession* http_session, |
| 232 const SpdySessionKey& key, | 233 const SpdySessionKey& key, |
| 233 const BoundNetLog& net_log); | 234 const NetLogWithSource& net_log); |
| 234 | 235 |
| 235 // Tries to create a SPDY session for the given key but expects the | 236 // Tries to create a SPDY session for the given key but expects the |
| 236 // attempt to fail with the given error. A SPDY session for |key| must | 237 // attempt to fail with the given error. A SPDY session for |key| must |
| 237 // not already exist. The session will be created but close in the | 238 // not already exist. The session will be created but close in the |
| 238 // next event loop iteration. | 239 // next event loop iteration. |
| 239 base::WeakPtr<SpdySession> TryCreateInsecureSpdySessionExpectingFailure( | 240 base::WeakPtr<SpdySession> TryCreateInsecureSpdySessionExpectingFailure( |
| 240 HttpNetworkSession* http_session, | 241 HttpNetworkSession* http_session, |
| 241 const SpdySessionKey& key, | 242 const SpdySessionKey& key, |
| 242 Error expected_error, | 243 Error expected_error, |
| 243 const BoundNetLog& net_log); | 244 const NetLogWithSource& net_log); |
| 244 | 245 |
| 245 // Like CreateInsecureSpdySession(), but uses TLS. | 246 // Like CreateInsecureSpdySession(), but uses TLS. |
| 246 base::WeakPtr<SpdySession> CreateSecureSpdySession( | 247 base::WeakPtr<SpdySession> CreateSecureSpdySession( |
| 247 HttpNetworkSession* http_session, | 248 HttpNetworkSession* http_session, |
| 248 const SpdySessionKey& key, | 249 const SpdySessionKey& key, |
| 249 const BoundNetLog& net_log); | 250 const NetLogWithSource& net_log); |
| 250 | 251 |
| 251 // Creates an insecure SPDY session for the given key and puts it in | 252 // Creates an insecure SPDY session for the given key and puts it in |
| 252 // |pool|. The returned session will neither receive nor send any | 253 // |pool|. The returned session will neither receive nor send any |
| 253 // data. A SPDY session for |key| must not already exist. | 254 // data. A SPDY session for |key| must not already exist. |
| 254 base::WeakPtr<SpdySession> CreateFakeSpdySession(SpdySessionPool* pool, | 255 base::WeakPtr<SpdySession> CreateFakeSpdySession(SpdySessionPool* pool, |
| 255 const SpdySessionKey& key); | 256 const SpdySessionKey& key); |
| 256 | 257 |
| 257 // Tries to create an insecure SPDY session for the given key but | 258 // Tries to create an insecure SPDY session for the given key but |
| 258 // expects the attempt to fail with the given error. The session will | 259 // expects the attempt to fail with the given error. The session will |
| 259 // neither receive nor send any data. A SPDY session for |key| must | 260 // neither receive nor send any data. A SPDY session for |key| must |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 | 517 |
| 517 GURL default_url_; | 518 GURL default_url_; |
| 518 | 519 |
| 519 // Track a FIFO list of the stream_id of all created requests by priority. | 520 // Track a FIFO list of the stream_id of all created requests by priority. |
| 520 std::map<int, std::vector<int>> priority_to_stream_id_list_; | 521 std::map<int, std::vector<int>> priority_to_stream_id_list_; |
| 521 }; | 522 }; |
| 522 | 523 |
| 523 } // namespace net | 524 } // namespace net |
| 524 | 525 |
| 525 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ | 526 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ |
| OLD | NEW |