Changeset 74390 in webkit


Ignore:
Timestamp:
Dec 20, 2010 9:44:07 PM (13 years ago)
Author:
yutak@chromium.org
Message:

2010-12-20 Yuta Kitamura <yutak@chromium.org>

Reviewed by Alexey Proskuryakov.

WebSocket errors should be logged to console
https://bugs.webkit.org/show_bug.cgi?id=40945

  • http/tests/inspector/console-websocket-error.html: Added.
  • platform/mac/http/tests/inspector/console-websocket-error-expected.txt: Added.
  • platform/win/Skipped: Added console-websocket-error.html because HTTPS server is not supported on Windows yet.

2010-12-20 Yuta Kitamura <yutak@chromium.org>

Reviewed by Alexey Proskuryakov.

WebSocket errors should be logged to console
https://bugs.webkit.org/show_bug.cgi?id=40945

Test: http/tests/inspector/console-websocket-error.html

  • platform/network/SocketStreamErrorBase.cpp: (WebCore::SocketStreamErrorBase::compare):
  • platform/network/SocketStreamErrorBase.h: (WebCore::SocketStreamErrorBase::failingURL): (WebCore::SocketStreamErrorBase::localizedDescription): (WebCore::SocketStreamErrorBase::SocketStreamErrorBase):
  • platform/network/cf/SocketStreamError.h: (WebCore::SocketStreamError::SocketStreamError):
  • platform/network/cf/SocketStreamHandle.h:
  • platform/network/cf/SocketStreamHandleCFNet.cpp: (WebCore::SocketStreamHandle::readStreamCallback): (WebCore::SocketStreamHandle::writeStreamCallback): (WebCore::SocketStreamHandle::reportErrorToClient):
  • websockets/WebSocketChannel.cpp: (WebCore::WebSocketChannel::didFail):
