chromium/components/optimization_guide/core/model_handler.h

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

#ifndef COMPONENTS_OPTIMIZATION_GUIDE_CORE_MODEL_HANDLER_H_
#define COMPONENTS_OPTIMIZATION_GUIDE_CORE_MODEL_HANDLER_H_

#include <optional>

#include "base/callback_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_functions.h"
#include "base/sequence_checker.h"
#include "base/task/cancelable_task_tracker.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/time.h"
#include "base/timer/elapsed_timer.h"
#include "base/types/optional_ref.h"
#include "components/optimization_guide/core/model_executor.h"
#include "components/optimization_guide/core/model_util.h"
#include "components/optimization_guide/core/optimization_guide_model_provider.h"
#include "components/optimization_guide/core/optimization_guide_util.h"
#include "components/optimization_guide/core/optimization_target_model_observer.h"
#include "components/optimization_guide/proto/models.pb.h"

namespace optimization_guide {

namespace {

void RecordTaskExecutionLatency(proto::OptimizationTarget optimization_target,
                                base::TimeDelta execution_time) {}

}  // namespace

// This class owns and handles the execution of models on the UI thread.
// Derived classes must provide an implementation of `ModelExecutor`
// which is then owned by `this`. The passed executor will be called
// and destroyed on the thread specified by `model_executor_task_runner`,
// which is all handled by this class.
//
// Derived classes that override `OnModelUpdated` must call the parent
// `OnModelUpdated` as the first step, for the internal state to be updated.
template <class OutputType, class InputType>
class ModelHandler : public OptimizationTargetModelObserver {};

}  // namespace optimization_guide

#endif  // COMPONENTS_OPTIMIZATION_GUIDE_CORE_MODEL_HANDLER_H_