| 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 12 matching lines...) Expand all Loading... |
| 23 // tasks to the blocking pool via PostTaskAndReply. By ensuring that the tasks | 23 // tasks to the blocking pool via PostTaskAndReply. By ensuring that the tasks |
| 24 // are run while the originating TestBroswserThreads still exist, we prevent | 24 // are run while the originating TestBroswserThreads still exist, we prevent |
| 25 // leakage of PostTaskAndReplyRelay objects. We also flush the blocking pool | 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 | 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 <memory> |
| 34 |
| 33 #include "base/macros.h" | 35 #include "base/macros.h" |
| 34 #include "base/memory/scoped_ptr.h" | |
| 35 | 36 |
| 36 namespace base { | 37 namespace base { |
| 37 class MessageLoop; | 38 class MessageLoop; |
| 38 } | 39 } |
| 39 | 40 |
| 40 namespace web { | 41 namespace web { |
| 41 | 42 |
| 42 class TestWebThread; | 43 class TestWebThread; |
| 43 | 44 |
| 44 class TestWebThreadBundle { | 45 class TestWebThreadBundle { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 TestWebThreadBundle(); | 60 TestWebThreadBundle(); |
| 60 explicit TestWebThreadBundle(int options); | 61 explicit TestWebThreadBundle(int options); |
| 61 | 62 |
| 62 ~TestWebThreadBundle(); | 63 ~TestWebThreadBundle(); |
| 63 | 64 |
| 64 private: | 65 private: |
| 65 void Init(int options); | 66 void Init(int options); |
| 66 | 67 |
| 67 scoped_ptr<base::MessageLoop> message_loop_; | 68 std::unique_ptr<base::MessageLoop> message_loop_; |
| 68 scoped_ptr<TestWebThread> ui_thread_; | 69 std::unique_ptr<TestWebThread> ui_thread_; |
| 69 scoped_ptr<TestWebThread> db_thread_; | 70 std::unique_ptr<TestWebThread> db_thread_; |
| 70 scoped_ptr<TestWebThread> file_thread_; | 71 std::unique_ptr<TestWebThread> file_thread_; |
| 71 scoped_ptr<TestWebThread> file_user_blocking_thread_; | 72 std::unique_ptr<TestWebThread> file_user_blocking_thread_; |
| 72 scoped_ptr<TestWebThread> cache_thread_; | 73 std::unique_ptr<TestWebThread> cache_thread_; |
| 73 scoped_ptr<TestWebThread> io_thread_; | 74 std::unique_ptr<TestWebThread> io_thread_; |
| 74 | 75 |
| 75 DISALLOW_COPY_AND_ASSIGN(TestWebThreadBundle); | 76 DISALLOW_COPY_AND_ASSIGN(TestWebThreadBundle); |
| 76 }; | 77 }; |
| 77 | 78 |
| 78 } // namespace web | 79 } // namespace web |
| 79 | 80 |
| 80 #endif // IOS_WEB_PUBLIC_TEST_TEST_WEB_THREAD_BUNDLE_H_ | 81 #endif // IOS_WEB_PUBLIC_TEST_TEST_WEB_THREAD_BUNDLE_H_ |
| OLD | NEW |