OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_TASK_MANAGEMENT_TASK_MANAGER_TESTER_H_ | 5 #ifndef CHROME_BROWSER_TASK_MANAGEMENT_TASK_MANAGER_TESTER_H_ |
6 #define CHROME_BROWSER_TASK_MANAGEMENT_TASK_MANAGER_TESTER_H_ | 6 #define CHROME_BROWSER_TASK_MANAGEMENT_TASK_MANAGER_TESTER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "chrome/browser/task_management/task_manager_browsertest_util.h" | 14 #include "chrome/browser/task_management/task_manager_browsertest_util.h" |
15 | 15 |
16 namespace task_management { | 16 namespace task_management { |
17 | 17 |
18 // An adapter that abstracts away the difference of old vs. new task manager. | 18 // An adapter that abstracts away the difference of old vs. new task manager. |
19 class TaskManagerTester { | 19 class TaskManagerTester { |
20 public: | 20 public: |
21 using ColumnSpecifier = browsertest_util::ColumnSpecifier; | 21 using ColumnSpecifier = browsertest_util::ColumnSpecifier; |
22 | 22 |
23 // Creates a TaskManagerTester backed by the current task manager. The task | 23 // Creates a TaskManagerTester backed by the current task manager. The task |
24 // manager should already be visible when you call this function. |callback|, | 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. | 25 // if not a null callback, will be invoked when the underlying model changes. |
26 static std::unique_ptr<TaskManagerTester> Create( | 26 static std::unique_ptr<TaskManagerTester> Create( |
27 const base::Closure& callback); | 27 const base::Closure& callback); |
28 | 28 |
| 29 // If using a legacy task manager, refresh the model. |
| 30 static void MaybeRefreshLegacyInstance(); |
| 31 |
29 virtual ~TaskManagerTester() {} | 32 virtual ~TaskManagerTester() {} |
30 | 33 |
31 // Get the number of rows currently in the task manager. | 34 // Get the number of rows currently in the task manager. |
32 virtual int GetRowCount() = 0; | 35 virtual int GetRowCount() = 0; |
33 | 36 |
34 // Get the title text of a particular |row|. | 37 // Get the title text of a particular |row|. |
35 virtual base::string16 GetRowTitle(int row) = 0; | 38 virtual base::string16 GetRowTitle(int row) = 0; |
36 | 39 |
37 // Hide or show a column. If a column is not visible its stats are not | 40 // Hide or show a column. If a column is not visible its stats are not |
38 // necessarily gathered. | 41 // necessarily gathered. |
39 virtual void ToggleColumnVisibility(ColumnSpecifier column) = 0; | 42 virtual void ToggleColumnVisibility(ColumnSpecifier column) = 0; |
40 | 43 |
41 // Get the value of a column as an int64. Memory values are in bytes. | 44 // Get the value of a column as an int64. Memory values are in bytes. |
42 virtual int64_t GetColumnValue(ColumnSpecifier column, int row) = 0; | 45 virtual int64_t GetColumnValue(ColumnSpecifier column, int row) = 0; |
43 | 46 |
44 // If |row| is associated with a WebContents, return its SessionID. Otherwise, | 47 // If |row| is associated with a WebContents, return its SessionID. Otherwise, |
45 // return -1. | 48 // return -1. |
46 virtual int32_t GetTabId(int row) = 0; | 49 virtual int32_t GetTabId(int row) = 0; |
47 | 50 |
48 // Kill the process of |row|. | 51 // Kill the process of |row|. |
49 virtual void Kill(int row) = 0; | 52 virtual void Kill(int row) = 0; |
| 53 |
| 54 private: |
| 55 // Always creates a tester for the non-legacy TaskManager. |
| 56 static std::unique_ptr<TaskManagerTester> CreateDefault( |
| 57 const base::Closure& callback); |
50 }; | 58 }; |
51 | 59 |
52 } // namespace task_management | 60 } // namespace task_management |
53 | 61 |
54 #endif // CHROME_BROWSER_TASK_MANAGEMENT_TASK_MANAGER_TESTER_H_ | 62 #endif // CHROME_BROWSER_TASK_MANAGEMENT_TASK_MANAGER_TESTER_H_ |
OLD | NEW |