#include "content/browser/service_worker/service_worker_context_watcher.h"
#include <utility>
#include "base/functional/bind.h"
#include "content/browser/service_worker/service_worker_context_wrapper.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/console_message.h"
#include "third_party/blink/public/common/service_worker/embedded_worker_status.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/mojom/devtools/console_message.mojom.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_object.mojom.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_registration.mojom.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace content {
namespace {
bool IsStoppedAndRedundant(const ServiceWorkerVersionInfo& version_info) { … }
}
ServiceWorkerContextWatcher::ServiceWorkerContextWatcher(
scoped_refptr<ServiceWorkerContextWrapper> context,
WorkerRegistrationUpdatedCallback registration_callback,
WorkerVersionUpdatedCallback version_callback,
WorkerErrorReportedCallback error_callback)
: … { … }
void ServiceWorkerContextWatcher::Start() { … }
void ServiceWorkerContextWatcher::Stop() { … }
void ServiceWorkerContextWatcher::OnStoredRegistrations(
blink::ServiceWorkerStatusCode status,
const std::vector<ServiceWorkerRegistrationInfo>& stored_registrations) { … }
ServiceWorkerContextWatcher::~ServiceWorkerContextWatcher() = default;
void ServiceWorkerContextWatcher::StoreRegistrationInfo(
const ServiceWorkerRegistrationInfo& registration_info,
std::unordered_map<int64_t, std::unique_ptr<ServiceWorkerRegistrationInfo>>*
info_map) { … }
void ServiceWorkerContextWatcher::StoreVersionInfo(
const ServiceWorkerVersionInfo& version_info) { … }
void ServiceWorkerContextWatcher::SendRegistrationInfo(
int64_t registration_id,
const GURL& scope,
const blink::StorageKey& key,
ServiceWorkerRegistrationInfo::DeleteFlag delete_flag) { … }
void ServiceWorkerContextWatcher::SendVersionInfo(
const ServiceWorkerVersionInfo& version_info) { … }
void ServiceWorkerContextWatcher::RunWorkerRegistrationUpdatedCallback(
std::unique_ptr<std::vector<ServiceWorkerRegistrationInfo>> registrations) { … }
void ServiceWorkerContextWatcher::RunWorkerVersionUpdatedCallback(
std::unique_ptr<std::vector<ServiceWorkerVersionInfo>> versions) { … }
void ServiceWorkerContextWatcher::RunWorkerErrorReportedCallback(
int64_t registration_id,
int64_t version_id,
std::unique_ptr<ServiceWorkerContextObserver::ErrorInfo> error_info) { … }
void ServiceWorkerContextWatcher::OnNewLiveRegistration(
int64_t registration_id,
const GURL& scope,
const blink::StorageKey& key) { … }
void ServiceWorkerContextWatcher::OnNewLiveVersion(
const ServiceWorkerVersionInfo& version_info) { … }
void ServiceWorkerContextWatcher::OnStarting(int64_t version_id) { … }
void ServiceWorkerContextWatcher::OnStarted(
int64_t version_id,
const GURL& scope,
int process_id,
const GURL& script_url,
const blink::ServiceWorkerToken& token,
const blink::StorageKey& key) { … }
void ServiceWorkerContextWatcher::OnStopping(int64_t version_id) { … }
void ServiceWorkerContextWatcher::OnStopped(int64_t version_id) { … }
void ServiceWorkerContextWatcher::OnVersionStateChanged(
int64_t version_id,
const GURL& scope,
const blink::StorageKey& key,
content::ServiceWorkerVersion::Status status) { … }
void ServiceWorkerContextWatcher::OnVersionRouterRulesChanged(
int64_t version_id,
const std::string& router_rules) { … }
void ServiceWorkerContextWatcher::OnVersionDevToolsRoutingIdChanged(
int64_t version_id,
int process_id,
int devtools_agent_route_id) { … }
void ServiceWorkerContextWatcher::OnMainScriptResponseSet(
int64_t version_id,
base::Time script_response_time,
base::Time script_last_modified) { … }
void ServiceWorkerContextWatcher::OnErrorReported(
int64_t version_id,
const GURL& scope,
const blink::StorageKey& key,
const ServiceWorkerContextObserver::ErrorInfo& info) { … }
void ServiceWorkerContextWatcher::OnReportConsoleMessage(
int64_t version_id,
const GURL& scope,
const blink::StorageKey& key,
const ConsoleMessage& message) { … }
void ServiceWorkerContextWatcher::OnControlleeAdded(
int64_t version_id,
const std::string& uuid,
const ServiceWorkerClientInfo& info) { … }
void ServiceWorkerContextWatcher::OnControlleeRemoved(int64_t version_id,
const std::string& uuid) { … }
void ServiceWorkerContextWatcher::OnRegistrationCompleted(
int64_t registration_id,
const GURL& scope,
const blink::StorageKey& key) { … }
void ServiceWorkerContextWatcher::OnRegistrationDeleted(
int64_t registration_id,
const GURL& scope,
const blink::StorageKey& key) { … }
void ServiceWorkerContextWatcher::OnRunningStateChanged(
int64_t version_id,
blink::EmbeddedWorkerStatus running_status) { … }
}