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