chromium/components/keyed_service/core/keyed_service_templated_factory.cc

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

#include "components/keyed_service/core/keyed_service_templated_factory.h"

#include <concepts>
#include <memory>
#include <utility>

#include "base/check.h"
#include "base/containers/contains.h"
#include "base/containers/flat_map.h"
#include "base/functional/callback.h"
#include "base/memory/scoped_refptr.h"
#include "base/no_destructor.h"
#include "components/keyed_service/core/dependency_manager.h"
#include "components/keyed_service/core/features_buildflags.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/keyed_service/core/refcounted_keyed_service.h"
#include "services/tracing/public/cpp/perfetto/macros.h"
#include "third_party/perfetto/protos/perfetto/trace/track_event/chrome_keyed_service.pbzero.h"

template <typename ServiceType>
KeyedServiceTemplatedFactory<ServiceType>::MappingInfo::MappingInfo() = default;

template <typename ServiceType>
KeyedServiceTemplatedFactory<ServiceType>::MappingInfo::MappingInfo(
    MappingInfo&&) = default;

template <typename ServiceType>
KeyedServiceTemplatedFactory<ServiceType>::MappingInfo&
KeyedServiceTemplatedFactory<ServiceType>::MappingInfo::operator=(
    MappingInfo&&) = default;

template <typename ServiceType>
KeyedServiceTemplatedFactory<ServiceType>::MappingInfo::~MappingInfo() =
    default;

// static
template <typename ServiceType>
size_t KeyedServiceTemplatedFactory<ServiceType>::GetServicesCount(
    const void* context) {}

template <typename ServiceType>
KeyedServiceTemplatedFactory<ServiceType>::~KeyedServiceTemplatedFactory() =
    default;

template <typename ServiceType>
void KeyedServiceTemplatedFactory<ServiceType>::SetTestingFactory(
    void* context,
    TestingFactory testing_factory) {}

template <typename ServiceType>
KeyedServiceTemplatedFactory<ServiceType>::ServicePtr
KeyedServiceTemplatedFactory<ServiceType>::SetTestingFactoryAndUse(
    void* context,
    TestingFactory testing_factory) {}

template <typename ServiceType>
KeyedServiceTemplatedFactory<ServiceType>::ServicePtr
KeyedServiceTemplatedFactory<ServiceType>::GetServiceForContext(void* context,
                                                                bool create) {}

#if BUILDFLAG(KEYED_SERVICE_HAS_DEPRECATED_ASSOCIATE_API)

template <typename ServiceType>
void KeyedServiceTemplatedFactory<ServiceType>::Associate(
    void* context,
    OwnedServicePtr service) {}

template <typename ServiceType>
void KeyedServiceTemplatedFactory<ServiceType>::Disassociate(void* context) {}

#endif

template <typename ServiceType>
void KeyedServiceTemplatedFactory<ServiceType>::ContextCreated(void* context) {}

template <typename ServiceType>
void KeyedServiceTemplatedFactory<ServiceType>::ContextInitialized(
    void* context,
    bool is_testing_context) {}

template <typename ServiceType>
void KeyedServiceTemplatedFactory<ServiceType>::ContextShutdown(void* context) {}

template <typename ServiceType>
void KeyedServiceTemplatedFactory<ServiceType>::ContextDestroyed(
    void* context) {}

template <typename ServiceType>
bool KeyedServiceTemplatedFactory<ServiceType>::IsServiceCreated(
    void* context) const {}

template <typename ServiceType>
void KeyedServiceTemplatedFactory<ServiceType>::CreateServiceNow(
    void* context) {}

template <typename ServiceType>
base::flat_map<const void*, size_t>&
KeyedServiceTemplatedFactory<ServiceType>::GetServicesCountMap() {}

template <typename ServiceType>
KeyedServiceTemplatedFactory<ServiceType>::Mapping::iterator
KeyedServiceTemplatedFactory<ServiceType>::FindOrCreateMapping(void* context) {}

// Explicitly instantiate the supported KeyedServiceTemplatedFactory variants.
template class KeyedServiceTemplatedFactory<KeyedService>;
template class KeyedServiceTemplatedFactory<RefcountedKeyedService>;