#ifndef MEDIA_LEARNING_IMPL_LEARNING_SESSION_IMPL_H_
#define MEDIA_LEARNING_IMPL_LEARNING_SESSION_IMPL_H_
#include <map>
#include "base/component_export.h"
#include "base/memory/weak_ptr.h"
#include "base/task/sequenced_task_runner.h"
#include "base/threading/sequence_bound.h"
#include "media/learning/common/learning_session.h"
#include "media/learning/common/learning_task_controller.h"
#include "media/learning/impl/feature_provider.h"
namespace media {
namespace learning {
class COMPONENT_EXPORT(LEARNING_IMPL) LearningSessionImpl
: public LearningSession {
public:
explicit LearningSessionImpl(
scoped_refptr<base::SequencedTaskRunner> task_runner);
~LearningSessionImpl() override;
using CreateTaskControllerCB =
base::RepeatingCallback<base::SequenceBound<LearningTaskController>(
scoped_refptr<base::SequencedTaskRunner>,
const LearningTask&,
SequenceBoundFeatureProvider)>;
void SetTaskControllerFactoryCBForTesting(CreateTaskControllerCB cb);
std::unique_ptr<LearningTaskController> GetController(
const std::string& task_name) override;
void RegisterTask(const LearningTask& task,
SequenceBoundFeatureProvider feature_provider =
SequenceBoundFeatureProvider());
private:
scoped_refptr<base::SequencedTaskRunner> task_runner_;
using LearningTaskControllerMap =
std::map<std::string, base::SequenceBound<LearningTaskController>>;
LearningTaskControllerMap controller_map_;
std::map<std::string, LearningTask> task_map_;
CreateTaskControllerCB controller_factory_;
base::WeakPtrFactory<LearningSessionImpl> weak_factory_{this};
};
}
}
#endif