#include "components/cronet/native/engine.h"
#include <unordered_set>
#include <utility>
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/no_destructor.h"
#include "build/build_config.h"
#include "components/cronet/cronet_context.h"
#include "components/cronet/cronet_global_state.h"
#include "components/cronet/native/generated/cronet.idl_impl_struct.h"
#include "components/cronet/native/include/cronet_c.h"
#include "components/cronet/native/runnables.h"
#include "components/cronet/url_request_context_config.h"
#include "components/cronet/version.h"
#include "components/grpc_support/include/bidirectional_stream_c.h"
#include "net/base/hash_value.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_context_getter.h"
namespace {
class SharedEngineState { … };
SharedEngineState* SharedEngineState::GetInstance() { … }
bool IsValidHostnameForPkp(const std::string& host) { … }
}
namespace cronet {
Cronet_EngineImpl::Cronet_EngineImpl()
: … { … }
Cronet_EngineImpl::~Cronet_EngineImpl() { … }
Cronet_RESULT Cronet_EngineImpl::StartWithParams(
Cronet_EngineParamsPtr params) { … }
bool Cronet_EngineImpl::StartNetLogToFile(Cronet_String file_name,
bool log_all) { … }
void Cronet_EngineImpl::StopNetLog() { … }
Cronet_String Cronet_EngineImpl::GetVersionString() { … }
Cronet_String Cronet_EngineImpl::GetDefaultUserAgent() { … }
Cronet_RESULT Cronet_EngineImpl::Shutdown() { … }
void Cronet_EngineImpl::AddRequestFinishedListener(
Cronet_RequestFinishedInfoListenerPtr listener,
Cronet_ExecutorPtr executor) { … }
void Cronet_EngineImpl::RemoveRequestFinishedListener(
Cronet_RequestFinishedInfoListenerPtr listener) { … }
namespace {
RequestFinishedInfo;
UrlResponseInfo;
CronetError;
template <typename T>
T* GetData(scoped_refptr<base::RefCountedData<T>> ptr) { … }
}
void Cronet_EngineImpl::ReportRequestFinished(
scoped_refptr<RequestFinishedInfo> request_info,
scoped_refptr<UrlResponseInfo> url_response_info,
scoped_refptr<CronetError> error) { … }
Cronet_RESULT Cronet_EngineImpl::CheckResult(Cronet_RESULT result) { … }
bool Cronet_EngineImpl::HasRequestFinishedListener() { … }
class Cronet_EngineImpl::StreamEngineImpl : public stream_engine { … };
class Cronet_EngineImpl::Callback : public CronetContext::Callback { … };
Cronet_EngineImpl::Callback::Callback(Cronet_EngineImpl* engine)
: … { … }
Cronet_EngineImpl::Callback::~Callback() = default;
void Cronet_EngineImpl::Callback::OnInitNetworkThread() { … }
void Cronet_EngineImpl::Callback::OnDestroyNetworkThread() { … }
void Cronet_EngineImpl::Callback::OnEffectiveConnectionTypeChanged(
net::EffectiveConnectionType effective_connection_type) { … }
void Cronet_EngineImpl::Callback::OnRTTOrThroughputEstimatesComputed(
int32_t http_rtt_ms,
int32_t transport_rtt_ms,
int32_t downstream_throughput_kbps) { … }
void Cronet_EngineImpl::Callback::OnRTTObservation(
int32_t rtt_ms,
int32_t timestamp_ms,
net::NetworkQualityObservationSource source) { … }
void Cronet_EngineImpl::Callback::OnThroughputObservation(
int32_t throughput_kbps,
int32_t timestamp_ms,
net::NetworkQualityObservationSource source) { … }
void Cronet_EngineImpl::Callback::OnStopNetLogCompleted() { … }
void Cronet_EngineImpl::SetMockCertVerifierForTesting(
std::unique_ptr<net::CertVerifier> mock_cert_verifier) { … }
stream_engine* Cronet_EngineImpl::GetBidirectionalStreamEngine() { … }
}
CRONET_EXPORT Cronet_EnginePtr Cronet_Engine_Create() { … }
CRONET_EXPORT void Cronet_Engine_SetMockCertVerifierForTesting(
Cronet_EnginePtr engine,
void* raw_mock_cert_verifier) { … }
CRONET_EXPORT stream_engine* Cronet_Engine_GetStreamEngine(
Cronet_EnginePtr engine) { … }