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

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

Issue 1153763002: Hardening the 'url::Origin' implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More. Created 5 years, 6 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
« no previous file with comments | « content/browser/frame_host/frame_tree_node.cc ('k') | content/child/websocket_bridge.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 } 343 }
344 344
345 void WebSocketHost::OnAddChannelRequest( 345 void WebSocketHost::OnAddChannelRequest(
346 const GURL& socket_url, 346 const GURL& socket_url,
347 const std::vector<std::string>& requested_protocols, 347 const std::vector<std::string>& requested_protocols,
348 const url::Origin& origin, 348 const url::Origin& origin,
349 int render_frame_id) { 349 int render_frame_id) {
350 DVLOG(3) << "WebSocketHost::OnAddChannelRequest" 350 DVLOG(3) << "WebSocketHost::OnAddChannelRequest"
351 << " routing_id=" << routing_id_ << " socket_url=\"" << socket_url 351 << " routing_id=" << routing_id_ << " socket_url=\"" << socket_url
352 << "\" requested_protocols=\"" 352 << "\" requested_protocols=\""
353 << JoinString(requested_protocols, ", ") << "\" origin=\"" 353 << JoinString(requested_protocols, ", ") << "\" origin=\"" << origin
354 << origin.string() << "\""; 354 << "\"";
355 355
356 DCHECK(!channel_); 356 DCHECK(!channel_);
357 if (delay_ > base::TimeDelta()) { 357 if (delay_ > base::TimeDelta()) {
358 base::MessageLoop::current()->PostDelayedTask( 358 base::MessageLoop::current()->PostDelayedTask(
359 FROM_HERE, 359 FROM_HERE,
360 base::Bind(&WebSocketHost::AddChannel, 360 base::Bind(&WebSocketHost::AddChannel,
361 weak_ptr_factory_.GetWeakPtr(), 361 weak_ptr_factory_.GetWeakPtr(),
362 socket_url, 362 socket_url,
363 requested_protocols, 363 requested_protocols,
364 origin, 364 origin,
365 render_frame_id), 365 render_frame_id),
366 delay_); 366 delay_);
367 } else { 367 } else {
368 AddChannel(socket_url, requested_protocols, origin, render_frame_id); 368 AddChannel(socket_url, requested_protocols, origin, render_frame_id);
369 } 369 }
370 // |this| may have been deleted here. 370 // |this| may have been deleted here.
371 } 371 }
372 372
373 void WebSocketHost::AddChannel( 373 void WebSocketHost::AddChannel(
374 const GURL& socket_url, 374 const GURL& socket_url,
375 const std::vector<std::string>& requested_protocols, 375 const std::vector<std::string>& requested_protocols,
376 const url::Origin& origin, 376 const url::Origin& origin,
377 int render_frame_id) { 377 int render_frame_id) {
378 DVLOG(3) << "WebSocketHost::AddChannel" 378 DVLOG(3) << "WebSocketHost::AddChannel"
379 << " routing_id=" << routing_id_ << " socket_url=\"" << socket_url 379 << " routing_id=" << routing_id_ << " socket_url=\"" << socket_url
380 << "\" requested_protocols=\"" 380 << "\" requested_protocols=\""
381 << JoinString(requested_protocols, ", ") << "\" origin=\"" 381 << JoinString(requested_protocols, ", ") << "\" origin=\"" << origin
382 << origin.string() << "\""; 382 << "\"";
383 383
384 DCHECK(!channel_); 384 DCHECK(!channel_);
385 385
386 scoped_ptr<net::WebSocketEventInterface> event_interface( 386 scoped_ptr<net::WebSocketEventInterface> event_interface(
387 new WebSocketEventHandler(dispatcher_, routing_id_, render_frame_id)); 387 new WebSocketEventHandler(dispatcher_, routing_id_, render_frame_id));
388 channel_.reset( 388 channel_.reset(
389 new net::WebSocketChannel(event_interface.Pass(), url_request_context_)); 389 new net::WebSocketChannel(event_interface.Pass(), url_request_context_));
390 390
391 if (pending_flow_control_quota_ > 0) { 391 if (pending_flow_control_quota_ > 0) {
392 // channel_->SendFlowControl(pending_flow_control_quota_) must be called 392 // channel_->SendFlowControl(pending_flow_control_quota_) must be called
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 ""); 449 "");
450 DCHECK_EQ(WebSocketDispatcherHost::WEBSOCKET_HOST_DELETED, result); 450 DCHECK_EQ(WebSocketDispatcherHost::WEBSOCKET_HOST_DELETED, result);
451 return; 451 return;
452 } 452 }
453 453
454 // TODO(yhirano): Handle |was_clean| appropriately. 454 // TODO(yhirano): Handle |was_clean| appropriately.
455 channel_->StartClosingHandshake(code, reason); 455 channel_->StartClosingHandshake(code, reason);
456 } 456 }
457 457
458 } // namespace content 458 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/frame_tree_node.cc ('k') | content/child/websocket_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698