chromium/content/browser/scheduler/responsiveness/calculator.cc

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

#include "content/browser/scheduler/responsiveness/calculator.h"

#include <algorithm>
#include <set>
#include <utility>

#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "content/public/browser/browser_thread.h"

namespace content {
namespace responsiveness {

namespace {

// We divide the measurement interval into discretized time slices. Each slice
// is marked as congested if it contained a congested task. A congested task is
// one whose execution latency is greater than kCongestionThreshold.
constexpr auto kMeasurementPeriod =;

// A task or event longer than kCongestionThreshold is considered congested.
constexpr auto kCongestionThreshold =;

// If there have been no events/tasks on the UI thread for a significant period
// of time, it's likely because Chrome was suspended.
// This value is copied from queueing_time_estimator.cc:kInvalidPeriodThreshold.
constexpr auto kSuspendInterval =;

constexpr char kLatencyEventCategory[] =;

// The names emitted for CongestedIntervals measurement events.
constexpr char kCongestedIntervalEvent[] =;
constexpr char kCongestedIntervalsMeasurementEvent[] =;

// Given a |congestion|, finds each congested slice between |start_time| and
// |end_time|, and adds it to |congested_slices|.
void AddCongestedSlices(std::set<int>* congested_slices,
                        const Calculator::Congestion& congestion,
                        base::TimeTicks start_time,
                        base::TimeTicks end_time) {}

}  // namespace

Calculator::Congestion::Congestion(base::TimeTicks start_time,
                                   base::TimeTicks end_time)
    :{}

Calculator::Calculator(
    std::unique_ptr<ResponsivenessCalculatorDelegate> delegate)
    :{}
#endif

Calculator::~Calculator() {}

void Calculator::TaskOrEventFinishedOnUIThread(
    base::TimeTicks queue_time,
    base::TimeTicks execution_start_time,
    base::TimeTicks execution_finish_time) {}

void Calculator::TaskOrEventFinishedOnIOThread(
    base::TimeTicks queue_time,
    base::TimeTicks execution_start_time,
    base::TimeTicks execution_finish_time) {}

void Calculator::OnFirstIdle() {}

void Calculator::EmitResponsiveness(CongestionType congestion_type,
                                    size_t num_congested_slices,
                                    StartupStage startup_stage) {}

void Calculator::EmitResponsivenessTraceEvents(
    CongestionType congestion_type,
    base::TimeTicks start_time,
    base::TimeTicks end_time,
    const std::set<int>& congested_slices) {}

void Calculator::EmitCongestedIntervalsMeasurementTraceEvent(
    base::TimeTicks start_time,
    base::TimeTicks end_time,
    size_t amount_of_slices) {}

void Calculator::EmitCongestedIntervalTraceEvent(base::TimeTicks start_time,
                                                 base::TimeTicks end_time) {}

base::TimeTicks Calculator::GetLastCalculationTime() {}

void Calculator::CalculateResponsivenessIfNecessary(
    base::TimeTicks current_time) {}

void Calculator::CalculateResponsiveness(
    CongestionType congestion_type,
    std::vector<CongestionList> congestions_from_multiple_threads,
    base::TimeTicks start_time,
    base::TimeTicks end_time) {}

Calculator::CongestionList& Calculator::GetExecutionCongestionOnUIThread() {}

Calculator::CongestionList& Calculator::GetCongestionOnUIThread() {}

#if BUILDFLAG(IS_ANDROID)
void Calculator::OnApplicationStateChanged(
    base::android::ApplicationState state) {
  DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
  switch (state) {
    case base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES:
    case base::android::APPLICATION_STATE_HAS_PAUSED_ACTIVITIES:
      // The application is still visible and partially hidden in paused state.
      is_application_visible_ = true;
      break;
    case base::android::APPLICATION_STATE_HAS_STOPPED_ACTIVITIES:
    case base::android::APPLICATION_STATE_HAS_DESTROYED_ACTIVITIES:
      is_application_visible_ = false;
      break;
    case base::android::APPLICATION_STATE_UNKNOWN:
      break;  // Keep in previous state.
  }
}
#endif

// static
Calculator::CongestionList Calculator::TakeCongestionsOlderThanTime(
    CongestionList* congestions,
    base::TimeTicks end_time) {}

}  // namespace responsiveness
}  // namespace content