- add sources.
[platform/framework/web/crosswalk.git] / src / net / websockets / websocket_handshake_stream_base.h
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_BASE_H_
6 #define NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_STREAM_BASE_H_
7
8 // This file is included from net/http files.
9 // Since net/http can be built without linking net/websockets code,
10 // this file must not introduce any link-time dependencies on websockets.
11
12 #include "base/basictypes.h"
13 #include "base/memory/weak_ptr.h"
14 #include "net/http/http_stream_base.h"
15 #include "net/websockets/websocket_stream.h"
16
17 namespace net {
18
19 class ClientSocketHandle;
20 class SpdySession;
21
22 // WebSocketHandshakeStreamBase is the base class of
23 // WebSocketBasicHandshakeStream.  net/http code uses this interface to handle
24 // WebSocketBasicHandshakeStream when it needs to be treated differently from
25 // HttpStreamBase.
26 class NET_EXPORT WebSocketHandshakeStreamBase : public HttpStreamBase {
27  public:
28   class Factory {
29    public:
30     virtual ~Factory() {}
31
32     // Create a WebSocketBasicHandshakeStream. This function (or the returned
33     // object) takes the ownership of |connection|. This is called after the
34     // underlying connection has been established but before any handshake data
35     // has been transferred.
36     virtual WebSocketHandshakeStreamBase* CreateBasicStream(
37         ClientSocketHandle* connection,
38         bool using_proxy) = 0;
39
40     // Create a WebSocketSpdyHandshakeStream (unimplemented as of October 2013)
41     virtual WebSocketHandshakeStreamBase* CreateSpdyStream(
42         const base::WeakPtr<SpdySession>& session,
43         bool use_relative_url) = 0;
44   };
45
46   virtual ~WebSocketHandshakeStreamBase() {}
47
48   // After the handshake has completed, this method creates a WebSocketStream
49   // (of the appropriate type) from the WebSocketHandshakeStreamBase object.
50   // The WebSocketHandshakeStreamBase object is unusable after Upgrade() has
51   // been called.
52   virtual scoped_ptr<WebSocketStream> Upgrade() = 0;
53
54  protected:
55   WebSocketHandshakeStreamBase() {}
56
57  private:
58   DISALLOW_COPY_AND_ASSIGN(WebSocketHandshakeStreamBase);
59 };
60
61 }  // namespace net
62
63 #endif  // NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_STREAM_BASE_H_