Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup for rebase #18

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Source/WebCore/PlatformHaiku.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -466,3 +466,4 @@ set(WebCore_FORWARDING_HEADERS_FILES
)

WEBKIT_CREATE_FORWARDING_HEADERS(WebCore DIRECTORIES ${WebCore_FORWARDING_HEADERS_DIRECTORIES} FILES ${WebCore_FORWARDING_HEADERS_FILES})

3 changes: 3 additions & 0 deletions Source/WebCore/platform/NotImplemented.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#define NotImplemented_h

#include <wtf/Assertions.h>
#include "BeDC.h"
#include <Application.h>
#include <Roster.h>

#if PLATFORM(HAIKU)
#include "BeDC.h"
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/platform/network/ResourceErrorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include <wtf/URL.h>
#include <wtf/text/WTFString.h>
#include "PlatformExportMacros.h"


namespace WebCore {

Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/platform/network/haiku/CertificateInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
#include "CertificateInfo.h"

#include "NotImplemented.h"
#include <ResourceError.h>
#include <ResourceResponse.h>
#include "ResourceError.h"
#include "ResourceResponse.h"

namespace WebCore {

Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/platform/network/haiku/ResourceError.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#ifndef ResourceError_h
#define ResourceError_h

#include "PlatformExportMacros.h"
#include "ResourceErrorBase.h"

namespace WebCore {
Expand Down
6 changes: 6 additions & 0 deletions Source/WebKit/NetworkProcess/NetworkDataTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
#if USE(CURL)
#include "NetworkDataTaskCurl.h"
#endif
#if PLATFORM(HAIKU)
#include "NetworkDataTaskHaiku.h"
#endif

namespace WebKit {
using namespace WebCore;
Expand All @@ -58,6 +61,9 @@ Ref<NetworkDataTask> NetworkDataTask::create(NetworkSession& session, NetworkDat
#if USE(CURL)
return NetworkDataTaskCurl::create(session, client, parameters.request, parameters.storedCredentialsPolicy, parameters.contentSniffingPolicy, parameters.contentEncodingSniffingPolicy, parameters.shouldClearReferrerOnHTTPSToHTTPRedirect, parameters.isMainFrameNavigation);
#endif
#if PLATFORM(HAIKU)
return NetworkDataTaskHaiku::create(session, client, parameters.request, parameters.storedCredentialsPolicy, parameters.contentSniffingPolicy, parameters.contentEncodingSniffingPolicy, parameters.shouldClearReferrerOnHTTPSToHTTPRedirect, parameters.isMainFrameNavigation);
#endif
}

NetworkDataTask::NetworkDataTask(NetworkSession& session, NetworkDataTaskClient& client, const ResourceRequest& requestWithCredentials, StoredCredentialsPolicy storedCredentialsPolicy, bool shouldClearReferrerOnHTTPSToHTTPRedirect, bool dataTaskIsForMainFrameNavigation)
Expand Down
415 changes: 107 additions & 308 deletions Source/WebKit/NetworkProcess/NetworkProcess.cpp

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -778,9 +778,12 @@ void NetworkResourceLoader::startBufferingTimerIfNeeded()
{
if (isSynchronous())
return;

if (m_bufferingTimer.isActive())
return;

m_bufferingTimer.startOneShot(m_parameters.maximumBufferingTime);

}

void NetworkResourceLoader::bufferingTimerFired()
Expand Down
167 changes: 167 additions & 0 deletions Source/WebKit/NetworkProcess/haiku/NetworkDataTaskHaiku.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
/*
* Copyright (C) 2019 Haiku, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "NetworkDataTaskHaiku.h"

#include <WebCore/AuthenticationChallenge.h>
#include <WebCore/CookieJar.h>
#include <WebCore/NetworkStorageSession.h>
#include <WebCore/ResourceError.h>
#include <WebCore/SameSiteInfo.h>
#include <WebCore/SharedBuffer.h>

#include <Url.h>
#include <UrlRequest.h>
#include <HttpRequest.h>
#include <assert.h>

namespace WebKit {

using namespace WebCore;

NetworkDataTaskHaiku::NetworkDataTaskHaiku(NetworkSession& session, NetworkDataTaskClient& client, const ResourceRequest& requestWithCredentials, StoredCredentialsPolicy storedCredentialsPolicy, ContentSniffingPolicy shouldContentSniff, ContentEncodingSniffingPolicy, bool shouldClearReferrerOnHTTPSToHTTPRedirect, bool dataTaskIsForMainFrameNavigation)
: NetworkDataTask(session, client, requestWithCredentials, storedCredentialsPolicy, shouldClearReferrerOnHTTPSToHTTPRedirect, dataTaskIsForMainFrameNavigation)
, m_postData(NULL)
{
if (m_scheduledFailureType != NoFailure)
return;

auto request = requestWithCredentials;
if (request.url().protocolIsInHTTPFamily()) {
m_startTime = MonotonicTime::now();
auto url = request.url();
if (m_storedCredentialsPolicy == StoredCredentialsPolicy::Use) {
m_user = url.user();
m_password = url.pass();
request.removeCredentials();
}
}
createRequest(WTFMove(request));
}

NetworkDataTaskHaiku::~NetworkDataTaskHaiku()
{
}

void NetworkDataTaskHaiku::createRequest(ResourceRequest&& request)
{
m_currentRequest = WTFMove(request);
m_request = m_currentRequest.toNetworkRequest(nullptr);

BString method = BString(m_currentRequest.httpMethod());

m_postData = NULL;

if (m_request == NULL)
return;

m_baseUrl = URL(m_request->Url());

BHttpRequest* httpRequest = dynamic_cast<BHttpRequest*>(m_request);
if(httpRequest) {

if(method == B_HTTP_POST || method == B_HTTP_PUT) {
FormData* form = m_currentRequest.httpBody();
if(form) {
m_postData = new BFormDataIO(form);
httpRequest->AdoptInputData(m_postData, m_postData->Size());
}
}

httpRequest->SetMethod(method.String());
}

if(this->SynchronousListener()) {
m_request->SetListener(this->SynchronousListener());
} else {
m_request->SetListener(this);
}

if (m_request->Run() < B_OK)
{
}
}
void NetworkDataTaskHaiku::cancel()
{
if(m_state == State::Canceling || m_state == State::Completed)
return;

m_state = State::Canceling;

if(m_request)
m_request->Stop();

}

void NetworkDataTaskHaiku::resume()
{
if(m_state == State::Completed || m_state == State::Canceling)
return;

m_state = State::Running;

}

void NetworkDataTaskHaiku::invalidateAndCancel()
{

}

NetworkDataTask::State NetworkDataTaskHaiku::state() const
{
return m_state;
}

void NetworkDataTaskHaiku::ConnectionOpened(BUrlRequest* caller)
{

}
void NetworkDataTaskHaiku::HeadersReceived(BUrlRequest* caller, const BUrlResult& result)
{
}
void NetworkDataTaskHaiku::DataReceived(BUrlRequest* caller, const char* data, off_t position,
ssize_t size)
{
if(size < 0 )
{
return;
}
m_client->didReceiveData(SharedBuffer::create(data,size));
}
void NetworkDataTaskHaiku::UploadProgress(BUrlRequest* caller, ssize_t bytesSent, ssize_t bytesTotal)
{

}
void NetworkDataTaskHaiku::RequestCompleted(BUrlRequest* caller, bool success)
{

}
bool NetworkDataTaskHaiku::CertificateVerificationFailed(BUrlRequest* caller, BCertificate& certificate, const char* message)
{

}

}
76 changes: 76 additions & 0 deletions Source/WebKit/NetworkProcess/haiku/NetworkDataTaskHaiku.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright (C) 2019 Haiku, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
*/

#pragma once

#include "config.h"
#include "HaikuFormDataStream.h"
#include "NetworkDataTask.h"
#include <WebCore/ResourceResponse.h>
#include <WebCore/ResourceRequest.h>

#include <UrlProtocolAsynchronousListener.h>
#include <Referenceable.h>
#include <Path.h>
namespace WebKit {
using namespace WebCore;

class NetworkDataTaskHaiku final : public NetworkDataTask,
public BUrlProtocolAsynchronousListener
{
public:
static Ref<NetworkDataTask> create(NetworkSession& session, NetworkDataTaskClient& client, const WebCore::ResourceRequest& request, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, WebCore::ContentSniffingPolicy shouldContentSniff, WebCore::ContentEncodingSniffingPolicy shouldContentEncodingSniff, bool shouldClearReferrerOnHTTPSToHTTPRedirect, bool dataTaskIsForMainFrameNavigation)
{
return adoptRef(*new NetworkDataTaskHaiku(session, client, request, storedCredentialsPolicy, shouldContentSniff, shouldContentEncodingSniff, shouldClearReferrerOnHTTPSToHTTPRedirect, dataTaskIsForMainFrameNavigation));
}

~NetworkDataTaskHaiku();
private:
NetworkDataTaskHaiku(NetworkSession&, NetworkDataTaskClient&, const WebCore::ResourceRequest&, WebCore::StoredCredentialsPolicy, WebCore::ContentSniffingPolicy, WebCore::ContentEncodingSniffingPolicy, bool shouldClearReferrerOnHTTPSToHTTPRedirect, bool dataTaskIsForMainFrameNavigation);
void createRequest(WebCore::ResourceRequest&&);
State m_state{State::Suspended};
void cancel() override;
void resume() override;
void invalidateAndCancel() override;
NetworkDataTask::State state() const override;

void ConnectionOpened(BUrlRequest* caller) override;
void HeadersReceived(BUrlRequest* caller, const BUrlResult& result) override;
void DataReceived(BUrlRequest* caller, const char* data, off_t position,
ssize_t size) override;
void UploadProgress(BUrlRequest* caller, ssize_t bytesSent, ssize_t bytesTotal) override;
void RequestCompleted(BUrlRequest* caller, bool success) override;
bool CertificateVerificationFailed(BUrlRequest* caller, BCertificate& certificate, const char* message) override;

WebCore::ResourceResponse m_response;
WebCore::ResourceRequest m_currentRequest;
unsigned m_redirectCount { 0 };
unsigned m_authFailureCount { 0 };
MonotonicTime m_startTime;
BUrlRequest* m_request;
BFormDataIO* m_postData;
URL m_baseUrl;
};
}
25 changes: 25 additions & 0 deletions Source/WebKit/Platform/IPC/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,12 +586,29 @@ std::unique_ptr<Decoder> Connection::waitForSyncReply(uint64_t syncRequestID, Se
WallTime absoluteTime = WallTime::now() + timeout;

willSendSyncMessage(sendSyncOptions);
<<<<<<< HEAD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have committed this without fixing the conflicts

<<<<<<< HEAD

bool timedOut = false;sleep(15);
while (!timedOut) {
// First, check if we have any messages that we need to process.
SyncMessageState::singleton().dispatchMessages(nullptr);

=======
fprintf(stderr,"\n %s place 2",__PRETTY_FUNCTION__);
=======

>>>>>>> 300d5858ace... Finalizing IPC communication related things
bool timedOut = false;sleep(15);
while (!timedOut) {
// First, check if we have any messages that we need to process.
SyncMessageState::singleton().dispatchMessages(nullptr);
<<<<<<< HEAD
fprintf(stderr,"\n %s place 3",__PRETTY_FUNCTION__);
>>>>>>> 09c34e3a25c... Message Listener attached to Workqueue thread first iteration
=======

>>>>>>> 300d5858ace... Finalizing IPC communication related things
{
LockHolder locker(m_syncReplyStateMutex);

Expand Down Expand Up @@ -622,7 +639,15 @@ std::unique_ptr<Decoder> Connection::waitForSyncReply(uint64_t syncRequestID, Se
// This allows the WebProcess to still serve clients while waiting for the message to return.
// Notably, it can continue to process accessibility requests, which are on the main thread.
timedOut = !SyncMessageState::singleton().wait(absoluteTime);
<<<<<<< HEAD
<<<<<<< HEAD

=======
fprintf(stderr,"\n %s place 6",__PRETTY_FUNCTION__);
>>>>>>> 09c34e3a25c... Message Listener attached to Workqueue thread first iteration
=======

>>>>>>> 300d5858ace... Finalizing IPC communication related things
}

RELEASE_LOG_ERROR(IPC, "Connection::waitForSyncReply: Timed-out while waiting for reply, id = %" PRIu64, syncRequestID);
Expand Down
6 changes: 3 additions & 3 deletions Source/WebKit/Platform/IPC/Connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ class Connection : public ThreadSafeRefCounted<Connection, WTF::DestructionThrea

template<typename T>
bool Connection::send(T&& message, uint64_t destinationID, OptionSet<SendOption> sendOptions)
{
{fprintf(stderr,"(%s-%ld)",__PRETTY_FUNCTION__,m_connectedProcess.connectedProcess);
COMPILE_ASSERT(!T::isSync, AsyncMessageExpected);

auto encoder = std::make_unique<Encoder>(T::receiverName(), T::name(), destinationID);
Expand Down Expand Up @@ -557,9 +557,9 @@ template<typename T> bool Connection::sendSync(T&& message, typename T::Reply&&
Optional<typename T::ReplyArguments> replyArguments;
*replyDecoder >> replyArguments;
if (!replyArguments)
return false;
return false;fprintf(stderr,"\n%s place 3\n",__PRETTY_FUNCTION__);
moveTuple(WTFMove(*replyArguments), reply);
return true;
return true;fprintf(stderr,"\n%s place 4\n",__PRETTY_FUNCTION__);
}

template<typename T> bool Connection::waitForAndDispatchImmediately(uint64_t destinationID, Seconds timeout, OptionSet<WaitForOption> waitForOptions)
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/Platform/IPC/Encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Encoder::Encoder(StringReference messageReceiverName, StringReference messageNam
, m_bufferSize(0)
, m_bufferCapacity(sizeof(m_inlineBuffer))
{
fprintf(stderr,"####%ld---%s#####\n",getpid(),messageName);
encodeHeader();
}

Expand Down
Loading