Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: webkit/support/webkit_support.cc

Issue 8638006: Early create AtExitManager on Android because eraly initialization code on Android needs to acces... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "webkit/support/webkit_support.h" 5 #include "webkit/support/webkit_support.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/base64.h" 8 #include "base/base64.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 class TestEnvironment { 121 class TestEnvironment {
122 public: 122 public:
123 #if defined(OS_ANDROID) 123 #if defined(OS_ANDROID)
124 // Android UI message loop goes through Java, so don't use it in tests. 124 // Android UI message loop goes through Java, so don't use it in tests.
125 typedef MessageLoop MessageLoopType; 125 typedef MessageLoop MessageLoopType;
126 #else 126 #else
127 typedef MessageLoopForUI MessageLoopType; 127 typedef MessageLoopForUI MessageLoopType;
128 #endif 128 #endif
129 129
130 explicit TestEnvironment(bool unit_test_mode) { 130 TestEnvironment(bool unit_test_mode,
131 base::AtExitManager* existing_at_exit_manager) {
131 if (!unit_test_mode) { 132 if (!unit_test_mode) {
132 at_exit_manager_.reset(new base::AtExitManager); 133 // The existing_at_exit_manager must be not NULL.
134 at_exit_manager_.reset(existing_at_exit_manager);
133 InitLogging(false); 135 InitLogging(false);
134 } 136 }
135 main_message_loop_.reset(new MessageLoopType); 137 main_message_loop_.reset(new MessageLoopType);
136 // TestWebKitPlatformSupport must be instantiated after MessageLoopType. 138 // TestWebKitPlatformSupport must be instantiated after MessageLoopType.
137 webkit_platform_support_.reset( 139 webkit_platform_support_.reset(
138 new TestWebKitPlatformSupport(unit_test_mode)); 140 new TestWebKitPlatformSupport(unit_test_mode));
139 } 141 }
140 142
141 ~TestEnvironment() { 143 ~TestEnvironment() {
142 SimpleResourceLoaderBridge::Shutdown(); 144 SimpleResourceLoaderBridge::Shutdown();
143 } 145 }
144 146
145 TestWebKitPlatformSupport* webkit_platform_support() const { 147 TestWebKitPlatformSupport* webkit_platform_support() const {
146 return webkit_platform_support_.get(); 148 return webkit_platform_support_.get();
147 } 149 }
148 150
149 #if defined(OS_WIN) || defined(OS_MACOSX) 151 #if defined(OS_WIN) || defined(OS_MACOSX)
150 void set_theme_engine(WebKit::WebThemeEngine* engine) { 152 void set_theme_engine(WebKit::WebThemeEngine* engine) {
151 DCHECK(webkit_platform_support_ != 0); 153 DCHECK(webkit_platform_support_ != 0);
152 webkit_platform_support_->SetThemeEngine(engine); 154 webkit_platform_support_->SetThemeEngine(engine);
153 } 155 }
154 156
155 WebKit::WebThemeEngine* theme_engine() const { 157 WebKit::WebThemeEngine* theme_engine() const {
156 return webkit_platform_support_->themeEngine(); 158 return webkit_platform_support_->themeEngine();
157 } 159 }
158 #endif 160 #endif
159 161
160 private: 162 private:
163 // Data member at_exit_manager_ will take the ownership of the input
164 // AtExitManager and manage its lifecycle.
161 scoped_ptr<base::AtExitManager> at_exit_manager_; 165 scoped_ptr<base::AtExitManager> at_exit_manager_;
162 scoped_ptr<MessageLoopType> main_message_loop_; 166 scoped_ptr<MessageLoopType> main_message_loop_;
163 scoped_ptr<TestWebKitPlatformSupport> webkit_platform_support_; 167 scoped_ptr<TestWebKitPlatformSupport> webkit_platform_support_;
164 }; 168 };
165 169
166 class WebPluginImplWithPageDelegate 170 class WebPluginImplWithPageDelegate
167 : public webkit_support::TestWebPluginPageDelegate, 171 : public webkit_support::TestWebPluginPageDelegate,
168 public base::SupportsWeakPtr<WebPluginImplWithPageDelegate>, 172 public base::SupportsWeakPtr<WebPluginImplWithPageDelegate>,
169 public webkit::npapi::WebPluginImpl { 173 public webkit::npapi::WebPluginImpl {
170 public: 174 public:
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 // webkit/glue/plugin/plugin_list_posix.cc checks --debug-plugin-loading. 234 // webkit/glue/plugin/plugin_list_posix.cc checks --debug-plugin-loading.
231 // webkit/glue/plugin/plugin_list_win.cc checks --old-wmp. 235 // webkit/glue/plugin/plugin_list_win.cc checks --old-wmp.
232 // If DRT needs these flags, specify them in the following kFixedArguments. 236 // If DRT needs these flags, specify them in the following kFixedArguments.
233 const char* kFixedArguments[] = {"DumpRenderTree"}; 237 const char* kFixedArguments[] = {"DumpRenderTree"};
234 CommandLine::Init(arraysize(kFixedArguments), kFixedArguments); 238 CommandLine::Init(arraysize(kFixedArguments), kFixedArguments);
235 239
236 // Explicitly initialize the GURL library before spawning any threads. 240 // Explicitly initialize the GURL library before spawning any threads.
237 // Otherwise crash may happend when different threads try to create a GURL 241 // Otherwise crash may happend when different threads try to create a GURL
238 // at same time. 242 // at same time.
239 url_util::Initialize(); 243 url_util::Initialize();
244 base::AtExitManager* at_exit_manager = NULL;
245 // Some initialization code may use a AtExitManager before initializing
246 // TestEnvironment, so we create a AtExitManager early and pass its ownership
247 // to TestEnvironment.
248 if (!unit_test_mode)
249 at_exit_manager = new base::AtExitManager;
240 BeforeInitialize(unit_test_mode); 250 BeforeInitialize(unit_test_mode);
241 test_environment = new TestEnvironment(unit_test_mode); 251 test_environment = new TestEnvironment(unit_test_mode, at_exit_manager);
242 AfterInitialize(unit_test_mode); 252 AfterInitialize(unit_test_mode);
243 if (!unit_test_mode) { 253 if (!unit_test_mode) {
244 // Load ICU data tables. This has to run after TestEnvironment is created 254 // Load ICU data tables. This has to run after TestEnvironment is created
245 // because on Linux, we need base::AtExitManager. 255 // because on Linux, we need base::AtExitManager.
246 icu_util::Initialize(); 256 icu_util::Initialize();
247 } 257 }
248 webkit_glue::SetUserAgent(webkit_glue::BuildUserAgentFromProduct( 258 webkit_glue::SetUserAgent(webkit_glue::BuildUserAgentFromProduct(
249 "DumpRenderTree/0.0.0.0"), false); 259 "DumpRenderTree/0.0.0.0"), false);
250 } 260 }
251 261
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 // Logging 636 // Logging
627 void EnableWebCoreLogChannels(const std::string& channels) { 637 void EnableWebCoreLogChannels(const std::string& channels) {
628 webkit_glue::EnableWebCoreLogChannels(channels); 638 webkit_glue::EnableWebCoreLogChannels(channels);
629 } 639 }
630 640
631 void SetGamepadData(const WebKit::WebGamepads& pads) { 641 void SetGamepadData(const WebKit::WebGamepads& pads) {
632 test_environment->webkit_platform_support()->setGamepadData(pads); 642 test_environment->webkit_platform_support()->setGamepadData(pads);
633 } 643 }
634 644
635 } // namespace webkit_support 645 } // namespace webkit_support
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698