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

Side by Side Diff: Source/modules/websockets/WebSocket.cpp

Issue 16385005: Avoid WebSocket::stop() being processed twice (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 } 482 }
483 483
484 void WebSocket::resume() 484 void WebSocket::resume()
485 { 485 {
486 if (m_channel) 486 if (m_channel)
487 m_channel->resume(); 487 m_channel->resume();
488 } 488 }
489 489
490 void WebSocket::stop() 490 void WebSocket::stop()
491 { 491 {
492 bool pending = hasPendingActivity(); 492 if (!hasPendingActivity()) {
493 if (m_channel) 493 ASSERT(!m_channel);
494 ASSERT(m_state == CLOSED);
495 return;
496 }
497 if (m_channel) {
494 m_channel->disconnect(); 498 m_channel->disconnect();
495 m_channel = 0; 499 m_channel = 0;
500 }
496 m_state = CLOSED; 501 m_state = CLOSED;
497 ActiveDOMObject::stop(); 502 ActiveDOMObject::stop();
498 if (pending) 503 ActiveDOMObject::unsetPendingActivity(this);
499 ActiveDOMObject::unsetPendingActivity(this);
500 } 504 }
501 505
502 void WebSocket::didConnect() 506 void WebSocket::didConnect()
503 { 507 {
504 LOG(Network, "WebSocket %p didConnect()", this); 508 LOG(Network, "WebSocket %p didConnect()", this);
505 if (m_state != CONNECTING) 509 if (m_state != CONNECTING)
506 return; 510 return;
507 ASSERT(scriptExecutionContext()); 511 ASSERT(scriptExecutionContext());
508 m_state = OPEN; 512 m_state = OPEN;
509 m_subprotocol = m_channel->subprotocol(); 513 m_subprotocol = m_channel->subprotocol();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 static const size_t minimumPayloadSizeWithEightByteExtendedPayloadLength = 0 x10000; 603 static const size_t minimumPayloadSizeWithEightByteExtendedPayloadLength = 0 x10000;
600 size_t overhead = hybiBaseFramingOverhead + hybiMaskingKeyLength; 604 size_t overhead = hybiBaseFramingOverhead + hybiMaskingKeyLength;
601 if (payloadSize >= minimumPayloadSizeWithEightByteExtendedPayloadLength) 605 if (payloadSize >= minimumPayloadSizeWithEightByteExtendedPayloadLength)
602 overhead += 8; 606 overhead += 8;
603 else if (payloadSize >= minimumPayloadSizeWithTwoByteExtendedPayloadLength) 607 else if (payloadSize >= minimumPayloadSizeWithTwoByteExtendedPayloadLength)
604 overhead += 2; 608 overhead += 2;
605 return overhead; 609 return overhead;
606 } 610 }
607 611
608 } // namespace WebCore 612 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698