Chromium Code Reviews| Index: webkit/support/webkit_support.cc |
| =================================================================== |
| --- webkit/support/webkit_support.cc (revision 111106) |
| +++ webkit/support/webkit_support.cc (working copy) |
| @@ -127,9 +127,15 @@ |
| typedef MessageLoopForUI MessageLoopType; |
| #endif |
| - explicit TestEnvironment(bool unit_test_mode) { |
| + // Sometimes we have to create a AtExitManager before initializing |
| + // TestEnvironment. Give TestEnvironment a chance to reuse existing |
| + // AtExitManager if needed. |
| + explicit TestEnvironment(bool unit_test_mode, |
|
tony
2011/11/22 17:28:55
Nit: No explicit.
Johnny(Jianning) Ding
2011/11/23 14:52:17
Done.
|
| + base::AtExitManager* existing_at_exit_manager) { |
| if (!unit_test_mode) { |
| - at_exit_manager_.reset(new base::AtExitManager); |
| + if (!existing_at_exit_manager) |
| + existing_at_exit_manager = new base::AtExitManager; |
| + at_exit_manager_.reset(existing_at_exit_manager); |
| InitLogging(false); |
| } |
| main_message_loop_.reset(new MessageLoopType); |
| @@ -237,8 +243,18 @@ |
| // Otherwise crash may happend when different threads try to create a GURL |
| // at same time. |
| url_util::Initialize(); |
| + base::AtExitManager* at_exit_manager = NULL; |
|
tony
2011/11/22 17:28:55
Can we just have all ports create the at_exit_mana
Johnny(Jianning) Ding
2011/11/23 14:52:17
Done.
|
| +#if defined(OS_ANDROID) |
| + // We need to register Android specific paths in BeforeInitialize routine |
| + // which are needed by TestEnvironment. Since PathService need a AtExitManager |
| + // to register a callback, (See LazyInstanceHelper::CompleteInstance.) we need |
| + // to create a AtExitManager before initializing TestEnvironment. We will pass |
| + // the ownership of the AtExitManager to TestEnvironment constructor to let |
| + // the TestEnvironment instance manage its lifecycle. |
| + at_exit_manager = new base::AtExitManager; |
| +#endif |
| BeforeInitialize(unit_test_mode); |
| - test_environment = new TestEnvironment(unit_test_mode); |
| + test_environment = new TestEnvironment(unit_test_mode, at_exit_manager); |
| AfterInitialize(unit_test_mode); |
| if (!unit_test_mode) { |
| // Load ICU data tables. This has to run after TestEnvironment is created |