#include "extensions/browser/service_worker/worker_id_set.h"
#include <algorithm>
#include <iterator>
#include <memory>
#include <string>
#include <vector>
#include "base/containers/flat_map.h"
#include "base/debug/crash_logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/string_number_conversions.h"
#include "content/public/browser/child_process_host.h"
#include "content/public/browser/service_worker_context.h"
#include "content/public/browser/service_worker_running_info.h"
#include "extensions/browser/extension_util.h"
#include "extensions/browser/process_map.h"
#include "extensions/browser/service_worker/worker_id.h"
#include "extensions/common/extension_id.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_registration.mojom.h"
namespace extensions {
namespace {
constexpr int64_t kSmallestVersionId = …;
constexpr int kSmallestThreadId = …;
constexpr int kSmallestRenderProcessId = …;
constexpr int kMaxWorkerCountToReport = …;
bool g_allow_multiple_workers_per_extension = …;
static_assert …;
static_assert …;
static_assert …;
content::ServiceWorkerRunningInfo::ServiceWorkerVersionStatus
GetWorkerLifecycleState(const WorkerId& worker_id,
content::BrowserContext* context) { … }
void EmitMultiWorkerMetrics(const char* metric_name,
const WorkerId& worker_id,
content::BrowserContext* context) { … }
}
WorkerIdSet::WorkerIdSet() = default;
WorkerIdSet::~WorkerIdSet() = default;
void WorkerIdSet::Add(const WorkerId& worker_id,
content::BrowserContext* context) { … }
bool WorkerIdSet::Remove(const WorkerId& worker_id) { … }
std::vector<WorkerId> WorkerIdSet::GetAllForExtension(
const ExtensionId& extension_id) const { … }
std::vector<WorkerId> WorkerIdSet::GetAllForExtension(
const ExtensionId& extension_id,
int64_t worker_version_id) const { … }
bool WorkerIdSet::Contains(const WorkerId& worker_id) const { … }
std::vector<WorkerId> WorkerIdSet::GetAllForExtension(
const ExtensionId& extension_id,
int render_process_id) const { … }
std::vector<WorkerId> WorkerIdSet::GetAllForTesting() const { … }
base::AutoReset<bool>
WorkerIdSet::AllowMultipleWorkersPerExtensionForTesting() { … }
namespace debug {
namespace {
const char* BoolToCrashKeyValue(bool value) { … }
std::string GetVersionIdValue(int64_t version_id) { … }
base::debug::CrashKeyString* GetExtensionIdCrashKey() { … }
base::debug::CrashKeyString* GetIdenticalVersionIdsCrashKey() { … }
base::debug::CrashKeyString* GetPreviousWorkerVersionIdCrashKey() { … }
base::debug::CrashKeyString* GetNewWorkerVersionIdCrashKey() { … }
base::debug::CrashKeyString* GetPreviousWorkerLifecycleStateCrashKey() { … }
base::debug::CrashKeyString* GetNewWorkerLifecycleStateCrashKey() { … }
const char* GetLifecycleStateValue(const WorkerId& worker_id,
content::BrowserContext* context) { … }
base::debug::CrashKeyString* GetIdenticalRendererProcessesIdsCrashKey() { … }
base::debug::CrashKeyString* GetPreviousWorkerRendererProcessRunningCrashKey() { … }
base::debug::CrashKeyString* GetNewWorkerRendererProcessRunningCrashKey() { … }
const char* GetRendererProcessRunningValue(const ExtensionId& extension_id,
int renderer_process_id,
content::BrowserContext* context) { … }
}
ScopedMultiWorkerCrashKeys::ScopedMultiWorkerCrashKeys(
const ExtensionId& extension_id,
const WorkerId& previous_worker_id,
const WorkerId& new_worker_id,
content::BrowserContext* context)
: … { … }
ScopedMultiWorkerCrashKeys::~ScopedMultiWorkerCrashKeys() = default;
}
}