| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" // for WARN_UNUSED_RESULT | 12 #include "base/compiler_specific.h" // for WARN_UNUSED_RESULT |
| 13 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 struct WebSocketHandshakeRequestInfo; | 17 struct WebSocketHandshakeRequestInfo; |
| 18 struct WebSocketHandshakeResponseInfo; | 18 struct WebSocketHandshakeResponseInfo; |
| 19 | 19 |
| 20 // Interface for events sent from the network layer to the content layer. These | 20 // Interface for events sent from the network layer to the content layer. These |
| 21 // events will generally be sent as-is to the renderer process. | 21 // events will generally be sent as-is to the renderer process. |
| 22 class NET_EXPORT WebSocketEventInterface { | 22 class NET_EXPORT WebSocketEventInterface { |
| 23 public: | 23 public: |
| 24 typedef int WebSocketMessageType; | 24 typedef int WebSocketMessageType; |
| 25 | 25 |
| 26 // Any event can cause the Channel to be deleted. The Channel needs to avoid | 26 // Any event can cause the Channel to be deleted. The Channel needs to avoid |
| 27 // doing further processing in this case. It does not need to do cleanup, as | 27 // doing further processing in this case. It does not need to do cleanup, as |
| 28 // cleanup will already have been done as a result of the deletion. | 28 // cleanup will already have been done as a result of the deletion. |
| 29 enum ChannelState { | 29 enum ChannelState { CHANNEL_ALIVE, CHANNEL_DELETED }; |
| 30 CHANNEL_ALIVE, | |
| 31 CHANNEL_DELETED | |
| 32 }; | |
| 33 | 30 |
| 34 virtual ~WebSocketEventInterface() {} | 31 virtual ~WebSocketEventInterface() {} |
| 35 | 32 |
| 36 // Called in response to an AddChannelRequest. This generally means that a | 33 // Called in response to an AddChannelRequest. This generally means that a |
| 37 // response has been received from the remote server, but the response might | 34 // response has been received from the remote server, but the response might |
| 38 // have been generated internally. If |fail| is true, the channel cannot be | 35 // have been generated internally. If |fail| is true, the channel cannot be |
| 39 // used and should be deleted, returning CHANNEL_DELETED. | 36 // used and should be deleted, returning CHANNEL_DELETED. |
| 40 virtual ChannelState OnAddChannelResponse( | 37 virtual ChannelState OnAddChannelResponse( |
| 41 bool fail, | 38 bool fail, |
| 42 const std::string& selected_subprotocol, | 39 const std::string& selected_subprotocol, |
| 43 const std::string& extensions) WARN_UNUSED_RESULT = 0; | 40 const std::string& extensions) WARN_UNUSED_RESULT = 0; |
| 44 | 41 |
| 45 // Called when a data frame has been received from the remote host and needs | 42 // Called when a data frame has been received from the remote host and needs |
| 46 // to be forwarded to the renderer process. | 43 // to be forwarded to the renderer process. |
| 47 virtual ChannelState OnDataFrame( | 44 virtual ChannelState OnDataFrame(bool fin, |
| 48 bool fin, | 45 WebSocketMessageType type, |
| 49 WebSocketMessageType type, | 46 const std::vector<char>& data) |
| 50 const std::vector<char>& data) WARN_UNUSED_RESULT = 0; | 47 WARN_UNUSED_RESULT = 0; |
| 51 | 48 |
| 52 // Called to provide more send quota for this channel to the renderer | 49 // Called to provide more send quota for this channel to the renderer |
| 53 // process. Currently the quota units are always bytes of message body | 50 // process. Currently the quota units are always bytes of message body |
| 54 // data. In future it might depend on the type of multiplexing in use. | 51 // data. In future it might depend on the type of multiplexing in use. |
| 55 virtual ChannelState OnFlowControl(int64 quota) WARN_UNUSED_RESULT = 0; | 52 virtual ChannelState OnFlowControl(int64 quota) WARN_UNUSED_RESULT = 0; |
| 56 | 53 |
| 57 // Called when the remote server has Started the WebSocket Closing | 54 // Called when the remote server has Started the WebSocket Closing |
| 58 // Handshake. The client should not attempt to send any more messages after | 55 // Handshake. The client should not attempt to send any more messages after |
| 59 // receiving this message. It will be followed by OnDropChannel() when the | 56 // receiving this message. It will be followed by OnDropChannel() when the |
| 60 // closing handshake is complete. | 57 // closing handshake is complete. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 88 // This method returns a ChannelState for consistency, but all implementations | 85 // This method returns a ChannelState for consistency, but all implementations |
| 89 // must delete the Channel and return CHANNEL_DELETED. | 86 // must delete the Channel and return CHANNEL_DELETED. |
| 90 virtual ChannelState OnFailChannel(const std::string& message) | 87 virtual ChannelState OnFailChannel(const std::string& message) |
| 91 WARN_UNUSED_RESULT = 0; | 88 WARN_UNUSED_RESULT = 0; |
| 92 | 89 |
| 93 // Called when the browser starts the WebSocket Opening Handshake. | 90 // Called when the browser starts the WebSocket Opening Handshake. |
| 94 virtual ChannelState OnStartOpeningHandshake( | 91 virtual ChannelState OnStartOpeningHandshake( |
| 95 scoped_ptr<WebSocketHandshakeRequestInfo> request) WARN_UNUSED_RESULT = 0; | 92 scoped_ptr<WebSocketHandshakeRequestInfo> request) WARN_UNUSED_RESULT = 0; |
| 96 | 93 |
| 97 // Called when the browser finishes the WebSocket Opening Handshake. | 94 // Called when the browser finishes the WebSocket Opening Handshake. |
| 98 virtual ChannelState OnFinishOpeningHandshake( | 95 virtual ChannelState OnFinishOpeningHandshake(scoped_ptr< |
| 99 scoped_ptr<WebSocketHandshakeResponseInfo> response) | 96 WebSocketHandshakeResponseInfo> response) WARN_UNUSED_RESULT = 0; |
| 100 WARN_UNUSED_RESULT = 0; | |
| 101 | 97 |
| 102 protected: | 98 protected: |
| 103 WebSocketEventInterface() {} | 99 WebSocketEventInterface() {} |
| 104 | 100 |
| 105 private: | 101 private: |
| 106 DISALLOW_COPY_AND_ASSIGN(WebSocketEventInterface); | 102 DISALLOW_COPY_AND_ASSIGN(WebSocketEventInterface); |
| 107 }; | 103 }; |
| 108 | 104 |
| 109 } // namespace net | 105 } // namespace net |
| 110 | 106 |
| 111 #endif // NET_WEBSOCKETS_WEBSOCKET_EVENT_INTERFACE_H_ | 107 #endif // NET_WEBSOCKETS_WEBSOCKET_EVENT_INTERFACE_H_ |
| OLD | NEW |