| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_STREAM_CREATE_HELPER_H_ | |
| 6 #define NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_STREAM_CREATE_HELPER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "net/base/net_export.h" | |
| 13 #include "net/websockets/websocket_handshake_stream_base.h" | |
| 14 #include "net/websockets/websocket_stream.h" | |
| 15 | |
| 16 namespace net { | |
| 17 | |
| 18 class WebSocketBasicHandshakeStream; | |
| 19 | |
| 20 // Implementation of WebSocketHandshakeStreamBase::CreateHelper. This class is | |
| 21 // used in the implementation of WebSocketStream::CreateAndConnectStream() and | |
| 22 // is not intended to be used by itself. | |
| 23 // | |
| 24 // Holds the information needed to construct a | |
| 25 // WebSocketBasicHandshakeStreamBase. | |
| 26 class NET_EXPORT_PRIVATE WebSocketHandshakeStreamCreateHelper | |
| 27 : public WebSocketHandshakeStreamBase::CreateHelper { | |
| 28 public: | |
| 29 // |connect_delegate| must out-live this object. | |
| 30 explicit WebSocketHandshakeStreamCreateHelper( | |
| 31 WebSocketStream::ConnectDelegate* connect_delegate, | |
| 32 const std::vector<std::string>& requested_subprotocols); | |
| 33 | |
| 34 ~WebSocketHandshakeStreamCreateHelper() override; | |
| 35 | |
| 36 // WebSocketHandshakeStreamBase::CreateHelper methods | |
| 37 | |
| 38 // Create a WebSocketBasicHandshakeStream. | |
| 39 WebSocketHandshakeStreamBase* CreateBasicStream( | |
| 40 scoped_ptr<ClientSocketHandle> connection, | |
| 41 bool using_proxy) override; | |
| 42 | |
| 43 // Unimplemented as of November 2013. | |
| 44 WebSocketHandshakeStreamBase* CreateSpdyStream( | |
| 45 const base::WeakPtr<SpdySession>& session, | |
| 46 bool use_relative_url) override; | |
| 47 | |
| 48 // Call Upgrade() on the WebSocketHandshakeStream and return the result. This | |
| 49 // must only be called if the handshake succeeded. | |
| 50 scoped_ptr<WebSocketStream> Upgrade(); | |
| 51 | |
| 52 // Set a pointer to the std::string into which to write any failure messages | |
| 53 // that are encountered. This method must be called before CreateBasicStream() | |
| 54 // or CreateSpdyStream(). The |failure_message| pointer must remain valid as | |
| 55 // long as this object exists. | |
| 56 void set_failure_message(std::string* failure_message) { | |
| 57 failure_message_ = failure_message; | |
| 58 } | |
| 59 | |
| 60 protected: | |
| 61 // This is used by DeterministicKeyWebSocketHandshakeStreamCreateHelper. | |
| 62 // The default implementation does nothing. | |
| 63 virtual void OnStreamCreated(WebSocketBasicHandshakeStream* stream); | |
| 64 | |
| 65 private: | |
| 66 const std::vector<std::string> requested_subprotocols_; | |
| 67 | |
| 68 // This is owned by the caller of CreateBaseStream() or | |
| 69 // CreateSpdyStream(). Both the stream and this object will be destroyed | |
| 70 // during the destruction of the URLRequest object associated with the | |
| 71 // handshake. This is only guaranteed to be a valid pointer if the handshake | |
| 72 // succeeded. | |
| 73 WebSocketHandshakeStreamBase* stream_; | |
| 74 | |
| 75 WebSocketStream::ConnectDelegate* connect_delegate_; | |
| 76 std::string* failure_message_; | |
| 77 | |
| 78 DISALLOW_COPY_AND_ASSIGN(WebSocketHandshakeStreamCreateHelper); | |
| 79 }; | |
| 80 | |
| 81 } // namespace net | |
| 82 | |
| 83 #endif // NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_STREAM_CREATE_HELPER_H_ | |
| OLD | NEW |