#include "components/cronet/native/url_request.h"
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_refptr.h"
#include "components/cronet/cronet_upload_data_stream.h"
#include "components/cronet/native/engine.h"
#include "components/cronet/native/generated/cronet.idl_impl_struct.h"
#include "components/cronet/native/include/cronet_c.h"
#include "components/cronet/native/io_buffer_with_cronet_buffer.h"
#include "components/cronet/native/native_metrics_util.h"
#include "components/cronet/native/runnables.h"
#include "components/cronet/native/upload_data_sink.h"
#include "net/base/io_buffer.h"
#include "net/base/load_states.h"
namespace {
RequestFinishedInfo;
UrlResponseInfo;
CronetError;
template <typename T>
T* GetData(scoped_refptr<base::RefCountedData<T>> ptr) { … }
net::RequestPriority ConvertRequestPriority(
Cronet_UrlRequestParams_REQUEST_PRIORITY priority) { … }
net::Idempotency ConvertIdempotency(
Cronet_UrlRequestParams_IDEMPOTENCY idempotency) { … }
scoped_refptr<UrlResponseInfo> CreateCronet_UrlResponseInfo(
const std::vector<std::string>& url_chain,
int http_status_code,
const std::string& http_status_text,
const net::HttpResponseHeaders* headers,
bool was_cached,
const std::string& negotiated_protocol,
const std::string& proxy_server,
int64_t received_byte_count) { … }
Cronet_Error_ERROR_CODE NetErrorToCronetErrorCode(int net_error) { … }
bool IsCronetErrorImmediatelyRetryable(Cronet_Error_ERROR_CODE error_code) { … }
scoped_refptr<CronetError> CreateCronet_Error(int net_error,
int quic_error,
const std::string& error_string) { … }
#if DCHECK_IS_ON()
class VerifyDestructionRunnable : public Cronet_Runnable { … };
#endif
Cronet_UrlRequestStatusListener_Status ConvertLoadState(
net::LoadState load_state) { … }
}
namespace cronet {
class Cronet_UrlRequestImpl::NetworkTasks : public CronetURLRequest::Callback { … };
Cronet_UrlRequestImpl::Cronet_UrlRequestImpl() = default;
Cronet_UrlRequestImpl::~Cronet_UrlRequestImpl() { … }
Cronet_RESULT Cronet_UrlRequestImpl::InitWithParams(
Cronet_EnginePtr engine,
Cronet_String url,
Cronet_UrlRequestParamsPtr params,
Cronet_UrlRequestCallbackPtr callback,
Cronet_ExecutorPtr executor) { … }
Cronet_RESULT Cronet_UrlRequestImpl::Start() { … }
Cronet_RESULT Cronet_UrlRequestImpl::FollowRedirect() { … }
Cronet_RESULT Cronet_UrlRequestImpl::Read(Cronet_BufferPtr buffer) { … }
void Cronet_UrlRequestImpl::Cancel() { … }
bool Cronet_UrlRequestImpl::IsDone() { … }
bool Cronet_UrlRequestImpl::IsDoneLocked() const { … }
bool Cronet_UrlRequestImpl::DestroyRequestUnlessDone(
Cronet_RequestFinishedInfo_FINISHED_REASON finished_reason) { … }
bool Cronet_UrlRequestImpl::DestroyRequestUnlessDoneLocked(
Cronet_RequestFinishedInfo_FINISHED_REASON finished_reason) { … }
void Cronet_UrlRequestImpl::GetStatus(
Cronet_UrlRequestStatusListenerPtr listener) { … }
void Cronet_UrlRequestImpl::PostCallbackOnFailedToExecutor() { … }
void Cronet_UrlRequestImpl::OnUploadDataProviderError(
const std::string& error_message) { … }
void Cronet_UrlRequestImpl::PostTaskToExecutor(base::OnceClosure task) { … }
void Cronet_UrlRequestImpl::InvokeCallbackOnRedirectReceived(
const std::string& new_location) { … }
void Cronet_UrlRequestImpl::InvokeCallbackOnResponseStarted() { … }
void Cronet_UrlRequestImpl::InvokeCallbackOnReadCompleted(
std::unique_ptr<Cronet_Buffer> cronet_buffer,
int bytes_read) { … }
void Cronet_UrlRequestImpl::InvokeCallbackOnSucceeded() { … }
void Cronet_UrlRequestImpl::InvokeCallbackOnFailed() { … }
void Cronet_UrlRequestImpl::InvokeCallbackOnCanceled() { … }
void Cronet_UrlRequestImpl::InvokeAllStatusListeners() { … }
void Cronet_UrlRequestImpl::MaybeReportMetrics(
Cronet_RequestFinishedInfo_FINISHED_REASON finished_reason) { … }
Cronet_UrlRequestImpl::NetworkTasks::NetworkTasks(
const std::string& url,
Cronet_UrlRequestImpl* url_request)
: … { … }
void Cronet_UrlRequestImpl::NetworkTasks::OnReceivedRedirect(
const std::string& new_location,
int http_status_code,
const std::string& http_status_text,
const net::HttpResponseHeaders* headers,
bool was_cached,
const std::string& negotiated_protocol,
const std::string& proxy_server,
int64_t received_byte_count) { … }
void Cronet_UrlRequestImpl::NetworkTasks::OnResponseStarted(
int http_status_code,
const std::string& http_status_text,
const net::HttpResponseHeaders* headers,
bool was_cached,
const std::string& negotiated_protocol,
const std::string& proxy_server,
int64_t received_byte_count) { … }
void Cronet_UrlRequestImpl::NetworkTasks::OnReadCompleted(
scoped_refptr<net::IOBuffer> buffer,
int bytes_read,
int64_t received_byte_count) { … }
void Cronet_UrlRequestImpl::NetworkTasks::OnSucceeded(
int64_t received_byte_count) { … }
void Cronet_UrlRequestImpl::NetworkTasks::OnError(
int net_error,
int quic_error,
quic::ConnectionCloseSource source,
const std::string& error_string,
int64_t received_byte_count) { … }
void Cronet_UrlRequestImpl::NetworkTasks::OnCanceled() { … }
void Cronet_UrlRequestImpl::NetworkTasks::OnDestroyed() { … }
void Cronet_UrlRequestImpl::NetworkTasks::OnMetricsCollected(
const base::Time& request_start_time,
const base::TimeTicks& request_start,
const base::TimeTicks& dns_start,
const base::TimeTicks& dns_end,
const base::TimeTicks& connect_start,
const base::TimeTicks& connect_end,
const base::TimeTicks& ssl_start,
const base::TimeTicks& ssl_end,
const base::TimeTicks& send_start,
const base::TimeTicks& send_end,
const base::TimeTicks& push_start,
const base::TimeTicks& push_end,
const base::TimeTicks& receive_headers_end,
const base::TimeTicks& request_end,
bool socket_reused,
int64_t sent_bytes_count,
int64_t received_bytes_count,
bool,
bool
) { … }
void Cronet_UrlRequestImpl::NetworkTasks::OnStatus(
Cronet_UrlRequestStatusListenerPtr listener,
net::LoadState load_state) { … }
}
CRONET_EXPORT Cronet_UrlRequestPtr Cronet_UrlRequest_Create() { … }