#include "components/sync/engine/net/http_bridge.h"
#include <stddef.h>
#include <utility>
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/threading/thread_restrictions.h"
#include "components/variations/net/variations_http_headers.h"
#include "google_apis/credentials_mode.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "third_party/zlib/google/compression_utils.h"
namespace syncer {
namespace {
constexpr base::TimeDelta kMaxHttpRequestTime = …;
void LogTimeout(bool timed_out) { … }
}
HttpBridgeFactory::HttpBridgeFactory(
const std::string& user_agent,
std::unique_ptr<network::PendingSharedURLLoaderFactory>
pending_url_loader_factory)
: … { … }
HttpBridgeFactory::~HttpBridgeFactory() = default;
scoped_refptr<HttpPostProvider> HttpBridgeFactory::Create() { … }
HttpBridge::URLFetchState::URLFetchState() = default;
HttpBridge::URLFetchState::~URLFetchState() = default;
HttpBridge::HttpBridge(
const std::string& user_agent,
scoped_refptr<base::SequencedTaskRunner> network_task_runner,
std::unique_ptr<network::PendingSharedURLLoaderFactory>
pending_url_loader_factory)
: … { … }
HttpBridge::~HttpBridge() { … }
void HttpBridge::SetExtraRequestHeaders(const char* headers) { … }
void HttpBridge::SetURL(const GURL& url) { … }
void HttpBridge::SetPostPayload(const char* content_type,
int content_length,
const char* content) { … }
bool HttpBridge::MakeSynchronousPost(int* net_error_code,
int* http_status_code) { … }
scoped_refptr<network::SharedURLLoaderFactory>
HttpBridge::CreateSharedURLLoader() { … }
void HttpBridge::MakeAsynchronousPost() { … }
int HttpBridge::GetResponseContentLength() const { … }
const char* HttpBridge::GetResponseContent() const { … }
const std::string HttpBridge::GetResponseHeaderValue(
const std::string& name) const { … }
void HttpBridge::Abort() { … }
void HttpBridge::OnURLLoadComplete(std::unique_ptr<std::string> response_body) { … }
void HttpBridge::OnURLLoadCompleteInternal(
int http_status_code,
int net_error_code,
const GURL& final_url,
std::unique_ptr<std::string> response_body) { … }
void HttpBridge::OnURLLoadUploadProgress(uint64_t position, uint64_t total) { … }
void HttpBridge::OnURLLoadTimedOut() { … }
}