Location:
trunk
Files:
3 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r74389 r74390  
     12010-12-20  Yuta Kitamura  <yutak@chromium.org>
     2
     3        Reviewed by Alexey Proskuryakov.
     4
     5        WebSocket errors should be logged to console
     6        https://bugs.webkit.org/show_bug.cgi?id=40945
     7
     8        * http/tests/inspector/console-websocket-error.html: Added.
     9        * platform/mac/http/tests/inspector/console-websocket-error-expected.txt: Added.
     10        * platform/win/Skipped: Added console-websocket-error.html
     11        because HTTPS server is not supported on Windows yet.
     12
    1132010-12-20  Sheriff Bot  <webkit.review.bot@gmail.com>
    214
  • trunk/LayoutTests/platform/win/Skipped

    r74270 r74390  
    4343http/tests/security/cross-frame-access-protocol-explicit-domain.html
    4444http/tests/security/cross-frame-access-protocol.html
     45http/tests/inspector/console-websocket-error.html
    4546
    4647# Fails <rdar://problem/5674289>
  • trunk/WebCore/ChangeLog

    r74386 r74390  
     12010-12-20  Yuta Kitamura  <yutak@chromium.org>
     2
     3        Reviewed by Alexey Proskuryakov.
     4
     5        WebSocket errors should be logged to console
     6        https://bugs.webkit.org/show_bug.cgi?id=40945
     7
     8        Test: http/tests/inspector/console-websocket-error.html
     9
     10        * platform/network/SocketStreamErrorBase.cpp:
     11        (WebCore::SocketStreamErrorBase::compare):
     12        * platform/network/SocketStreamErrorBase.h:
     13        (WebCore::SocketStreamErrorBase::failingURL):
     14        (WebCore::SocketStreamErrorBase::localizedDescription):
     15        (WebCore::SocketStreamErrorBase::SocketStreamErrorBase):
     16        * platform/network/cf/SocketStreamError.h:
     17        (WebCore::SocketStreamError::SocketStreamError):
     18        * platform/network/cf/SocketStreamHandle.h:
     19        * platform/network/cf/SocketStreamHandleCFNet.cpp:
     20        (WebCore::SocketStreamHandle::readStreamCallback):
     21        (WebCore::SocketStreamHandle::writeStreamCallback):
     22        (WebCore::SocketStreamHandle::reportErrorToClient):
     23        * websockets/WebSocketChannel.cpp:
     24        (WebCore::WebSocketChannel::didFail):
     25
    1262010-12-17  MORITA Hajime  <morrita@google.com>
    227
  • trunk/WebCore/platform/network/SocketStreamErrorBase.cpp

    r47788 r74390  
    4343bool SocketStreamErrorBase::compare(const SocketStreamError& a, const SocketStreamError& b)
    4444{
    45     return a.errorCode() == b.errorCode();
     45    if (a.isNull() && b.isNull())
     46        return true;
     47
     48    if (a.isNull() || b.isNull())
     49        return false;
     50
     51    if (a.errorCode() != b.errorCode())
     52        return false;
     53
     54    if (a.failingURL() != b.failingURL())
     55        return false;
     56
     57    if (a.localizedDescription() != b.localizedDescription())
     58        return false;
     59
     60    return true;
    4661}
    4762
  • trunk/WebCore/platform/network/SocketStreamErrorBase.h

    r47788 r74390  
    3333#define SocketStreamErrorBase_h
    3434
     35#include "PlatformString.h"
     36
    3537namespace WebCore {
    3638
     
    4547
    4648        int errorCode() const { return m_errorCode; }
     49        const String& failingURL() const { return m_failingURL; }
     50        const String& localizedDescription() const { return m_localizedDescription; }
    4751
    4852        static bool compare(const SocketStreamError&, const SocketStreamError&);
     
    6165        }
    6266
     67        SocketStreamErrorBase(int errorCode, const String& failingURL, const String& localizedDescription)
     68            : m_errorCode(errorCode)
     69            , m_failingURL(failingURL)
     70            , m_localizedDescription(localizedDescription)
     71            , m_isNull(false)
     72        {
     73        }
     74
    6375        int m_errorCode;
     76        String m_failingURL;
     77        String m_localizedDescription;
    6478        bool m_isNull;
    6579    };
  • trunk/WebCore/platform/network/cf/SocketStreamError.h

    r70339 r74390  
    4343    {
    4444    }
    45 
     45    SocketStreamError(int errorCode, const String& failingURL, const String& localizedDescription)
     46        : SocketStreamErrorBase(errorCode, failingURL, localizedDescription)
     47    {
     48    }
    4649};
    4750
  • trunk/WebCore/platform/network/cf/SocketStreamHandle.h

    r70339 r74390  
    8585    void writeStreamCallback(CFStreamEventType);
    8686
     87#ifndef BUILDING_ON_TIGER
     88    void reportErrorToClient(CFErrorRef);
     89#endif
     90
    8791    // No authentication for streams per se, but proxy may ask for credentials.
    8892    virtual void receivedCredential(const AuthenticationChallenge&, const Credential&);
  • trunk/WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp

    r72498 r74390  
    4040#include "SocketStreamHandleClient.h"
    4141#include <wtf/MainThread.h>
     42#include <wtf/text/StringConcatenate.h>
    4243
    4344#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD)
     
    531532        break;
    532533    case kCFStreamEventErrorOccurred: {
     534#ifndef BUILDING_ON_TIGER
     535        RetainPtr<CFErrorRef> error(AdoptCF, CFReadStreamCopyError(m_readStream.get()));
     536        reportErrorToClient(error.get());
     537#else
    533538        CFStreamError error = CFReadStreamGetError(m_readStream.get());
    534539        m_client->didFail(this, SocketStreamError(error.error)); // FIXME: Provide a sensible error.
     540#endif
    535541        break;
    536542    }
     
    575581    }
    576582    case kCFStreamEventErrorOccurred: {
     583#ifndef BUILDING_ON_TIGER
     584        RetainPtr<CFErrorRef> error(AdoptCF, CFWriteStreamCopyError(m_writeStream.get()));
     585        reportErrorToClient(error.get());
     586#else
    577587        CFStreamError error = CFWriteStreamGetError(m_writeStream.get());
    578588        m_client->didFail(this, SocketStreamError(error.error)); // FIXME: Provide a sensible error.
     589#endif
    579590        break;
    580591    }
     
    584595    }
    585596}
     597
     598#ifndef BUILDING_ON_TIGER
     599void SocketStreamHandle::reportErrorToClient(CFErrorRef error)
     600{
     601    CFIndex errorCode = CFErrorGetCode(error);
     602    String description;
     603
     604#if PLATFORM(MAC)
     605    if (CFEqual(CFErrorGetDomain(error), kCFErrorDomainOSStatus)) {
     606        const char* descriptionOSStatus = GetMacOSStatusCommentString(static_cast<OSStatus>(errorCode));
     607        if (descriptionOSStatus && descriptionOSStatus[0] != '\0')
     608            description = makeString("OSStatus Error ", String::number(errorCode), ": ", descriptionOSStatus);
     609    }
     610#endif
     611
     612    if (description.isNull()) {
     613        RetainPtr<CFStringRef> descriptionCF(AdoptCF, CFErrorCopyDescription(error));
     614        description = String(descriptionCF.get());
     615    }
     616
     617    m_client->didFail(this, SocketStreamError(static_cast<int>(errorCode), m_url.string(), description));
     618}
     619#endif // BUILDING_ON_TIGER
    586620
    587621SocketStreamHandle::~SocketStreamHandle()
  • trunk/WebCore/websockets/WebSocketChannel.cpp

    r73939 r74390  
    207207}
    208208
    209 void WebSocketChannel::didFail(SocketStreamHandle* handle, const SocketStreamError&)
     209void WebSocketChannel::didFail(SocketStreamHandle* handle, const SocketStreamError& error)
    210210{
    211211    LOG(Network, "WebSocketChannel %p didFail", this);
    212212    ASSERT(handle == m_handle || !m_handle);
     213    if (m_context) {
     214        String message;
     215        if (error.isNull())
     216            message = "WebSocket network error";
     217        else if (error.localizedDescription().isNull())
     218            message = makeString("WebSocket network error: error code ", String::number(error.errorCode()));
     219        else
     220            message = makeString("WebSocket network error: ", error.localizedDescription());
     221        m_context->addMessage(OtherMessageSource, NetworkErrorMessageType, ErrorMessageLevel, message, 0, error.failingURL());
     222    }
    213223    m_shouldDiscardReceivedData = true;
    214224    handle->close();
Note: See TracChangeset for help on using the changeset viewer.