OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_WEBSOCKETS_WEBSOCKET_EVENT_INTERFACE_H_ | 5 #ifndef NET_WEBSOCKETS_WEBSOCKET_EVENT_INTERFACE_H_ |
6 #define NET_WEBSOCKETS_WEBSOCKET_EVENT_INTERFACE_H_ | 6 #define NET_WEBSOCKETS_WEBSOCKET_EVENT_INTERFACE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/compiler_specific.h" // for WARN_UNUSED_RESULT | 14 #include "base/compiler_specific.h" // for WARN_UNUSED_RESULT |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" |
16 #include "net/base/net_export.h" | 17 #include "net/base/net_export.h" |
17 | 18 |
18 class GURL; | 19 class GURL; |
19 | 20 |
20 namespace net { | 21 namespace net { |
21 | 22 |
| 23 class IOBuffer; |
22 class SSLInfo; | 24 class SSLInfo; |
23 struct WebSocketHandshakeRequestInfo; | 25 struct WebSocketHandshakeRequestInfo; |
24 struct WebSocketHandshakeResponseInfo; | 26 struct WebSocketHandshakeResponseInfo; |
25 | 27 |
26 // Interface for events sent from the network layer to the content layer. These | 28 // Interface for events sent from the network layer to the content layer. These |
27 // events will generally be sent as-is to the renderer process. | 29 // events will generally be sent as-is to the renderer process. |
28 class NET_EXPORT WebSocketEventInterface { | 30 class NET_EXPORT WebSocketEventInterface { |
29 public: | 31 public: |
30 typedef int WebSocketMessageType; | 32 typedef int WebSocketMessageType; |
31 | 33 |
32 // Any event can cause the Channel to be deleted. The Channel needs to avoid | 34 // Any event can cause the Channel to be deleted. The Channel needs to avoid |
33 // doing further processing in this case. It does not need to do cleanup, as | 35 // doing further processing in this case. It does not need to do cleanup, as |
34 // cleanup will already have been done as a result of the deletion. | 36 // cleanup will already have been done as a result of the deletion. |
35 enum ChannelState { | 37 enum ChannelState { |
36 CHANNEL_ALIVE, | 38 CHANNEL_ALIVE, |
37 CHANNEL_DELETED | 39 CHANNEL_DELETED |
38 }; | 40 }; |
39 | 41 |
40 virtual ~WebSocketEventInterface() {} | 42 virtual ~WebSocketEventInterface() {} |
41 | 43 |
42 // Called in response to an AddChannelRequest. This means that a response has | 44 // Called in response to an AddChannelRequest. This means that a response has |
43 // been received from the remote server. | 45 // been received from the remote server. |
44 virtual ChannelState OnAddChannelResponse( | 46 virtual ChannelState OnAddChannelResponse( |
45 const std::string& selected_subprotocol, | 47 const std::string& selected_subprotocol, |
46 const std::string& extensions) WARN_UNUSED_RESULT = 0; | 48 const std::string& extensions) WARN_UNUSED_RESULT = 0; |
47 | 49 |
48 // Called when a data frame has been received from the remote host and needs | 50 // Called when a data frame has been received from the remote host and needs |
49 // to be forwarded to the renderer process. | 51 // to be forwarded to the renderer process. |
50 virtual ChannelState OnDataFrame( | 52 virtual ChannelState OnDataFrame(bool fin, |
51 bool fin, | 53 WebSocketMessageType type, |
52 WebSocketMessageType type, | 54 scoped_refptr<IOBuffer> buffer, |
53 const std::vector<char>& data) WARN_UNUSED_RESULT = 0; | 55 size_t buffer_size) WARN_UNUSED_RESULT = 0; |
54 | 56 |
55 // Called to provide more send quota for this channel to the renderer | 57 // Called to provide more send quota for this channel to the renderer |
56 // process. Currently the quota units are always bytes of message body | 58 // process. Currently the quota units are always bytes of message body |
57 // data. In future it might depend on the type of multiplexing in use. | 59 // data. In future it might depend on the type of multiplexing in use. |
58 virtual ChannelState OnFlowControl(int64_t quota) WARN_UNUSED_RESULT = 0; | 60 virtual ChannelState OnFlowControl(int64_t quota) WARN_UNUSED_RESULT = 0; |
59 | 61 |
60 // Called when the remote server has Started the WebSocket Closing | 62 // Called when the remote server has Started the WebSocket Closing |
61 // Handshake. The client should not attempt to send any more messages after | 63 // Handshake. The client should not attempt to send any more messages after |
62 // receiving this message. It will be followed by OnDropChannel() when the | 64 // receiving this message. It will be followed by OnDropChannel() when the |
63 // closing handshake is complete. | 65 // closing handshake is complete. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 protected: | 134 protected: |
133 WebSocketEventInterface() {} | 135 WebSocketEventInterface() {} |
134 | 136 |
135 private: | 137 private: |
136 DISALLOW_COPY_AND_ASSIGN(WebSocketEventInterface); | 138 DISALLOW_COPY_AND_ASSIGN(WebSocketEventInterface); |
137 }; | 139 }; |
138 | 140 |
139 } // namespace net | 141 } // namespace net |
140 | 142 |
141 #endif // NET_WEBSOCKETS_WEBSOCKET_EVENT_INTERFACE_H_ | 143 #endif // NET_WEBSOCKETS_WEBSOCKET_EVENT_INTERFACE_H_ |
OLD | NEW |