#include "content/browser/background_fetch/storage/create_metadata_task.h"
#include <numeric>
#include <set>
#include <utility>
#include "base/barrier_closure.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/observer_list.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/trace_event/trace_event.h"
#include "content/browser/background_fetch/background_fetch_data_manager.h"
#include "content/browser/background_fetch/background_fetch_data_manager_observer.h"
#include "content/browser/background_fetch/storage/database_helpers.h"
#include "content/browser/background_fetch/storage/image_helpers.h"
#include "content/browser/background_fetch/storage/mark_registration_for_deletion_task.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/common/background_fetch/background_fetch_types.h"
#include "content/common/fetch/fetch_api_request_proto.h"
#include "third_party/blink/public/common/cache_storage/cache_storage_utils.h"
#include "third_party/blink/public/common/service_worker/service_worker_status_code.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom.h"
namespace content {
namespace background_fetch {
namespace {
constexpr size_t kRegistrationLimitPerStorageKey = …;
class CanCreateRegistrationTask : public DatabaseTask { … };
proto::ImageResource_Purpose
ManifestImageResourcePurposeToImageResoucePurposeProto(
blink::mojom::ManifestImageResource_Purpose purpose) { … }
}
CreateMetadataTask::CreateMetadataTask(
DatabaseTaskHost* host,
const BackgroundFetchRegistrationId& registration_id,
std::vector<blink::mojom::FetchAPIRequestPtr> requests,
blink::mojom::BackgroundFetchOptionsPtr options,
const SkBitmap& icon,
bool start_paused,
const net::IsolationInfo& isolation_info,
CreateMetadataCallback callback)
: … { … }
CreateMetadataTask::~CreateMetadataTask() = default;
void CreateMetadataTask::Start() { … }
void CreateMetadataTask::DidGetCanCreateRegistration(
blink::mojom::BackgroundFetchError error,
bool can_create) { … }
void CreateMetadataTask::DidGetIsQuotaAvailable(bool is_available) { … }
void CreateMetadataTask::GetRegistrationUniqueId() { … }
void CreateMetadataTask::DidGetUniqueId(const std::vector<std::string>& data,
blink::ServiceWorkerStatusCode status) { … }
void CreateMetadataTask::InitializeMetadataProto() { … }
void CreateMetadataTask::DidSerializeIcon(std::string serialized_icon) { … }
void CreateMetadataTask::StoreMetadata() { … }
void CreateMetadataTask::DidStoreMetadata(
blink::ServiceWorkerStatusCode status) { … }
void CreateMetadataTask::DidOpenCache(int64_t trace_id,
blink::mojom::CacheStorageError error) { … }
void CreateMetadataTask::DidStoreRequests(
blink::mojom::CacheStorageVerboseErrorPtr error) { … }
void CreateMetadataTask::FinishWithError(
blink::mojom::BackgroundFetchError error) { … }
}
}