OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 IOS_WEB_PUBLIC_TEST_TEST_WEB_THREAD_BUNDLE_H_ | 5 #ifndef IOS_WEB_PUBLIC_TEST_TEST_WEB_THREAD_BUNDLE_H_ |
6 #define IOS_WEB_PUBLIC_TEST_TEST_WEB_THREAD_BUNDLE_H_ | 6 #define IOS_WEB_PUBLIC_TEST_TEST_WEB_THREAD_BUNDLE_H_ |
7 | 7 |
8 // TestWebThreadBundle is a convenience class for creating a set of | 8 // TestWebThreadBundle is a convenience class for creating a set of |
9 // TestWebThreads in unit tests. For most tests, it is sufficient to | 9 // TestWebThreads in unit tests. For most tests, it is sufficient to |
10 // just instantiate the TestWebThreadBundle as a member variable. | 10 // just instantiate the TestWebThreadBundle as a member variable. |
(...skipping 15 matching lines...) Expand all Loading... |
26 // again at the point where it would normally be shut down, to better simulate | 26 // again at the point where it would normally be shut down, to better simulate |
27 // the normal thread shutdown process. | 27 // the normal thread shutdown process. |
28 // | 28 // |
29 // Some tests using the IO thread expect a MessageLoopForIO. Passing | 29 // Some tests using the IO thread expect a MessageLoopForIO. Passing |
30 // IO_MAINLOOP will use a MessageLoopForIO for the main MessageLoop. | 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. | 31 // Most of the time, this avoids needing to use a REAL_IO_THREAD. |
32 | 32 |
33 #include "base/macros.h" | 33 #include "base/macros.h" |
34 #include "base/memory/scoped_ptr.h" | 34 #include "base/memory/scoped_ptr.h" |
35 | 35 |
| 36 namespace base { |
| 37 class MessageLoop; |
| 38 } |
| 39 |
36 namespace web { | 40 namespace web { |
37 | 41 |
38 class TestWebThreadBundleImpl; | 42 class TestWebThread; |
39 | 43 |
40 class TestWebThreadBundle { | 44 class TestWebThreadBundle { |
41 public: | 45 public: |
42 // Used to specify the type of MessageLoop that backs the UI thread, and | 46 // 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 | 47 // 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. | 48 // threads. The UI thread is always the main thread in a unit test. |
45 enum Options { | 49 enum Options { |
46 DEFAULT = 0x00, | 50 DEFAULT = 0x00, |
47 IO_MAINLOOP = 0x01, | 51 IO_MAINLOOP = 0x01, |
48 REAL_DB_THREAD = 0x02, | 52 REAL_DB_THREAD = 0x02, |
49 REAL_FILE_THREAD = 0x08, | 53 REAL_FILE_THREAD = 0x08, |
50 REAL_FILE_USER_BLOCKING_THREAD = 0x10, | 54 REAL_FILE_USER_BLOCKING_THREAD = 0x10, |
51 REAL_CACHE_THREAD = 0x20, | 55 REAL_CACHE_THREAD = 0x20, |
52 REAL_IO_THREAD = 0x40, | 56 REAL_IO_THREAD = 0x40, |
53 }; | 57 }; |
54 | 58 |
55 TestWebThreadBundle(); | 59 TestWebThreadBundle(); |
56 explicit TestWebThreadBundle(int options); | 60 explicit TestWebThreadBundle(int options); |
57 | 61 |
58 ~TestWebThreadBundle(); | 62 ~TestWebThreadBundle(); |
59 | 63 |
60 private: | 64 private: |
61 scoped_ptr<TestWebThreadBundleImpl> impl_; | 65 void Init(int options); |
| 66 |
| 67 scoped_ptr<base::MessageLoop> message_loop_; |
| 68 scoped_ptr<TestWebThread> ui_thread_; |
| 69 scoped_ptr<TestWebThread> db_thread_; |
| 70 scoped_ptr<TestWebThread> file_thread_; |
| 71 scoped_ptr<TestWebThread> file_user_blocking_thread_; |
| 72 scoped_ptr<TestWebThread> cache_thread_; |
| 73 scoped_ptr<TestWebThread> io_thread_; |
62 | 74 |
63 DISALLOW_COPY_AND_ASSIGN(TestWebThreadBundle); | 75 DISALLOW_COPY_AND_ASSIGN(TestWebThreadBundle); |
64 }; | 76 }; |
65 | 77 |
66 } // namespace web | 78 } // namespace web |
67 | 79 |
68 #endif // IOS_WEB_PUBLIC_TEST_TEST_WEB_THREAD_BUNDLE_H_ | 80 #endif // IOS_WEB_PUBLIC_TEST_TEST_WEB_THREAD_BUNDLE_H_ |
OLD | NEW |