Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Side by Side Diff: net/websockets/websocket_event_interface.h

Issue 12764006: WebSocketChannel implementation (Closed) Base URL: http://git.chromium.org/chromium/src.git@web_socket_dispatcher
Patch Set: Comment fixes and clarifications Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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_EVENT_INTERFACE_H_
6 #define NET_WEBSOCKETS_WEBSOCKET_EVENT_INTERFACE_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "net/base/net_export.h"
13
14 namespace net {
15
16 // Interface for events sent from the network layer to the content layer. These
17 // events will generally be sent as-is to the renderer process.
18 class NET_EXPORT WebSocketEventInterface {
19 public:
20 typedef int WebSocketMessageType;
21 virtual ~WebSocketEventInterface() {}
22 // Called in response to an AddChannelRequest. This generally means that a
23 // response has been received from the remote server, but the response might
24 // have been generated internally. If |fail| is true, the channel cannot be
25 // used and it is valid to delete the WebSocketChannel from within this
26 // callback.
27 virtual void OnAddChannelResponse(
28 bool fail,
29 const std::string& selected_subprotocol) = 0;
30
31 // Called when a data frame has been received from the remote host and needs
32 // to be forwarded to the renderer process. It is not safe to delete the
33 // WebSocketChannel object from within this callback.
34 virtual void OnDataFrame(bool fin,
35 WebSocketMessageType type,
36 const std::vector<char>& data) = 0;
37
38 // Called to provide more send quota for this channel to the renderer
39 // process. It is not safe to delete the WebSocketChannel from within this
40 // callback.
41 virtual void OnFlowControl(int64 quota) = 0;
42
43 // Called when the remote server has Started the WebSocket Closing
44 // Handshake. The client should not attempt to send any more messages after
45 // receiving this message. It will be followed by OnDropChannel() when the
46 // closing handshake is complete. It is not safe to delete the
47 // WebSocketChannel from within this callback.
48 virtual void OnClosingHandshake() = 0;
49
50 // Called when the channel has been dropped, either due to a network close, a
51 // network error, or a protocol error. This may or may not be preceeded by a
52 // call to OnClosingHandshake().
53 //
54 // Warning: Both the |code| and |reason| are passed through to Javascript, so
55 // callers must take care not to provide details that could be useful to
56 // attackers attempting to use WebSockets to probe networks.
57 //
58 // It is expected that the WebSocketChannel object will be deleted from within
59 // this callback.
60 virtual void OnDropChannel(uint16 code, const std::string& reason) = 0;
61
62 protected:
63 WebSocketEventInterface() {}
64
65 private:
66 DISALLOW_COPY_AND_ASSIGN(WebSocketEventInterface);
67 };
68
69 } // namespace net
70
71 #endif // NET_WEBSOCKETS_WEBSOCKET_EVENT_INTERFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698