#include "content/browser/devtools/devtools_background_services_context_impl.h"
#include <algorithm>
#include "base/check_deref.h"
#include "base/observer_list.h"
#include "base/strings/string_number_conversions.h"
#include "base/time/time.h"
#include "base/uuid.h"
#include "content/public/browser/browser_context.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/browser/service_worker_context.h"
#include "content/public/common/content_client.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "url/origin.h"
namespace content {
namespace {
std::string CreateEntryKeyPrefix(devtools::proto::BackgroundService service) { … }
std::string CreateEntryKey(devtools::proto::BackgroundService service) { … }
constexpr devtools::proto::BackgroundService ServiceToProtoEnum(
DevToolsBackgroundService service) { … }
}
DevToolsBackgroundServicesContextImpl::DevToolsBackgroundServicesContextImpl(
BrowserContext* browser_context,
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context)
: … { … }
DevToolsBackgroundServicesContextImpl::
~DevToolsBackgroundServicesContextImpl() = default;
void DevToolsBackgroundServicesContextImpl::AddObserver(
EventObserver* observer) { … }
void DevToolsBackgroundServicesContextImpl::RemoveObserver(
const EventObserver* observer) { … }
void DevToolsBackgroundServicesContextImpl::StartRecording(
devtools::proto::BackgroundService service) { … }
void DevToolsBackgroundServicesContextImpl::StopRecording(
devtools::proto::BackgroundService service) { … }
bool DevToolsBackgroundServicesContextImpl::IsRecording(
DevToolsBackgroundService service) { … }
bool DevToolsBackgroundServicesContextImpl::IsRecording(
devtools::proto::BackgroundService service) { … }
bool DevToolsBackgroundServicesContextImpl::IsRecordingExpired(
devtools::proto::BackgroundService service) { … }
void DevToolsBackgroundServicesContextImpl::GetLoggedBackgroundServiceEvents(
devtools::proto::BackgroundService service,
GetLoggedBackgroundServiceEventsCallback callback) { … }
void DevToolsBackgroundServicesContextImpl::DidGetUserData(
GetLoggedBackgroundServiceEventsCallback callback,
const std::vector<std::pair<int64_t, std::string>>& user_data,
blink::ServiceWorkerStatusCode status) { … }
void DevToolsBackgroundServicesContextImpl::ClearLoggedBackgroundServiceEvents(
devtools::proto::BackgroundService service) { … }
void DevToolsBackgroundServicesContextImpl::LogBackgroundServiceEvent(
uint64_t service_worker_registration_id,
blink::StorageKey storage_key,
DevToolsBackgroundService service,
const std::string& event_name,
const std::string& instance_id,
const std::map<std::string, std::string>& event_metadata) { … }
void DevToolsBackgroundServicesContextImpl::NotifyEventObservers(
const devtools::proto::BackgroundServiceEvent& event) { … }
void DevToolsBackgroundServicesContextImpl::OnRecordingTimeExpired(
devtools::proto::BackgroundService service) { … }
}