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

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

Issue 2366253002: Remove ActiveDOMObject::stop() (Closed)
Patch Set: temp Created 4 years, 2 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 static const int32_t kBucketCountForMessageSizeHistogram = 50; 66 static const int32_t kBucketCountForMessageSizeHistogram = 50;
67 67
68 namespace blink { 68 namespace blink {
69 69
70 DOMWebSocket::EventQueue::EventQueue(EventTarget* target) 70 DOMWebSocket::EventQueue::EventQueue(EventTarget* target)
71 : m_state(Active), 71 : m_state(Active),
72 m_target(target), 72 m_target(target),
73 m_resumeTimer(this, &EventQueue::resumeTimerFired) {} 73 m_resumeTimer(this, &EventQueue::resumeTimerFired) {}
74 74
75 DOMWebSocket::EventQueue::~EventQueue() { 75 DOMWebSocket::EventQueue::~EventQueue() {
76 stop(); 76 contextDestroyed();
77 } 77 }
78 78
79 void DOMWebSocket::EventQueue::dispatch(Event* event) { 79 void DOMWebSocket::EventQueue::dispatch(Event* event) {
80 switch (m_state) { 80 switch (m_state) {
81 case Active: 81 case Active:
82 DCHECK(m_events.isEmpty()); 82 DCHECK(m_events.isEmpty());
83 DCHECK(m_target->getExecutionContext()); 83 DCHECK(m_target->getExecutionContext());
84 m_target->dispatchEvent(event); 84 m_target->dispatchEvent(event);
85 break; 85 break;
86 case Suspended: 86 case Suspended:
(...skipping 18 matching lines...) Expand all
105 m_state = Suspended; 105 m_state = Suspended;
106 } 106 }
107 107
108 void DOMWebSocket::EventQueue::resume() { 108 void DOMWebSocket::EventQueue::resume() {
109 if (m_state != Suspended || m_resumeTimer.isActive()) 109 if (m_state != Suspended || m_resumeTimer.isActive())
110 return; 110 return;
111 111
112 m_resumeTimer.startOneShot(0, BLINK_FROM_HERE); 112 m_resumeTimer.startOneShot(0, BLINK_FROM_HERE);
113 } 113 }
114 114
115 void DOMWebSocket::EventQueue::stop() { 115 void DOMWebSocket::EventQueue::contextDestroyed() {
116 if (m_state == Stopped) 116 if (m_state == Stopped)
117 return; 117 return;
118 118
119 m_state = Stopped; 119 m_state = Stopped;
120 m_resumeTimer.stop(); 120 m_resumeTimer.stop();
121 m_events.clear(); 121 m_events.clear();
122 } 122 }
123 123
124 void DOMWebSocket::EventQueue::dispatchQueuedEvents() { 124 void DOMWebSocket::EventQueue::dispatchQueuedEvents() {
125 if (m_state != Active) 125 if (m_state != Active)
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 const AtomicString& DOMWebSocket::interfaceName() const { 644 const AtomicString& DOMWebSocket::interfaceName() const {
645 return EventTargetNames::DOMWebSocket; 645 return EventTargetNames::DOMWebSocket;
646 } 646 }
647 647
648 ExecutionContext* DOMWebSocket::getExecutionContext() const { 648 ExecutionContext* DOMWebSocket::getExecutionContext() const {
649 return ActiveDOMObject::getExecutionContext(); 649 return ActiveDOMObject::getExecutionContext();
650 } 650 }
651 651
652 void DOMWebSocket::contextDestroyed() { 652 void DOMWebSocket::contextDestroyed() {
653 NETWORK_DVLOG(1) << "WebSocket " << this << " contextDestroyed()"; 653 NETWORK_DVLOG(1) << "WebSocket " << this << " contextDestroyed()";
654 DCHECK(!m_channel); 654 m_eventQueue->contextDestroyed();
655 DCHECK_EQ(kClosed, m_state); 655 if (m_channel) {
656 ActiveDOMObject::contextDestroyed(); 656 m_channel->close(WebSocketChannel::CloseEventCodeGoingAway, String());
657 releaseChannel();
658 }
659 if (m_state != kClosed) {
660 m_state = kClosed;
661 logBinaryTypeChangesAfterOpen();
662 }
657 } 663 }
658 664
659 bool DOMWebSocket::hasPendingActivity() const { 665 bool DOMWebSocket::hasPendingActivity() const {
660 return m_channel || !m_eventQueue->isEmpty(); 666 return m_channel || !m_eventQueue->isEmpty();
661 } 667 }
662 668
663 void DOMWebSocket::suspend() { 669 void DOMWebSocket::suspend() {
664 m_eventQueue->suspend(); 670 m_eventQueue->suspend();
665 } 671 }
666 672
667 void DOMWebSocket::resume() { 673 void DOMWebSocket::resume() {
668 m_eventQueue->resume(); 674 m_eventQueue->resume();
669 } 675 }
670 676
671 void DOMWebSocket::stop() {
672 m_eventQueue->stop();
673 if (m_channel) {
674 m_channel->close(WebSocketChannel::CloseEventCodeGoingAway, String());
675 releaseChannel();
676 }
677 if (m_state != kClosed) {
678 m_state = kClosed;
679 logBinaryTypeChangesAfterOpen();
680 }
681 }
682
683 void DOMWebSocket::didConnect(const String& subprotocol, 677 void DOMWebSocket::didConnect(const String& subprotocol,
684 const String& extensions) { 678 const String& extensions) {
685 NETWORK_DVLOG(1) << "WebSocket " << this << " didConnect()"; 679 NETWORK_DVLOG(1) << "WebSocket " << this << " didConnect()";
686 if (m_state != kConnecting) 680 if (m_state != kConnecting)
687 return; 681 return;
688 m_state = kOpen; 682 m_state = kOpen;
689 m_subprotocol = subprotocol; 683 m_subprotocol = subprotocol;
690 m_extensions = extensions; 684 m_extensions = extensions;
691 m_eventQueue->dispatch(Event::create(EventTypeNames::open)); 685 m_eventQueue->dispatch(Event::create(EventTypeNames::open));
692 } 686 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 856
863 DEFINE_TRACE(DOMWebSocket) { 857 DEFINE_TRACE(DOMWebSocket) {
864 visitor->trace(m_channel); 858 visitor->trace(m_channel);
865 visitor->trace(m_eventQueue); 859 visitor->trace(m_eventQueue);
866 WebSocketChannelClient::trace(visitor); 860 WebSocketChannelClient::trace(visitor);
867 EventTargetWithInlineData::trace(visitor); 861 EventTargetWithInlineData::trace(visitor);
868 ActiveDOMObject::trace(visitor); 862 ActiveDOMObject::trace(visitor);
869 } 863 }
870 864
871 } // namespace blink 865 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698