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

Side by Side Diff: content/public/test/test_utils.h

Issue 380993002: Upstream RunBlockingPoolTask(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 #ifndef CONTENT_PUBLIC_TEST_TEST_UTILS_H_ 5 #ifndef CONTENT_PUBLIC_TEST_TEST_UTILS_H_
6 #define CONTENT_PUBLIC_TEST_TEST_UTILS_H_ 6 #define CONTENT_PUBLIC_TEST_TEST_UTILS_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "content/public/browser/browser_child_process_observer.h" 12 #include "content/public/browser/browser_child_process_observer.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/notification_details.h" 14 #include "content/public/browser/notification_details.h"
15 #include "content/public/browser/notification_observer.h" 15 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_registrar.h" 16 #include "content/public/browser/notification_registrar.h"
17 #include "content/public/browser/notification_source.h" 17 #include "content/public/browser/notification_source.h"
18 18
19 namespace base { 19 namespace base {
20 class Value; 20 class Value;
21 } 21 } // namespace base
22 22
23 // A collection of functions designed for use with unit and browser tests. 23 // A collection of functions designed for use with unit and browser tests.
24 24
25 namespace content { 25 namespace content {
26 26
27 class RenderFrameHost; 27 class RenderFrameHost;
28 28
29 // Turns on nestable tasks, runs the message loop, then resets nestable tasks 29 // Turns on nestable tasks, runs the message loop, then resets nestable tasks
30 // to what they were originally. Prefer this over MessageLoop::Run for in 30 // to what they were originally. Prefer this over MessageLoop::Run for in
31 // process browser tests that need to block until a condition is met. 31 // process browser tests that need to block until a condition is met.
32 void RunMessageLoop(); 32 void RunMessageLoop();
33 33
34 // Variant of RunMessageLoop that takes RunLoop. 34 // Variant of RunMessageLoop that takes RunLoop.
35 void RunThisRunLoop(base::RunLoop* run_loop); 35 void RunThisRunLoop(base::RunLoop* run_loop);
36 36
37 // Turns on nestable tasks, runs all pending tasks in the message loop, 37 // Turns on nestable tasks, runs all pending tasks in the message loop,
38 // then resets nestable tasks to what they were originally. Prefer this 38 // then resets nestable tasks to what they were originally. Prefer this
39 // over MessageLoop::RunAllPending for in process browser tests to run 39 // over MessageLoop::RunAllPending for in process browser tests to run
40 // all pending tasks. 40 // all pending tasks.
41 void RunAllPendingInMessageLoop(); 41 void RunAllPendingInMessageLoop();
42 42
43 // Blocks the current thread until all the pending messages in the loop of the 43 // Blocks the current thread until all the pending messages in the loop of the
44 // thread |thread_id| have been processed. 44 // thread |thread_id| have been processed.
45 void RunAllPendingInMessageLoop(BrowserThread::ID thread_id); 45 void RunAllPendingInMessageLoop(BrowserThread::ID thread_id);
46 46
47 // Runs all tasks posted to the blocking pool, including subsequent tasks posted
sky 2014/07/11 16:37:54 You're description seems overly complicated, maybe
mtomasz 2014/07/14 07:33:57 Done.
48 // to the UI message loop and the blocking pool.
49 //
50 // A task is often posted to the blocking pool with PostTaskAndReply(). In
51 // that case, a task is posted back to the UI message loop, which can again
52 // post a task to the blocking pool. This function processes these tasks
53 // repeatedly.
54 void RunAllBlockingPoolTasksUntilIdle();
55
47 // Get task to quit the given RunLoop. It allows a few generations of pending 56 // Get task to quit the given RunLoop. It allows a few generations of pending
48 // tasks to run as opposed to run_loop->QuitClosure(). 57 // tasks to run as opposed to run_loop->QuitClosure().
49 base::Closure GetQuitTaskForRunLoop(base::RunLoop* run_loop); 58 base::Closure GetQuitTaskForRunLoop(base::RunLoop* run_loop);
50 59
51 // Executes the specified JavaScript in the specified frame, and runs a nested 60 // Executes the specified JavaScript in the specified frame, and runs a nested
52 // MessageLoop. When the result is available, it is returned. 61 // MessageLoop. When the result is available, it is returned.
53 // This should not be used; the use of the ExecuteScript functions in 62 // This should not be used; the use of the ExecuteScript functions in
54 // browser_test_utils is preferable. 63 // browser_test_utils is preferable.
55 scoped_ptr<base::Value> ExecuteScriptAndGetValue( 64 scoped_ptr<base::Value> ExecuteScriptAndGetValue(
56 RenderFrameHost* render_frame_host, const std::string& script); 65 RenderFrameHost* render_frame_host, const std::string& script);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 217
209 int child_thread_count_; 218 int child_thread_count_;
210 scoped_refptr<MessageLoopRunner> runner_; 219 scoped_refptr<MessageLoopRunner> runner_;
211 220
212 DISALLOW_COPY_AND_ASSIGN(InProcessUtilityThreadHelper); 221 DISALLOW_COPY_AND_ASSIGN(InProcessUtilityThreadHelper);
213 }; 222 };
214 223
215 } // namespace content 224 } // namespace content
216 225
217 #endif // CONTENT_PUBLIC_TEST_TEST_UTILS_H_ 226 #endif // CONTENT_PUBLIC_TEST_TEST_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698