Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(896)

Side by Side Diff: chrome/browser/task_manager/task_manager_browsertest_util.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/task_manager.h" 10 #include "chrome/browser/task_manager/task_manager.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 OnResourceChange(); 59 OnResourceChange();
60 } 60 }
61 61
62 virtual void OnItemsRemoved(int start, int length) OVERRIDE { 62 virtual void OnItemsRemoved(int start, int length) OVERRIDE {
63 OnResourceChange(); 63 OnResourceChange();
64 } 64 }
65 65
66 private: 66 private:
67 void OnResourceChange() { 67 void OnResourceChange() {
68 if (GetWebResourceCount(model_) == target_resource_count_) 68 if (GetWebResourceCount(model_) == target_resource_count_)
69 MessageLoopForUI::current()->Quit(); 69 base::MessageLoopForUI::current()->Quit();
70 } 70 }
71 71
72 const TaskManagerModel* model_; 72 const TaskManagerModel* model_;
73 const int target_resource_count_; 73 const int target_resource_count_;
74 }; 74 };
75 75
76 } // namespace 76 } // namespace
77 77
78 // static 78 // static
79 void TaskManagerBrowserTestUtil::WaitForWebResourceChange(int target_count) { 79 void TaskManagerBrowserTestUtil::WaitForWebResourceChange(int target_count) {
80 TaskManagerModel* model = TaskManager::GetInstance()->model(); 80 TaskManagerModel* model = TaskManager::GetInstance()->model();
81 81
82 ResourceChangeObserver observer(model, target_count); 82 ResourceChangeObserver observer(model, target_count);
83 model->AddObserver(&observer); 83 model->AddObserver(&observer);
84 84
85 // Checks that the condition has not been satisfied yet. 85 // Checks that the condition has not been satisfied yet.
86 // This check has to be placed after the installation of the observer, 86 // This check has to be placed after the installation of the observer,
87 // because resources may change before that. 87 // because resources may change before that.
88 if (GetWebResourceCount(model) == target_count) { 88 if (GetWebResourceCount(model) == target_count) {
89 model->RemoveObserver(&observer); 89 model->RemoveObserver(&observer);
90 return; 90 return;
91 } 91 }
92 92
93 content::RunMessageLoop(); 93 content::RunMessageLoop();
94 model->RemoveObserver(&observer); 94 model->RemoveObserver(&observer);
95 } 95 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698