Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / ios / web / public / test / test_web_thread_bundle.h
blob425cc51b1303d8b71ce04dff2ff45e0d46c4ce6a
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef IOS_WEB_PUBLIC_TEST_TEST_WEB_THREAD_BUNDLE_H_
6 #define IOS_WEB_PUBLIC_TEST_TEST_WEB_THREAD_BUNDLE_H_
8 // TestWebThreadBundle is a convenience class for creating a set of
9 // TestWebThreads in unit tests. For most tests, it is sufficient to
10 // just instantiate the TestWebThreadBundle as a member variable.
12 // By default, all of the created TestWebThreads will be backed by a single
13 // shared MessageLoop. If a test truly needs separate threads, it can do
14 // so by passing the appropriate combination of RealThreadsMask values during
15 // the TestWebThreadBundle construction.
17 // The TestWebThreadBundle will attempt to drain the MessageLoop on
18 // destruction. Sometimes a test needs to drain currently enqueued tasks
19 // mid-test.
21 // The TestWebThreadBundle will also flush the blocking pool on destruction.
22 // We do this to avoid memory leaks, particularly in the case of threads posting
23 // tasks to the blocking pool via PostTaskAndReply. By ensuring that the tasks
24 // are run while the originating TestBroswserThreads still exist, we prevent
25 // leakage of PostTaskAndReplyRelay objects. We also flush the blocking pool
26 // again at the point where it would normally be shut down, to better simulate
27 // the normal thread shutdown process.
29 // Some tests using the IO thread expect a MessageLoopForIO. Passing
30 // IO_MAINLOOP will use a MessageLoopForIO for the main MessageLoop.
31 // Most of the time, this avoids needing to use a REAL_IO_THREAD.
33 #include "base/macros.h"
34 #include "base/memory/scoped_ptr.h"
36 namespace web {
38 class TestWebThreadBundleImpl;
40 class TestWebThreadBundle {
41 public:
42 // Used to specify the type of MessageLoop that backs the UI thread, and
43 // which of the named WebThreads should be backed by a real
44 // threads. The UI thread is always the main thread in a unit test.
45 enum Options {
46 DEFAULT = 0x00,
47 IO_MAINLOOP = 0x01,
48 REAL_DB_THREAD = 0x02,
49 REAL_FILE_THREAD = 0x08,
50 REAL_FILE_USER_BLOCKING_THREAD = 0x10,
51 REAL_CACHE_THREAD = 0x20,
52 REAL_IO_THREAD = 0x40,
55 TestWebThreadBundle();
56 explicit TestWebThreadBundle(int options);
58 ~TestWebThreadBundle();
60 private:
61 scoped_ptr<TestWebThreadBundleImpl> impl_;
63 DISALLOW_COPY_AND_ASSIGN(TestWebThreadBundle);
66 } // namespace web
68 #endif // IOS_WEB_PUBLIC_TEST_TEST_WEB_THREAD_BUNDLE_H_