OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 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_HTTP_WEBSOCKET_STREAM_BASE_H_ | |
6 #define NET_HTTP_WEBSOCKET_STREAM_BASE_H_ | |
7 | |
8 // This file is placed on net/http because net/http classes depends it. | |
9 // Since net/http can be built without linking net/websockets code, | |
10 // you should not introduce dependency to net/websockets in this file. | |
mmenke
2013/05/28 21:22:37
My suggestion is just to put this in net/websocket
yhirano
2013/05/30 04:44:32
Currently, files in net/websockets are excluded in
mmenke
2013/05/30 19:27:12
Header files excluded from the build don't break c
yhirano
2013/05/31 08:36:45
Done.
| |
11 | |
12 #include <base/basictypes.h> | |
13 | |
14 namespace net { | |
15 | |
16 class ClientSocketHandle; | |
17 class SpdySession; | |
18 | |
19 // WebSocketStreamBase is the base class of WebSocketStream. | |
20 // net/http code can hold WebSocketStream objects via this interface | |
21 // without linking net/websockets code. | |
mmenke
2013/05/28 21:22:37
Not really following the second sentence here.
yhirano
2013/05/30 04:44:32
Done?
| |
22 class WebSocketStreamBase { | |
23 public: | |
24 // The enum describing the stream type. | |
25 // Each type corresponds to a WebSocketStream derived class. | |
26 enum StreamType { | |
27 // correspond to WebSocketBasicStream | |
28 kStreamTypeBasic, | |
29 // correspond to WebSockeSpdyStream | |
mmenke
2013/05/28 21:22:37
nit: Comments should generally start with a capit
yhirano
2013/05/30 04:44:32
Done.
| |
30 kStreamTypeSpdy, | |
31 // for testing purpose | |
32 kStreamTypeTest | |
mmenke
2013/05/28 21:22:37
Prefer not to add this unless / until we need it.
yhirano
2013/05/30 04:44:32
Done.
| |
33 }; | |
34 | |
35 // You can derive this class and implement each factory method. | |
mmenke
2013/05/28 21:22:37
Comment doesn't add anything useful.
yhirano
2013/05/30 04:44:32
Done.
| |
36 class Factory { | |
mmenke
2013/05/28 21:22:37
Long term, I'd like to get rid of this class, and
yhirano
2013/05/30 04:44:32
Likely enough. Or, perhaps we may be able to decou
| |
37 public: | |
38 // Create a WebSocketBasicStream. | |
39 // This function (or the returned object) takes the ownership | |
40 // of |connection|. | |
41 virtual WebSocketStreamBase* CreateBasicStream( | |
42 ClientSocketHandle* connection, | |
43 bool using_proxy) = 0; | |
44 | |
45 // Create a WebSocketSpdyStream. | |
46 virtual WebSocketStreamBase* CreateSpdyStream( | |
47 SpdySession* session, | |
48 bool use_relative_url) = 0; | |
49 | |
50 virtual ~Factory() {} | |
mmenke
2013/05/28 21:22:37
The destructor should go first (It could also be p
yhirano
2013/05/30 04:44:32
Done.
| |
51 }; | |
52 | |
53 StreamType type() const { | |
54 return type_; | |
55 } | |
56 | |
57 virtual ~WebSocketStreamBase() { } | |
mmenke
2013/05/28 21:22:37
nit: Google style guide says no horizontal whites
yhirano
2013/05/30 04:44:32
Done.
| |
58 | |
59 protected: | |
60 explicit WebSocketStreamBase(StreamType type): type_(type) {} | |
mmenke
2013/05/28 21:22:37
Mind de-inlining this?
mmenke
2013/05/28 21:22:37
nit: Space before the colon.
yhirano
2013/05/30 04:44:32
Done.
yhirano
2013/05/30 04:44:32
Done.
| |
61 | |
62 private: | |
63 const StreamType type_; | |
64 DISALLOW_COPY_AND_ASSIGN(WebSocketStreamBase); | |
65 }; | |
66 | |
67 } // namespace net | |
68 | |
69 #endif // NET_HTTP_WEBSOCKET_STREAM_BASE_H_ | |
OLD | NEW |