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

Side by Side Diff: content/browser/renderer_host/websocket_host.cc

Issue 2102993002: Fix WebSocket to set first party for cookies (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: a Created 4 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
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 <inttypes.h> 7 #include <inttypes.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 IPC_MESSAGE_HANDLER(WebSocketMsg_DropChannel, OnDropChannel) 392 IPC_MESSAGE_HANDLER(WebSocketMsg_DropChannel, OnDropChannel)
393 IPC_MESSAGE_UNHANDLED(handled = false) 393 IPC_MESSAGE_UNHANDLED(handled = false)
394 IPC_END_MESSAGE_MAP() 394 IPC_END_MESSAGE_MAP()
395 return handled; 395 return handled;
396 } 396 }
397 397
398 void WebSocketHost::OnAddChannelRequest( 398 void WebSocketHost::OnAddChannelRequest(
399 const GURL& socket_url, 399 const GURL& socket_url,
400 const std::vector<std::string>& requested_protocols, 400 const std::vector<std::string>& requested_protocols,
401 const url::Origin& origin, 401 const url::Origin& origin,
402 const GURL& first_party_for_cookies,
402 int render_frame_id) { 403 int render_frame_id) {
403 DVLOG(3) << "WebSocketHost::OnAddChannelRequest" 404 DVLOG(3) << "WebSocketHost::OnAddChannelRequest"
404 << " routing_id=" << routing_id_ << " socket_url=\"" << socket_url 405 << " routing_id=" << routing_id_ << " socket_url=\"" << socket_url
405 << "\" requested_protocols=\"" 406 << "\" requested_protocols=\""
406 << base::JoinString(requested_protocols, ", ") << "\" origin=\"" 407 << base::JoinString(requested_protocols, ", ") << "\" origin=\""
407 << origin << "\""; 408 << origin << "\" first_party_for_cookies=\""
409 << first_party_for_cookies << "\"";
408 410
409 DCHECK(!channel_); 411 DCHECK(!channel_);
410 if (delay_ > base::TimeDelta()) { 412 if (delay_ > base::TimeDelta()) {
411 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 413 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
412 FROM_HERE, 414 FROM_HERE,
413 base::Bind(&WebSocketHost::AddChannel, weak_ptr_factory_.GetWeakPtr(), 415 base::Bind(&WebSocketHost::AddChannel, weak_ptr_factory_.GetWeakPtr(),
414 socket_url, requested_protocols, origin, render_frame_id), 416 socket_url, requested_protocols, origin,
417 first_party_for_cookies, render_frame_id),
415 delay_); 418 delay_);
416 } else { 419 } else {
417 AddChannel(socket_url, requested_protocols, origin, render_frame_id); 420 AddChannel(
421 socket_url, requested_protocols, origin, first_party_for_cookies,
422 render_frame_id);
418 } 423 }
419 // |this| may have been deleted here. 424 // |this| may have been deleted here.
420 } 425 }
421 426
422 void WebSocketHost::AddChannel( 427 void WebSocketHost::AddChannel(
423 const GURL& socket_url, 428 const GURL& socket_url,
424 const std::vector<std::string>& requested_protocols, 429 const std::vector<std::string>& requested_protocols,
425 const url::Origin& origin, 430 const url::Origin& origin,
431 const GURL& first_party_for_cookies,
426 int render_frame_id) { 432 int render_frame_id) {
427 DVLOG(3) << "WebSocketHost::AddChannel" 433 DVLOG(3) << "WebSocketHost::AddChannel"
428 << " routing_id=" << routing_id_ << " socket_url=\"" << socket_url 434 << " routing_id=" << routing_id_ << " socket_url=\"" << socket_url
429 << "\" requested_protocols=\"" 435 << "\" requested_protocols=\""
430 << base::JoinString(requested_protocols, ", ") << "\" origin=\"" 436 << base::JoinString(requested_protocols, ", ") << "\" origin=\""
431 << origin << "\""; 437 << origin << "\" first_party_for_cookies=\""
438 << first_party_for_cookies << "\"";
432 439
433 DCHECK(!channel_); 440 DCHECK(!channel_);
434 441
435 std::unique_ptr<net::WebSocketEventInterface> event_interface( 442 std::unique_ptr<net::WebSocketEventInterface> event_interface(
436 new WebSocketEventHandler(dispatcher_, this, routing_id_, 443 new WebSocketEventHandler(dispatcher_, this, routing_id_,
437 render_frame_id)); 444 render_frame_id));
438 channel_.reset(new net::WebSocketChannel(std::move(event_interface), 445 channel_.reset(new net::WebSocketChannel(std::move(event_interface),
439 url_request_context_)); 446 url_request_context_));
440 447
441 if (pending_flow_control_quota_ > 0) { 448 if (pending_flow_control_quota_ > 0) {
442 // channel_->SendFlowControl(pending_flow_control_quota_) must be called 449 // channel_->SendFlowControl(pending_flow_control_quota_) must be called
443 // after channel_->SendAddChannelRequest() below. 450 // after channel_->SendAddChannelRequest() below.
444 // We post OnFlowControl() here using |weak_ptr_factory_| instead of 451 // We post OnFlowControl() here using |weak_ptr_factory_| instead of
445 // calling SendFlowControl directly, because |this| may have been deleted 452 // calling SendFlowControl directly, because |this| may have been deleted
446 // after channel_->SendAddChannelRequest(). 453 // after channel_->SendAddChannelRequest().
447 base::ThreadTaskRunnerHandle::Get()->PostTask( 454 base::ThreadTaskRunnerHandle::Get()->PostTask(
448 FROM_HERE, base::Bind(&WebSocketHost::OnFlowControl, 455 FROM_HERE, base::Bind(&WebSocketHost::OnFlowControl,
449 weak_ptr_factory_.GetWeakPtr(), 456 weak_ptr_factory_.GetWeakPtr(),
450 pending_flow_control_quota_)); 457 pending_flow_control_quota_));
451 pending_flow_control_quota_ = 0; 458 pending_flow_control_quota_ = 0;
452 } 459 }
453 460
454 channel_->SendAddChannelRequest(socket_url, requested_protocols, origin); 461 channel_->SendAddChannelRequest(
462 socket_url, requested_protocols, origin, first_party_for_cookies);
455 // |this| may have been deleted here. 463 // |this| may have been deleted here.
456 } 464 }
457 465
458 void WebSocketHost::OnSendBlob(const std::string& uuid, 466 void WebSocketHost::OnSendBlob(const std::string& uuid,
459 uint64_t expected_size) { 467 uint64_t expected_size) {
460 DVLOG(3) << "WebSocketHost::OnSendBlob" 468 DVLOG(3) << "WebSocketHost::OnSendBlob"
461 << " routing_id=" << routing_id_ << " uuid=" << uuid 469 << " routing_id=" << routing_id_ << " uuid=" << uuid
462 << " expected_size=" << expected_size; 470 << " expected_size=" << expected_size;
463 471
464 DCHECK(channel_); 472 DCHECK(channel_);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 default: 582 default:
575 ignore_result(dispatcher_->NotifyFailure( 583 ignore_result(dispatcher_->NotifyFailure(
576 routing_id_, 584 routing_id_,
577 "Failed to load Blob: error code = " + net::ErrorToString(result))); 585 "Failed to load Blob: error code = " + net::ErrorToString(result)));
578 // |this| is destroyed here. 586 // |this| is destroyed here.
579 return; 587 return;
580 } 588 }
581 } 589 }
582 590
583 } // namespace content 591 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698