#include "content/browser/service_worker/service_worker_update_checker.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/trace_event/trace_event.h"
#include "content/browser/loader/browser_initiated_resource_request.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_context_wrapper.h"
#include "content/browser/service_worker/service_worker_single_script_update_checker.h"
#include "content/browser/service_worker/service_worker_version.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "net/http/http_request_headers.h"
#include "services/network/public/cpp/constants.h"
#include "services/network/public/cpp/features.h"
#include "third_party/blink/public/common/renderer_preferences/renderer_preferences.h"
namespace content {
ServiceWorkerUpdateChecker::ServiceWorkerUpdateChecker(
std::vector<storage::mojom::ServiceWorkerResourceRecordPtr>
scripts_to_compare,
const GURL& main_script_url,
int64_t main_script_resource_id,
const std::optional<std::string>& main_script_sha256_checksum,
scoped_refptr<ServiceWorkerVersion> version_to_update,
scoped_refptr<network::SharedURLLoaderFactory> loader_factory,
bool force_bypass_cache,
blink::mojom::ScriptType worker_script_type,
blink::mojom::ServiceWorkerUpdateViaCache update_via_cache,
base::TimeDelta time_since_last_check,
ServiceWorkerContextCore* context,
blink::mojom::FetchClientSettingsObjectPtr fetch_client_settings_object)
: … { … }
ServiceWorkerUpdateChecker::~ServiceWorkerUpdateChecker() = default;
void ServiceWorkerUpdateChecker::Start(UpdateStatusCallback callback) { … }
void ServiceWorkerUpdateChecker::OnOneUpdateCheckFinished(
int64_t old_resource_id,
const GURL& script_url,
ServiceWorkerSingleScriptUpdateChecker::Result result,
std::unique_ptr<ServiceWorkerSingleScriptUpdateChecker::FailureInfo>
failure_info,
std::unique_ptr<ServiceWorkerSingleScriptUpdateChecker::PausedState>
paused_state,
const std::optional<std::string>& sha256_checksum) { … }
std::map<GURL, ServiceWorkerUpdateChecker::ComparedScriptInfo>
ServiceWorkerUpdateChecker::TakeComparedResults() { … }
void ServiceWorkerUpdateChecker::CheckOneScript(const GURL& url,
const int64_t resource_id) { … }
void ServiceWorkerUpdateChecker::OnResourceIdAssignedForOneScriptCheck(
const GURL& url,
const int64_t resource_id,
const int64_t new_resource_id) { … }
ServiceWorkerUpdateChecker::ComparedScriptInfo::ComparedScriptInfo() = default;
ServiceWorkerUpdateChecker::ComparedScriptInfo::ComparedScriptInfo(
int64_t old_resource_id,
ServiceWorkerSingleScriptUpdateChecker::Result result,
std::unique_ptr<ServiceWorkerSingleScriptUpdateChecker::PausedState>
paused_state,
std::unique_ptr<ServiceWorkerSingleScriptUpdateChecker::FailureInfo>
failure_info)
: … { … }
ServiceWorkerUpdateChecker::ComparedScriptInfo::~ComparedScriptInfo() = default;
ServiceWorkerUpdateChecker::ComparedScriptInfo::ComparedScriptInfo(
ServiceWorkerUpdateChecker::ComparedScriptInfo&& other) = default;
ServiceWorkerUpdateChecker::ComparedScriptInfo&
ServiceWorkerUpdateChecker::ComparedScriptInfo::operator=(
ServiceWorkerUpdateChecker::ComparedScriptInfo&& other) = default;
}