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

Side by Side Diff: content/browser/websockets/websocket_impl.cc

Issue 2397393002: Provide child/frame IDs for WebSocket handshake request (Closed)
Patch Set: fix Created 4 years, 2 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
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/websockets/websocket_impl.h" 5 #include "content/browser/websockets/websocket_impl.h"
6 6
7 #include <inttypes.h> 7 #include <inttypes.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
20 #include "base/threading/thread_task_runner_handle.h" 20 #include "base/threading/thread_task_runner_handle.h"
21 #include "content/browser/bad_message.h" 21 #include "content/browser/bad_message.h"
22 #include "content/browser/child_process_security_policy_impl.h" 22 #include "content/browser/child_process_security_policy_impl.h"
23 #include "content/browser/ssl/ssl_error_handler.h" 23 #include "content/browser/ssl/ssl_error_handler.h"
24 #include "content/browser/ssl/ssl_manager.h" 24 #include "content/browser/ssl/ssl_manager.h"
25 #include "content/browser/websockets/websocket_handshake_request_info_impl.h"
25 #include "content/public/browser/storage_partition.h" 26 #include "content/public/browser/storage_partition.h"
26 #include "ipc/ipc_message.h" 27 #include "ipc/ipc_message.h"
27 #include "net/base/io_buffer.h" 28 #include "net/base/io_buffer.h"
28 #include "net/base/net_errors.h" 29 #include "net/base/net_errors.h"
29 #include "net/http/http_request_headers.h" 30 #include "net/http/http_request_headers.h"
30 #include "net/http/http_response_headers.h" 31 #include "net/http/http_response_headers.h"
31 #include "net/http/http_util.h" 32 #include "net/http/http_util.h"
32 #include "net/ssl/ssl_info.h" 33 #include "net/ssl/ssl_info.h"
33 #include "net/url_request/url_request_context_getter.h" 34 #include "net/url_request/url_request_context_getter.h"
34 #include "net/websockets/websocket_channel.h" 35 #include "net/websockets/websocket_channel.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // Implementation of net::WebSocketEventInterface. Receives events from our 84 // Implementation of net::WebSocketEventInterface. Receives events from our
84 // WebSocketChannel object. 85 // WebSocketChannel object.
85 class WebSocketImpl::WebSocketEventHandler final 86 class WebSocketImpl::WebSocketEventHandler final
86 : public net::WebSocketEventInterface { 87 : public net::WebSocketEventInterface {
87 public: 88 public:
88 explicit WebSocketEventHandler(WebSocketImpl* impl); 89 explicit WebSocketEventHandler(WebSocketImpl* impl);
89 ~WebSocketEventHandler() override; 90 ~WebSocketEventHandler() override;
90 91
91 // net::WebSocketEventInterface implementation 92 // net::WebSocketEventInterface implementation
92 93
94 void OnCreateURLRequest(net::URLRequest* url_request) override;
93 ChannelState OnAddChannelResponse(const std::string& selected_subprotocol, 95 ChannelState OnAddChannelResponse(const std::string& selected_subprotocol,
94 const std::string& extensions) override; 96 const std::string& extensions) override;
95 ChannelState OnDataFrame(bool fin, 97 ChannelState OnDataFrame(bool fin,
96 WebSocketMessageType type, 98 WebSocketMessageType type,
97 scoped_refptr<net::IOBuffer> buffer, 99 scoped_refptr<net::IOBuffer> buffer,
98 size_t buffer_size) override; 100 size_t buffer_size) override;
99 ChannelState OnClosingHandshake() override; 101 ChannelState OnClosingHandshake() override;
100 ChannelState OnFlowControl(int64_t quota) override; 102 ChannelState OnFlowControl(int64_t quota) override;
101 ChannelState OnDropChannel(bool was_clean, 103 ChannelState OnDropChannel(bool was_clean,
102 uint16_t code, 104 uint16_t code,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 : impl_(impl) { 146 : impl_(impl) {
145 DVLOG(1) << "WebSocketEventHandler created @" 147 DVLOG(1) << "WebSocketEventHandler created @"
146 << reinterpret_cast<void*>(this); 148 << reinterpret_cast<void*>(this);
147 } 149 }
148 150
149 WebSocketImpl::WebSocketEventHandler::~WebSocketEventHandler() { 151 WebSocketImpl::WebSocketEventHandler::~WebSocketEventHandler() {
150 DVLOG(1) << "WebSocketEventHandler destroyed @" 152 DVLOG(1) << "WebSocketEventHandler destroyed @"
151 << reinterpret_cast<void*>(this); 153 << reinterpret_cast<void*>(this);
152 } 154 }
153 155
156 void WebSocketImpl::WebSocketEventHandler::OnCreateURLRequest(
157 net::URLRequest* url_request) {
158 WebSocketHandshakeRequestInfoImpl::CreateInfoAndAssociateWithRequest(
159 impl_->child_id_, impl_->frame_id_, url_request);
160 }
161
154 ChannelState WebSocketImpl::WebSocketEventHandler::OnAddChannelResponse( 162 ChannelState WebSocketImpl::WebSocketEventHandler::OnAddChannelResponse(
155 const std::string& selected_protocol, 163 const std::string& selected_protocol,
156 const std::string& extensions) { 164 const std::string& extensions) {
157 DVLOG(3) << "WebSocketEventHandler::OnAddChannelResponse @" 165 DVLOG(3) << "WebSocketEventHandler::OnAddChannelResponse @"
158 << reinterpret_cast<void*>(this) 166 << reinterpret_cast<void*>(this)
159 << " selected_protocol=\"" << selected_protocol << "\"" 167 << " selected_protocol=\"" << selected_protocol << "\""
160 << " extensions=\"" << extensions << "\""; 168 << " extensions=\"" << extensions << "\"";
161 169
162 impl_->delegate_->OnReceivedResponseFromServer(impl_); 170 impl_->delegate_->OnReceivedResponseFromServer(impl_);
163 171
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 : static_cast<net::CertStatus>(-1)); 355 : static_cast<net::CertStatus>(-1));
348 callbacks_->CancelSSLRequest(error, ssl_info); 356 callbacks_->CancelSSLRequest(error, ssl_info);
349 } 357 }
350 358
351 void WebSocketImpl::WebSocketEventHandler::SSLErrorHandlerDelegate:: 359 void WebSocketImpl::WebSocketEventHandler::SSLErrorHandlerDelegate::
352 ContinueSSLRequest() { 360 ContinueSSLRequest() {
353 DVLOG(3) << "SSLErrorHandlerDelegate::ContinueSSLRequest"; 361 DVLOG(3) << "SSLErrorHandlerDelegate::ContinueSSLRequest";
354 callbacks_->ContinueSSLRequest(); 362 callbacks_->ContinueSSLRequest();
355 } 363 }
356 364
357 WebSocketImpl::WebSocketImpl( 365 WebSocketImpl::WebSocketImpl(Delegate* delegate,
358 Delegate* delegate, 366 blink::mojom::WebSocketRequest request,
359 blink::mojom::WebSocketRequest request, 367 int child_id,
360 int frame_id, 368 int frame_id,
361 base::TimeDelta delay) 369 base::TimeDelta delay)
362 : delegate_(delegate), 370 : delegate_(delegate),
363 binding_(this, std::move(request)), 371 binding_(this, std::move(request)),
364 delay_(delay), 372 delay_(delay),
365 pending_flow_control_quota_(0), 373 pending_flow_control_quota_(0),
374 child_id_(child_id),
366 frame_id_(frame_id), 375 frame_id_(frame_id),
367 handshake_succeeded_(false), 376 handshake_succeeded_(false),
368 weak_ptr_factory_(this) { 377 weak_ptr_factory_(this) {
369 binding_.set_connection_error_handler( 378 binding_.set_connection_error_handler(
370 base::Bind(&WebSocketImpl::OnConnectionError, base::Unretained(this))); 379 base::Bind(&WebSocketImpl::OnConnectionError, base::Unretained(this)));
371 } 380 }
372 381
373 WebSocketImpl::~WebSocketImpl() {} 382 WebSocketImpl::~WebSocketImpl() {}
374 383
375 void WebSocketImpl::GoAway() { 384 void WebSocketImpl::GoAway() {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 net::HttpRequestHeaders::kUserAgent, 538 net::HttpRequestHeaders::kUserAgent,
530 user_agent_override.c_str()); 539 user_agent_override.c_str());
531 } 540 }
532 channel_->SendAddChannelRequest(socket_url, requested_protocols, origin, 541 channel_->SendAddChannelRequest(socket_url, requested_protocols, origin,
533 first_party_for_cookies, additional_headers); 542 first_party_for_cookies, additional_headers);
534 if (quota > 0) 543 if (quota > 0)
535 SendFlowControl(quota); 544 SendFlowControl(quota);
536 } 545 }
537 546
538 } // namespace content 547 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698