| 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.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/task_manager/resource_provider.h" | 10 #include "chrome/browser/task_manager/resource_provider.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 OnResourceChange(); | 60 OnResourceChange(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 virtual void OnItemsRemoved(int start, int length) OVERRIDE { | 63 virtual void OnItemsRemoved(int start, int length) OVERRIDE { |
| 64 OnResourceChange(); | 64 OnResourceChange(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 void OnResourceChange() { | 68 void OnResourceChange() { |
| 69 if (GetWebResourceCount(model_) == target_resource_count_) | 69 if (GetWebResourceCount(model_) == target_resource_count_) |
| 70 MessageLoopForUI::current()->Quit(); | 70 base::MessageLoopForUI::current()->Quit(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 const TaskManagerModel* model_; | 73 const TaskManagerModel* model_; |
| 74 const int target_resource_count_; | 74 const int target_resource_count_; |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 } // namespace | 77 } // namespace |
| 78 | 78 |
| 79 // static | 79 // static |
| 80 void TaskManagerBrowserTestUtil::WaitForWebResourceChange(int target_count) { | 80 void TaskManagerBrowserTestUtil::WaitForWebResourceChange(int target_count) { |
| 81 TaskManagerModel* model = TaskManager::GetInstance()->model(); | 81 TaskManagerModel* model = TaskManager::GetInstance()->model(); |
| 82 | 82 |
| 83 ResourceChangeObserver observer(model, target_count); | 83 ResourceChangeObserver observer(model, target_count); |
| 84 model->AddObserver(&observer); | 84 model->AddObserver(&observer); |
| 85 | 85 |
| 86 // Checks that the condition has not been satisfied yet. | 86 // Checks that the condition has not been satisfied yet. |
| 87 // This check has to be placed after the installation of the observer, | 87 // This check has to be placed after the installation of the observer, |
| 88 // because resources may change before that. | 88 // because resources may change before that. |
| 89 if (GetWebResourceCount(model) == target_count) { | 89 if (GetWebResourceCount(model) == target_count) { |
| 90 model->RemoveObserver(&observer); | 90 model->RemoveObserver(&observer); |
| 91 return; | 91 return; |
| 92 } | 92 } |
| 93 | 93 |
| 94 content::RunMessageLoop(); | 94 content::RunMessageLoop(); |
| 95 model->RemoveObserver(&observer); | 95 model->RemoveObserver(&observer); |
| 96 } | 96 } |
| OLD | NEW |