diff options
author | jnd@chromium.org <jnd@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-24 08:28:29 +0000 |
---|---|---|
committer | jnd@chromium.org <jnd@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-24 08:28:29 +0000 |
commit | 9da43990629c541f0227bd1b1e77966f047816ed (patch) | |
tree | c2183a892c5482972255c9a62aee120052ca2445 /webkit/support | |
parent | 72546f14bae9d91a171ff5df6534cf1abd3bcffe (diff) | |
download | chromium_src-9da43990629c541f0227bd1b1e77966f047816ed.zip chromium_src-9da43990629c541f0227bd1b1e77966f047816ed.tar.gz chromium_src-9da43990629c541f0227bd1b1e77966f047816ed.tar.bz2 |
Create AtExitManager early on Android.
The initialization code on Android needs to access AtExitManager before initializing TestEnvironment.
BUG=None
Test=Layout Tests on Android.
Review URL: http://codereview.chromium.org/8638006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111504 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/support')
-rw-r--r-- | webkit/support/webkit_support.cc | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/webkit/support/webkit_support.cc b/webkit/support/webkit_support.cc index c448f59..613ad08 100644 --- a/webkit/support/webkit_support.cc +++ b/webkit/support/webkit_support.cc @@ -127,9 +127,11 @@ class TestEnvironment { typedef MessageLoopForUI MessageLoopType; #endif - explicit TestEnvironment(bool unit_test_mode) { + TestEnvironment(bool unit_test_mode, + base::AtExitManager* existing_at_exit_manager) { if (!unit_test_mode) { - at_exit_manager_.reset(new base::AtExitManager); + // The existing_at_exit_manager must be not NULL. + at_exit_manager_.reset(existing_at_exit_manager); InitLogging(false); } main_message_loop_.reset(new MessageLoopType); @@ -158,6 +160,8 @@ class TestEnvironment { #endif private: + // Data member at_exit_manager_ will take the ownership of the input + // AtExitManager and manage its lifecycle. scoped_ptr<base::AtExitManager> at_exit_manager_; scoped_ptr<MessageLoopType> main_message_loop_; scoped_ptr<TestWebKitPlatformSupport> webkit_platform_support_; @@ -237,8 +241,14 @@ static void SetUpTestEnvironmentImpl(bool unit_test_mode) { // Otherwise crash may happend when different threads try to create a GURL // at same time. url_util::Initialize(); + base::AtExitManager* at_exit_manager = NULL; + // Some initialization code may use a AtExitManager before initializing + // TestEnvironment, so we create a AtExitManager early and pass its ownership + // to TestEnvironment. + if (!unit_test_mode) + at_exit_manager = new base::AtExitManager; 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 |