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

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

Issue 2652973002: [scheduler] Plumb websocket information to scheduler (Closed)
Patch Set: Removed include Created 3 years, 10 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 28 matching lines...) Expand all
39 #include "core/frame/LocalFrame.h" 39 #include "core/frame/LocalFrame.h"
40 #include "core/inspector/ConsoleMessage.h" 40 #include "core/inspector/ConsoleMessage.h"
41 #include "core/inspector/InspectorInstrumentation.h" 41 #include "core/inspector/InspectorInstrumentation.h"
42 #include "core/loader/FrameLoader.h" 42 #include "core/loader/FrameLoader.h"
43 #include "core/loader/FrameLoaderClient.h" 43 #include "core/loader/FrameLoaderClient.h"
44 #include "core/loader/MixedContentChecker.h" 44 #include "core/loader/MixedContentChecker.h"
45 #include "modules/websockets/InspectorWebSocketEvents.h" 45 #include "modules/websockets/InspectorWebSocketEvents.h"
46 #include "modules/websockets/WebSocketChannelClient.h" 46 #include "modules/websockets/WebSocketChannelClient.h"
47 #include "modules/websockets/WebSocketFrame.h" 47 #include "modules/websockets/WebSocketFrame.h"
48 #include "modules/websockets/WebSocketHandleImpl.h" 48 #include "modules/websockets/WebSocketHandleImpl.h"
49 #include "platform/WebFrameScheduler.h"
49 #include "platform/network/NetworkLog.h" 50 #include "platform/network/NetworkLog.h"
50 #include "platform/network/WebSocketHandshakeRequest.h" 51 #include "platform/network/WebSocketHandshakeRequest.h"
51 #include "platform/weborigin/SecurityOrigin.h" 52 #include "platform/weborigin/SecurityOrigin.h"
52 #include "public/platform/InterfaceProvider.h" 53 #include "public/platform/InterfaceProvider.h"
53 #include "public/platform/Platform.h" 54 #include "public/platform/Platform.h"
54 #include "wtf/PtrUtil.h" 55 #include "wtf/PtrUtil.h"
55 #include <memory> 56 #include <memory>
56 57
57 namespace blink { 58 namespace blink {
58 59
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 m_client(client), 137 m_client(client),
137 m_identifier(createUniqueIdentifier()), 138 m_identifier(createUniqueIdentifier()),
138 m_document(document), 139 m_document(document),
139 m_sendingQuota(0), 140 m_sendingQuota(0),
140 m_receivedDataSizeForFlowControl( 141 m_receivedDataSizeForFlowControl(
141 receivedDataSizeForFlowControlHighWaterMark * 2), // initial quota 142 receivedDataSizeForFlowControlHighWaterMark * 2), // initial quota
142 m_sentSizeOfTopMessage(0), 143 m_sentSizeOfTopMessage(0),
143 m_locationAtConstruction(std::move(location)) {} 144 m_locationAtConstruction(std::move(location)) {}
144 145
145 DocumentWebSocketChannel::~DocumentWebSocketChannel() { 146 DocumentWebSocketChannel::~DocumentWebSocketChannel() {
146 DCHECK(!m_blobLoader); 147 DCHECK(!m_blobLoader);
alex clarke (OOO till 29th) 2017/01/24 18:15:33 How well do we understand the lifetime of this obj
altimin 2017/01/24 18:39:04 Done.
147 } 148 }
148 149
149 bool DocumentWebSocketChannel::connect(const KURL& url, 150 bool DocumentWebSocketChannel::connect(const KURL& url,
150 const String& protocol) { 151 const String& protocol) {
151 NETWORK_DVLOG(1) << this << " connect()"; 152 NETWORK_DVLOG(1) << this << " connect()";
152 if (!m_handle) 153 if (!m_handle)
153 return false; 154 return false;
154 155
155 if (document()->frame()) { 156 if (document()->frame()) {
156 if (MixedContentChecker::shouldBlockWebSocket(document()->frame(), url)) 157 if (MixedContentChecker::shouldBlockWebSocket(document()->frame(), url))
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 return m_document; 453 return m_document;
453 } 454 }
454 455
455 void DocumentWebSocketChannel::didConnect(WebSocketHandle* handle, 456 void DocumentWebSocketChannel::didConnect(WebSocketHandle* handle,
456 const String& selectedProtocol, 457 const String& selectedProtocol,
457 const String& extensions) { 458 const String& extensions) {
458 NETWORK_DVLOG(1) << this << " didConnect(" << handle << ", " 459 NETWORK_DVLOG(1) << this << " didConnect(" << handle << ", "
459 << String(selectedProtocol) << ", " << String(extensions) 460 << String(selectedProtocol) << ", " << String(extensions)
460 << ")"; 461 << ")";
461 462
463 if (document()->frame()) {
464 document()->frame()->frameScheduler()->didOpenWebSocket();
465 }
alex clarke (OOO till 29th) 2017/01/24 18:15:33 nit: although I prefer the google3 style braces I
altimin 2017/01/24 18:39:04 Acknowledged.
466
462 DCHECK(m_handle); 467 DCHECK(m_handle);
463 DCHECK_EQ(handle, m_handle.get()); 468 DCHECK_EQ(handle, m_handle.get());
464 DCHECK(m_client); 469 DCHECK(m_client);
465 470
466 m_client->didConnect(selectedProtocol, extensions); 471 m_client->didConnect(selectedProtocol, extensions);
467 } 472 }
468 473
469 void DocumentWebSocketChannel::didStartOpeningHandshake( 474 void DocumentWebSocketChannel::didStartOpeningHandshake(
470 WebSocketHandle* handle, 475 WebSocketHandle* handle,
471 PassRefPtr<WebSocketHandshakeRequest> request) { 476 PassRefPtr<WebSocketHandshakeRequest> request) {
(...skipping 24 matching lines...) Expand all
496 InspectorInstrumentation::didReceiveWebSocketHandshakeResponse( 501 InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(
497 document(), m_identifier, m_handshakeRequest.get(), response); 502 document(), m_identifier, m_handshakeRequest.get(), response);
498 m_handshakeRequest.clear(); 503 m_handshakeRequest.clear();
499 } 504 }
500 505
501 void DocumentWebSocketChannel::didFail(WebSocketHandle* handle, 506 void DocumentWebSocketChannel::didFail(WebSocketHandle* handle,
502 const String& message) { 507 const String& message) {
503 NETWORK_DVLOG(1) << this << " didFail(" << handle << ", " << String(message) 508 NETWORK_DVLOG(1) << this << " didFail(" << handle << ", " << String(message)
504 << ")"; 509 << ")";
505 510
511 if (document()->frame()) {
512 document()->frame()->frameScheduler()->didCloseWebSocket();
513 }
alex clarke (OOO till 29th) 2017/01/24 18:15:33 Ditto.
altimin 2017/01/24 18:39:04 Acknowledged.
514
506 DCHECK(m_handle); 515 DCHECK(m_handle);
507 DCHECK_EQ(handle, m_handle.get()); 516 DCHECK_EQ(handle, m_handle.get());
508 517
509 // This function is called when the browser is required to fail the 518 // This function is called when the browser is required to fail the
510 // WebSocketConnection. Hence we fail this channel by calling 519 // WebSocketConnection. Hence we fail this channel by calling
511 // |this->failAsError| function. 520 // |this->failAsError| function.
512 failAsError(message); 521 failAsError(message);
513 // |this| may be deleted. 522 // |this| may be deleted.
514 } 523 }
515 524
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 } 587 }
579 } 588 }
580 589
581 void DocumentWebSocketChannel::didClose(WebSocketHandle* handle, 590 void DocumentWebSocketChannel::didClose(WebSocketHandle* handle,
582 bool wasClean, 591 bool wasClean,
583 unsigned short code, 592 unsigned short code,
584 const String& reason) { 593 const String& reason) {
585 NETWORK_DVLOG(1) << this << " didClose(" << handle << ", " << wasClean << ", " 594 NETWORK_DVLOG(1) << this << " didClose(" << handle << ", " << wasClean << ", "
586 << code << ", " << String(reason) << ")"; 595 << code << ", " << String(reason) << ")";
587 596
597 if (document()->frame()) {
598 document()->frame()->frameScheduler()->didCloseWebSocket();
599 }
600
588 DCHECK(m_handle); 601 DCHECK(m_handle);
589 DCHECK_EQ(handle, m_handle.get()); 602 DCHECK_EQ(handle, m_handle.get());
590 603
591 m_handle.reset(); 604 m_handle.reset();
592 605
593 if (m_identifier) { 606 if (m_identifier) {
594 TRACE_EVENT_INSTANT1( 607 TRACE_EVENT_INSTANT1(
595 "devtools.timeline", "WebSocketDestroy", TRACE_EVENT_SCOPE_THREAD, 608 "devtools.timeline", "WebSocketDestroy", TRACE_EVENT_SCOPE_THREAD,
596 "data", InspectorWebSocketEvent::data(document(), m_identifier)); 609 "data", InspectorWebSocketEvent::data(document(), m_identifier));
597 InspectorInstrumentation::didCloseWebSocket(document(), m_identifier); 610 InspectorInstrumentation::didCloseWebSocket(document(), m_identifier);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 WebSocketChannel::trace(visitor); 670 WebSocketChannel::trace(visitor);
658 } 671 }
659 672
660 std::ostream& operator<<(std::ostream& ostream, 673 std::ostream& operator<<(std::ostream& ostream,
661 const DocumentWebSocketChannel* channel) { 674 const DocumentWebSocketChannel* channel) {
662 return ostream << "DocumentWebSocketChannel " 675 return ostream << "DocumentWebSocketChannel "
663 << static_cast<const void*>(channel); 676 << static_cast<const void*>(channel);
664 } 677 }
665 678
666 } // namespace blink 679 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698