Files
cefsharp/CefSharp.Core/Internals/CefResourceHandlerAdapter.cpp
T
Alex Maitland f7569d8f0e Net Core - Make more VC++ classes private
They aren't used publicly so make private so they don't show up in the ref assembly.

Issue #3197
2020-11-09 20:04:18 +10:00

82 lines
3.0 KiB
C++

// Copyright © 2010 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#include "Stdafx.h"
#include "Request.h"
#include "CefResourceHandlerAdapter.h"
#include "Internals/CefResponseWrapper.h"
#include "Internals/CefCallbackWrapper.h"
#include "Internals/CefResourceReadCallbackWrapper.h"
#include "Internals/CefResourceSkipCallbackWrapper.h"
#include "Internals/TypeConversion.h"
using namespace System::Runtime::InteropServices;
using namespace System::IO;
namespace CefSharp
{
namespace Internals
{
bool CefResourceHandlerAdapter::Open(CefRefPtr<CefRequest> request, bool& handleRequest, CefRefPtr<CefCallback> callback)
{
auto callbackWrapper = gcnew CefCallbackWrapper(callback);
_request = gcnew Request(request);
return _handler->Open(_request, handleRequest, callbackWrapper);
}
void CefResourceHandlerAdapter::GetResponseHeaders(CefRefPtr<CefResponse> response, int64& response_length, CefString& redirectUrl)
{
String^ newRedirectUrl;
CefResponseWrapper responseWrapper(response);
_handler->GetResponseHeaders(% responseWrapper, response_length, newRedirectUrl);
redirectUrl = StringUtils::ToNative(newRedirectUrl);
}
bool CefResourceHandlerAdapter::Skip(int64 bytesToSkip, int64& bytesSkipped, CefRefPtr<CefResourceSkipCallback> callback)
{
auto callbackWrapper = gcnew CefResourceSkipCallbackWrapper(callback);
return _handler->Skip(bytesToSkip, bytesSkipped, callbackWrapper);
}
bool CefResourceHandlerAdapter::Read(void* dataOut, int bytesToRead, int& bytesRead, CefRefPtr<CefResourceReadCallback> callback)
{
auto writeStream = gcnew UnmanagedMemoryStream((Byte*)dataOut, (Int64)bytesToRead, (Int64)bytesToRead, FileAccess::Write);
auto callbackWrapper = gcnew CefResourceReadCallbackWrapper(callback);
return _handler->Read(writeStream, bytesRead, callbackWrapper);
}
void CefResourceHandlerAdapter::Cancel()
{
_handler->Cancel();
delete _request;
_request = nullptr;
}
//Deprecated
bool CefResourceHandlerAdapter::ProcessRequest(CefRefPtr<CefRequest> request, CefRefPtr<CefCallback> callback)
{
auto callbackWrapper = gcnew CefCallbackWrapper(callback);
_request = gcnew Request(request);
return _handler->ProcessRequest(_request, callbackWrapper);
}
bool CefResourceHandlerAdapter::ReadResponse(void* dataOut, int bytesToRead, int& bytesRead, CefRefPtr<CefCallback> callback)
{
auto writeStream = gcnew UnmanagedMemoryStream((Byte*)dataOut, (Int64)bytesToRead, (Int64)bytesToRead, FileAccess::Write);
auto callbackWrapper = gcnew CefCallbackWrapper(callback);
return _handler->ReadResponse(writeStream, bytesRead, callbackWrapper);
}
}
}