Chromium Code Reviews| Index: android_webview/lib/main/aw_main_delegate.cc |
| diff --git a/android_webview/lib/main/aw_main_delegate.cc b/android_webview/lib/main/aw_main_delegate.cc |
| index aba8ae3976913cb5ac05c2214d0f1334caa7e3dc..44a02c4a03f441d20f23b1fd8bc181001520b8a9 100644 |
| --- a/android_webview/lib/main/aw_main_delegate.cc |
| +++ b/android_webview/lib/main/aw_main_delegate.cc |
| @@ -6,6 +6,7 @@ |
| #include "android_webview/browser/aw_content_browser_client.h" |
| #include "android_webview/browser/in_process_renderer/in_process_renderer_client.h" |
| +#include "android_webview/browser/scoped_allow_wait_for_legacy_web_view_api.h" |
| #include "android_webview/common/aw_switches.h" |
| #include "android_webview/lib/aw_browser_dependency_factory_impl.h" |
| #include "android_webview/native/aw_geolocation_permission_context.h" |
| @@ -13,6 +14,7 @@ |
| #include "android_webview/native/aw_web_contents_view_delegate.h" |
| #include "android_webview/renderer/aw_content_renderer_client.h" |
| #include "base/command_line.h" |
| +#include "base/lazy_instance.h" |
| #include "base/logging.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "content/public/browser/browser_main_runner.h" |
| @@ -22,6 +24,17 @@ |
| namespace android_webview { |
| +namespace { |
| + |
| +base::LazyInstance<scoped_ptr<ScopedAllowWaitForLegacyWebViewApi> > |
| + g_allow_wait_in_ui_thread = LAZY_INSTANCE_INITIALIZER; |
| + |
| +bool UIAndRendererCompositorThreadsNotMerged() { |
| + return CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kNoMergeUIAndRendererCompositorThreads); |
| +} |
| +} |
| + |
| AwMainDelegate::AwMainDelegate() { |
| } |
| @@ -35,13 +48,12 @@ bool AwMainDelegate::BasicStartupComplete(int* exit_code) { |
| ::EnableVirtualizedContext(); |
| CommandLine* cl = CommandLine::ForCurrentProcess(); |
| - // Set the command line to enable synchronous API compatibility. |
| - if (cl->HasSwitch(switches::kMergeUIAndRendererCompositorThreads)) { |
| - cl->AppendSwitch(switches::kEnableSynchronousRendererCompositor); |
| - } else { |
| + if (UIAndRendererCompositorThreadsNotMerged()) { |
| cl->AppendSwitch(switches::kEnableWebViewSynchronousAPIs); |
| + } else { |
| + // Set the command line to enable synchronous API compatibility. |
| + cl->AppendSwitch(switches::kEnableSynchronousRendererCompositor); |
| } |
| - |
| return false; |
| } |
| @@ -64,6 +76,11 @@ int AwMainDelegate::RunProcess( |
| int exit_code = browser_runner_->Initialize(main_function_params); |
| DCHECK(exit_code < 0); |
| + if (!UIAndRendererCompositorThreadsNotMerged()) { |
|
boliu
2013/05/08 12:46:03
Leave a comment that this is temporary until we re
joth
2013/05/08 12:49:11
+1
|
| + g_allow_wait_in_ui_thread.Get().reset( |
| + new ScopedAllowWaitForLegacyWebViewApi()); |
| + } |
| + |
| // Return 0 so that we do NOT trigger the default behavior. On Android, the |
| // UI message loop is managed by the Java application. |
| return 0; |
| @@ -90,12 +107,10 @@ content::ContentRendererClient* |
| DCHECK(CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)); |
| // During transition period allow running in either threading mode; eventually |
| // only the compositor/UI thread merge mode will be supported. |
| - const bool merge_threads = |
| - CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kMergeUIAndRendererCompositorThreads); |
| + const bool no_merge_threads = UIAndRendererCompositorThreadsNotMerged(); |
| content_renderer_client_.reset( |
| - merge_threads ? new InProcessRendererClient() : |
| - new AwContentRendererClient()); |
| + no_merge_threads ? new AwContentRendererClient() : |
| + new InProcessRendererClient()); |
| return content_renderer_client_.get(); |
| } |