| 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 "base/memory/ref_counted.h" |
| 17 #include "net/base/net_export.h" | 17 #include "net/base/net_export.h" |
| 18 | 18 |
| 19 class GURL; | 19 class GURL; |
| 20 | 20 |
| 21 namespace net { | 21 namespace net { |
| 22 | 22 |
| 23 class IOBuffer; | 23 class IOBuffer; |
| 24 class SSLInfo; | 24 class SSLInfo; |
| 25 class URLRequest; |
| 25 struct WebSocketHandshakeRequestInfo; | 26 struct WebSocketHandshakeRequestInfo; |
| 26 struct WebSocketHandshakeResponseInfo; | 27 struct WebSocketHandshakeResponseInfo; |
| 27 | 28 |
| 28 // Interface for events sent from the network layer to the content layer. These | 29 // Interface for events sent from the network layer to the content layer. These |
| 29 // events will generally be sent as-is to the renderer process. | 30 // events will generally be sent as-is to the renderer process. |
| 30 class NET_EXPORT WebSocketEventInterface { | 31 class NET_EXPORT WebSocketEventInterface { |
| 31 public: | 32 public: |
| 32 typedef int WebSocketMessageType; | 33 typedef int WebSocketMessageType; |
| 33 | 34 |
| 34 // Any event can cause the Channel to be deleted. The Channel needs to avoid | 35 // Any event can cause the Channel to be deleted. The Channel needs to avoid |
| 35 // doing further processing in this case. It does not need to do cleanup, as | 36 // doing further processing in this case. It does not need to do cleanup, as |
| 36 // cleanup will already have been done as a result of the deletion. | 37 // cleanup will already have been done as a result of the deletion. |
| 37 enum ChannelState { | 38 enum ChannelState { |
| 38 CHANNEL_ALIVE, | 39 CHANNEL_ALIVE, |
| 39 CHANNEL_DELETED | 40 CHANNEL_DELETED |
| 40 }; | 41 }; |
| 41 | 42 |
| 42 virtual ~WebSocketEventInterface() {} | 43 virtual ~WebSocketEventInterface() {} |
| 43 | 44 |
| 45 // Called when a URLRequest is created for handshaking. |
| 46 virtual void OnCreateURLRequest(URLRequest* request) = 0; |
| 47 |
| 44 // Called in response to an AddChannelRequest. This means that a response has | 48 // Called in response to an AddChannelRequest. This means that a response has |
| 45 // been received from the remote server. | 49 // been received from the remote server. |
| 46 virtual ChannelState OnAddChannelResponse( | 50 virtual ChannelState OnAddChannelResponse( |
| 47 const std::string& selected_subprotocol, | 51 const std::string& selected_subprotocol, |
| 48 const std::string& extensions) WARN_UNUSED_RESULT = 0; | 52 const std::string& extensions) WARN_UNUSED_RESULT = 0; |
| 49 | 53 |
| 50 // Called when a data frame has been received from the remote host and needs | 54 // Called when a data frame has been received from the remote host and needs |
| 51 // to be forwarded to the renderer process. | 55 // to be forwarded to the renderer process. |
| 52 virtual ChannelState OnDataFrame(bool fin, | 56 virtual ChannelState OnDataFrame(bool fin, |
| 53 WebSocketMessageType type, | 57 WebSocketMessageType type, |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 protected: | 138 protected: |
| 135 WebSocketEventInterface() {} | 139 WebSocketEventInterface() {} |
| 136 | 140 |
| 137 private: | 141 private: |
| 138 DISALLOW_COPY_AND_ASSIGN(WebSocketEventInterface); | 142 DISALLOW_COPY_AND_ASSIGN(WebSocketEventInterface); |
| 139 }; | 143 }; |
| 140 | 144 |
| 141 } // namespace net | 145 } // namespace net |
| 142 | 146 |
| 143 #endif // NET_WEBSOCKETS_WEBSOCKET_EVENT_INTERFACE_H_ | 147 #endif // NET_WEBSOCKETS_WEBSOCKET_EVENT_INTERFACE_H_ |
| OLD | NEW |