#include "components/background_fetch/background_fetch_delegate_base.h"
#include <utility>
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/not_fatal_until.h"
#include "base/notreached.h"
#include "base/task/sequenced_task_runner.h"
#include "build/build_config.h"
#include "components/background_fetch/job_details.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/download/public/background_service/background_download_service.h"
#include "components/download/public/background_service/blob_context_getter_factory.h"
#include "components/download/public/background_service/download_params.h"
#include "content/public/browser/background_fetch_description.h"
#include "content/public/browser/background_fetch_response.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/download_manager_delegate.h"
#include "content/public/browser/web_contents.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/network/public/mojom/data_pipe_getter.mojom.h"
#include "third_party/blink/public/mojom/background_fetch/background_fetch.mojom.h"
#include "third_party/blink/public/mojom/blob/blob.mojom.h"
#include "ui/gfx/geometry/size.h"
namespace background_fetch {
BackgroundFetchDelegateBase::BackgroundFetchDelegateBase(
content::BrowserContext* context)
: … { … }
BackgroundFetchDelegateBase::~BackgroundFetchDelegateBase() = default;
void BackgroundFetchDelegateBase::GetIconDisplaySize(
BackgroundFetchDelegate::GetIconDisplaySizeCallback callback) { … }
void BackgroundFetchDelegateBase::CreateDownloadJob(
base::WeakPtr<Client> client,
std::unique_ptr<content::BackgroundFetchDescription> fetch_description) { … }
void BackgroundFetchDelegateBase::DownloadUrl(
const std::string& job_id,
const std::string& download_guid,
const std::string& method,
const GURL& url,
::network::mojom::CredentialsMode credentials_mode,
const net::NetworkTrafficAnnotationTag& traffic_annotation,
const net::HttpRequestHeaders& headers,
bool has_request_body) { … }
void BackgroundFetchDelegateBase::PauseDownload(const std::string& job_id) { … }
void BackgroundFetchDelegateBase::ResumeDownload(const std::string& job_id) { … }
void BackgroundFetchDelegateBase::CancelDownload(std::string job_id) { … }
void BackgroundFetchDelegateBase::OnUiFinished(const std::string& job_id) { … }
void BackgroundFetchDelegateBase::OnUiActivated(const std::string& job_id) { … }
JobDetails* BackgroundFetchDelegateBase::GetJobDetails(
const std::string& job_id,
bool allow_null) { … }
void BackgroundFetchDelegateBase::StartDownload(const std::string& job_id,
download::DownloadParams params,
bool has_request_body) { … }
void BackgroundFetchDelegateBase::Abort(const std::string& job_id) { … }
void BackgroundFetchDelegateBase::MarkJobComplete(const std::string& job_id) { … }
void BackgroundFetchDelegateBase::FailFetch(const std::string& job_id,
const std::string& download_guid) { … }
void BackgroundFetchDelegateBase::OnDownloadStarted(
const std::string& download_guid,
std::unique_ptr<content::BackgroundFetchResponse> response) { … }
void BackgroundFetchDelegateBase::OnDownloadUpdated(
const std::string& download_guid,
uint64_t bytes_uploaded,
uint64_t bytes_downloaded) { … }
void BackgroundFetchDelegateBase::OnDownloadFailed(
const std::string& download_guid,
std::unique_ptr<content::BackgroundFetchResult> result) { … }
void BackgroundFetchDelegateBase::OnDownloadSucceeded(
const std::string& download_guid,
std::unique_ptr<content::BackgroundFetchResult> result) { … }
void BackgroundFetchDelegateBase::OnDownloadReceived(
const std::string& download_guid,
download::DownloadParams::StartResult result) { … }
bool BackgroundFetchDelegateBase::IsGuidOutstanding(
const std::string& guid) const { … }
void BackgroundFetchDelegateBase::RestartPausedDownload(
const std::string& download_guid) { … }
std::set<std::string> BackgroundFetchDelegateBase::TakeOutstandingGuids() { … }
void BackgroundFetchDelegateBase::GetUploadData(
const std::string& download_guid,
download::GetUploadDataCallback callback) { … }
void BackgroundFetchDelegateBase::DidGetUploadData(
const std::string& job_id,
const std::string& download_guid,
download::GetUploadDataCallback callback,
blink::mojom::SerializedBlobPtr blob) { … }
base::WeakPtr<content::BackgroundFetchDelegate::Client>
BackgroundFetchDelegateBase::GetClient(const std::string& job_id) { … }
}