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 #include "net/spdy/spdy_test_util_common.h" | 5 #include "net/spdy/spdy_test_util_common.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 ptr += len; | 201 ptr += len; |
202 } | 202 } |
203 return total_len; | 203 return total_len; |
204 } | 204 } |
205 | 205 |
206 namespace { | 206 namespace { |
207 | 207 |
208 class PriorityGetter : public BufferedSpdyFramerVisitorInterface { | 208 class PriorityGetter : public BufferedSpdyFramerVisitorInterface { |
209 public: | 209 public: |
210 PriorityGetter() : priority_(0) {} | 210 PriorityGetter() : priority_(0) {} |
211 virtual ~PriorityGetter() {} | 211 ~PriorityGetter() override {} |
212 | 212 |
213 SpdyPriority priority() const { | 213 SpdyPriority priority() const { |
214 return priority_; | 214 return priority_; |
215 } | 215 } |
216 | 216 |
217 virtual void OnError(SpdyFramer::SpdyError error_code) override {} | 217 void OnError(SpdyFramer::SpdyError error_code) override {} |
218 virtual void OnStreamError(SpdyStreamId stream_id, | 218 void OnStreamError(SpdyStreamId stream_id, |
219 const std::string& description) override {} | 219 const std::string& description) override {} |
220 virtual void OnSynStream(SpdyStreamId stream_id, | 220 void OnSynStream(SpdyStreamId stream_id, |
221 SpdyStreamId associated_stream_id, | 221 SpdyStreamId associated_stream_id, |
222 SpdyPriority priority, | 222 SpdyPriority priority, |
223 bool fin, | 223 bool fin, |
224 bool unidirectional, | 224 bool unidirectional, |
225 const SpdyHeaderBlock& headers) override { | 225 const SpdyHeaderBlock& headers) override { |
226 priority_ = priority; | 226 priority_ = priority; |
227 } | 227 } |
228 virtual void OnSynReply(SpdyStreamId stream_id, | 228 void OnSynReply(SpdyStreamId stream_id, |
229 bool fin, | 229 bool fin, |
230 const SpdyHeaderBlock& headers) override {} | 230 const SpdyHeaderBlock& headers) override {} |
231 virtual void OnHeaders(SpdyStreamId stream_id, | 231 void OnHeaders(SpdyStreamId stream_id, |
232 bool fin, | 232 bool fin, |
233 const SpdyHeaderBlock& headers) override {} | 233 const SpdyHeaderBlock& headers) override {} |
234 virtual void OnDataFrameHeader(SpdyStreamId stream_id, | 234 void OnDataFrameHeader(SpdyStreamId stream_id, |
235 size_t length, | 235 size_t length, |
236 bool fin) override {} | 236 bool fin) override {} |
237 virtual void OnStreamFrameData(SpdyStreamId stream_id, | 237 void OnStreamFrameData(SpdyStreamId stream_id, |
238 const char* data, | 238 const char* data, |
239 size_t len, | 239 size_t len, |
240 bool fin) override {} | 240 bool fin) override {} |
241 virtual void OnSettings(bool clear_persisted) override {} | 241 void OnSettings(bool clear_persisted) override {} |
242 virtual void OnSetting( | 242 void OnSetting(SpdySettingsIds id, uint8 flags, uint32 value) override {} |
243 SpdySettingsIds id, uint8 flags, uint32 value) override {} | 243 void OnPing(SpdyPingId unique_id, bool is_ack) override {} |
244 virtual void OnPing(SpdyPingId unique_id, bool is_ack) override {} | 244 void OnRstStream(SpdyStreamId stream_id, |
245 virtual void OnRstStream(SpdyStreamId stream_id, | 245 SpdyRstStreamStatus status) override {} |
246 SpdyRstStreamStatus status) override {} | 246 void OnGoAway(SpdyStreamId last_accepted_stream_id, |
247 virtual void OnGoAway(SpdyStreamId last_accepted_stream_id, | 247 SpdyGoAwayStatus status) override {} |
248 SpdyGoAwayStatus status) override {} | 248 void OnWindowUpdate(SpdyStreamId stream_id, |
249 virtual void OnWindowUpdate(SpdyStreamId stream_id, | 249 uint32 delta_window_size) override {} |
250 uint32 delta_window_size) override {} | 250 void OnPushPromise(SpdyStreamId stream_id, |
251 virtual void OnPushPromise(SpdyStreamId stream_id, | 251 SpdyStreamId promised_stream_id, |
252 SpdyStreamId promised_stream_id, | 252 const SpdyHeaderBlock& headers) override {} |
253 const SpdyHeaderBlock& headers) override {} | 253 bool OnUnknownFrame(SpdyStreamId stream_id, int frame_type) override { |
254 virtual bool OnUnknownFrame(SpdyStreamId stream_id, int frame_type) override { | |
255 return false; | 254 return false; |
256 } | 255 } |
257 | 256 |
258 private: | 257 private: |
259 SpdyPriority priority_; | 258 SpdyPriority priority_; |
260 }; | 259 }; |
261 | 260 |
262 } // namespace | 261 } // namespace |
263 | 262 |
264 bool GetSpdyPriority(SpdyMajorVersion version, | 263 bool GetSpdyPriority(SpdyMajorVersion version, |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 | 605 |
607 namespace { | 606 namespace { |
608 | 607 |
609 // A ClientSocket used for CreateFakeSpdySession() below. | 608 // A ClientSocket used for CreateFakeSpdySession() below. |
610 class FakeSpdySessionClientSocket : public MockClientSocket { | 609 class FakeSpdySessionClientSocket : public MockClientSocket { |
611 public: | 610 public: |
612 FakeSpdySessionClientSocket(int read_result) | 611 FakeSpdySessionClientSocket(int read_result) |
613 : MockClientSocket(BoundNetLog()), | 612 : MockClientSocket(BoundNetLog()), |
614 read_result_(read_result) {} | 613 read_result_(read_result) {} |
615 | 614 |
616 virtual ~FakeSpdySessionClientSocket() {} | 615 ~FakeSpdySessionClientSocket() override {} |
617 | 616 |
618 virtual int Read(IOBuffer* buf, int buf_len, | 617 int Read(IOBuffer* buf, |
619 const CompletionCallback& callback) override { | 618 int buf_len, |
| 619 const CompletionCallback& callback) override { |
620 return read_result_; | 620 return read_result_; |
621 } | 621 } |
622 | 622 |
623 virtual int Write(IOBuffer* buf, int buf_len, | 623 int Write(IOBuffer* buf, |
624 const CompletionCallback& callback) override { | 624 int buf_len, |
| 625 const CompletionCallback& callback) override { |
625 return ERR_IO_PENDING; | 626 return ERR_IO_PENDING; |
626 } | 627 } |
627 | 628 |
628 // Return kProtoUnknown to use the pool's default protocol. | 629 // Return kProtoUnknown to use the pool's default protocol. |
629 virtual NextProto GetNegotiatedProtocol() const override { | 630 NextProto GetNegotiatedProtocol() const override { return kProtoUnknown; } |
630 return kProtoUnknown; | |
631 } | |
632 | 631 |
633 // The functions below are not expected to be called. | 632 // The functions below are not expected to be called. |
634 | 633 |
635 virtual int Connect(const CompletionCallback& callback) override { | 634 int Connect(const CompletionCallback& callback) override { |
636 ADD_FAILURE(); | 635 ADD_FAILURE(); |
637 return ERR_UNEXPECTED; | 636 return ERR_UNEXPECTED; |
638 } | 637 } |
639 | 638 |
640 virtual bool WasEverUsed() const override { | 639 bool WasEverUsed() const override { |
641 ADD_FAILURE(); | 640 ADD_FAILURE(); |
642 return false; | 641 return false; |
643 } | 642 } |
644 | 643 |
645 virtual bool UsingTCPFastOpen() const override { | 644 bool UsingTCPFastOpen() const override { |
646 ADD_FAILURE(); | 645 ADD_FAILURE(); |
647 return false; | 646 return false; |
648 } | 647 } |
649 | 648 |
650 virtual bool WasNpnNegotiated() const override { | 649 bool WasNpnNegotiated() const override { |
651 ADD_FAILURE(); | 650 ADD_FAILURE(); |
652 return false; | 651 return false; |
653 } | 652 } |
654 | 653 |
655 virtual bool GetSSLInfo(SSLInfo* ssl_info) override { | 654 bool GetSSLInfo(SSLInfo* ssl_info) override { |
656 ADD_FAILURE(); | 655 ADD_FAILURE(); |
657 return false; | 656 return false; |
658 } | 657 } |
659 | 658 |
660 private: | 659 private: |
661 int read_result_; | 660 int read_result_; |
662 }; | 661 }; |
663 | 662 |
664 base::WeakPtr<SpdySession> CreateFakeSpdySessionHelper( | 663 base::WeakPtr<SpdySession> CreateFakeSpdySessionHelper( |
665 SpdySessionPool* pool, | 664 SpdySessionPool* pool, |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1317 } | 1316 } |
1318 } | 1317 } |
1319 | 1318 |
1320 void SpdyTestUtil::SetPriority(RequestPriority priority, | 1319 void SpdyTestUtil::SetPriority(RequestPriority priority, |
1321 SpdySynStreamIR* ir) const { | 1320 SpdySynStreamIR* ir) const { |
1322 ir->set_priority(ConvertRequestPriorityToSpdyPriority( | 1321 ir->set_priority(ConvertRequestPriorityToSpdyPriority( |
1323 priority, spdy_version())); | 1322 priority, spdy_version())); |
1324 } | 1323 } |
1325 | 1324 |
1326 } // namespace net | 1325 } // namespace net |
OLD | NEW |