| 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 #include "chrome/browser/task_management/task_manager_tester.h" | 5 #include "chrome/browser/task_management/task_manager_tester.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/sessions/session_tab_helper.h" | 10 #include "chrome/browser/sessions/session_tab_helper.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 ui::TableModel* model_to_intercept_; | 60 ui::TableModel* model_to_intercept_; |
| 61 ui::TableModelObserver* real_table_model_observer_; | 61 ui::TableModelObserver* real_table_model_observer_; |
| 62 base::Closure callback_; | 62 base::Closure callback_; |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 } // namespace | 65 } // namespace |
| 66 | 66 |
| 67 // Implementation of TaskManagerTester for the 'new' TaskManager. | |
| 68 class TaskManagerTesterImpl : public TaskManagerTester { | 67 class TaskManagerTesterImpl : public TaskManagerTester { |
| 69 public: | 68 public: |
| 70 explicit TaskManagerTesterImpl(const base::Closure& on_resource_change) | 69 explicit TaskManagerTesterImpl(const base::Closure& on_resource_change) |
| 71 : model_(GetRealModel()) { | 70 : model_(GetRealModel()) { |
| 72 // Eavesdrop the model->view conversation, since the model only supports | 71 // Eavesdrop the model->view conversation, since the model only supports |
| 73 // single observation. | 72 // single observation. |
| 74 if (!on_resource_change.is_null()) { | 73 if (!on_resource_change.is_null()) { |
| 75 interceptor_.reset(new ScopedInterceptTableModelObserver( | 74 interceptor_.reset(new ScopedInterceptTableModelObserver( |
| 76 model_, model_->table_model_observer_, on_resource_change)); | 75 model_, model_->table_model_observer_, on_resource_change)); |
| 77 } | 76 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 // Returns the TaskManagerTableModel for the the visible NewTaskManagerView. | 149 // Returns the TaskManagerTableModel for the the visible NewTaskManagerView. |
| 151 static task_management::TaskManagerTableModel* GetRealModel() { | 150 static task_management::TaskManagerTableModel* GetRealModel() { |
| 152 return chrome::ShowTaskManager(nullptr); | 151 return chrome::ShowTaskManager(nullptr); |
| 153 } | 152 } |
| 154 | 153 |
| 155 task_management::TaskManagerTableModel* model_; | 154 task_management::TaskManagerTableModel* model_; |
| 156 std::unique_ptr<ScopedInterceptTableModelObserver> interceptor_; | 155 std::unique_ptr<ScopedInterceptTableModelObserver> interceptor_; |
| 157 }; | 156 }; |
| 158 | 157 |
| 159 // static | 158 // static |
| 160 std::unique_ptr<TaskManagerTester> TaskManagerTester::CreateDefault( | 159 std::unique_ptr<TaskManagerTester> TaskManagerTester::Create( |
| 161 const base::Closure& callback) { | 160 const base::Closure& callback) { |
| 162 return base::WrapUnique(new TaskManagerTesterImpl(callback)); | 161 return base::WrapUnique(new TaskManagerTesterImpl(callback)); |
| 163 } | 162 } |
| 164 | 163 |
| 165 } // namespace task_management | 164 } // namespace task_management |
| OLD | NEW |