File: test_task_manager.cc

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (207 lines) | stat: -rw-r--r-- 4,991 bytes parent folder | download | duplicates (5)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
// 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.

#include "chrome/browser/task_manager/test_task_manager.h"

#include "base/timer/mock_timer.h"

namespace task_manager {

TestTaskManager::TestTaskManager()
    : handle_(base::kNullProcessHandle),
      pid_(base::kNullProcessId) {
  set_timer_for_testing(std::make_unique<base::MockRepeatingTimer>());
}

TestTaskManager::~TestTaskManager() = default;

void TestTaskManager::ActivateTask(TaskId task_id) {
}

bool TestTaskManager::IsTaskKillable(TaskId task_id) {
  return true;
}

bool TestTaskManager::KillTask(TaskId task_id) {
  return true;
}

double TestTaskManager::GetPlatformIndependentCPUUsage(TaskId task_id) const {
  return 0.0;
}

base::Time TestTaskManager::GetStartTime(TaskId task_id) const {
  return base::Time();
}

base::TimeDelta TestTaskManager::GetCpuTime(TaskId task_id) const {
  return base::TimeDelta();
}

int64_t TestTaskManager::GetMemoryFootprintUsage(TaskId task_id) const {
  return -1;
}

int64_t TestTaskManager::GetSwappedMemoryUsage(TaskId task_id) const {
  return -1;
}

int64_t TestTaskManager::GetGpuMemoryUsage(TaskId task_id,
                                           bool* has_duplicates) const {
  return -1;
}

int TestTaskManager::GetIdleWakeupsPerSecond(TaskId task_id) const {
  return -1;
}

int TestTaskManager::GetHardFaultsPerSecond(TaskId task_id) const {
  return -1;
}

int TestTaskManager::GetNaClDebugStubPort(TaskId task_id) const {
  return -1;
}

void TestTaskManager::GetGDIHandles(TaskId task_id,
                                    int64_t* current,
                                    int64_t* peak) const {}

void TestTaskManager::GetUSERHandles(TaskId task_id,
                                     int64_t* current,
                                     int64_t* peak) const {}

int TestTaskManager::GetOpenFdCount(TaskId task_id) const {
  return -1;
}

bool TestTaskManager::IsTaskOnBackgroundedProcess(TaskId task_id) const {
  return false;
}

const std::u16string& TestTaskManager::GetTitle(TaskId task_id) const {
  return title_;
}

std::u16string TestTaskManager::GetProfileName(TaskId task_id) const {
  return std::u16string();
}

const gfx::ImageSkia& TestTaskManager::GetIcon(TaskId task_id) const {
  return icon_;
}

const base::ProcessHandle& TestTaskManager::GetProcessHandle(
    TaskId task_id) const {
  return handle_;
}

const base::ProcessId& TestTaskManager::GetProcessId(TaskId task_id) const {
  return pid_;
}

TaskId TestTaskManager::GetRootTaskId(TaskId task_id) const {
  return 0;
}

Task::Type TestTaskManager::GetType(TaskId task_id) const {
  return Task::UNKNOWN;
}

Task::SubType TestTaskManager::GetSubType(TaskId task_id) const {
  return Task::SubType::kNoSubType;
}

SessionID TestTaskManager::GetTabId(TaskId task_id) const {
  return SessionID::InvalidValue();
}

int TestTaskManager::GetChildProcessUniqueId(TaskId task_id) const {
  return 0;
}

void TestTaskManager::GetTerminationStatus(TaskId task_id,
                                           base::TerminationStatus* out_status,
                                           int* out_error_code) const {
  DCHECK(out_status);
  DCHECK(out_error_code);

  *out_status = base::TERMINATION_STATUS_STILL_RUNNING;
  *out_error_code = 0;
}

int64_t TestTaskManager::GetNetworkUsage(TaskId task_id) const {
  return 0;
}

int64_t TestTaskManager::GetProcessTotalNetworkUsage(TaskId task_id) const {
  return -1;
}

int64_t TestTaskManager::GetCumulativeNetworkUsage(TaskId task_id) const {
  return 0;
}

int64_t TestTaskManager::GetCumulativeProcessTotalNetworkUsage(
    TaskId task_id) const {
  return 0;
}

int64_t TestTaskManager::GetSqliteMemoryUsed(TaskId task_id) const {
  return -1;
}

bool TestTaskManager::GetV8Memory(TaskId task_id,
                                  int64_t* allocated,
                                  int64_t* used) const {
  return false;
}

bool TestTaskManager::GetWebCacheStats(
    TaskId task_id,
    blink::WebCacheResourceTypeStats* stats) const {
  return false;
}

int TestTaskManager::GetKeepaliveCount(TaskId task_id) const {
  return -1;
}

const TaskIdList& TestTaskManager::GetTaskIdsList() const {
  return ids_;
}

TaskIdList TestTaskManager::GetIdsOfTasksSharingSameProcess(
    TaskId task_id) const {
  TaskIdList result;
  result.push_back(task_id);
  return result;
}

size_t TestTaskManager::GetNumberOfTasksOnSameProcess(TaskId task_id) const {
  return 1;
}

bool TestTaskManager::IsRunningInVM(TaskId task_id) const {
  return false;
}

TaskId TestTaskManager::GetTaskIdForWebContents(
    content::WebContents* web_contents) const {
  return -1;
}

bool TestTaskManager::IsTaskValid(TaskId task_id) const {
  return true;
}

base::TimeDelta TestTaskManager::GetRefreshTime() {
  return GetCurrentRefreshTime();
}

int64_t TestTaskManager::GetEnabledFlags() {
  return enabled_resources_flags();
}

}  // namespace task_manager