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

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: Fixed. 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 until both the blocking pool and the current message loop are empty
48 // (have no more scheduled tasks) and no tasks are running.
49 void RunAllBlockingPoolTasksUntilIdle();
50
47 // Get task to quit the given RunLoop. It allows a few generations of pending 51 // Get task to quit the given RunLoop. It allows a few generations of pending
48 // tasks to run as opposed to run_loop->QuitClosure(). 52 // tasks to run as opposed to run_loop->QuitClosure().
49 base::Closure GetQuitTaskForRunLoop(base::RunLoop* run_loop); 53 base::Closure GetQuitTaskForRunLoop(base::RunLoop* run_loop);
50 54
51 // Executes the specified JavaScript in the specified frame, and runs a nested 55 // Executes the specified JavaScript in the specified frame, and runs a nested
52 // MessageLoop. When the result is available, it is returned. 56 // MessageLoop. When the result is available, it is returned.
53 // This should not be used; the use of the ExecuteScript functions in 57 // This should not be used; the use of the ExecuteScript functions in
54 // browser_test_utils is preferable. 58 // browser_test_utils is preferable.
55 scoped_ptr<base::Value> ExecuteScriptAndGetValue( 59 scoped_ptr<base::Value> ExecuteScriptAndGetValue(
56 RenderFrameHost* render_frame_host, const std::string& script); 60 RenderFrameHost* render_frame_host, const std::string& script);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 212
209 int child_thread_count_; 213 int child_thread_count_;
210 scoped_refptr<MessageLoopRunner> runner_; 214 scoped_refptr<MessageLoopRunner> runner_;
211 215
212 DISALLOW_COPY_AND_ASSIGN(InProcessUtilityThreadHelper); 216 DISALLOW_COPY_AND_ASSIGN(InProcessUtilityThreadHelper);
213 }; 217 };
214 218
215 } // namespace content 219 } // namespace content
216 220
217 #endif // CONTENT_PUBLIC_TEST_TEST_UTILS_H_ 221 #endif // CONTENT_PUBLIC_TEST_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc ('k') | content/public/test/test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698