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

Side by Side Diff: third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp

Issue 2930263002: Add blink::WebSocketHandshakeThrottle (Closed)
Patch Set: Remove surplus include Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "modules/websockets/DocumentWebSocketChannel.h" 31 #include "modules/websockets/DocumentWebSocketChannel.h"
32 32
33 #include <memory>
34 #include "core/dom/DOMArrayBuffer.h" 33 #include "core/dom/DOMArrayBuffer.h"
35 #include "core/dom/ExecutionContext.h" 34 #include "core/dom/ExecutionContext.h"
36 #include "core/dom/TaskRunnerHelper.h" 35 #include "core/dom/TaskRunnerHelper.h"
37 #include "core/fileapi/FileReaderLoader.h" 36 #include "core/fileapi/FileReaderLoader.h"
38 #include "core/fileapi/FileReaderLoaderClient.h" 37 #include "core/fileapi/FileReaderLoaderClient.h"
39 #include "core/frame/LocalFrame.h" 38 #include "core/frame/LocalFrame.h"
40 #include "core/frame/LocalFrameClient.h" 39 #include "core/frame/LocalFrameClient.h"
40 #include "core/frame/WebLocalFrameBase.h"
41 #include "core/inspector/ConsoleMessage.h" 41 #include "core/inspector/ConsoleMessage.h"
42 #include "core/loader/DocumentLoader.h" 42 #include "core/loader/DocumentLoader.h"
43 #include "core/loader/FrameLoader.h" 43 #include "core/loader/FrameLoader.h"
44 #include "core/loader/MixedContentChecker.h" 44 #include "core/loader/MixedContentChecker.h"
45 #include "core/loader/SubresourceFilter.h" 45 #include "core/loader/SubresourceFilter.h"
46 #include "core/loader/ThreadableLoadingContext.h" 46 #include "core/loader/ThreadableLoadingContext.h"
47 #include "core/page/ChromeClient.h"
48 #include "core/page/Page.h"
47 #include "core/probe/CoreProbes.h" 49 #include "core/probe/CoreProbes.h"
48 #include "modules/websockets/InspectorWebSocketEvents.h" 50 #include "modules/websockets/InspectorWebSocketEvents.h"
49 #include "modules/websockets/WebSocketChannelClient.h" 51 #include "modules/websockets/WebSocketChannelClient.h"
50 #include "modules/websockets/WebSocketFrame.h" 52 #include "modules/websockets/WebSocketFrame.h"
51 #include "modules/websockets/WebSocketHandleImpl.h" 53 #include "modules/websockets/WebSocketHandleImpl.h"
52 #include "platform/WebFrameScheduler.h" 54 #include "platform/WebFrameScheduler.h"
53 #include "platform/WebTaskRunner.h" 55 #include "platform/WebTaskRunner.h"
54 #include "platform/loader/fetch/UniqueIdentifier.h" 56 #include "platform/loader/fetch/UniqueIdentifier.h"
55 #include "platform/network/NetworkLog.h" 57 #include "platform/network/NetworkLog.h"
56 #include "platform/network/WebSocketHandshakeRequest.h" 58 #include "platform/network/WebSocketHandshakeRequest.h"
57 #include "platform/weborigin/SecurityOrigin.h" 59 #include "platform/weborigin/SecurityOrigin.h"
58 #include "platform/wtf/Functional.h" 60 #include "platform/wtf/Functional.h"
59 #include "platform/wtf/PtrUtil.h" 61 #include "platform/wtf/PtrUtil.h"
60 #include "public/platform/InterfaceProvider.h" 62 #include "public/platform/InterfaceProvider.h"
61 #include "public/platform/Platform.h" 63 #include "public/platform/Platform.h"
64 #include "public/platform/WebSocketHandshakeThrottle.h"
62 #include "public/platform/WebTraceLocation.h" 65 #include "public/platform/WebTraceLocation.h"
66 #include "public/platform/WebURL.h"
63 67
64 namespace blink { 68 namespace blink {
65 69
66 class DocumentWebSocketChannel::BlobLoader final 70 class DocumentWebSocketChannel::BlobLoader final
67 : public GarbageCollectedFinalized<DocumentWebSocketChannel::BlobLoader>, 71 : public GarbageCollectedFinalized<DocumentWebSocketChannel::BlobLoader>,
68 public FileReaderLoaderClient { 72 public FileReaderLoaderClient {
69 public: 73 public:
70 BlobLoader(PassRefPtr<BlobDataHandle>, DocumentWebSocketChannel*); 74 BlobLoader(PassRefPtr<BlobDataHandle>, DocumentWebSocketChannel*);
71 ~BlobLoader() override {} 75 ~BlobLoader() override {}
72 76
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 channel_->DidFinishLoadingBlob(loader_->ArrayBufferResult()); 132 channel_->DidFinishLoadingBlob(loader_->ArrayBufferResult());
129 // |this| is deleted here. 133 // |this| is deleted here.
130 } 134 }
131 135
132 void DocumentWebSocketChannel::BlobLoader::DidFail( 136 void DocumentWebSocketChannel::BlobLoader::DidFail(
133 FileError::ErrorCode error_code) { 137 FileError::ErrorCode error_code) {
134 channel_->DidFailLoadingBlob(error_code); 138 channel_->DidFailLoadingBlob(error_code);
135 // |this| is deleted here. 139 // |this| is deleted here.
136 } 140 }
137 141
142 struct DocumentWebSocketChannel::ConnectInfo {
143 ConnectInfo(const String& selected_protocol, const String& extensions)
144 : selected_protocol(selected_protocol), extensions(extensions) {}
145
146 String selected_protocol;
yhirano 2017/06/13 09:14:39 const
Adam Rice 2017/06/13 12:53:42 Done.
147 String extensions;
yhirano 2017/06/13 09:14:39 ditto
Adam Rice 2017/06/13 12:53:42 Done.
148 };
149
150 // static
151 DocumentWebSocketChannel* DocumentWebSocketChannel::CreateForTesting(
152 Document* document,
153 WebSocketChannelClient* client,
154 std::unique_ptr<SourceLocation> location,
155 WebSocketHandle* handle,
156 std::unique_ptr<WebSocketHandshakeThrottle> handshake_throttle) {
157 return new DocumentWebSocketChannel(
158 ThreadableLoadingContext::Create(*document), client, std::move(location),
159 handle, std::move(handshake_throttle));
160 }
161
162 // static
163 DocumentWebSocketChannel* DocumentWebSocketChannel::Create(
164 ThreadableLoadingContext* loading_context,
165 WebSocketChannelClient* client,
166 std::unique_ptr<SourceLocation> location,
167 WebSocketHandle* handle) {
168 return new DocumentWebSocketChannel(
169 loading_context, client, std::move(location), handle,
170 Platform::Current()->CreateWebSocketHandshakeThrottle());
171 }
172
138 DocumentWebSocketChannel::DocumentWebSocketChannel( 173 DocumentWebSocketChannel::DocumentWebSocketChannel(
139 ThreadableLoadingContext* loading_context, 174 ThreadableLoadingContext* loading_context,
140 WebSocketChannelClient* client, 175 WebSocketChannelClient* client,
141 std::unique_ptr<SourceLocation> location, 176 std::unique_ptr<SourceLocation> location,
142 WebSocketHandle* handle) 177 WebSocketHandle* handle,
178 std::unique_ptr<WebSocketHandshakeThrottle> handshake_throttle)
143 : handle_(WTF::WrapUnique(handle ? handle : new WebSocketHandleImpl())), 179 : handle_(WTF::WrapUnique(handle ? handle : new WebSocketHandleImpl())),
144 client_(client), 180 client_(client),
145 identifier_(CreateUniqueIdentifier()), 181 identifier_(CreateUniqueIdentifier()),
146 loading_context_(loading_context), 182 loading_context_(loading_context),
147 sending_quota_(0), 183 sending_quota_(0),
148 received_data_size_for_flow_control_( 184 received_data_size_for_flow_control_(
149 kReceivedDataSizeForFlowControlHighWaterMark * 2), // initial quota 185 kReceivedDataSizeForFlowControlHighWaterMark * 2), // initial quota
150 sent_size_of_top_message_(0), 186 sent_size_of_top_message_(0),
151 location_at_construction_(std::move(location)) {} 187 location_at_construction_(std::move(location)),
188 handshake_throttle_(std::move(handshake_throttle)),
189 throttle_passed_(false) {}
152 190
153 DocumentWebSocketChannel::~DocumentWebSocketChannel() { 191 DocumentWebSocketChannel::~DocumentWebSocketChannel() {
154 DCHECK(!blob_loader_); 192 DCHECK(!blob_loader_);
155 } 193 }
156 194
157 bool DocumentWebSocketChannel::Connect(const KURL& url, 195 bool DocumentWebSocketChannel::Connect(const KURL& url,
158 const String& protocol) { 196 const String& protocol) {
159 NETWORK_DVLOG(1) << this << " connect()"; 197 NETWORK_DVLOG(1) << this << " connect()";
160 if (!handle_) 198 if (!handle_)
161 return false; 199 return false;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 // This is important so that the browser can show UI associated with 253 // This is important so that the browser can show UI associated with
216 // the WebSocket (e.g., for certificate errors). 254 // the WebSocket (e.g., for certificate errors).
217 handle_->Initialize(GetDocument()->GetFrame()->GetInterfaceProvider()); 255 handle_->Initialize(GetDocument()->GetFrame()->GetInterfaceProvider());
218 } else { 256 } else {
219 handle_->Initialize(Platform::Current()->GetInterfaceProvider()); 257 handle_->Initialize(Platform::Current()->GetInterfaceProvider());
220 } 258 }
221 handle_->Connect(url, protocols, loading_context_->GetSecurityOrigin(), 259 handle_->Connect(url, protocols, loading_context_->GetSecurityOrigin(),
222 loading_context_->FirstPartyForCookies(), 260 loading_context_->FirstPartyForCookies(),
223 loading_context_->UserAgent(), this); 261 loading_context_->UserAgent(), this);
224 262
263 // TODO(ricea): Maybe lookup GetDocument()->GetFrame() less often?
264 if (handshake_throttle_ && GetDocument() && GetDocument()->GetFrame() &&
265 GetDocument()->GetFrame()->GetPage()) {
266 // TODO(ricea): We may need to do something special here for SharedWorkers
267 // and ServiceWorkers
268 // TODO(ricea): Figure out who owns this WebFrame object and how long it can
269 // be expected to live.
270 LocalFrame* frame = GetDocument()->GetFrame();
271 WebLocalFrame* web_frame =
272 frame->GetPage()->GetChromeClient().GetWebLocalFrameBase(frame);
273 handshake_throttle_->ThrottleHandshake(url, web_frame, this);
274 } else {
275 // Treat no throttle as success.
276 throttle_passed_ = true;
277 }
278
225 FlowControlIfNecessary(); 279 FlowControlIfNecessary();
226 TRACE_EVENT_INSTANT1("devtools.timeline", "WebSocketCreate", 280 TRACE_EVENT_INSTANT1("devtools.timeline", "WebSocketCreate",
227 TRACE_EVENT_SCOPE_THREAD, "data", 281 TRACE_EVENT_SCOPE_THREAD, "data",
228 InspectorWebSocketCreateEvent::Data( 282 InspectorWebSocketCreateEvent::Data(
229 GetDocument(), identifier_, url, protocol)); 283 GetDocument(), identifier_, url, protocol));
230 probe::didCreateWebSocket(GetDocument(), identifier_, url, protocol); 284 probe::didCreateWebSocket(GetDocument(), identifier_, url, protocol);
231 return true; 285 return true;
232 } 286 }
233 287
234 void DocumentWebSocketChannel::Send(const CString& message) { 288 void DocumentWebSocketChannel::Send(const CString& message) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 void DocumentWebSocketChannel::Disconnect() { 388 void DocumentWebSocketChannel::Disconnect() {
335 NETWORK_DVLOG(1) << this << " disconnect()"; 389 NETWORK_DVLOG(1) << this << " disconnect()";
336 if (identifier_) { 390 if (identifier_) {
337 TRACE_EVENT_INSTANT1( 391 TRACE_EVENT_INSTANT1(
338 "devtools.timeline", "WebSocketDestroy", TRACE_EVENT_SCOPE_THREAD, 392 "devtools.timeline", "WebSocketDestroy", TRACE_EVENT_SCOPE_THREAD,
339 "data", InspectorWebSocketEvent::Data(GetDocument(), identifier_)); 393 "data", InspectorWebSocketEvent::Data(GetDocument(), identifier_));
340 probe::didCloseWebSocket(GetDocument(), identifier_); 394 probe::didCloseWebSocket(GetDocument(), identifier_);
341 } 395 }
342 connection_handle_for_scheduler_.reset(); 396 connection_handle_for_scheduler_.reset();
343 AbortAsyncOperations(); 397 AbortAsyncOperations();
398 handshake_throttle_.reset();
344 handle_.reset(); 399 handle_.reset();
345 client_ = nullptr; 400 client_ = nullptr;
346 identifier_ = 0; 401 identifier_ = 0;
347 } 402 }
348 403
349 DocumentWebSocketChannel::Message::Message(const CString& text) 404 DocumentWebSocketChannel::Message::Message(const CString& text)
350 : type(kMessageTypeText), text(text) {} 405 : type(kMessageTypeText), text(text) {}
351 406
352 DocumentWebSocketChannel::Message::Message( 407 DocumentWebSocketChannel::Message::Message(
353 PassRefPtr<BlobDataHandle> blob_data_handle) 408 PassRefPtr<BlobDataHandle> blob_data_handle)
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 break; 481 break;
427 case kMessageTypeBinaryAsCharVector: 482 case kMessageTypeBinaryAsCharVector:
428 SendInternal(WebSocketHandle::kMessageTypeBinary, 483 SendInternal(WebSocketHandle::kMessageTypeBinary,
429 message->vector_data->data(), message->vector_data->size(), 484 message->vector_data->data(), message->vector_data->size(),
430 &consumed_buffered_amount); 485 &consumed_buffered_amount);
431 break; 486 break;
432 case kMessageTypeClose: { 487 case kMessageTypeClose: {
433 // No message should be sent from now on. 488 // No message should be sent from now on.
434 DCHECK_EQ(messages_.size(), 1u); 489 DCHECK_EQ(messages_.size(), 1u);
435 DCHECK_EQ(sent_size_of_top_message_, 0u); 490 DCHECK_EQ(sent_size_of_top_message_, 0u);
491 handshake_throttle_.reset();
436 handle_->Close(message->code, message->reason); 492 handle_->Close(message->code, message->reason);
437 messages_.pop_front(); 493 messages_.pop_front();
438 break; 494 break;
439 } 495 }
440 } 496 }
441 } 497 }
442 if (client_ && consumed_buffered_amount > 0) 498 if (client_ && consumed_buffered_amount > 0)
443 client_->DidConsumeBufferedAmount(consumed_buffered_amount); 499 client_->DidConsumeBufferedAmount(consumed_buffered_amount);
444 } 500 }
445 501
446 void DocumentWebSocketChannel::FlowControlIfNecessary() { 502 void DocumentWebSocketChannel::FlowControlIfNecessary() {
447 if (!handle_ || received_data_size_for_flow_control_ < 503 if (!handle_ || received_data_size_for_flow_control_ <
448 kReceivedDataSizeForFlowControlHighWaterMark) { 504 kReceivedDataSizeForFlowControlHighWaterMark) {
449 return; 505 return;
450 } 506 }
451 handle_->FlowControl(received_data_size_for_flow_control_); 507 handle_->FlowControl(received_data_size_for_flow_control_);
452 received_data_size_for_flow_control_ = 0; 508 received_data_size_for_flow_control_ = 0;
453 } 509 }
454 510
455 void DocumentWebSocketChannel::AbortAsyncOperations() { 511 void DocumentWebSocketChannel::AbortAsyncOperations() {
456 if (blob_loader_) { 512 if (blob_loader_) {
457 blob_loader_->Cancel(); 513 blob_loader_->Cancel();
458 blob_loader_.Clear(); 514 blob_loader_.Clear();
459 } 515 }
460 } 516 }
461 517
462 void DocumentWebSocketChannel::HandleDidClose(bool was_clean, 518 void DocumentWebSocketChannel::HandleDidClose(bool was_clean,
463 unsigned short code, 519 unsigned short code,
464 const String& reason) { 520 const String& reason) {
521 handshake_throttle_.reset();
465 handle_.reset(); 522 handle_.reset();
466 AbortAsyncOperations(); 523 AbortAsyncOperations();
467 if (!client_) { 524 if (!client_) {
468 return; 525 return;
469 } 526 }
470 WebSocketChannelClient* client = client_; 527 WebSocketChannelClient* client = client_;
471 client_ = nullptr; 528 client_ = nullptr;
472 WebSocketChannelClient::ClosingHandshakeCompletionStatus status = 529 WebSocketChannelClient::ClosingHandshakeCompletionStatus status =
473 was_clean ? WebSocketChannelClient::kClosingHandshakeComplete 530 was_clean ? WebSocketChannelClient::kClosingHandshakeComplete
474 : WebSocketChannelClient::kClosingHandshakeIncomplete; 531 : WebSocketChannelClient::kClosingHandshakeIncomplete;
(...skipping 13 matching lines...) Expand all
488 const String& selected_protocol, 545 const String& selected_protocol,
489 const String& extensions) { 546 const String& extensions) {
490 NETWORK_DVLOG(1) << this << " didConnect(" << handle << ", " 547 NETWORK_DVLOG(1) << this << " didConnect(" << handle << ", "
491 << String(selected_protocol) << ", " << String(extensions) 548 << String(selected_protocol) << ", " << String(extensions)
492 << ")"; 549 << ")";
493 550
494 DCHECK(handle_); 551 DCHECK(handle_);
495 DCHECK_EQ(handle, handle_.get()); 552 DCHECK_EQ(handle, handle_.get());
496 DCHECK(client_); 553 DCHECK(client_);
497 554
555 if (!throttle_passed_) {
556 connect_info_ = WTF::MakeUnique<ConnectInfo>(selected_protocol, extensions);
557 return;
558 }
559
560 handshake_throttle_.reset();
561
498 client_->DidConnect(selected_protocol, extensions); 562 client_->DidConnect(selected_protocol, extensions);
499 } 563 }
500 564
501 void DocumentWebSocketChannel::DidStartOpeningHandshake( 565 void DocumentWebSocketChannel::DidStartOpeningHandshake(
502 WebSocketHandle* handle, 566 WebSocketHandle* handle,
503 PassRefPtr<WebSocketHandshakeRequest> request) { 567 PassRefPtr<WebSocketHandshakeRequest> request) {
504 NETWORK_DVLOG(1) << this << " didStartOpeningHandshake(" << handle << ")"; 568 NETWORK_DVLOG(1) << this << " didStartOpeningHandshake(" << handle << ")";
505 569
506 DCHECK(handle_); 570 DCHECK(handle_);
507 DCHECK_EQ(handle, handle_.get()); 571 DCHECK_EQ(handle, handle_.get());
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 WebSocketHandle* handle) { 727 WebSocketHandle* handle) {
664 NETWORK_DVLOG(1) << this << " didStartClosingHandshake(" << handle << ")"; 728 NETWORK_DVLOG(1) << this << " didStartClosingHandshake(" << handle << ")";
665 729
666 DCHECK(handle_); 730 DCHECK(handle_);
667 DCHECK_EQ(handle, handle_.get()); 731 DCHECK_EQ(handle, handle_.get());
668 732
669 if (client_) 733 if (client_)
670 client_->DidStartClosingHandshake(); 734 client_->DidStartClosingHandshake();
671 } 735 }
672 736
737 void DocumentWebSocketChannel::OnSuccess() {
yhirano 2017/06/13 09:14:39 DCHECK(!throttle_passed);
Adam Rice 2017/06/13 12:53:42 Done. I also added a check that handshake_throttle
738 throttle_passed_ = true;
739 handshake_throttle_ = nullptr;
740 if (connect_info_) {
741 client_->DidConnect(std::move(connect_info_->selected_protocol),
742 std::move(connect_info_->extensions));
743 connect_info_.reset();
744 }
745 }
746
747 void DocumentWebSocketChannel::OnError(const WebString& console_message) {
yhirano 2017/06/13 09:14:39 DCHECK(!throttle_passed);
Adam Rice 2017/06/13 12:53:42 Done.
748 handshake_throttle_ = nullptr;
749 FailAsError(console_message);
750 }
751
673 void DocumentWebSocketChannel::DidFinishLoadingBlob(DOMArrayBuffer* buffer) { 752 void DocumentWebSocketChannel::DidFinishLoadingBlob(DOMArrayBuffer* buffer) {
674 blob_loader_.Clear(); 753 blob_loader_.Clear();
675 DCHECK(handle_); 754 DCHECK(handle_);
676 // The loaded blob is always placed on m_messages[0]. 755 // The loaded blob is always placed on m_messages[0].
677 DCHECK_GT(messages_.size(), 0u); 756 DCHECK_GT(messages_.size(), 0u);
678 DCHECK_EQ(messages_.front()->type, kMessageTypeBlob); 757 DCHECK_EQ(messages_.front()->type, kMessageTypeBlob);
679 // We replace it with the loaded blob. 758 // We replace it with the loaded blob.
680 messages_.front() = new Message(buffer); 759 messages_.front() = new Message(buffer);
681 ProcessSendQueue(); 760 ProcessSendQueue();
682 } 761 }
683 762
684 void DocumentWebSocketChannel::DidFailLoadingBlob( 763 void DocumentWebSocketChannel::DidFailLoadingBlob(
685 FileError::ErrorCode error_code) { 764 FileError::ErrorCode error_code) {
686 blob_loader_.Clear(); 765 blob_loader_.Clear();
687 if (error_code == FileError::kAbortErr) { 766 if (error_code == FileError::kAbortErr) {
688 // The error is caused by cancel(). 767 // The error is caused by cancel().
689 return; 768 return;
690 } 769 }
691 // FIXME: Generate human-friendly reason message. 770 // FIXME: Generate human-friendly reason message.
692 FailAsError("Failed to load Blob: error code = " + 771 FailAsError("Failed to load Blob: error code = " +
693 String::Number(error_code)); 772 String::Number(error_code));
694 // |this| can be deleted here. 773 // |this| can be deleted here.
695 } 774 }
696 775
697 void DocumentWebSocketChannel::TearDownFailedConnection() { 776 void DocumentWebSocketChannel::TearDownFailedConnection() {
698 // m_handle and m_client can be null here. 777 // m_handle and m_client can be null here.
699 connection_handle_for_scheduler_.reset(); 778 connection_handle_for_scheduler_.reset();
779 handshake_throttle_.reset();
700 780
701 if (client_) 781 if (client_)
702 client_->DidError(); 782 client_->DidError();
703 783
704 HandleDidClose(false, kCloseEventCodeAbnormalClosure, String()); 784 HandleDidClose(false, kCloseEventCodeAbnormalClosure, String());
705 // handleDidClose may delete this object. 785 // handleDidClose may delete this object.
706 } 786 }
707 787
708 bool DocumentWebSocketChannel::ShouldDisallowConnection(const KURL& url) { 788 bool DocumentWebSocketChannel::ShouldDisallowConnection(const KURL& url) {
709 DCHECK(handle_); 789 DCHECK(handle_);
(...skipping 14 matching lines...) Expand all
724 WebSocketChannel::Trace(visitor); 804 WebSocketChannel::Trace(visitor);
725 } 805 }
726 806
727 std::ostream& operator<<(std::ostream& ostream, 807 std::ostream& operator<<(std::ostream& ostream,
728 const DocumentWebSocketChannel* channel) { 808 const DocumentWebSocketChannel* channel) {
729 return ostream << "DocumentWebSocketChannel " 809 return ostream << "DocumentWebSocketChannel "
730 << static_cast<const void*>(channel); 810 << static_cast<const void*>(channel);
731 } 811 }
732 812
733 } // namespace blink 813 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698