diff options
-rw-r--r-- | net/spdy/spdy_http_stream.cc | 2 | ||||
-rw-r--r-- | net/spdy/spdy_http_stream.h | 1 | ||||
-rw-r--r-- | net/spdy/spdy_http_stream_spdy2_unittest.cc | 9 | ||||
-rw-r--r-- | net/spdy/spdy_http_stream_spdy3_unittest.cc | 9 |
4 files changed, 20 insertions, 1 deletions
diff --git a/net/spdy/spdy_http_stream.cc b/net/spdy/spdy_http_stream.cc index 5bcd82c..7b3100b 100644 --- a/net/spdy/spdy_http_stream.cc +++ b/net/spdy/spdy_http_stream.cc @@ -97,7 +97,7 @@ const HttpResponseInfo* SpdyHttpStream::GetResponseInfo() const { } UploadProgress SpdyHttpStream::GetUploadProgress() const { - if (!HasUploadData()) + if (!request_info_ || !HasUploadData()) return UploadProgress(); return UploadProgress(request_info_->upload_data_stream->position(), diff --git a/net/spdy/spdy_http_stream.h b/net/spdy/spdy_http_stream.h index 34483d0..1ad8576 100644 --- a/net/spdy/spdy_http_stream.h +++ b/net/spdy/spdy_http_stream.h @@ -94,6 +94,7 @@ class NET_EXPORT_PRIVATE SpdyHttpStream : public SpdyStream::Delegate, virtual void OnClose(int status) OVERRIDE; private: + // Must be called only when |request_info_| is non-NULL. bool HasUploadData() const; void OnStreamCreated(const CompletionCallback& callback, int rv); diff --git a/net/spdy/spdy_http_stream_spdy2_unittest.cc b/net/spdy/spdy_http_stream_spdy2_unittest.cc index 06bab80..581d530 100644 --- a/net/spdy/spdy_http_stream_spdy2_unittest.cc +++ b/net/spdy/spdy_http_stream_spdy2_unittest.cc @@ -147,6 +147,15 @@ class SpdyHttpStreamSpdy2Test : public testing::Test { scoped_refptr<TransportSocketParams> transport_params_; }; +// SpdyHttpStream::GetUploadProgress() should still work even before the +// stream is initialized. +TEST_F(SpdyHttpStreamSpdy2Test, GetUploadProgressBeforeInitialization) { + SpdyHttpStream stream(NULL, false); + UploadProgress progress = stream.GetUploadProgress(); + EXPECT_EQ(0u, progress.size()); + EXPECT_EQ(0u, progress.position()); +} + TEST_F(SpdyHttpStreamSpdy2Test, SendRequest) { scoped_ptr<SpdyFrame> req( spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); diff --git a/net/spdy/spdy_http_stream_spdy3_unittest.cc b/net/spdy/spdy_http_stream_spdy3_unittest.cc index f9482d6..b14606b 100644 --- a/net/spdy/spdy_http_stream_spdy3_unittest.cc +++ b/net/spdy/spdy_http_stream_spdy3_unittest.cc @@ -167,6 +167,15 @@ class SpdyHttpStreamSpdy3Test : public testing::Test { MockECSignatureCreatorFactory ec_signature_creator_factory_; }; +// SpdyHttpStream::GetUploadProgress() should still work even before the +// stream is initialized. +TEST_F(SpdyHttpStreamSpdy3Test, GetUploadProgressBeforeInitialization) { + SpdyHttpStream stream(NULL, false); + UploadProgress progress = stream.GetUploadProgress(); + EXPECT_EQ(0u, progress.size()); + EXPECT_EQ(0u, progress.position()); +} + TEST_F(SpdyHttpStreamSpdy3Test, SendRequest) { scoped_ptr<SpdyFrame> req( spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |