Index: net/spdy/spdy_websocket_stream.h |
diff --git a/net/spdy/spdy_websocket_stream.h b/net/spdy/spdy_websocket_stream.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..75ac3550b56b9a07f3b53347968587290b655491 |
--- /dev/null |
+++ b/net/spdy/spdy_websocket_stream.h |
@@ -0,0 +1,96 @@ |
+// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef NET_SPDY_SPDY_WEBSOCKET_STREAM_H_ |
+#define NET_SPDY_SPDY_WEBSOCKET_STREAM_H_ |
+#pragma once |
+ |
+#include "base/linked_ptr.h" |
+#include "base/ref_counted.h" |
+#include "base/time.h" |
+#include "net/base/completion_callback.h" |
+#include "net/base/request_priority.h" |
+#include "net/spdy/spdy_framer.h" |
+#include "net/spdy/spdy_stream.h" |
+ |
+class GURL; |
+ |
+namespace net { |
+ |
+class SpdyWebSocketStream; |
+ |
+// The SpdyWebSocketStream is a WebSocket-specific type of stream known to |
+// a SpdySession. |
+class SpdyWebSocketStreamDelegate { |
+ public: |
+ virtual void OnCreatedSpdyStream( |
+ SpdyWebSocketStream* spdy_websocket_stream, int result) = 0; |
+ virtual void OnSentSpdyHeaders( |
+ SpdyWebSocketStream* spdy_websocket_stream) = 0; |
+ virtual int OnReceivedSpdyResponseHeader( |
+ SpdyWebSocketStream* spdy_websocket_stream, |
+ const spdy::SpdyHeaderBlock& headers, |
+ int status) = 0; |
+ virtual void OnSentSpdyData( |
+ SpdyWebSocketStream* spdy_websocket_stream, int amount_sent) = 0; |
+ virtual void OnReceivedSpdyData( |
+ SpdyWebSocketStream* spdy_websocket_stream, |
+ const char* data, int length) = 0; |
+ virtual void OnCloseSpdyStream( |
+ SpdyWebSocketStream* spdy_websocket_stream) = 0; |
+}; |
+ |
+class SpdyWebSocketStream : public SpdyStream::Delegate { |
+ public: |
+ SpdyWebSocketStream(SpdySession* spdy_session, |
+ SpdyWebSocketStreamDelegate* delegate); |
+ virtual ~SpdyWebSocketStream(); |
+ |
+ // Initializes SPDY stream for the WebSocket. |
+ // It might create SPDY stream asynchronously. In this case, this method |
+ // returns ERR_IO_PENDING. |
+ // In any case, delegate's OnCreatedSpdyStream will be called with result |
+ // that indicates SPDY stream is created or not. |
+ int InitializeStream(const GURL& url, |
+ RequestPriority request_priority, |
+ const BoundNetLog& stream_net_log); |
+ |
+ void SendRequest(linked_ptr<spdy::SpdyHeaderBlock> headers); |
+ void SendData(const char* data, int length); |
+ void Close(); |
+ |
+ // SpdyStream::Delegate |
+ virtual bool OnSendHeadersComplete(int status); |
+ virtual int OnSendBody(); |
+ virtual bool OnSendBodyComplete(int status); |
+ virtual bool IsFinishedSendingBody(); |
+ virtual int OnResponseReceived(const spdy::SpdyHeaderBlock& response, |
+ base::Time response_time, |
+ int status); |
+ virtual void OnDataReceived(const char* data, int length); |
+ virtual void OnDataSent(int length); |
+ virtual void OnClose(int status); |
+ |
+ spdy::SpdyStreamId stream_id() const { |
+ if (!stream_) |
+ return 0; |
+ return stream_->stream_id(); |
+ } |
+ |
+ private: |
+ void OnIOCompleted(int status); |
+ void OnSpdyStreamCreated(int status); |
+ |
+ scoped_refptr<SpdyStream> stream_; |
+ scoped_refptr<SpdySession> spdy_session_; |
+ SpdyWebSocketStreamDelegate* delegate_; |
+ |
+ CompletionCallbackImpl<SpdyWebSocketStream> io_callback_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(SpdyWebSocketStream); |
+}; |
+ |
+} // namespace net |
+ |
+#endif // NET_SPDY_SPDY_WEBSOCKET_STREAM_H_ |