Index: content/browser/renderer_host/websocket_dispatcher_host.h |
diff --git a/content/browser/renderer_host/websocket_dispatcher_host.h b/content/browser/renderer_host/websocket_dispatcher_host.h |
index 94d34f3402dfe0139d40b796ff72363536318205..9d7261f38556fff8965764fa8ee303ce196f7e26 100644 |
--- a/content/browser/renderer_host/websocket_dispatcher_host.h |
+++ b/content/browser/renderer_host/websocket_dispatcher_host.h |
@@ -28,6 +28,15 @@ class WebSocketDispatcherHost : public BrowserMessageFilter { |
public: |
typedef base::Callback<net::URLRequestContext*()> GetRequestContextCallback; |
+ // Return value for methods that may delete the WebSocketHost. This enum is |
+ // binary-compatible with net::WebSocketEventInterface::ChannelState, to make |
+ // conversion cheap. By using a separate enum including net/ header files can |
+ // be avoided. |
+ enum WebSocketHostState { |
+ WEBSOCKET_HOST_ALIVE, |
+ WEBSOCKET_HOST_DELETED |
+ }; |
+ |
explicit WebSocketDispatcherHost( |
const GetRequestContextCallback& get_context_callback); |
@@ -37,30 +46,34 @@ class WebSocketDispatcherHost : public BrowserMessageFilter { |
// The following methods are used by WebSocketHost::EventInterface to send |
// IPCs from the browser to the renderer or child process. Any of them may |
- // delete the WebSocketHost on failure, leading to the WebSocketChannel and |
- // EventInterface also being deleted. |
+ // return WEBSOCKET_HOST_DELETED and delete the WebSocketHost on failure, |
+ // leading to the WebSocketChannel and EventInterface also being deleted. |
// Sends a WebSocketMsg_AddChannelResponse IPC, and then deletes and |
// unregisters the WebSocketHost if |fail| is true. |
- void SendAddChannelResponse(int routing_id, |
- bool fail, |
- const std::string& selected_protocol, |
- const std::string& extensions); |
+ WebSocketHostState SendAddChannelResponse( |
yhirano
2013/10/10 09:22:27
Should we have WARN_UNUSED_RESULT here?
Adam Rice
2013/10/11 05:42:54
Done.
|
+ int routing_id, |
+ bool fail, |
+ const std::string& selected_protocol, |
+ const std::string& extensions); |
// Sends a WebSocketMsg_SendFrame IPC. |
- void SendFrame(int routing_id, |
- bool fin, |
- WebSocketMessageType type, |
- const std::vector<char>& data); |
+ WebSocketHostState SendFrame(int routing_id, |
yhirano
2013/10/10 09:22:27
ditto
Adam Rice
2013/10/11 05:42:54
Done.
|
+ bool fin, |
+ WebSocketMessageType type, |
+ const std::vector<char>& data); |
// Sends a WebSocketMsg_FlowControl IPC. |
- void SendFlowControl(int routing_id, int64 quota); |
+ WebSocketHostState SendFlowControl(int routing_id, int64 quota); |
yhirano
2013/10/10 09:22:27
ditto
Adam Rice
2013/10/11 05:42:54
Done.
|
// Sends a WebSocketMsg_SendClosing IPC |
- void SendClosing(int routing_id); |
+ WebSocketHostState SendClosing(int routing_id); |
yhirano
2013/10/10 09:22:27
ditto
Adam Rice
2013/10/11 05:42:54
Done.
|
- // Sends a WebSocketMsg_DropChannel IPC and delete and unregister the channel. |
- void DoDropChannel(int routing_id, uint16 code, const std::string& reason); |
+ // Sends a WebSocketMsg_DropChannel IPC and deletes and unregisters the |
+ // channel. |
+ WebSocketHostState DoDropChannel(int routing_id, |
yhirano
2013/10/10 09:22:27
ditto
Adam Rice
2013/10/11 05:42:54
Done.
|
+ uint16 code, |
+ const std::string& reason); |
private: |
typedef base::hash_map<int, WebSocketHost*> WebSocketHostTable; |
@@ -74,11 +87,10 @@ class WebSocketDispatcherHost : public BrowserMessageFilter { |
// Sends the passed in IPC::Message via the BrowserMessageFilter::Send() |
// method. If the Send() fails, logs it and deletes the corresponding |
// WebSocketHost object (the client is probably dead). |
- void SendOrDrop(IPC::Message* message); |
+ WebSocketHostState SendOrDrop(IPC::Message* message); |
// Deletes the WebSocketHost object associated with the given |routing_id| and |
- // removes it from the |hosts_| table. Does nothing if the |routing_id| is |
- // unknown, since SendAddChannelResponse() may call this method twice. |
+ // removes it from the |hosts_| table. |
void DeleteWebSocketHost(int routing_id); |
// Table of WebSocketHost objects, owned by this object, indexed by |