Diff
Modified: trunk/Source/WebCore/ChangeLog (101327 => 101328)
--- trunk/Source/WebCore/ChangeLog 2011-11-29 06:25:48 UTC (rev 101327)
+++ trunk/Source/WebCore/ChangeLog 2011-11-29 06:33:01 UTC (rev 101328)
@@ -1,3 +1,34 @@
+2011-11-28 Leo Yang <[email protected]>
+
+ Upstream the BlackBerry porting of SocketStream
+ https://bugs.webkit.org/show_bug.cgi?id=73283
+
+ Reviewed by Daniel Bates.
+
+ Other main contributors:
+ Joe Mason <[email protected]>
+ Lyon Chen <[email protected]>
+
+ Initial upstream, can't be built yet, no new tests.
+
+ * platform/network/blackberry/SocketStreamError.h: Added.
+ (WebCore::SocketStreamError::SocketStreamError):
+ * platform/network/blackberry/SocketStreamHandle.h: Added.
+ (WebCore::SocketStreamHandle::create):
+ * platform/network/blackberry/SocketStreamHandleBlackBerry.cpp: Added.
+ (WebCore::SocketStreamHandle::SocketStreamHandle):
+ (WebCore::SocketStreamHandle::~SocketStreamHandle):
+ (WebCore::SocketStreamHandle::platformSend):
+ (WebCore::SocketStreamHandle::platformClose):
+ (WebCore::SocketStreamHandle::didReceiveAuthenticationChallenge):
+ (WebCore::SocketStreamHandle::receivedCredential):
+ (WebCore::SocketStreamHandle::receivedRequestToContinueWithoutCredential):
+ (WebCore::SocketStreamHandle::receivedCancellation):
+ (WebCore::SocketStreamHandle::notifyStatusReceived):
+ (WebCore::SocketStreamHandle::notifyDataReceived):
+ (WebCore::SocketStreamHandle::notifyReadyToSendData):
+ (WebCore::SocketStreamHandle::notifyClose):
+
2011-11-28 Yongjun Zhang <[email protected]>
Size of ResourceRequestBase could be reduced by using bitfields.
Added: trunk/Source/WebCore/platform/network/blackberry/SocketStreamError.h (0 => 101328)
--- trunk/Source/WebCore/platform/network/blackberry/SocketStreamError.h (rev 0)
+++ trunk/Source/WebCore/platform/network/blackberry/SocketStreamError.h 2011-11-29 06:33:01 UTC (rev 101328)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SocketStreamError_h
+#define SocketStreamError_h
+
+#include "SocketStreamErrorBase.h"
+
+namespace WebCore {
+
+class SocketStreamError : public SocketStreamErrorBase {
+public:
+ SocketStreamError() { }
+ explicit SocketStreamError(int errorCode)
+ : SocketStreamErrorBase(errorCode)
+ {
+ }
+
+};
+
+} // namespace WebCore
+
+#endif // SocketStreamError_h
Added: trunk/Source/WebCore/platform/network/blackberry/SocketStreamHandle.h (0 => 101328)
--- trunk/Source/WebCore/platform/network/blackberry/SocketStreamHandle.h (rev 0)
+++ trunk/Source/WebCore/platform/network/blackberry/SocketStreamHandle.h 2011-11-29 06:33:01 UTC (rev 101328)
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2010 Research In Motion Limited. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SocketStreamHandle_h
+#define SocketStreamHandle_h
+
+#include "SocketStreamHandleBase.h"
+
+#include <network/FilterStream.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class AuthenticationChallenge;
+class Credential;
+class SocketStreamHandleClient;
+
+class SocketStreamHandle : public RefCounted<SocketStreamHandle>, public BlackBerry::Platform::FilterStream, public SocketStreamHandleBase {
+public:
+ static PassRefPtr<SocketStreamHandle> create(const String& groupName, const KURL& url, SocketStreamHandleClient* client) { return adoptRef(new SocketStreamHandle(groupName, url, client)); }
+
+ virtual ~SocketStreamHandle();
+
+ // FilterStream interface
+ virtual void notifyStatusReceived(int status, const char* message);
+ virtual void notifyDataReceived(BlackBerry::Platform::NetworkBuffer*);
+ virtual void notifyReadyToSendData();
+ virtual void notifyClose(int status);
+
+protected:
+ virtual int platformSend(const char* data, int length);
+ virtual void platformClose();
+
+private:
+ SocketStreamHandle(const String& groupName, const KURL&, SocketStreamHandleClient*);
+
+ // No authentication for streams per se, but proxy may ask for credentials.
+ void didReceiveAuthenticationChallenge(const AuthenticationChallenge&);
+ void receivedCredential(const AuthenticationChallenge&, const Credential&);
+ void receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&);
+ void receivedCancellation(const AuthenticationChallenge&);
+
+ OwnPtr<BlackBerry::Platform::FilterStream> m_socketStream;
+};
+
+} // namespace WebCore
+
+#endif // SocketStreamHandle_h
Added: trunk/Source/WebCore/platform/network/blackberry/SocketStreamHandleBlackBerry.cpp (0 => 101328)
--- trunk/Source/WebCore/platform/network/blackberry/SocketStreamHandleBlackBerry.cpp (rev 0)
+++ trunk/Source/WebCore/platform/network/blackberry/SocketStreamHandleBlackBerry.cpp 2011-11-29 06:33:01 UTC (rev 101328)
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2010 Research In Motion Limited. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "SocketStreamHandle.h"
+
+#include "Chrome.h"
+#include "FrameLoaderClientBlackBerry.h"
+#include "KURL.h"
+#include "Logging.h"
+#include "NotImplemented.h"
+#include "Page.h"
+#include "PageClientBlackBerry.h"
+#include "PageGroup.h"
+#include "SocketStreamError.h"
+#include "SocketStreamHandleClient.h"
+
+#include <network/NetworkStreamFactory.h>
+#include <wtf/text/CString.h>
+
+namespace WebCore {
+
+SocketStreamHandle::SocketStreamHandle(const String& groupName, const KURL& url, SocketStreamHandleClient* client)
+ : SocketStreamHandleBase(url, client)
+{
+ LOG(Network, "SocketStreamHandle %p new client %p", this, m_client);
+
+ // Find a playerId to pass to the platform client. It can be from any page
+ // in the PageGroup, since they all share the same network profile and
+ // resources.
+ PageGroup* pageGroup = PageGroup::pageGroup(groupName);
+ ASSERT(pageGroup && !pageGroup->pages().isEmpty());
+ Page* page = *(pageGroup->pages().begin());
+ ASSERT(page && page->mainFrame());
+ int playerId = static_cast<FrameLoaderClientBlackBerry*>(page->mainFrame()->loader()->client())->playerId();
+
+ // Create a platform socket stream
+ BlackBerry::Platform::NetworkStreamFactory* factory = page->chrome()->platformPageClient()->networkStreamFactory();
+ ASSERT(factory);
+ m_socketStream = adoptPtr(factory->createSocketStream(playerId));
+ ASSERT(m_socketStream);
+ m_socketStream->setListener(this);
+
+ // Open the socket
+ BlackBerry::Platform::NetworkRequest request;
+ request.setRequestUrl(url.string().latin1().data(), "CONNECT");
+
+ m_socketStream->setRequest(request);
+
+ m_socketStream->streamOpen();
+}
+
+SocketStreamHandle::~SocketStreamHandle()
+{
+ LOG(Network, "SocketStreamHandle %p delete", this);
+ setClient(0);
+}
+
+int SocketStreamHandle::platformSend(const char* buf, int length)
+{
+ LOG(Network, "SocketStreamHandle %p platformSend", this);
+ ASSERT(m_socketStream);
+ return m_socketStream->streamSendData(buf, length);
+}
+
+void SocketStreamHandle::platformClose()
+{
+ LOG(Network, "SocketStreamHandle %p platformClose", this);
+ ASSERT(m_socketStream);
+ m_socketStream->streamClose();
+}
+
+void SocketStreamHandle::didReceiveAuthenticationChallenge(const AuthenticationChallenge&)
+{
+ notImplemented();
+}
+
+void SocketStreamHandle::receivedCredential(const AuthenticationChallenge&, const Credential&)
+{
+ notImplemented();
+}
+
+void SocketStreamHandle::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&)
+{
+ notImplemented();
+}
+
+void SocketStreamHandle::receivedCancellation(const AuthenticationChallenge&)
+{
+ notImplemented();
+}
+
+// FilterStream interface
+
+void SocketStreamHandle::notifyStatusReceived(int status, const char* message)
+{
+ ASSERT(m_client);
+
+ // The client can close the handle, potentially removing the last reference.
+ RefPtr<SocketStreamHandle> protect(this);
+
+ if (FilterStream::StatusSuccess != status)
+ m_client->didFailSocketStream(this, SocketStreamError(status));
+ else {
+ m_state = Open;
+ m_client->didOpenSocketStream(this);
+ }
+}
+
+void SocketStreamHandle::notifyDataReceived(BlackBerry::Platform::NetworkBuffer* buffer)
+{
+ ASSERT(m_client);
+
+ // The client can close the handle, potentially removing the last reference.
+ RefPtr<SocketStreamHandle> protect(this);
+ m_client->didReceiveSocketStreamData(this, BlackBerry::Platform::networkBufferData(buffer), BlackBerry::Platform::networkBufferDataLength(buffer));
+}
+
+void SocketStreamHandle::notifyReadyToSendData()
+{
+ sendPendingData();
+}
+
+void SocketStreamHandle::notifyClose(int status)
+{
+ ASSERT(m_client);
+
+ // The client can close the handle, potentially removing the last reference.
+ RefPtr<SocketStreamHandle> protect(this);
+
+ if (FilterStream::StatusSuccess != status)
+ m_client->didFailSocketStream(this, SocketStreamError(status));
+
+ m_client->didCloseSocketStream(this);
+}
+
+} // namespace WebCore