blob: be9964724615b57927e75198d47d42a30834ebff [file] [log] [blame]
nick22bcc7722016-05-10 18:43:411// Copyright 2016 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_TASK_MANAGEMENT_TASK_MANAGER_TESTER_H_
6#define CHROME_BROWSER_TASK_MANAGEMENT_TASK_MANAGER_TESTER_H_
7
nick50b06492016-05-10 23:40:278#include <stdint.h>
nick22bcc7722016-05-10 18:43:419
10#include <memory>
11
12#include "base/callback_forward.h"
13#include "base/strings/string16.h"
nick50b06492016-05-10 23:40:2714#include "chrome/browser/task_management/task_manager_browsertest_util.h"
nick22bcc7722016-05-10 18:43:4115
16namespace task_management {
17
18// An adapter that abstracts away the difference of old vs. new task manager.
19class TaskManagerTester {
20 public:
nick50b06492016-05-10 23:40:2721 using ColumnSpecifier = browsertest_util::ColumnSpecifier;
nick22bcc7722016-05-10 18:43:4122
23 // Creates a TaskManagerTester backed by the current task manager. The task
24 // manager should already be visible when you call this function. |callback|,
25 // if not a null callback, will be invoked when the underlying model changes.
26 static std::unique_ptr<TaskManagerTester> Create(
27 const base::Closure& callback);
28
afakhry174069722016-05-24 19:16:1629 // If using a legacy task manager, refresh the model.
30 static void MaybeRefreshLegacyInstance();
31
nick22bcc7722016-05-10 18:43:4132 virtual ~TaskManagerTester() {}
33
34 // Get the number of rows currently in the task manager.
35 virtual int GetRowCount() = 0;
36
37 // Get the title text of a particular |row|.
38 virtual base::string16 GetRowTitle(int row) = 0;
39
40 // Hide or show a column. If a column is not visible its stats are not
41 // necessarily gathered.
42 virtual void ToggleColumnVisibility(ColumnSpecifier column) = 0;
43
44 // Get the value of a column as an int64. Memory values are in bytes.
45 virtual int64_t GetColumnValue(ColumnSpecifier column, int row) = 0;
46
47 // If |row| is associated with a WebContents, return its SessionID. Otherwise,
48 // return -1.
49 virtual int32_t GetTabId(int row) = 0;
50
51 // Kill the process of |row|.
52 virtual void Kill(int row) = 0;
afakhry174069722016-05-24 19:16:1653
avi1c6f3ff82016-08-01 22:33:3554 // Gets the start index and length of the group to which the task at
55 // |row_index| belongs.
56 virtual void GetRowsGroupRange(int row, int* out_start, int* out_length) = 0;
57
afakhry174069722016-05-24 19:16:1658 private:
59 // Always creates a tester for the non-legacy TaskManager.
60 static std::unique_ptr<TaskManagerTester> CreateDefault(
61 const base::Closure& callback);
nick22bcc7722016-05-10 18:43:4162};
63
64} // namespace task_management
65
66#endif // CHROME_BROWSER_TASK_MANAGEMENT_TASK_MANAGER_TESTER_H_