chromium/extensions/browser/api/offscreen/lifetime_enforcer_factories.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "extensions/browser/api/offscreen/lifetime_enforcer_factories.h"

#include "base/check.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/not_fatal_until.h"
#include "base/types/cxx23_to_underlying.h"
#include "extensions/browser/api/offscreen/audio_lifetime_enforcer.h"
#include "extensions/browser/api/offscreen/offscreen_document_lifetime_enforcer.h"
#include "extensions/common/api/offscreen.h"

namespace extensions {

namespace {

LifetimeEnforcerFactories::TestingOverride* g_testing_override =;

// A lifetime enforcer that gives offscreen documents unbounded lifetime. This
// can be used for both reasons that may always have unbounded life (like
// testing) and for reasons for which we do not have custom lifetime enforcement
// yet.
class EmptyLifetimeEnforcer : public OffscreenDocumentLifetimeEnforcer {};

std::unique_ptr<OffscreenDocumentLifetimeEnforcer> CreateEmptyEnforcer(
    OffscreenDocumentHost* offscreen_document,
    OffscreenDocumentLifetimeEnforcer::TerminationCallback termination_callback,
    OffscreenDocumentLifetimeEnforcer::NotifyInactiveCallback
        notify_inactive_callback) {}

std::unique_ptr<OffscreenDocumentLifetimeEnforcer> CreateAudioLifetimeEnforcer(
    OffscreenDocumentHost* offscreen_document,
    OffscreenDocumentLifetimeEnforcer::TerminationCallback termination_callback,
    OffscreenDocumentLifetimeEnforcer::NotifyInactiveCallback
        notify_inactive_callback) {}

LifetimeEnforcerFactories& GetFactoriesInstance() {}

FactoryMethodPtr;

struct ReasonAndFactoryMethodPair {};

// A mapping between each of the different reasons and their corresponding
// factory methods.
constexpr ReasonAndFactoryMethodPair kReasonAndFactoryMethodPairs[] =;

static_assert;

}  // namespace

LifetimeEnforcerFactories::LifetimeEnforcerFactories() {}

LifetimeEnforcerFactories::~LifetimeEnforcerFactories() = default;

// static
std::unique_ptr<OffscreenDocumentLifetimeEnforcer>
LifetimeEnforcerFactories::GetLifetimeEnforcer(
    api::offscreen::Reason reason,
    OffscreenDocumentHost* offscreen_document,
    OffscreenDocumentLifetimeEnforcer::TerminationCallback termination_callback,
    OffscreenDocumentLifetimeEnforcer::NotifyInactiveCallback
        notify_inactive_callback) {}

LifetimeEnforcerFactories::TestingOverride::TestingOverride() {}

LifetimeEnforcerFactories::TestingOverride::~TestingOverride() {}

void LifetimeEnforcerFactories::InitializeFactories() {}

}  // namespace extensions