chromium/chrome/browser/ui/views/performance_controls/memory_saver_resource_view.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "chrome/browser/ui/views/performance_controls/memory_saver_resource_view.h"

#include <string>

#include "base/numerics/angle_conversions.h"
#include "chrome/grit/generated_resources.h"
#include "components/performance_manager/public/features.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/text/bytes_formatting.h"
#include "ui/color/color_id.h"
#include "ui/color/color_provider.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/vector2d_f.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/flex_layout_view.h"
#include "ui/views/layout/layout_types.h"

DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(
    MemorySaverResourceView,
    kMemorySaverResourceViewMemorySavingsElementId);
DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(
    MemorySaverResourceView,
    kMemorySaverResourceViewMemoryLabelElementId);

namespace {

constexpr int kMemoryLabelSizeDelta =;
constexpr int kGaugeRadius =;
constexpr int kStrokeWidth =;
constexpr int kTickStrokeWidth =;
constexpr int kBucketCount =;
constexpr double kBucketWidthDegrees =;

constexpr int64_t kMemorySaverChartPmf25PercentileBytes =;
constexpr int64_t kMemorySaverChartPmf50PercentileBytes =;
constexpr int64_t kMemorySaverChartPmf75PercentileBytes =;
constexpr int64_t kMemorySaverChartPmf99PercentileBytes =;

// Enum to represent memory savings quartiles.
enum MemorySavingsQuartile {};

// Each element represents the label for the chart when memory savings are in
// the quartile represented by `MemorySavingsQuartile`. The last "quartile"
// instead represents the 99th percentile (or a full chart).
constexpr int kQuartilesLabels[] =;

// Returns which of the four quartiles of memory savings this number falls into.
// The lowest memory usage quartile (0-24th percentile) returns 0 and the
// highest quartile (75-99 percentile) returns 3.
int GetMemorySavingsQuartile(const int64_t memory_savings_bytes) {}

class GaugeView : public views::FlexLayoutView {};

BEGIN_METADATA()

}  // namespace

MemorySaverResourceView::MemorySaverResourceView(
    const int64_t memory_savings_bytes) {}