summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/http/http_stream_factory_impl_unittest.cc110
-rw-r--r--net/websockets/websocket_basic_stream.cc22
-rw-r--r--net/websockets/websocket_basic_stream.h12
-rw-r--r--net/websockets/websocket_channel_test.cc19
-rw-r--r--net/websockets/websocket_deflate_stream.cc31
-rw-r--r--net/websockets/websocket_deflate_stream.h9
-rw-r--r--net/websockets/websocket_deflate_stream_test.cc20
-rw-r--r--net/websockets/websocket_stream.cc2
-rw-r--r--net/websockets/websocket_stream.h39
-rw-r--r--net/websockets/websocket_stream_base.h24
10 files changed, 100 insertions, 188 deletions
diff --git a/net/http/http_stream_factory_impl_unittest.cc b/net/http/http_stream_factory_impl_unittest.cc
index 217fa50..b5c772e 100644
--- a/net/http/http_stream_factory_impl_unittest.cc
+++ b/net/http/http_stream_factory_impl_unittest.cc
@@ -57,23 +57,61 @@ class UseAlternateProtocolsScopedSetter {
bool use_alternate_protocols_;
};
-class MockWebSocketStream : public WebSocketStreamBase {
+class MockWebSocketHandshakeStream : public WebSocketStreamBase {
public:
enum StreamType {
kStreamTypeBasic,
kStreamTypeSpdy,
};
- explicit MockWebSocketStream(StreamType type) : type_(type) {}
+ explicit MockWebSocketHandshakeStream(StreamType type) : type_(type) {}
- virtual ~MockWebSocketStream() {}
-
- virtual WebSocketStream* AsWebSocketStream() OVERRIDE { return NULL; }
+ virtual ~MockWebSocketHandshakeStream() {}
StreamType type() const {
return type_;
}
+ // HttpStreamBase methods
+ virtual int InitializeStream(const HttpRequestInfo* request_info,
+ RequestPriority priority,
+ const BoundNetLog& net_log,
+ const CompletionCallback& callback) OVERRIDE {
+ return ERR_IO_PENDING;
+ }
+ virtual int SendRequest(const HttpRequestHeaders& request_headers,
+ HttpResponseInfo* response,
+ const CompletionCallback& callback) OVERRIDE {
+ return ERR_IO_PENDING;
+ }
+ virtual int ReadResponseHeaders(const CompletionCallback& callback) OVERRIDE {
+ return ERR_IO_PENDING;
+ }
+ virtual const HttpResponseInfo* GetResponseInfo() const OVERRIDE {
+ return NULL;
+ }
+ virtual int ReadResponseBody(IOBuffer* buf,
+ int buf_len,
+ const CompletionCallback& callback) OVERRIDE {
+ return ERR_IO_PENDING;
+ }
+ virtual void Close(bool not_reusable) OVERRIDE {}
+ virtual bool IsResponseBodyComplete() const OVERRIDE { return false; }
+ virtual bool CanFindEndOfResponse() const OVERRIDE { return false; }
+ virtual bool IsConnectionReused() const OVERRIDE { return false; }
+ virtual void SetConnectionReused() OVERRIDE {}
+ virtual bool IsConnectionReusable() const OVERRIDE { return false; }
+ virtual bool GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const
+ OVERRIDE {
+ return false;
+ }
+ virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE {}
+ virtual void GetSSLCertRequestInfo(
+ SSLCertRequestInfo* cert_request_info) OVERRIDE {}
+ virtual bool IsSpdyHttpStream() const OVERRIDE { return false; }
+ virtual void Drain(HttpNetworkSession* session) OVERRIDE {}
+ virtual void SetPriority(RequestPriority priority) OVERRIDE {}
+
private:
const StreamType type_;
};
@@ -128,10 +166,9 @@ class StreamRequestWaiter : public HttpStreamRequest::Delegate {
used_proxy_info_ = used_proxy_info;
}
- virtual void OnWebSocketStreamReady(
- const SSLConfig& used_ssl_config,
- const ProxyInfo& used_proxy_info,
- WebSocketStreamBase* stream) OVERRIDE {
+ virtual void OnWebSocketStreamReady(const SSLConfig& used_ssl_config,
+ const ProxyInfo& used_proxy_info,
+ WebSocketStreamBase* stream) OVERRIDE {
stream_done_ = true;
if (waiting_for_stream_)
base::MessageLoop::current()->Quit();
@@ -182,8 +219,8 @@ class StreamRequestWaiter : public HttpStreamRequest::Delegate {
return stream_.get();
}
- MockWebSocketStream* websocket_stream() {
- return static_cast<MockWebSocketStream*>(websocket_stream_.get());
+ MockWebSocketHandshakeStream* websocket_stream() {
+ return static_cast<MockWebSocketHandshakeStream*>(websocket_stream_.get());
}
bool stream_done() const { return stream_done_; }
@@ -199,12 +236,14 @@ class StreamRequestWaiter : public HttpStreamRequest::Delegate {
DISALLOW_COPY_AND_ASSIGN(StreamRequestWaiter);
};
-class WebSocketSpdyStream : public MockWebSocketStream {
+class WebSocketSpdyHandshakeStream : public MockWebSocketHandshakeStream {
public:
- explicit WebSocketSpdyStream(const base::WeakPtr<SpdySession>& spdy_session)
- : MockWebSocketStream(kStreamTypeSpdy), spdy_session_(spdy_session) {}
+ explicit WebSocketSpdyHandshakeStream(
+ const base::WeakPtr<SpdySession>& spdy_session)
+ : MockWebSocketHandshakeStream(kStreamTypeSpdy),
+ spdy_session_(spdy_session) {}
- virtual ~WebSocketSpdyStream() {}
+ virtual ~WebSocketSpdyHandshakeStream() {}
SpdySession* spdy_session() { return spdy_session_.get(); }
@@ -212,12 +251,13 @@ class WebSocketSpdyStream : public MockWebSocketStream {
base::WeakPtr<SpdySession> spdy_session_;
};
-class WebSocketBasicStream : public MockWebSocketStream {
+class WebSocketBasicHandshakeStream : public MockWebSocketHandshakeStream {
public:
- explicit WebSocketBasicStream(ClientSocketHandle* connection)
- : MockWebSocketStream(kStreamTypeBasic), connection_(connection) {}
+ explicit WebSocketBasicHandshakeStream(ClientSocketHandle* connection)
+ : MockWebSocketHandshakeStream(kStreamTypeBasic),
+ connection_(connection) {}
- virtual ~WebSocketBasicStream() {
+ virtual ~WebSocketBasicHandshakeStream() {
connection_->socket()->Disconnect();
}
@@ -233,13 +273,13 @@ class WebSocketStreamFactory : public WebSocketStreamBase::Factory {
virtual WebSocketStreamBase* CreateBasicStream(ClientSocketHandle* connection,
bool using_proxy) OVERRIDE {
- return new WebSocketBasicStream(connection);
+ return new WebSocketBasicHandshakeStream(connection);
}
virtual WebSocketStreamBase* CreateSpdyStream(
const base::WeakPtr<SpdySession>& spdy_session,
bool use_relative_url) OVERRIDE {
- return new WebSocketSpdyStream(spdy_session);
+ return new WebSocketSpdyHandshakeStream(spdy_session);
}
};
@@ -865,7 +905,7 @@ TEST_P(HttpStreamFactoryTest, RequestHttpStreamOverProxy) {
EXPECT_FALSE(waiter.used_proxy_info().is_direct());
}
-TEST_P(HttpStreamFactoryTest, RequestWebSocketBasicStream) {
+TEST_P(HttpStreamFactoryTest, RequestWebSocketBasicHandshakeStream) {
SpdySessionDependencies session_deps(
GetParam(), ProxyService::CreateDirect());
@@ -898,7 +938,7 @@ TEST_P(HttpStreamFactoryTest, RequestWebSocketBasicStream) {
EXPECT_TRUE(waiter.stream_done());
EXPECT_TRUE(NULL == waiter.stream());
ASSERT_TRUE(NULL != waiter.websocket_stream());
- EXPECT_EQ(MockWebSocketStream::kStreamTypeBasic,
+ EXPECT_EQ(MockWebSocketHandshakeStream::kStreamTypeBasic,
waiter.websocket_stream()->type());
EXPECT_EQ(0, GetSocketPoolGroupCount(
session->GetTransportSocketPool(HttpNetworkSession::NORMAL_SOCKET_POOL)));
@@ -912,7 +952,7 @@ TEST_P(HttpStreamFactoryTest, RequestWebSocketBasicStream) {
EXPECT_TRUE(waiter.used_proxy_info().is_direct());
}
-TEST_P(HttpStreamFactoryTest, RequestWebSocketBasicStreamOverSSL) {
+TEST_P(HttpStreamFactoryTest, RequestWebSocketBasicHandshakeStreamOverSSL) {
SpdySessionDependencies session_deps(
GetParam(), ProxyService::CreateDirect());
@@ -949,7 +989,7 @@ TEST_P(HttpStreamFactoryTest, RequestWebSocketBasicStreamOverSSL) {
EXPECT_TRUE(waiter.stream_done());
EXPECT_TRUE(NULL == waiter.stream());
ASSERT_TRUE(NULL != waiter.websocket_stream());
- EXPECT_EQ(MockWebSocketStream::kStreamTypeBasic,
+ EXPECT_EQ(MockWebSocketHandshakeStream::kStreamTypeBasic,
waiter.websocket_stream()->type());
EXPECT_EQ(0, GetSocketPoolGroupCount(
session->GetTransportSocketPool(HttpNetworkSession::NORMAL_SOCKET_POOL)));
@@ -963,7 +1003,7 @@ TEST_P(HttpStreamFactoryTest, RequestWebSocketBasicStreamOverSSL) {
EXPECT_TRUE(waiter.used_proxy_info().is_direct());
}
-TEST_P(HttpStreamFactoryTest, RequestWebSocketBasicStreamOverProxy) {
+TEST_P(HttpStreamFactoryTest, RequestWebSocketBasicHandshakeStreamOverProxy) {
SpdySessionDependencies session_deps(
GetParam(), ProxyService::CreateFixed("myproxy:8888"));
@@ -997,7 +1037,7 @@ TEST_P(HttpStreamFactoryTest, RequestWebSocketBasicStreamOverProxy) {
EXPECT_TRUE(waiter.stream_done());
EXPECT_TRUE(NULL == waiter.stream());
ASSERT_TRUE(NULL != waiter.websocket_stream());
- EXPECT_EQ(MockWebSocketStream::kStreamTypeBasic,
+ EXPECT_EQ(MockWebSocketHandshakeStream::kStreamTypeBasic,
waiter.websocket_stream()->type());
EXPECT_EQ(0, GetSocketPoolGroupCount(
session->GetTransportSocketPool(
@@ -1072,7 +1112,7 @@ TEST_P(HttpStreamFactoryTest, RequestSpdyHttpStream) {
EXPECT_TRUE(waiter.used_proxy_info().is_direct());
}
-TEST_P(HttpStreamFactoryTest, RequestWebSocketSpdyStream) {
+TEST_P(HttpStreamFactoryTest, RequestWebSocketSpdyHandshakeStream) {
SpdySessionDependencies session_deps(GetParam(),
ProxyService::CreateDirect());
@@ -1110,7 +1150,7 @@ TEST_P(HttpStreamFactoryTest, RequestWebSocketSpdyStream) {
waiter1.WaitForStream();
EXPECT_TRUE(waiter1.stream_done());
ASSERT_TRUE(NULL != waiter1.websocket_stream());
- EXPECT_EQ(MockWebSocketStream::kStreamTypeSpdy,
+ EXPECT_EQ(MockWebSocketHandshakeStream::kStreamTypeSpdy,
waiter1.websocket_stream()->type());
EXPECT_TRUE(NULL == waiter1.stream());
@@ -1127,14 +1167,14 @@ TEST_P(HttpStreamFactoryTest, RequestWebSocketSpdyStream) {
waiter2.WaitForStream();
EXPECT_TRUE(waiter2.stream_done());
ASSERT_TRUE(NULL != waiter2.websocket_stream());
- EXPECT_EQ(MockWebSocketStream::kStreamTypeSpdy,
+ EXPECT_EQ(MockWebSocketHandshakeStream::kStreamTypeSpdy,
waiter2.websocket_stream()->type());
EXPECT_TRUE(NULL == waiter2.stream());
EXPECT_NE(waiter2.websocket_stream(), waiter1.websocket_stream());
- EXPECT_EQ(static_cast<WebSocketSpdyStream*>(waiter2.websocket_stream())->
- spdy_session(),
- static_cast<WebSocketSpdyStream*>(waiter1.websocket_stream())->
- spdy_session());
+ EXPECT_EQ(static_cast<WebSocketSpdyHandshakeStream*>(
+ waiter2.websocket_stream())->spdy_session(),
+ static_cast<WebSocketSpdyHandshakeStream*>(
+ waiter1.websocket_stream())->spdy_session());
EXPECT_EQ(0, GetSocketPoolGroupCount(
session->GetTransportSocketPool(HttpNetworkSession::NORMAL_SOCKET_POOL)));
@@ -1201,7 +1241,7 @@ TEST_P(HttpStreamFactoryTest, OrphanedWebSocketStream) {
EXPECT_TRUE(waiter.stream_done());
EXPECT_TRUE(NULL == waiter.stream());
ASSERT_TRUE(NULL != waiter.websocket_stream());
- EXPECT_EQ(MockWebSocketStream::kStreamTypeSpdy,
+ EXPECT_EQ(MockWebSocketHandshakeStream::kStreamTypeSpdy,
waiter.websocket_stream()->type());
// Make sure that there was an alternative connection
diff --git a/net/websockets/websocket_basic_stream.cc b/net/websockets/websocket_basic_stream.cc
index d3b1c40..fa598d0 100644
--- a/net/websockets/websocket_basic_stream.cc
+++ b/net/websockets/websocket_basic_stream.cc
@@ -50,8 +50,7 @@ int CalculateSerializedSizeAndTurnOnMaskBit(
const int kMaximumTotalSize = std::numeric_limits<int>::max();
int total_size = 0;
- for (WebSocketFrameIterator it = frames->begin();
- it != frames->end(); ++it) {
+ for (WebSocketFrameIterator it = frames->begin(); it != frames->end(); ++it) {
WebSocketFrame* frame = *it;
// Force the masked bit on.
frame->header.masked = true;
@@ -137,8 +136,7 @@ int WebSocketBasicStream::WriteFrames(ScopedVector<WebSocketFrame>* frames,
char* dest = combined_buffer->data();
int remaining_size = total_size;
- for (WebSocketFrameIterator it = frames->begin();
- it != frames->end(); ++it) {
+ for (WebSocketFrameIterator it = frames->begin(); it != frames->end(); ++it) {
WebSocketFrame* frame = *it;
WebSocketMaskingKey mask = generate_websocket_masking_key_();
int result =
@@ -173,22 +171,6 @@ std::string WebSocketBasicStream::GetSubProtocol() const {
std::string WebSocketBasicStream::GetExtensions() const { return extensions_; }
-int WebSocketBasicStream::SendHandshakeRequest(
- const GURL& url,
- const HttpRequestHeaders& headers,
- HttpResponseInfo* response_info,
- const CompletionCallback& callback) {
- // TODO(ricea): Implement handshake-related functionality.
- NOTREACHED();
- return ERR_NOT_IMPLEMENTED;
-}
-
-int WebSocketBasicStream::ReadHandshakeResponse(
- const CompletionCallback& callback) {
- NOTREACHED();
- return ERR_NOT_IMPLEMENTED;
-}
-
/*static*/
scoped_ptr<WebSocketBasicStream>
WebSocketBasicStream::CreateWebSocketBasicStreamForTesting(
diff --git a/net/websockets/websocket_basic_stream.h b/net/websockets/websocket_basic_stream.h
index a071e61..601a236 100644
--- a/net/websockets/websocket_basic_stream.h
+++ b/net/websockets/websocket_basic_stream.h
@@ -19,8 +19,6 @@ namespace net {
class ClientSocketHandle;
class DrainableIOBuffer;
class GrowableIOBuffer;
-class HttpRequestHeaders;
-class HttpResponseInfo;
class IOBufferWithSize;
struct WebSocketFrame;
struct WebSocketFrameChunk;
@@ -52,16 +50,6 @@ class NET_EXPORT_PRIVATE WebSocketBasicStream : public WebSocketStream {
virtual std::string GetExtensions() const OVERRIDE;
- // Writes WebSocket handshake request HTTP-style to the connection. Adds
- // "Sec-WebSocket-Key" header; this should not be included in |headers|.
- virtual int SendHandshakeRequest(const GURL& url,
- const HttpRequestHeaders& headers,
- HttpResponseInfo* response_info,
- const CompletionCallback& callback) OVERRIDE;
-
- virtual int ReadHandshakeResponse(
- const CompletionCallback& callback) OVERRIDE;
-
////////////////////////////////////////////////////////////////////////////
// Methods for testing only.
diff --git a/net/websockets/websocket_channel_test.cc b/net/websockets/websocket_channel_test.cc
index 6bc2a54..77701a5 100644
--- a/net/websockets/websocket_channel_test.cc
+++ b/net/websockets/websocket_channel_test.cc
@@ -161,19 +161,6 @@ class FakeWebSocketStream : public WebSocketStream {
const std::string& extensions)
: protocol_(protocol), extensions_(extensions) {}
- virtual int SendHandshakeRequest(
- const GURL& url,
- const HttpRequestHeaders& headers,
- HttpResponseInfo* response_info,
- const CompletionCallback& callback) OVERRIDE {
- return ERR_IO_PENDING;
- }
-
- virtual int ReadHandshakeResponse(
- const CompletionCallback& callback) OVERRIDE {
- return ERR_IO_PENDING;
- }
-
virtual int ReadFrames(ScopedVector<WebSocketFrame>* frames,
const CompletionCallback& callback) OVERRIDE {
return ERR_IO_PENDING;
@@ -607,12 +594,6 @@ class MockWebSocketStream : public WebSocketStream {
MOCK_CONST_METHOD0(GetSubProtocol, std::string());
MOCK_CONST_METHOD0(GetExtensions, std::string());
MOCK_METHOD0(AsWebSocketStream, WebSocketStream*());
- MOCK_METHOD4(SendHandshakeRequest,
- int(const GURL& url,
- const HttpRequestHeaders& headers,
- HttpResponseInfo* response_info,
- const CompletionCallback& callback));
- MOCK_METHOD1(ReadHandshakeResponse, int(const CompletionCallback& callback));
};
struct ArgumentCopyingWebSocketStreamFactory {
diff --git a/net/websockets/websocket_deflate_stream.cc b/net/websockets/websocket_deflate_stream.cc
index d4fe775..fe9fd9e 100644
--- a/net/websockets/websocket_deflate_stream.cc
+++ b/net/websockets/websocket_deflate_stream.cc
@@ -72,9 +72,7 @@ int WebSocketDeflateStream::WriteFrames(ScopedVector<WebSocketFrame>* frames,
return stream_->WriteFrames(frames, callback);
}
-void WebSocketDeflateStream::Close() {
- stream_->Close();
-}
+void WebSocketDeflateStream::Close() { stream_->Close(); }
std::string WebSocketDeflateStream::GetSubProtocol() const {
return stream_->GetSubProtocol();
@@ -84,23 +82,6 @@ std::string WebSocketDeflateStream::GetExtensions() const {
return stream_->GetExtensions();
}
-int WebSocketDeflateStream::SendHandshakeRequest(
- const GURL& url,
- const HttpRequestHeaders& headers,
- HttpResponseInfo* response_info,
- const CompletionCallback& callback) {
- // TODO(yhirano) handshake related functions will be moved to somewhere.
- NOTIMPLEMENTED();
- return OK;
-}
-
-int WebSocketDeflateStream::ReadHandshakeResponse(
- const CompletionCallback& callback) {
- // TODO(yhirano) handshake related functions will be moved to somewhere.
- NOTIMPLEMENTED();
- return OK;
-}
-
void WebSocketDeflateStream::OnReadComplete(
ScopedVector<WebSocketFrame>* frames,
const CompletionCallback& callback,
@@ -143,9 +124,8 @@ int WebSocketDeflateStream::Deflate(ScopedVector<WebSocketFrame>* frames) {
current_writing_opcode_ = WebSocketFrameHeader::kOpCodeContinuation;
} else {
DCHECK_EQ(WRITING_COMPRESSED_MESSAGE, writing_state_);
- if (frame->data &&
- !deflater_.AddBytes(frame->data->data(),
- frame->header.payload_length)) {
+ if (frame->data && !deflater_.AddBytes(frame->data->data(),
+ frame->header.payload_length)) {
DVLOG(1) << "WebSocket protocol error. "
<< "deflater_.AddBytes() returns an error.";
return ERR_WS_PROTOCOL_ERROR;
@@ -217,9 +197,8 @@ int WebSocketDeflateStream::Inflate(ScopedVector<WebSocketFrame>* frames) {
frames_to_output.push_back(frame.release());
} else {
DCHECK_EQ(reading_state_, READING_COMPRESSED_MESSAGE);
- if (frame->data &&
- !inflater_.AddBytes(frame->data->data(),
- frame->header.payload_length)) {
+ if (frame->data && !inflater_.AddBytes(frame->data->data(),
+ frame->header.payload_length)) {
DVLOG(1) << "WebSocket protocol error. "
<< "inflater_.AddBytes() returns an error.";
return ERR_WS_PROTOCOL_ERROR;
diff --git a/net/websockets/websocket_deflate_stream.h b/net/websockets/websocket_deflate_stream.h
index 224bfeb..d83696d 100644
--- a/net/websockets/websocket_deflate_stream.h
+++ b/net/websockets/websocket_deflate_stream.h
@@ -21,9 +21,6 @@ class GURL;
namespace net {
-class HttpRequestHeaders;
-class HttpResponseInfo;
-
// WebSocketDeflateStream is a WebSocketStream subclass.
// WebSocketDeflateStream is for permessage-deflate WebSocket extension[1].
//
@@ -41,12 +38,6 @@ class NET_EXPORT_PRIVATE WebSocketDeflateStream : public WebSocketStream {
virtual void Close() OVERRIDE;
virtual std::string GetSubProtocol() const OVERRIDE;
virtual std::string GetExtensions() const OVERRIDE;
- virtual int SendHandshakeRequest(const GURL& url,
- const HttpRequestHeaders& headers,
- HttpResponseInfo* response_info,
- const CompletionCallback& callback) OVERRIDE;
- virtual int ReadHandshakeResponse(const CompletionCallback& callback)
- OVERRIDE;
private:
enum ReadingState {
diff --git a/net/websockets/websocket_deflate_stream_test.cc b/net/websockets/websocket_deflate_stream_test.cc
index 63955f1..260991d 100644
--- a/net/websockets/websocket_deflate_stream_test.cc
+++ b/net/websockets/websocket_deflate_stream_test.cc
@@ -15,7 +15,6 @@
#include "net/base/completion_callback.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
-#include "net/http/http_request_headers.h"
#include "net/websockets/websocket_deflater.h"
#include "net/websockets/websocket_frame.h"
#include "net/websockets/websocket_inflater.h"
@@ -23,19 +22,15 @@
#include "net/websockets/websocket_test_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "url/gurl.h"
namespace net {
-
-class HttpResponseInfo;
-
namespace {
-typedef testing::MockFunction<void(int)> MockCallback; // NOLINT
-using testing::_;
-using testing::InSequence;
-using testing::Invoke;
-using testing::Return;
+typedef ::testing::MockFunction<void(int)> MockCallback; // NOLINT
+using ::testing::_;
+using ::testing::InSequence;
+using ::testing::Invoke;
+using ::testing::Return;
typedef uint32_t FrameFlag;
const FrameFlag kNoFlag = 0;
@@ -104,11 +99,6 @@ class MockWebSocketStream : public WebSocketStream {
MOCK_METHOD0(Close, void());
MOCK_CONST_METHOD0(GetSubProtocol, std::string());
MOCK_CONST_METHOD0(GetExtensions, std::string());
- MOCK_METHOD4(SendHandshakeRequest, int(const GURL& url,
- const HttpRequestHeaders& headers,
- HttpResponseInfo* response_info,
- const CompletionCallback& callback));
- MOCK_METHOD1(ReadHandshakeResponse, int(const CompletionCallback& callback));
};
class WebSocketDeflateStreamTest : public ::testing::Test {
diff --git a/net/websockets/websocket_stream.cc b/net/websockets/websocket_stream.cc
index b2d316b..9d1394c 100644
--- a/net/websockets/websocket_stream.cc
+++ b/net/websockets/websocket_stream.cc
@@ -27,6 +27,4 @@ scoped_ptr<WebSocketStreamRequest> WebSocketStream::CreateAndConnectStream(
return make_scoped_ptr(new WebSocketStreamRequest());
}
-WebSocketStream* WebSocketStream::AsWebSocketStream() { return this; }
-
} // namespace net
diff --git a/net/websockets/websocket_stream.h b/net/websockets/websocket_stream.h
index ca29f57..ce9551d 100644
--- a/net/websockets/websocket_stream.h
+++ b/net/websockets/websocket_stream.h
@@ -14,15 +14,12 @@
#include "base/memory/scoped_vector.h"
#include "net/base/completion_callback.h"
#include "net/base/net_export.h"
-#include "net/websockets/websocket_stream_base.h"
class GURL;
namespace net {
class BoundNetLog;
-class HttpRequestHeaders;
-class HttpResponseInfo;
class URLRequestContext;
struct WebSocketFrame;
@@ -49,7 +46,7 @@ class NET_EXPORT_PRIVATE WebSocketStreamRequest {
// |callback| will be called when the operation is finished. Non-null |callback|
// must be provided to these functions.
-class NET_EXPORT_PRIVATE WebSocketStream : public WebSocketStreamBase {
+class NET_EXPORT_PRIVATE WebSocketStream {
public:
// A concrete object derived from ConnectDelegate is supplied by the caller to
// CreateAndConnectStream() to receive the result of the connection.
@@ -156,40 +153,6 @@ class NET_EXPORT_PRIVATE WebSocketStream : public WebSocketStreamBase {
// extensions were negotiated, the empty string is returned.
virtual std::string GetExtensions() const = 0;
- // TODO(yutak): Add following interfaces:
- // - RenewStreamForAuth for authentication (is this necessary?)
- // - GetSSLInfo, GetSSLCertRequestInfo for SSL
-
- // WebSocketStreamBase derived functions
- virtual WebSocketStream* AsWebSocketStream() OVERRIDE;
-
- ////////////////////////////////////////////////////////////////////////////
- // Methods used during the stream handshake. These must not be called once a
- // WebSocket protocol stream has been established (ie. after the
- // SuccessCallback or FailureCallback has been called.)
-
- // Writes WebSocket handshake request to the underlying socket. Must be called
- // before ReadHandshakeResponse().
- //
- // |callback| will only be called if this method returns ERR_IO_PENDING.
- //
- // |response_info| must remain valid until the callback from
- // ReadHandshakeResponse has been called.
- //
- // TODO(ricea): This function is only used during the handshake and is
- // probably only applicable to certain subclasses of WebSocketStream. Move it
- // somewhere else? Also applies to ReadHandshakeResponse.
- virtual int SendHandshakeRequest(const GURL& url,
- const HttpRequestHeaders& headers,
- HttpResponseInfo* response_info,
- const CompletionCallback& callback) = 0;
-
- // Reads WebSocket handshake response from the underlying socket. Must be
- // called after SendHandshakeRequest() completes.
- //
- // |callback| will only be called if this method returns ERR_IO_PENDING.
- virtual int ReadHandshakeResponse(const CompletionCallback& callback) = 0;
-
protected:
WebSocketStream();
diff --git a/net/websockets/websocket_stream_base.h b/net/websockets/websocket_stream_base.h
index dc863d2..fbf90ff 100644
--- a/net/websockets/websocket_stream_base.h
+++ b/net/websockets/websocket_stream_base.h
@@ -9,30 +9,33 @@
// Since net/http can be built without linking net/websockets code,
// this file should not depend on net/websockets.
-#include <base/basictypes.h>
+#include "base/basictypes.h"
+#include "base/memory/weak_ptr.h"
+#include "net/http/http_stream_base.h"
namespace net {
class ClientSocketHandle;
class SpdySession;
-class WebSocketStream;
-// WebSocketStreamBase is the base class of WebSocketStream.
-// net/http code uses this interface to handle WebSocketStream.
-class NET_EXPORT WebSocketStreamBase {
+// WebSocketStreamBase is the base class of WebSocketBasicHandshakeStream.
+// net/http code uses this interface to handle WebSocketBasicHandshakeStream
+// when it needs to be treated differently from HttpStreamBase.
+class NET_EXPORT WebSocketStreamBase : public HttpStreamBase {
public:
class Factory {
public:
virtual ~Factory() {}
- // Create a WebSocketBasicStream.
- // This function (or the returned object) takes the ownership
- // of |connection|.
+ // Create a WebSocketBasicHandshakeStream. This function (or the returned
+ // object) takes the ownership of |connection|. This is called after the
+ // underlying connection has been established but before any handshake data
+ // has been transferred.
virtual WebSocketStreamBase* CreateBasicStream(
ClientSocketHandle* connection,
bool using_proxy) = 0;
- // Create a WebSocketSpdyStream.
+ // Create a WebSocketSpdyHandshakeStream (unimplemented as of October 2013)
virtual WebSocketStreamBase* CreateSpdyStream(
const base::WeakPtr<SpdySession>& session,
bool use_relative_url) = 0;
@@ -40,9 +43,6 @@ class NET_EXPORT WebSocketStreamBase {
virtual ~WebSocketStreamBase() {}
- // Return this object as a WebSocketStream.
- virtual WebSocketStream* AsWebSocketStream() = 0;
-
protected:
WebSocketStreamBase() {}