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

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

Issue 36033003: Notify WebSocket connection failure, Blink side (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 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) 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 22 matching lines...) Expand all
33 33
34 #include "core/dom/ContextLifecycleObserver.h" 34 #include "core/dom/ContextLifecycleObserver.h"
35 #include "core/dom/ExecutionContext.h" 35 #include "core/dom/ExecutionContext.h"
36 #include "core/fileapi/Blob.h" 36 #include "core/fileapi/Blob.h"
37 #include "core/fileapi/FileError.h" 37 #include "core/fileapi/FileError.h"
38 #include "core/fileapi/FileReaderLoader.h" 38 #include "core/fileapi/FileReaderLoader.h"
39 #include "core/fileapi/FileReaderLoaderClient.h" 39 #include "core/fileapi/FileReaderLoaderClient.h"
40 #include "modules/websockets/WebSocketChannel.h" 40 #include "modules/websockets/WebSocketChannel.h"
41 #include "modules/websockets/WebSocketChannelClient.h" 41 #include "modules/websockets/WebSocketChannelClient.h"
42 #include "platform/Logging.h" 42 #include "platform/Logging.h"
43 #include "platform/NotImplemented.h"
43 #include "public/platform/Platform.h" 44 #include "public/platform/Platform.h"
44 #include "public/platform/WebSocketHandle.h" 45 #include "public/platform/WebSocketHandle.h"
45 #include "public/platform/WebString.h" 46 #include "public/platform/WebString.h"
46 #include "public/platform/WebURL.h" 47 #include "public/platform/WebURL.h"
47 #include "public/platform/WebVector.h" 48 #include "public/platform/WebVector.h"
48 #include "weborigin/SecurityOrigin.h" 49 #include "weborigin/SecurityOrigin.h"
49 #include "wtf/ArrayBuffer.h" 50 #include "wtf/ArrayBuffer.h"
50 #include "wtf/Vector.h" 51 #include "wtf/Vector.h"
51 #include "wtf/text/WTFString.h" 52 #include "wtf/text/WTFString.h"
52 53
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 } else { 353 } else {
353 handleDidClose(CloseEventCodeAbnormalClosure, reason); 354 handleDidClose(CloseEventCodeAbnormalClosure, reason);
354 // handleDidClose may delete this object. 355 // handleDidClose may delete this object.
355 } 356 }
356 } 357 }
357 358
358 void NewWebSocketChannelImpl::disconnect() 359 void NewWebSocketChannelImpl::disconnect()
359 { 360 {
360 LOG(Network, "NewWebSocketChannelImpl %p disconnect()", this); 361 LOG(Network, "NewWebSocketChannelImpl %p disconnect()", this);
361 abortAsyncOperations(); 362 abortAsyncOperations();
362 if (m_handle)
363 m_handle->close(CloseEventCodeAbnormalClosure, "");
364 m_handle.clear(); 363 m_handle.clear();
365 m_client = 0; 364 m_client = 0;
366 } 365 }
367 366
368 void NewWebSocketChannelImpl::suspend() 367 void NewWebSocketChannelImpl::suspend()
369 { 368 {
370 LOG(Network, "NewWebSocketChannelImpl %p suspend()", this); 369 LOG(Network, "NewWebSocketChannelImpl %p suspend()", this);
371 m_resumer->suspend(); 370 m_resumer->suspend();
372 } 371 }
373 372
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 return; 518 return;
520 } 519 }
521 m_subprotocol = selectedProtocol; 520 m_subprotocol = selectedProtocol;
522 m_extensions = extensions; 521 m_extensions = extensions;
523 if (m_isSuspended) 522 if (m_isSuspended)
524 m_resumer->append(PendingEvent(PendingEvent::DidConnectComplete)); 523 m_resumer->append(PendingEvent(PendingEvent::DidConnectComplete));
525 else 524 else
526 m_client->didConnect(); 525 m_client->didConnect();
527 } 526 }
528 527
528 void NewWebSocketChannelImpl::didFail(WebSocketHandle* handle, const WebKit::Web String& message)
529 {
530 LOG(Network, "NewWebSocketChannelImpl %p didFail(%p, %s)", this, handle, mes sage.utf8().data());
531 notImplemented();
532 }
533
529 void NewWebSocketChannelImpl::didReceiveData(WebSocketHandle* handle, bool fin, WebSocketHandle::MessageType type, const char* data, size_t size) 534 void NewWebSocketChannelImpl::didReceiveData(WebSocketHandle* handle, bool fin, WebSocketHandle::MessageType type, const char* data, size_t size)
530 { 535 {
531 LOG(Network, "NewWebSocketChannelImpl %p didReceiveData(%p, %d, %d, (%p, %zu ))", this, handle, fin, type, data, size); 536 LOG(Network, "NewWebSocketChannelImpl %p didReceiveData(%p, %d, %d, (%p, %zu ))", this, handle, fin, type, data, size);
532 ASSERT(m_handle); 537 ASSERT(m_handle);
533 ASSERT(handle == m_handle); 538 ASSERT(handle == m_handle);
534 ASSERT(m_client); 539 ASSERT(m_client);
535 // Non-final frames cannot be empty. 540 // Non-final frames cannot be empty.
536 ASSERT(fin || size); 541 ASSERT(fin || size);
537 switch (type) { 542 switch (type) {
538 case WebSocketHandle::MessageTypeText: 543 case WebSocketHandle::MessageTypeText:
(...skipping 24 matching lines...) Expand all
563 messageData.swap(m_receivingMessageData); 568 messageData.swap(m_receivingMessageData);
564 if (m_receivingMessageTypeIsText) { 569 if (m_receivingMessageTypeIsText) {
565 handleTextMessage(&messageData); 570 handleTextMessage(&messageData);
566 // handleTextMessage may delete this object. 571 // handleTextMessage may delete this object.
567 } else { 572 } else {
568 handleBinaryMessage(&messageData); 573 handleBinaryMessage(&messageData);
569 } 574 }
570 } 575 }
571 576
572 577
573 void NewWebSocketChannelImpl::didClose(WebSocketHandle* handle, unsigned short c ode, const WebKit::WebString& reason) 578 void NewWebSocketChannelImpl::didClose(WebSocketHandle* handle, bool wasClean, u nsigned short code, const WebKit::WebString& reason)
574 { 579 {
575 LOG(Network, "NewWebSocketChannelImpl %p didClose(%p, %u, %s)", this, handle , code, String(reason).utf8().data()); 580 // FIXME: Use |wasClean| appropriately.
581 LOG(Network, "NewWebSocketChannelImpl %p didClose(%p, %d, %u, %s)", this, ha ndle, wasClean, code, String(reason).utf8().data());
576 ASSERT(m_handle); 582 ASSERT(m_handle);
577 m_handle.clear(); 583 m_handle.clear();
578 // FIXME: Maybe we should notify an error to m_client for some didClose mess ages. 584 // FIXME: Maybe we should notify an error to m_client for some didClose mess ages.
579 if (m_isSuspended) { 585 if (m_isSuspended) {
580 m_resumer->append(PendingEvent(code, reason)); 586 m_resumer->append(PendingEvent(code, reason));
581 } else { 587 } else {
582 handleDidClose(code, reason); 588 handleDidClose(code, reason);
583 // handleDidClose may delete this object. 589 // handleDidClose may delete this object.
584 } 590 }
585 } 591 }
(...skipping 15 matching lines...) Expand all
601 if (errorCode == FileError::ABORT_ERR) { 607 if (errorCode == FileError::ABORT_ERR) {
602 // The error is caused by cancel(). 608 // The error is caused by cancel().
603 return; 609 return;
604 } 610 }
605 // FIXME: Generate human-friendly reason message. 611 // FIXME: Generate human-friendly reason message.
606 failAsError("Failed to load Blob: error code = " + String::number(errorCode) ); 612 failAsError("Failed to load Blob: error code = " + String::number(errorCode) );
607 // |this| can be deleted here. 613 // |this| can be deleted here.
608 } 614 }
609 615
610 } // namespace WebCore 616 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698