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 #include "content/browser/renderer_host/websocket_host.h" | 5 #include "content/browser/renderer_host/websocket_host.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "content/browser/renderer_host/websocket_dispatcher_host.h" | 10 #include "content/browser/renderer_host/websocket_dispatcher_host.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 81 } |
82 | 82 |
83 // Implementation of net::WebSocketEventInterface. Receives events from our | 83 // Implementation of net::WebSocketEventInterface. Receives events from our |
84 // WebSocketChannel object. Each event is translated to an IPC and sent to the | 84 // WebSocketChannel object. Each event is translated to an IPC and sent to the |
85 // renderer or child process via WebSocketDispatcherHost. | 85 // renderer or child process via WebSocketDispatcherHost. |
86 class WebSocketEventHandler : public net::WebSocketEventInterface { | 86 class WebSocketEventHandler : public net::WebSocketEventInterface { |
87 public: | 87 public: |
88 WebSocketEventHandler(WebSocketDispatcherHost* dispatcher, | 88 WebSocketEventHandler(WebSocketDispatcherHost* dispatcher, |
89 int routing_id, | 89 int routing_id, |
90 int render_frame_id); | 90 int render_frame_id); |
91 virtual ~WebSocketEventHandler(); | 91 ~WebSocketEventHandler() override; |
92 | 92 |
93 // net::WebSocketEventInterface implementation | 93 // net::WebSocketEventInterface implementation |
94 | 94 |
95 virtual ChannelState OnAddChannelResponse( | 95 ChannelState OnAddChannelResponse(bool fail, |
96 bool fail, | 96 const std::string& selected_subprotocol, |
97 const std::string& selected_subprotocol, | 97 const std::string& extensions) override; |
98 const std::string& extensions) override; | 98 ChannelState OnDataFrame(bool fin, |
99 virtual ChannelState OnDataFrame(bool fin, | 99 WebSocketMessageType type, |
100 WebSocketMessageType type, | 100 const std::vector<char>& data) override; |
101 const std::vector<char>& data) override; | 101 ChannelState OnClosingHandshake() override; |
102 virtual ChannelState OnClosingHandshake() override; | 102 ChannelState OnFlowControl(int64 quota) override; |
103 virtual ChannelState OnFlowControl(int64 quota) override; | 103 ChannelState OnDropChannel(bool was_clean, |
104 virtual ChannelState OnDropChannel(bool was_clean, | 104 uint16 code, |
105 uint16 code, | 105 const std::string& reason) override; |
106 const std::string& reason) override; | 106 ChannelState OnFailChannel(const std::string& message) override; |
107 virtual ChannelState OnFailChannel(const std::string& message) override; | 107 ChannelState OnStartOpeningHandshake( |
108 virtual ChannelState OnStartOpeningHandshake( | |
109 scoped_ptr<net::WebSocketHandshakeRequestInfo> request) override; | 108 scoped_ptr<net::WebSocketHandshakeRequestInfo> request) override; |
110 virtual ChannelState OnFinishOpeningHandshake( | 109 ChannelState OnFinishOpeningHandshake( |
111 scoped_ptr<net::WebSocketHandshakeResponseInfo> response) override; | 110 scoped_ptr<net::WebSocketHandshakeResponseInfo> response) override; |
112 virtual ChannelState OnSSLCertificateError( | 111 ChannelState OnSSLCertificateError( |
113 scoped_ptr<net::WebSocketEventInterface::SSLErrorCallbacks> callbacks, | 112 scoped_ptr<net::WebSocketEventInterface::SSLErrorCallbacks> callbacks, |
114 const GURL& url, | 113 const GURL& url, |
115 const net::SSLInfo& ssl_info, | 114 const net::SSLInfo& ssl_info, |
116 bool fatal) override; | 115 bool fatal) override; |
117 | 116 |
118 private: | 117 private: |
119 class SSLErrorHandlerDelegate : public SSLErrorHandler::Delegate { | 118 class SSLErrorHandlerDelegate : public SSLErrorHandler::Delegate { |
120 public: | 119 public: |
121 SSLErrorHandlerDelegate( | 120 SSLErrorHandlerDelegate( |
122 scoped_ptr<net::WebSocketEventInterface::SSLErrorCallbacks> callbacks); | 121 scoped_ptr<net::WebSocketEventInterface::SSLErrorCallbacks> callbacks); |
123 virtual ~SSLErrorHandlerDelegate(); | 122 ~SSLErrorHandlerDelegate() override; |
124 | 123 |
125 base::WeakPtr<SSLErrorHandler::Delegate> GetWeakPtr(); | 124 base::WeakPtr<SSLErrorHandler::Delegate> GetWeakPtr(); |
126 | 125 |
127 // SSLErrorHandler::Delegate methods | 126 // SSLErrorHandler::Delegate methods |
128 virtual void CancelSSLRequest(int error, | 127 void CancelSSLRequest(int error, const net::SSLInfo* ssl_info) override; |
129 const net::SSLInfo* ssl_info) override; | 128 void ContinueSSLRequest() override; |
130 virtual void ContinueSSLRequest() override; | |
131 | 129 |
132 private: | 130 private: |
133 scoped_ptr<net::WebSocketEventInterface::SSLErrorCallbacks> callbacks_; | 131 scoped_ptr<net::WebSocketEventInterface::SSLErrorCallbacks> callbacks_; |
134 base::WeakPtrFactory<SSLErrorHandlerDelegate> weak_ptr_factory_; | 132 base::WeakPtrFactory<SSLErrorHandlerDelegate> weak_ptr_factory_; |
135 | 133 |
136 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandlerDelegate); | 134 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandlerDelegate); |
137 }; | 135 }; |
138 | 136 |
139 WebSocketDispatcherHost* const dispatcher_; | 137 WebSocketDispatcherHost* const dispatcher_; |
140 const int routing_id_; | 138 const int routing_id_; |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 DVLOG(3) << "WebSocketHost::OnDropChannel" | 383 DVLOG(3) << "WebSocketHost::OnDropChannel" |
386 << " routing_id=" << routing_id_ << " was_clean=" << was_clean | 384 << " routing_id=" << routing_id_ << " was_clean=" << was_clean |
387 << " code=" << code << " reason=\"" << reason << "\""; | 385 << " code=" << code << " reason=\"" << reason << "\""; |
388 | 386 |
389 DCHECK(channel_); | 387 DCHECK(channel_); |
390 // TODO(yhirano): Handle |was_clean| appropriately. | 388 // TODO(yhirano): Handle |was_clean| appropriately. |
391 channel_->StartClosingHandshake(code, reason); | 389 channel_->StartClosingHandshake(code, reason); |
392 } | 390 } |
393 | 391 |
394 } // namespace content | 392 } // namespace content |
OLD | NEW |