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

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

Issue 23201008: Active WebSocket should send closing handshake to server on page navigation or page close (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing! Created 7 years, 4 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 | « LayoutTests/http/tests/websocket/tests/hybi/close-on-unload_wsh.py ('k') | 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 } 498 }
499 499
500 void WebSocket::stop() 500 void WebSocket::stop()
501 { 501 {
502 if (!hasPendingActivity()) { 502 if (!hasPendingActivity()) {
503 ASSERT(!m_channel); 503 ASSERT(!m_channel);
504 ASSERT(m_state == CLOSED); 504 ASSERT(m_state == CLOSED);
505 return; 505 return;
506 } 506 }
507 if (m_channel) { 507 if (m_channel) {
508 m_channel->close(WebSocketChannel::CloseEventCodeGoingAway, String());
508 m_channel->disconnect(); 509 m_channel->disconnect();
509 m_channel = 0; 510 m_channel = 0;
510 } 511 }
511 m_state = CLOSED; 512 m_state = CLOSED;
512 ActiveDOMObject::stop(); 513 ActiveDOMObject::stop();
513 ActiveDOMObject::unsetPendingActivity(this); 514 ActiveDOMObject::unsetPendingActivity(this);
514 } 515 }
515 516
516 void WebSocket::didConnect() 517 void WebSocket::didConnect()
517 { 518 {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 static const size_t minimumPayloadSizeWithEightByteExtendedPayloadLength = 0 x10000; 614 static const size_t minimumPayloadSizeWithEightByteExtendedPayloadLength = 0 x10000;
614 size_t overhead = hybiBaseFramingOverhead + hybiMaskingKeyLength; 615 size_t overhead = hybiBaseFramingOverhead + hybiMaskingKeyLength;
615 if (payloadSize >= minimumPayloadSizeWithEightByteExtendedPayloadLength) 616 if (payloadSize >= minimumPayloadSizeWithEightByteExtendedPayloadLength)
616 overhead += 8; 617 overhead += 8;
617 else if (payloadSize >= minimumPayloadSizeWithTwoByteExtendedPayloadLength) 618 else if (payloadSize >= minimumPayloadSizeWithTwoByteExtendedPayloadLength)
618 overhead += 2; 619 overhead += 2;
619 return overhead; 620 return overhead;
620 } 621 }
621 622
622 } // namespace WebCore 623 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/websocket/tests/hybi/close-on-unload_wsh.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698