1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_TASK_MANAGER_PROVIDERS_CHILD_PROCESS_TASK_H_
#define CHROME_BROWSER_TASK_MANAGER_PROVIDERS_CHILD_PROCESS_TASK_H_
#include <stdint.h>
#include <memory>
#include "chrome/browser/task_manager/providers/task.h"
#include "chrome/common/buildflags.h"
class ProcessResourceUsage;
namespace content {
struct ChildProcessData;
} // namespace content
namespace task_manager {
// Represents several types of the browser's child processes such as
// a plugin or a GPU process, ... etc.
class ChildProcessTask : public Task {
public:
// ChildProcessData has a ProcessType but that's not always granular enough to
// correctly determine what string to show as the name of the task. This enum
// is used to provide that information.
//
// Please consult Task Manager OWNERs when adding a new ProcessSubType.
// There is a dependency between Task Manager categories and a processes
// subtype.
enum class ProcessSubtype {
kNoSubtype,
// The "spare" render process, a render process used so that there is always
// a render process ready to go.
kSpareRenderProcess,
#if BUILDFLAG(ENABLE_GLIC)
// A render process used for chrome://glic.
kGlicRenderProcess,
#endif
// A render process that is unknown and for which no provider is available.
// Should not be used; all processes should be shown in the Task Manager.
// See https://crbug.com/739782 .
kUnknownRenderProcess,
};
// Creates a child process task given its |data| which is
// received from observing |content::BrowserChildProcessObserver|.
ChildProcessTask(const content::ChildProcessData& data,
ProcessSubtype subtype);
ChildProcessTask(const ChildProcessTask&) = delete;
ChildProcessTask& operator=(const ChildProcessTask&) = delete;
~ChildProcessTask() override;
// task_manager::Task:
void Refresh(const base::TimeDelta& update_interval,
int64_t refresh_flags) override;
Type GetType() const override;
SubType GetSubType() const override;
int GetChildProcessUniqueID() const override;
int64_t GetV8MemoryAllocated() const override;
int64_t GetV8MemoryUsed() const override;
private:
static gfx::ImageSkia* s_icon_;
// The Mojo service wrapper that will provide us with the V8 memory usage of
// the browser child process represented by this object.
std::unique_ptr<ProcessResourceUsage> process_resources_sampler_;
// The allocated and used V8 memory (in bytes).
int64_t v8_memory_allocated_;
int64_t v8_memory_used_;
// The unique ID of the child process. It is not the PID of the process.
// See |content::ChildProcessData::id|.
const int unique_child_process_id_;
// The type of the child process. See |content::ProcessType| and
// |NaClTrustedProcessType|.
const int process_type_;
// The subtype of the child process.
const ProcessSubtype process_subtype_;
// Depending on the |process_type_|, determines whether this task uses V8
// memory or not.
const bool uses_v8_memory_;
};
} // namespace task_manager
#endif // CHROME_BROWSER_TASK_MANAGER_PROVIDERS_CHILD_PROCESS_TASK_H_
|