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

Unified Diff: content/public/test/test_utils.cc

Issue 15808008: GTTF: Remove message loop hooks from TestLauncherDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/test/test_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/test_utils.cc
===================================================================
--- content/public/test/test_utils.cc (revision 202993)
+++ content/public/test/test_utils.cc (working copy)
@@ -5,6 +5,7 @@
#include "content/public/test/test_utils.h"
#include "base/bind.h"
+#include "base/lazy_instance.h"
#include "base/message_loop.h"
#include "base/run_loop.h"
#include "base/utf_string_conversions.h"
@@ -18,6 +19,12 @@
namespace {
+base::LazyInstance<std::vector<RunMessageLoopHook> >::Leaky
+ g_pre_run_message_loop_hooks = LAZY_INSTANCE_INITIALIZER;
+
+base::LazyInstance<std::vector<RunMessageLoopHook> >::Leaky
+ g_post_run_message_loop_hooks = LAZY_INSTANCE_INITIALIZER;
+
// Number of times to repost a Quit task so that the MessageLoop finishes up
// pending tasks and tasks posted by those pending tasks without risking the
// potential hang behavior of MessageLoop::QuitWhenIdle.
@@ -78,19 +85,23 @@
base::MessageLoop::ScopedNestableTaskAllower allow(
base::MessageLoop::current());
- // If we're running inside a browser test, we might need to allow the test
- // launcher to do extra work before/after running a nested message loop.
- TestLauncherDelegate* delegate = NULL;
-#if !defined(OS_IOS)
- delegate = GetCurrentTestLauncherDelegate();
-#endif
- if (delegate)
- delegate->PreRunMessageLoop(run_loop);
+ for (size_t i = 0; i < g_pre_run_message_loop_hooks.Get().size(); i++)
sky 2013/05/31 19:27:03 Should this use ObserverList for the case of the l
Paweł Hajdan Jr. 2013/05/31 19:50:15 Good question. ObserverList<RunMessageLoopHook>::
+ g_pre_run_message_loop_hooks.Get()[i].Run(run_loop);
+
run_loop->Run();
- if (delegate)
- delegate->PostRunMessageLoop();
+
+ for (size_t i = 0; i < g_pre_run_message_loop_hooks.Get().size(); i++)
+ g_post_run_message_loop_hooks.Get()[i].Run(run_loop);
}
+void AddPreRunMessageLoopHook(const RunMessageLoopHook& hook) {
+ g_pre_run_message_loop_hooks.Get().push_back(hook);
+}
+
+void AddPostRunMessageLoopHook(const RunMessageLoopHook& hook) {
+ g_post_run_message_loop_hooks.Get().push_back(hook);
+}
+
void RunAllPendingInMessageLoop() {
base::MessageLoop::current()->PostTask(
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
« no previous file with comments | « content/public/test/test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698