#include "content/browser/service_worker/service_worker_script_loader_factory.h"
#include <memory>
#include <string>
#include <utility>
#include "base/functional/callback_helpers.h"
#include "base/strings/string_number_conversions.h"
#include "content/browser/service_worker/service_worker_cache_writer.h"
#include "content/browser/service_worker/service_worker_consts.h"
#include "content/browser/service_worker/service_worker_context_core.h"
#include "content/browser/service_worker/service_worker_host.h"
#include "content/browser/service_worker/service_worker_installed_script_loader.h"
#include "content/browser/service_worker/service_worker_new_script_loader.h"
#include "content/browser/service_worker/service_worker_updated_script_loader.h"
#include "content/browser/service_worker/service_worker_version.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "services/network/public/cpp/request_destination.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
namespace content {
ServiceWorkerScriptLoaderFactory::ServiceWorkerScriptLoaderFactory(
base::WeakPtr<ServiceWorkerContextCore> context,
base::WeakPtr<ServiceWorkerHost> worker_host,
scoped_refptr<network::SharedURLLoaderFactory>
loader_factory_for_new_scripts)
: … { … }
ServiceWorkerScriptLoaderFactory::~ServiceWorkerScriptLoaderFactory() = default;
void ServiceWorkerScriptLoaderFactory::CreateLoaderAndStart(
mojo::PendingReceiver<network::mojom::URLLoader> receiver,
int32_t request_id,
uint32_t options,
const network::ResourceRequest& resource_request,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) { … }
void ServiceWorkerScriptLoaderFactory::Clone(
mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver) { … }
void ServiceWorkerScriptLoaderFactory::Update(
scoped_refptr<network::SharedURLLoaderFactory> loader_factory) { … }
bool ServiceWorkerScriptLoaderFactory::CheckIfScriptRequestIsValid(
const network::ResourceRequest& resource_request) { … }
void ServiceWorkerScriptLoaderFactory::CopyScript(
const GURL& url,
int64_t resource_id,
base::OnceCallback<void(int64_t, net::Error)> callback,
int64_t new_resource_id) { … }
void ServiceWorkerScriptLoaderFactory::OnCopyScriptFinished(
mojo::PendingReceiver<network::mojom::URLLoader> receiver,
uint32_t options,
const network::ResourceRequest& resource_request,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
int64_t new_resource_id,
net::Error error) { … }
void ServiceWorkerScriptLoaderFactory::OnResourceIdAssignedForNewScriptLoader(
mojo::PendingReceiver<network::mojom::URLLoader> receiver,
int32_t request_id,
uint32_t options,
const network::ResourceRequest& resource_request,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
int64_t resource_id) { … }
}