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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // Returns the SpdyPriority embedded in the given frame. Returns true | 107 // Returns the SpdyPriority embedded in the given frame. Returns true |
108 // and fills in |priority| on success. | 108 // and fills in |priority| on success. |
109 bool GetSpdyPriority(SpdyMajorVersion version, | 109 bool GetSpdyPriority(SpdyMajorVersion version, |
110 const SpdyFrame& frame, | 110 const SpdyFrame& frame, |
111 SpdyPriority* priority); | 111 SpdyPriority* priority); |
112 | 112 |
113 // Tries to create a stream in |session| synchronously. Returns NULL | 113 // Tries to create a stream in |session| synchronously. Returns NULL |
114 // on failure. | 114 // on failure. |
115 base::WeakPtr<SpdyStream> CreateStreamSynchronously( | 115 base::WeakPtr<SpdyStream> CreateStreamSynchronously( |
116 SpdyStreamType type, | 116 SpdyStreamType type, |
117 const scoped_refptr<SpdySession>& session, | 117 const base::WeakPtr<SpdySession>& session, |
118 const GURL& url, | 118 const GURL& url, |
119 RequestPriority priority, | 119 RequestPriority priority, |
120 const BoundNetLog& net_log); | 120 const BoundNetLog& net_log); |
121 | 121 |
122 // Helper class used by some tests to release a stream as soon as it's | 122 // Helper class used by some tests to release a stream as soon as it's |
123 // created. | 123 // created. |
124 class StreamReleaserCallback : public TestCompletionCallbackBase { | 124 class StreamReleaserCallback : public TestCompletionCallbackBase { |
125 public: | 125 public: |
126 StreamReleaserCallback(); | 126 StreamReleaserCallback(); |
127 | 127 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 MockClientSocketFactory socket_factory_; | 233 MockClientSocketFactory socket_factory_; |
234 net::URLRequestContextStorage storage_; | 234 net::URLRequestContextStorage storage_; |
235 }; | 235 }; |
236 | 236 |
237 // Equivalent to pool->GetIfExists(spdy_session_key, BoundNetLog()) != NULL. | 237 // Equivalent to pool->GetIfExists(spdy_session_key, BoundNetLog()) != NULL. |
238 bool HasSpdySession(SpdySessionPool* pool, const SpdySessionKey& key); | 238 bool HasSpdySession(SpdySessionPool* pool, const SpdySessionKey& key); |
239 | 239 |
240 // Creates a SPDY session for the given key and puts it in the SPDY | 240 // Creates a SPDY session for the given key and puts it in the SPDY |
241 // session pool in |http_session|. A SPDY session for |key| must not | 241 // session pool in |http_session|. A SPDY session for |key| must not |
242 // already exist. | 242 // already exist. |
243 scoped_refptr<SpdySession> CreateInsecureSpdySession( | 243 base::WeakPtr<SpdySession> CreateInsecureSpdySession( |
244 const scoped_refptr<HttpNetworkSession>& http_session, | 244 const scoped_refptr<HttpNetworkSession>& http_session, |
245 const SpdySessionKey& key, | 245 const SpdySessionKey& key, |
246 const BoundNetLog& net_log); | 246 const BoundNetLog& net_log); |
247 | 247 |
248 // Tries to create a SPDY session for the given key but expects the | 248 // Tries to create a SPDY session for the given key but expects the |
249 // attempt to fail with the given error. A SPDY session for |key| must | 249 // attempt to fail with the given error. A SPDY session for |key| must |
250 // not already exist. | 250 // not already exist. |
251 void TryCreateInsecureSpdySessionExpectingFailure( | 251 void TryCreateInsecureSpdySessionExpectingFailure( |
252 const scoped_refptr<HttpNetworkSession>& http_session, | 252 const scoped_refptr<HttpNetworkSession>& http_session, |
253 const SpdySessionKey& key, | 253 const SpdySessionKey& key, |
254 Error expected_error, | 254 Error expected_error, |
255 const BoundNetLog& net_log); | 255 const BoundNetLog& net_log); |
256 | 256 |
257 // Like CreateInsecureSpdySession(), but uses TLS. | 257 // Like CreateInsecureSpdySession(), but uses TLS. |
258 scoped_refptr<SpdySession> CreateSecureSpdySession( | 258 base::WeakPtr<SpdySession> CreateSecureSpdySession( |
259 const scoped_refptr<HttpNetworkSession>& http_session, | 259 const scoped_refptr<HttpNetworkSession>& http_session, |
260 const SpdySessionKey& key, | 260 const SpdySessionKey& key, |
261 const BoundNetLog& net_log); | 261 const BoundNetLog& net_log); |
262 | 262 |
263 // Creates an insecure SPDY session for the given key and puts it in | 263 // Creates an insecure SPDY session for the given key and puts it in |
264 // |pool|. The returned session will neither receive nor send any | 264 // |pool|. The returned session will neither receive nor send any |
265 // data. A SPDY session for |key| must not already exist. | 265 // data. A SPDY session for |key| must not already exist. |
266 scoped_refptr<SpdySession> CreateFakeSpdySession(SpdySessionPool* pool, | 266 base::WeakPtr<SpdySession> CreateFakeSpdySession(SpdySessionPool* pool, |
267 const SpdySessionKey& key); | 267 const SpdySessionKey& key); |
268 | 268 |
269 // Tries to create an insecure SPDY session for the given key but | 269 // Tries to create an insecure SPDY session for the given key but |
270 // expects the attempt to fail with the given error. The session will | 270 // expects the attempt to fail with the given error. The session will |
271 // neither receive nor send any data. A SPDY session for |key| must | 271 // neither receive nor send any data. A SPDY session for |key| must |
272 // not already exist. | 272 // not already exist. |
273 void TryCreateFakeSpdySessionExpectingFailure(SpdySessionPool* pool, | 273 void TryCreateFakeSpdySessionExpectingFailure(SpdySessionPool* pool, |
274 const SpdySessionKey& key, | 274 const SpdySessionKey& key, |
275 Error expected_error); | 275 Error expected_error); |
276 | 276 |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 base::StringPiece url, | 538 base::StringPiece url, |
539 int64* content_length) const; | 539 int64* content_length) const; |
540 | 540 |
541 const NextProto protocol_; | 541 const NextProto protocol_; |
542 const SpdyMajorVersion spdy_version_; | 542 const SpdyMajorVersion spdy_version_; |
543 }; | 543 }; |
544 | 544 |
545 } // namespace net | 545 } // namespace net |
546 | 546 |
547 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ | 547 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ |
OLD | NEW |