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

#ifndef CONTENT_PUBLIC_BROWSER_ANDROID_CHILD_PROCESS_IMPORTANCE_H_
#define CONTENT_PUBLIC_BROWSER_ANDROID_CHILD_PROCESS_IMPORTANCE_H_

#include <iosfwd>

#include "base/process/process.h"
#include "content/common/content_export.h"

namespace content {

// Importance of a child process. For renderer processes, the importance is
// independent from visibility of its WebContents.
// Values are listed in increasing importance.
//
// Each importance results in a service binding with different service binding
// flags to tell the priority of the renderer process to Android system.
//
// NOT_PERCEPTIBLE importance leads to a service binding with
// `Context.BIND_NOT_PERCEPTIBLE` which is supported on Android Q+. On older
// Android version, NOT_PERCEPTIBLE importance falls back to NORMAL importance
// and the corresponding waived service binding.
//
// Note that the numerical order in ChildProcessImportance should be consistent
// because ChildProcessImportance is compared numerically in
// ChildProcessRanking.java.
//
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.content_public.browser
enum class ChildProcessImportance {
  // NORMAL is the default value.
  NORMAL = 0,
  NOT_PERCEPTIBLE,
  MODERATE,
  IMPORTANT,
};

CONTENT_EXPORT std::ostream& operator<<(std::ostream& out,
                                        ChildProcessImportance importance);

// Whether the device supports `ChildProcessImportance.PERCEPTIBLE` or not.
CONTENT_EXPORT bool IsNotPerceptibleImportanceSupported();

// Mapping from base::Process::Priority to ChildProcessImportance for
// integration with Performance Manager.
CONTENT_EXPORT ChildProcessImportance
PriorityToChildProcessImportance(base::Process::Priority priority);

}  // namespace content

#endif  // CONTENT_PUBLIC_BROWSER_ANDROID_CHILD_PROCESS_IMPORTANCE_H_
