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/location.h" | 8 #include "base/location.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 } | 346 } |
347 | 347 |
348 void WebSocketHost::OnAddChannelRequest( | 348 void WebSocketHost::OnAddChannelRequest( |
349 const GURL& socket_url, | 349 const GURL& socket_url, |
350 const std::vector<std::string>& requested_protocols, | 350 const std::vector<std::string>& requested_protocols, |
351 const url::DeprecatedSerializedOrigin& origin, | 351 const url::DeprecatedSerializedOrigin& origin, |
352 int render_frame_id) { | 352 int render_frame_id) { |
353 DVLOG(3) << "WebSocketHost::OnAddChannelRequest" | 353 DVLOG(3) << "WebSocketHost::OnAddChannelRequest" |
354 << " routing_id=" << routing_id_ << " socket_url=\"" << socket_url | 354 << " routing_id=" << routing_id_ << " socket_url=\"" << socket_url |
355 << "\" requested_protocols=\"" | 355 << "\" requested_protocols=\"" |
356 << JoinString(requested_protocols, ", ") << "\" origin=\"" | 356 << base::JoinString(requested_protocols, ", ") << "\" origin=\"" |
357 << origin.string() << "\""; | 357 << origin.string() << "\""; |
358 | 358 |
359 DCHECK(!channel_); | 359 DCHECK(!channel_); |
360 if (delay_ > base::TimeDelta()) { | 360 if (delay_ > base::TimeDelta()) { |
361 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 361 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
362 FROM_HERE, | 362 FROM_HERE, |
363 base::Bind(&WebSocketHost::AddChannel, weak_ptr_factory_.GetWeakPtr(), | 363 base::Bind(&WebSocketHost::AddChannel, weak_ptr_factory_.GetWeakPtr(), |
364 socket_url, requested_protocols, origin, render_frame_id), | 364 socket_url, requested_protocols, origin, render_frame_id), |
365 delay_); | 365 delay_); |
366 } else { | 366 } else { |
367 AddChannel(socket_url, requested_protocols, origin, render_frame_id); | 367 AddChannel(socket_url, requested_protocols, origin, render_frame_id); |
368 } | 368 } |
369 // |this| may have been deleted here. | 369 // |this| may have been deleted here. |
370 } | 370 } |
371 | 371 |
372 void WebSocketHost::AddChannel( | 372 void WebSocketHost::AddChannel( |
373 const GURL& socket_url, | 373 const GURL& socket_url, |
374 const std::vector<std::string>& requested_protocols, | 374 const std::vector<std::string>& requested_protocols, |
375 const url::DeprecatedSerializedOrigin& origin, | 375 const url::DeprecatedSerializedOrigin& origin, |
376 int render_frame_id) { | 376 int render_frame_id) { |
377 DVLOG(3) << "WebSocketHost::AddChannel" | 377 DVLOG(3) << "WebSocketHost::AddChannel" |
378 << " routing_id=" << routing_id_ << " socket_url=\"" << socket_url | 378 << " routing_id=" << routing_id_ << " socket_url=\"" << socket_url |
379 << "\" requested_protocols=\"" | 379 << "\" requested_protocols=\"" |
380 << JoinString(requested_protocols, ", ") << "\" origin=\"" | 380 << base::JoinString(requested_protocols, ", ") << "\" origin=\"" |
381 << origin.string() << "\""; | 381 << origin.string() << "\""; |
382 | 382 |
383 DCHECK(!channel_); | 383 DCHECK(!channel_); |
384 | 384 |
385 scoped_ptr<net::WebSocketEventInterface> event_interface( | 385 scoped_ptr<net::WebSocketEventInterface> event_interface( |
386 new WebSocketEventHandler(dispatcher_, routing_id_, render_frame_id)); | 386 new WebSocketEventHandler(dispatcher_, routing_id_, render_frame_id)); |
387 channel_.reset( | 387 channel_.reset( |
388 new net::WebSocketChannel(event_interface.Pass(), url_request_context_)); | 388 new net::WebSocketChannel(event_interface.Pass(), url_request_context_)); |
389 | 389 |
390 if (pending_flow_control_quota_ > 0) { | 390 if (pending_flow_control_quota_ > 0) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 ""); | 447 ""); |
448 DCHECK_EQ(WebSocketDispatcherHost::WEBSOCKET_HOST_DELETED, result); | 448 DCHECK_EQ(WebSocketDispatcherHost::WEBSOCKET_HOST_DELETED, result); |
449 return; | 449 return; |
450 } | 450 } |
451 | 451 |
452 // TODO(yhirano): Handle |was_clean| appropriately. | 452 // TODO(yhirano): Handle |was_clean| appropriately. |
453 channel_->StartClosingHandshake(code, reason); | 453 channel_->StartClosingHandshake(code, reason); |
454 } | 454 } |
455 | 455 |
456 } // namespace content | 456 } // namespace content |
OLD | NEW |