OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" | 5 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" |
6 | 6 |
7 #include "base/bind_helpers.h" | |
7 #include "base/command_line.h" | 8 #include "base/command_line.h" |
8 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/ptr_util.h" | |
9 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
10 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
11 #include "base/strings/pattern.h" | 13 #include "base/strings/pattern.h" |
12 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
13 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
14 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
15 #include "base/test/test_timeouts.h" | 17 #include "base/test/test_timeouts.h" |
16 #include "base/thread_task_runner_handle.h" | 18 #include "base/thread_task_runner_handle.h" |
17 #include "base/timer/timer.h" | 19 #include "base/timer/timer.h" |
18 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/sessions/session_tab_helper.h" | |
23 #include "chrome/browser/task_management/task_manager_interface.h" | |
20 #include "chrome/browser/task_manager/resource_provider.h" | 24 #include "chrome/browser/task_manager/resource_provider.h" |
21 #include "chrome/browser/task_manager/task_manager.h" | 25 #include "chrome/browser/task_manager/task_manager.h" |
26 #include "chrome/browser/ui/task_manager/task_manager_table_model.h" | |
afakhry
2016/04/28 00:03:13
I don't see you changed any DEPS. Does that mean y
ncarter (slow)
2016/05/02 18:33:28
It's ui/views (to get the view) that had the deps
afakhry
2016/05/02 18:58:17
Oh cool. Glad I moved there earlier! :)
| |
22 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
23 #include "chrome/grit/generated_resources.h" | 28 #include "chrome/grit/generated_resources.h" |
24 #include "extensions/strings/grit/extensions_strings.h" | 29 #include "extensions/strings/grit/extensions_strings.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
26 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
32 #include "ui/base/models/table_model_observer.h" | |
33 | |
34 // TODO(nick): Move everything here (except for LegacyTaskManagerTesterImpl) | |
35 // into the task_management namespace. | |
36 namespace task_management { | |
37 | |
38 // Temporarily intercepts the calls between a TableModel and its Observer, | |
39 // running |callback| whenever anything happens. | |
40 class ScopedInterceptTableModelObserver : public ui::TableModelObserver { | |
41 public: | |
42 ScopedInterceptTableModelObserver( | |
43 ui::TableModel* model, | |
afakhry
2016/04/28 00:03:13
The naming of the variables can be confusing. Woul
ncarter (slow)
2016/05/02 18:33:28
Done.
| |
44 ui::TableModelObserver* real_table_model_observer, | |
45 const base::Closure& callback) | |
46 : model_(model), | |
47 real_table_model_observer_(real_table_model_observer), | |
48 callback_(callback) { | |
49 model_->SetObserver(this); | |
50 } | |
51 | |
52 ~ScopedInterceptTableModelObserver() override { | |
53 model_->SetObserver(real_table_model_observer_); | |
54 } | |
55 | |
56 // ui::TableModelObserver: | |
57 void OnModelChanged() override { | |
58 real_table_model_observer_->OnModelChanged(); | |
59 callback_.Run(); | |
60 } | |
61 void OnItemsChanged(int start, int length) override { | |
62 real_table_model_observer_->OnItemsChanged(start, length); | |
63 callback_.Run(); | |
64 } | |
65 void OnItemsAdded(int start, int length) override { | |
66 real_table_model_observer_->OnItemsAdded(start, length); | |
67 callback_.Run(); | |
68 } | |
69 void OnItemsRemoved(int start, int length) override { | |
70 real_table_model_observer_->OnItemsRemoved(start, length); | |
71 callback_.Run(); | |
72 } | |
73 | |
74 private: | |
75 ui::TableModel* model_; | |
76 ui::TableModelObserver* real_table_model_observer_; | |
77 base::Closure callback_; | |
78 }; | |
79 | |
80 class TaskManagerTesterImpl | |
81 : public task_manager::browsertest_util::TaskManagerTester { | |
82 public: | |
83 explicit TaskManagerTesterImpl(const base::Closure& on_resource_change) | |
84 : model_(GetRealModel()) { | |
85 // Eavesdrop the model->view conversation, since the model only supports | |
86 // single observation. | |
87 if (!on_resource_change.is_null()) { | |
88 interceptor_.reset(new ScopedInterceptTableModelObserver( | |
89 model_, model_->table_model_observer_, on_resource_change)); | |
90 } | |
91 } | |
92 | |
93 ~TaskManagerTesterImpl() override { | |
94 CHECK_EQ(GetRealModel(), model_) << "Task Manager should not be hidden " | |
95 "while TaskManagerTester is alive. " | |
96 "This indicates a test bug."; | |
97 } | |
98 | |
99 // TaskManagerTester: | |
100 int GetRowCount() override { return model_->RowCount(); } | |
101 | |
102 base::string16 GetRowTitle(int row) override { | |
103 return model_->GetText(row, IDS_TASK_MANAGER_TASK_COLUMN); | |
104 } | |
105 | |
106 void ToggleColumnVisibility( | |
107 task_manager::browsertest_util::ColumnSpecifier column) override { | |
108 int column_id = 0; | |
109 switch (column) { | |
110 case task_manager::browsertest_util::COLUMN_NONE: | |
111 return; | |
112 case task_manager::browsertest_util::SQLITE_MEMORY_USED: | |
113 column_id = IDS_TASK_MANAGER_SQLITE_MEMORY_USED_COLUMN; | |
114 break; | |
115 case task_manager::browsertest_util::V8_MEMORY_USED: | |
116 case task_manager::browsertest_util::V8_MEMORY: | |
117 column_id = IDS_TASK_MANAGER_JAVASCRIPT_MEMORY_ALLOCATED_COLUMN; | |
118 break; | |
119 } | |
120 model_->ToggleColumnVisibility(column_id); | |
121 } | |
122 | |
123 int64_t GetColumnValue(task_manager::browsertest_util::ColumnSpecifier column, | |
124 int row) override { | |
125 TaskId task_id = model_->tasks_[row]; | |
126 int64_t value = 0; | |
127 int64_t ignored = 0; | |
128 bool success = false; | |
129 | |
130 switch (column) { | |
131 case task_manager::browsertest_util::COLUMN_NONE: | |
132 break; | |
133 case task_manager::browsertest_util::V8_MEMORY: | |
134 success = task_manager()->GetV8Memory(task_id, &value, &ignored); | |
135 break; | |
136 case task_manager::browsertest_util::V8_MEMORY_USED: | |
137 success = task_manager()->GetV8Memory(task_id, &ignored, &value); | |
138 break; | |
139 case task_manager::browsertest_util::SQLITE_MEMORY_USED: | |
140 value = task_manager()->GetSqliteMemoryUsed(task_id); | |
141 success = true; | |
142 break; | |
143 } | |
144 if (!success) | |
145 return 0; | |
146 return value; | |
147 } | |
148 | |
149 int32_t GetTabId(int row) override { | |
150 TaskId task_id = model_->tasks_[row]; | |
151 return task_manager()->GetTabId(task_id); | |
152 } | |
153 | |
154 void Kill(int row) override { model_->KillTask(row); } | |
155 | |
156 private: | |
157 TaskManagerInterface* task_manager() { | |
158 return model_->observed_task_manager(); | |
159 } | |
160 | |
161 // Returns the TaskManagerTableModel for the the visible NewTaskManagerView. | |
162 static TaskManagerTableModel* GetRealModel() { | |
163 // TODO(nick): Solve the following ui/views layering/deps problem: | |
164 // TaskManagerTableModel::GetInstanceForTesting() and its global variable | |
165 // only exist so that we can call it here. That's kind of lame. If we were | |
166 // allowed to #include ui/views here, we could befriend and call | |
167 // NewTaskManagerView::GetInstanceForTesting() and get the model from that. | |
168 TaskManagerTableModel* result = | |
169 TaskManagerTableModel::GetInstanceForTesting(); | |
170 CHECK(result) << "Task Manager must be visible to get the model."; | |
171 return result; | |
172 } | |
173 | |
174 TaskManagerTableModel* model_; | |
175 std::unique_ptr<ScopedInterceptTableModelObserver> interceptor_; | |
176 }; | |
177 | |
178 } // namespace task_management | |
27 | 179 |
28 namespace task_manager { | 180 namespace task_manager { |
29 namespace browsertest_util { | 181 namespace browsertest_util { |
30 | 182 |
31 namespace { | 183 namespace { |
32 | 184 |
33 class ResourceChangeObserver : public TaskManagerModelObserver { | 185 class LegacyTaskManagerTesterImpl : public TaskManagerTester, |
34 public: | 186 public TaskManagerModelObserver { |
35 ResourceChangeObserver(const TaskManagerModel* model, | 187 public: |
36 int required_count, | 188 explicit LegacyTaskManagerTesterImpl(const base::Closure& on_resource_change) |
189 : on_resource_change_(on_resource_change), | |
190 model_(TaskManager::GetInstance()->model()) { | |
191 if (!on_resource_change_.is_null()) | |
192 model_->AddObserver(this); | |
193 } | |
194 ~LegacyTaskManagerTesterImpl() override { | |
195 if (!on_resource_change_.is_null()) | |
196 model_->RemoveObserver(this); | |
197 } | |
198 | |
199 // TaskManagerTester: | |
200 int GetRowCount() override { return model_->ResourceCount(); } | |
201 | |
202 base::string16 GetRowTitle(int row) override { | |
203 return model_->GetResourceTitle(row); | |
204 } | |
205 | |
206 int64_t GetColumnValue(ColumnSpecifier column, int row) override { | |
207 size_t value = 0; | |
208 bool success = false; | |
209 switch (column) { | |
210 case COLUMN_NONE: | |
211 break; | |
212 case V8_MEMORY: | |
213 success = model_->GetV8Memory(row, &value); | |
214 break; | |
215 case V8_MEMORY_USED: | |
216 success = model_->GetV8MemoryUsed(row, &value); | |
217 break; | |
218 case SQLITE_MEMORY_USED: | |
219 success = model_->GetSqliteMemoryUsedBytes(row, &value); | |
220 break; | |
221 } | |
222 if (!success) | |
223 return 0; | |
224 return static_cast<int64_t>(value); | |
225 } | |
226 | |
227 void ToggleColumnVisibility(ColumnSpecifier column) override { | |
228 // Doing nothing is okay here; the legacy TaskManager always collects all | |
229 // stats. | |
230 } | |
231 | |
232 int32_t GetTabId(int row) override { | |
233 if (model_->GetResourceWebContents(row)) { | |
234 return SessionTabHelper::IdForTab(model_->GetResourceWebContents(row)); | |
235 } | |
236 return -1; | |
237 } | |
238 | |
239 void Kill(int row) override { TaskManager::GetInstance()->KillProcess(row); } | |
240 | |
241 // TaskManagerModelObserver: | |
242 void OnModelChanged() override { OnResourceChange(); } | |
243 void OnItemsChanged(int start, int length) override { OnResourceChange(); } | |
244 void OnItemsAdded(int start, int length) override { OnResourceChange(); } | |
245 void OnItemsRemoved(int start, int length) override { OnResourceChange(); } | |
246 | |
247 private: | |
248 void OnResourceChange() { | |
249 if (!on_resource_change_.is_null()) | |
250 on_resource_change_.Run(); | |
251 } | |
252 base::Closure on_resource_change_; | |
253 TaskManagerModel* model_; | |
254 }; | |
255 | |
256 // Helper class to run a message loop until a TaskManagerTester is in an | |
257 // expected state. If timeout occurs, an ASCII version of the task manager's | |
258 // contents, along with a summary of the expected state, are dumped to test | |
259 // output, to assist debugging. | |
260 class ResourceChangeObserver { | |
261 public: | |
262 ResourceChangeObserver(int required_count, | |
37 const base::string16& title_pattern, | 263 const base::string16& title_pattern, |
38 ColumnSpecifier column_specifier, | 264 ColumnSpecifier column_specifier, |
39 size_t min_column_value) | 265 size_t min_column_value) |
40 : model_(model), | 266 : required_count_(required_count), |
41 required_count_(required_count), | |
42 title_pattern_(title_pattern), | 267 title_pattern_(title_pattern), |
43 column_specifier_(column_specifier), | 268 column_specifier_(column_specifier), |
44 min_column_value_(min_column_value) {} | 269 min_column_value_(min_column_value) { |
45 | 270 base::Closure on_resource_change = base::Bind( |
46 void OnModelChanged() override { OnResourceChange(); } | 271 &ResourceChangeObserver::OnResourceChange, base::Unretained(this)); |
47 | 272 |
48 void OnItemsChanged(int start, int length) override { OnResourceChange(); } | 273 if (switches::NewTaskManagerEnabled()) { |
49 | 274 model_.reset( |
afakhry
2016/04/28 00:03:13
There are too many things that are called |model_|
ncarter (slow)
2016/05/02 18:33:28
Done.
afakhry
2016/05/02 18:58:17
Mmmm, seems you missed that one?
ncarter (slow)
2016/05/02 23:09:57
Apparently I need to hit Ctrl+S before uploading.
| |
50 void OnItemsAdded(int start, int length) override { OnResourceChange(); } | 275 new task_management::TaskManagerTesterImpl(on_resource_change)); |
51 | 276 } else { |
52 void OnItemsRemoved(int start, int length) override { OnResourceChange(); } | 277 model_.reset(new LegacyTaskManagerTesterImpl(on_resource_change)); |
278 } | |
279 } | |
53 | 280 |
54 void RunUntilSatisfied() { | 281 void RunUntilSatisfied() { |
55 // See if the condition is satisfied without having to run the loop. This | 282 // See if the condition is satisfied without having to run the loop. This |
56 // check has to be placed after the installation of the | 283 // check has to be placed after the installation of the |
57 // TaskManagerModelObserver, because resources may change before that. | 284 // TaskManagerModelObserver, because resources may change before that. |
58 if (IsSatisfied()) | 285 if (IsSatisfied()) |
59 return; | 286 return; |
60 | 287 |
61 timer_.Start(FROM_HERE, | 288 timer_.Start(FROM_HERE, TestTimeouts::action_timeout(), this, |
62 TestTimeouts::action_timeout(), | |
63 this, | |
64 &ResourceChangeObserver::OnTimeout); | 289 &ResourceChangeObserver::OnTimeout); |
65 | 290 |
66 run_loop_.Run(); | 291 run_loop_.Run(); |
67 | 292 |
68 // If we succeeded normally (no timeout), check our post condition again | 293 // If we succeeded normally (no timeout), check our post condition again |
69 // before returning control to the test. If it is no longer satisfied, the | 294 // before returning control to the test. If it is no longer satisfied, the |
70 // test is likely flaky: we were waiting for a state that was only achieved | 295 // test is likely flaky: we were waiting for a state that was only achieved |
71 // emphemerally), so treat this as a failure. | 296 // emphemerally), so treat this as a failure. |
72 if (!IsSatisfied() && timer_.IsRunning()) { | 297 if (!IsSatisfied() && timer_.IsRunning()) { |
73 FAIL() << "Wait condition satisfied only emphemerally. Likely test " | 298 FAIL() << "Wait condition satisfied only emphemerally. Likely test " |
(...skipping 10 matching lines...) Expand all Loading... | |
84 return; | 309 return; |
85 | 310 |
86 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 311 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
87 run_loop_.QuitClosure()); | 312 run_loop_.QuitClosure()); |
88 } | 313 } |
89 | 314 |
90 bool IsSatisfied() { return CountMatches() == required_count_; } | 315 bool IsSatisfied() { return CountMatches() == required_count_; } |
91 | 316 |
92 int CountMatches() { | 317 int CountMatches() { |
93 int match_count = 0; | 318 int match_count = 0; |
94 for (int i = 0; i < model_->ResourceCount(); i++) { | 319 for (int i = 0; i < model_->GetRowCount(); i++) { |
95 if (!base::MatchPattern(model_->GetResourceTitle(i), title_pattern_)) | 320 if (!base::MatchPattern(model_->GetRowTitle(i), title_pattern_)) |
96 continue; | 321 continue; |
97 | 322 |
98 if (GetColumnValue(i) < min_column_value_) | 323 if (GetColumnValue(i) < min_column_value_) |
99 continue; | 324 continue; |
100 | 325 |
101 match_count++; | 326 match_count++; |
102 } | 327 } |
103 return match_count; | 328 return match_count; |
104 } | 329 } |
105 | 330 |
106 size_t GetColumnValue(int index) { | 331 int64_t GetColumnValue(int index) { |
107 size_t value = 0; | 332 return model_->GetColumnValue(column_specifier_, index); |
108 bool success = false; | |
109 switch (column_specifier_) { | |
110 case COLUMN_NONE: | |
111 break; | |
112 case V8_MEMORY: | |
113 success = model_->GetV8Memory(index, &value); | |
114 break; | |
115 case V8_MEMORY_USED: | |
116 success = model_->GetV8MemoryUsed(index, &value); | |
117 break; | |
118 case SQLITE_MEMORY_USED: | |
119 success = model_->GetSqliteMemoryUsedBytes(index, &value); | |
120 break; | |
121 } | |
122 if (!success) | |
123 return 0; | |
124 return value; | |
125 } | 333 } |
126 | 334 |
127 const char* GetColumnName() { | 335 const char* GetColumnName() { |
128 switch (column_specifier_) { | 336 switch (column_specifier_) { |
129 case COLUMN_NONE: | 337 case COLUMN_NONE: |
130 return "N/A"; | 338 return "N/A"; |
131 case V8_MEMORY: | 339 case V8_MEMORY: |
132 return "V8 Memory"; | 340 return "V8 Memory"; |
133 case V8_MEMORY_USED: | 341 case V8_MEMORY_USED: |
134 return "V8 Memory Used"; | 342 return "V8 Memory Used"; |
(...skipping 14 matching lines...) Expand all Loading... | |
149 task_manager_state_dump << "Waiting for exactly " << required_count_ | 357 task_manager_state_dump << "Waiting for exactly " << required_count_ |
150 << " matches of wildcard pattern \"" | 358 << " matches of wildcard pattern \"" |
151 << base::UTF16ToASCII(title_pattern_) << "\""; | 359 << base::UTF16ToASCII(title_pattern_) << "\""; |
152 if (min_column_value_ > 0) { | 360 if (min_column_value_ > 0) { |
153 task_manager_state_dump << " && [" << GetColumnName() | 361 task_manager_state_dump << " && [" << GetColumnName() |
154 << " >= " << min_column_value_ << "]"; | 362 << " >= " << min_column_value_ << "]"; |
155 } | 363 } |
156 task_manager_state_dump << "\nCurrently there are " << CountMatches() | 364 task_manager_state_dump << "\nCurrently there are " << CountMatches() |
157 << " matches."; | 365 << " matches."; |
158 task_manager_state_dump << "\nCurrent Task Manager Model is:"; | 366 task_manager_state_dump << "\nCurrent Task Manager Model is:"; |
159 for (int i = 0; i < model_->ResourceCount(); i++) { | 367 for (int i = 0; i < model_->GetRowCount(); i++) { |
160 task_manager_state_dump | 368 task_manager_state_dump << "\n > " << std::setw(40) << std::left |
161 << "\n > " << std::setw(40) << std::left | 369 << base::UTF16ToASCII(model_->GetRowTitle(i)); |
162 << base::UTF16ToASCII(model_->GetResourceTitle(i)); | |
163 if (min_column_value_ > 0) { | 370 if (min_column_value_ > 0) { |
164 task_manager_state_dump << " [" << GetColumnName() | 371 task_manager_state_dump << " [" << GetColumnName() |
165 << " == " << GetColumnValue(i) << "]"; | 372 << " == " << GetColumnValue(i) << "]"; |
166 } | 373 } |
167 } | 374 } |
168 return task_manager_state_dump; | 375 return task_manager_state_dump; |
169 } | 376 } |
170 | 377 |
171 const TaskManagerModel* model_; | 378 std::unique_ptr<TaskManagerTester> model_; |
172 const int required_count_; | 379 const int required_count_; |
173 const base::string16 title_pattern_; | 380 const base::string16 title_pattern_; |
174 const ColumnSpecifier column_specifier_; | 381 const ColumnSpecifier column_specifier_; |
175 const size_t min_column_value_; | 382 const int64_t min_column_value_; |
176 base::RunLoop run_loop_; | 383 base::RunLoop run_loop_; |
177 base::OneShotTimer timer_; | 384 base::OneShotTimer timer_; |
178 }; | 385 }; |
179 | 386 |
180 } // namespace | 387 } // namespace |
181 | 388 |
182 void EnableOldTaskManager() { | 389 std::unique_ptr<TaskManagerTester> GetTaskManagerTester() { |
183 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 390 if (switches::NewTaskManagerEnabled()) { |
184 switches::kDisableNewTaskManager); | 391 return base::WrapUnique( |
afakhry
2016/04/28 00:03:13
Are we not allowed to use std::make_unique()?
ncarter (slow)
2016/05/02 18:33:28
make_unique is not in C++11, it's C++14. Also, Wra
afakhry
2016/05/02 18:58:17
Yes, I know, but thanks for the explanation anyway
| |
392 new task_management::TaskManagerTesterImpl(base::Closure())); | |
393 } else { | |
394 return base::WrapUnique(new LegacyTaskManagerTesterImpl(base::Closure())); | |
395 } | |
185 } | 396 } |
186 | 397 |
187 void WaitForTaskManagerRows(int required_count, | 398 void WaitForTaskManagerRows(int required_count, |
188 const base::string16& title_pattern) { | 399 const base::string16& title_pattern) { |
189 TaskManagerModel* model = TaskManager::GetInstance()->model(); | |
190 | |
191 const int column_value_dont_care = 0; | 400 const int column_value_dont_care = 0; |
192 ResourceChangeObserver observer(model, required_count, title_pattern, | 401 ResourceChangeObserver observer(required_count, title_pattern, COLUMN_NONE, |
193 COLUMN_NONE, column_value_dont_care); | 402 column_value_dont_care); |
194 model->AddObserver(&observer); | |
195 observer.RunUntilSatisfied(); | 403 observer.RunUntilSatisfied(); |
196 model->RemoveObserver(&observer); | |
197 } | 404 } |
198 | 405 |
199 void WaitForTaskManagerStatToExceed(const base::string16& title_pattern, | 406 void WaitForTaskManagerStatToExceed(const base::string16& title_pattern, |
200 ColumnSpecifier column_getter, | 407 ColumnSpecifier column_getter, |
201 size_t min_column_value) { | 408 size_t min_column_value) { |
202 TaskManagerModel* model = TaskManager::GetInstance()->model(); | |
203 | |
204 const int wait_for_one_match = 1; | 409 const int wait_for_one_match = 1; |
205 ResourceChangeObserver observer(model, wait_for_one_match, title_pattern, | 410 ResourceChangeObserver observer(wait_for_one_match, title_pattern, |
206 column_getter, min_column_value); | 411 column_getter, min_column_value); |
207 model->AddObserver(&observer); | |
208 observer.RunUntilSatisfied(); | 412 observer.RunUntilSatisfied(); |
209 model->RemoveObserver(&observer); | |
210 } | 413 } |
211 | 414 |
212 base::string16 MatchTab(const char* title) { | 415 base::string16 MatchTab(const char* title) { |
213 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_TAB_PREFIX, | 416 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_TAB_PREFIX, |
214 base::ASCIIToUTF16(title)); | 417 base::ASCIIToUTF16(title)); |
215 } | 418 } |
216 | 419 |
217 base::string16 MatchAnyTab() { return MatchTab("*"); } | 420 base::string16 MatchAnyTab() { |
421 return MatchTab("*"); | |
422 } | |
218 | 423 |
219 base::string16 MatchAboutBlankTab() { return MatchTab("about:blank"); } | 424 base::string16 MatchAboutBlankTab() { |
425 return MatchTab("about:blank"); | |
426 } | |
220 | 427 |
221 base::string16 MatchExtension(const char* title) { | 428 base::string16 MatchExtension(const char* title) { |
222 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_EXTENSION_PREFIX, | 429 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_EXTENSION_PREFIX, |
223 base::ASCIIToUTF16(title)); | 430 base::ASCIIToUTF16(title)); |
224 } | 431 } |
225 | 432 |
226 base::string16 MatchAnyExtension() { return MatchExtension("*"); } | 433 base::string16 MatchAnyExtension() { |
434 return MatchExtension("*"); | |
435 } | |
227 | 436 |
228 base::string16 MatchApp(const char* title) { | 437 base::string16 MatchApp(const char* title) { |
229 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_APP_PREFIX, | 438 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_APP_PREFIX, |
230 base::ASCIIToUTF16(title)); | 439 base::ASCIIToUTF16(title)); |
231 } | 440 } |
232 | 441 |
233 base::string16 MatchAnyApp() { return MatchApp("*"); } | 442 base::string16 MatchAnyApp() { |
443 return MatchApp("*"); | |
444 } | |
234 | 445 |
235 base::string16 MatchWebView(const char* title) { | 446 base::string16 MatchWebView(const char* title) { |
236 return l10n_util::GetStringFUTF16( | 447 return l10n_util::GetStringFUTF16( |
237 IDS_EXTENSION_TASK_MANAGER_WEBVIEW_TAG_PREFIX, | 448 IDS_EXTENSION_TASK_MANAGER_WEBVIEW_TAG_PREFIX, base::ASCIIToUTF16(title)); |
238 base::ASCIIToUTF16(title)); | |
239 } | 449 } |
240 | 450 |
241 base::string16 MatchAnyWebView() { return MatchWebView("*"); } | 451 base::string16 MatchAnyWebView() { |
452 return MatchWebView("*"); | |
453 } | |
242 | 454 |
243 base::string16 MatchBackground(const char* title) { | 455 base::string16 MatchBackground(const char* title) { |
244 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_BACKGROUND_PREFIX, | 456 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_BACKGROUND_PREFIX, |
245 base::ASCIIToUTF16(title)); | 457 base::ASCIIToUTF16(title)); |
246 } | 458 } |
247 | 459 |
248 base::string16 MatchAnyBackground() { return MatchBackground("*"); } | 460 base::string16 MatchAnyBackground() { |
461 return MatchBackground("*"); | |
462 } | |
249 | 463 |
250 base::string16 MatchPrint(const char* title) { | 464 base::string16 MatchPrint(const char* title) { |
251 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PRINT_PREFIX, | 465 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PRINT_PREFIX, |
252 base::ASCIIToUTF16(title)); | 466 base::ASCIIToUTF16(title)); |
253 } | 467 } |
254 | 468 |
255 base::string16 MatchAnyPrint() { return MatchPrint("*"); } | 469 base::string16 MatchAnyPrint() { |
470 return MatchPrint("*"); | |
471 } | |
256 | 472 |
257 base::string16 MatchSubframe(const char* title) { | 473 base::string16 MatchSubframe(const char* title) { |
258 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_SUBFRAME_PREFIX, | 474 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_SUBFRAME_PREFIX, |
259 base::ASCIIToUTF16(title)); | 475 base::ASCIIToUTF16(title)); |
260 } | 476 } |
261 | 477 |
262 base::string16 MatchAnySubframe() { | 478 base::string16 MatchAnySubframe() { |
263 return MatchSubframe("*"); | 479 return MatchSubframe("*"); |
264 } | 480 } |
265 | 481 |
266 base::string16 MatchUtility(const base::string16& title) { | 482 base::string16 MatchUtility(const base::string16& title) { |
267 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_UTILITY_PREFIX, title); | 483 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_UTILITY_PREFIX, title); |
268 } | 484 } |
269 | 485 |
270 base::string16 MatchAnyUtility() { | 486 base::string16 MatchAnyUtility() { |
271 return MatchUtility(base::ASCIIToUTF16("*")); | 487 return MatchUtility(base::ASCIIToUTF16("*")); |
272 } | 488 } |
273 | 489 |
274 } // namespace browsertest_util | 490 } // namespace browsertest_util |
275 } // namespace task_manager | 491 } // namespace task_manager |
OLD | NEW |