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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
128 virtual ~StreamReleaserCallback(); | 128 ~StreamReleaserCallback() override; |
129 | 129 |
130 // Returns a callback that releases |request|'s stream. | 130 // Returns a callback that releases |request|'s stream. |
131 CompletionCallback MakeCallback(SpdyStreamRequest* request); | 131 CompletionCallback MakeCallback(SpdyStreamRequest* request); |
132 | 132 |
133 private: | 133 private: |
134 void OnComplete(SpdyStreamRequest* request, int result); | 134 void OnComplete(SpdyStreamRequest* request, int result); |
135 }; | 135 }; |
136 | 136 |
137 const size_t kSpdyCredentialSlotUnused = 0; | 137 const size_t kSpdyCredentialSlotUnused = 0; |
138 | 138 |
(...skipping 11 matching lines...) Expand all Loading... |
150 uint32 data_length; | 150 uint32 data_length; |
151 SpdyDataFlags data_flags; | 151 SpdyDataFlags data_flags; |
152 }; | 152 }; |
153 | 153 |
154 // An ECSignatureCreator that returns deterministic signatures. | 154 // An ECSignatureCreator that returns deterministic signatures. |
155 class MockECSignatureCreator : public crypto::ECSignatureCreator { | 155 class MockECSignatureCreator : public crypto::ECSignatureCreator { |
156 public: | 156 public: |
157 explicit MockECSignatureCreator(crypto::ECPrivateKey* key); | 157 explicit MockECSignatureCreator(crypto::ECPrivateKey* key); |
158 | 158 |
159 // crypto::ECSignatureCreator | 159 // crypto::ECSignatureCreator |
160 virtual bool Sign(const uint8* data, | 160 bool Sign(const uint8* data, |
161 int data_len, | 161 int data_len, |
162 std::vector<uint8>* signature) override; | 162 std::vector<uint8>* signature) override; |
163 virtual bool DecodeSignature(const std::vector<uint8>& signature, | 163 bool DecodeSignature(const std::vector<uint8>& signature, |
164 std::vector<uint8>* out_raw_sig) override; | 164 std::vector<uint8>* out_raw_sig) override; |
165 | 165 |
166 private: | 166 private: |
167 crypto::ECPrivateKey* key_; | 167 crypto::ECPrivateKey* key_; |
168 | 168 |
169 DISALLOW_COPY_AND_ASSIGN(MockECSignatureCreator); | 169 DISALLOW_COPY_AND_ASSIGN(MockECSignatureCreator); |
170 }; | 170 }; |
171 | 171 |
172 // An ECSignatureCreatorFactory creates MockECSignatureCreator. | 172 // An ECSignatureCreatorFactory creates MockECSignatureCreator. |
173 class MockECSignatureCreatorFactory : public crypto::ECSignatureCreatorFactory { | 173 class MockECSignatureCreatorFactory : public crypto::ECSignatureCreatorFactory { |
174 public: | 174 public: |
175 MockECSignatureCreatorFactory(); | 175 MockECSignatureCreatorFactory(); |
176 virtual ~MockECSignatureCreatorFactory(); | 176 ~MockECSignatureCreatorFactory() override; |
177 | 177 |
178 // crypto::ECSignatureCreatorFactory | 178 // crypto::ECSignatureCreatorFactory |
179 virtual crypto::ECSignatureCreator* Create( | 179 crypto::ECSignatureCreator* Create(crypto::ECPrivateKey* key) override; |
180 crypto::ECPrivateKey* key) override; | |
181 | 180 |
182 private: | 181 private: |
183 DISALLOW_COPY_AND_ASSIGN(MockECSignatureCreatorFactory); | 182 DISALLOW_COPY_AND_ASSIGN(MockECSignatureCreatorFactory); |
184 }; | 183 }; |
185 | 184 |
186 // Helper to manage the lifetimes of the dependencies for a | 185 // Helper to manage the lifetimes of the dependencies for a |
187 // HttpNetworkTransaction. | 186 // HttpNetworkTransaction. |
188 struct SpdySessionDependencies { | 187 struct SpdySessionDependencies { |
189 // Default set of dependencies -- "null" proxy service. | 188 // Default set of dependencies -- "null" proxy service. |
190 explicit SpdySessionDependencies(NextProto protocol); | 189 explicit SpdySessionDependencies(NextProto protocol); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 bool use_alternate_protocols; | 224 bool use_alternate_protocols; |
226 bool enable_websocket_over_spdy; | 225 bool enable_websocket_over_spdy; |
227 NetLog* net_log; | 226 NetLog* net_log; |
228 }; | 227 }; |
229 | 228 |
230 class SpdyURLRequestContext : public URLRequestContext { | 229 class SpdyURLRequestContext : public URLRequestContext { |
231 public: | 230 public: |
232 SpdyURLRequestContext(NextProto protocol, | 231 SpdyURLRequestContext(NextProto protocol, |
233 bool force_spdy_over_ssl, | 232 bool force_spdy_over_ssl, |
234 bool force_spdy_always); | 233 bool force_spdy_always); |
235 virtual ~SpdyURLRequestContext(); | 234 ~SpdyURLRequestContext() override; |
236 | 235 |
237 MockClientSocketFactory& socket_factory() { return socket_factory_; } | 236 MockClientSocketFactory& socket_factory() { return socket_factory_; } |
238 | 237 |
239 private: | 238 private: |
240 MockClientSocketFactory socket_factory_; | 239 MockClientSocketFactory socket_factory_; |
241 net::URLRequestContextStorage storage_; | 240 net::URLRequestContextStorage storage_; |
242 }; | 241 }; |
243 | 242 |
244 // Equivalent to pool->GetIfExists(spdy_session_key, BoundNetLog()) != NULL. | 243 // Equivalent to pool->GetIfExists(spdy_session_key, BoundNetLog()) != NULL. |
245 bool HasSpdySession(SpdySessionPool* pool, const SpdySessionKey& key); | 244 bool HasSpdySession(SpdySessionPool* pool, const SpdySessionKey& key); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 base::StringPiece url, | 571 base::StringPiece url, |
573 int64* content_length) const; | 572 int64* content_length) const; |
574 | 573 |
575 const NextProto protocol_; | 574 const NextProto protocol_; |
576 const SpdyMajorVersion spdy_version_; | 575 const SpdyMajorVersion spdy_version_; |
577 }; | 576 }; |
578 | 577 |
579 } // namespace net | 578 } // namespace net |
580 | 579 |
581 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ | 580 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ |
OLD | NEW |