| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "android_webview/lib/main/aw_main_delegate.h" | 5 #include "android_webview/lib/main/aw_main_delegate.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/aw_content_browser_client.h" | 7 #include "android_webview/browser/aw_content_browser_client.h" |
| 8 #include "android_webview/browser/in_process_renderer/in_process_renderer_client
.h" | 8 #include "android_webview/browser/in_process_renderer/in_process_renderer_client
.h" |
| 9 #include "android_webview/browser/scoped_allow_wait_for_legacy_web_view_api.h" | 9 #include "android_webview/browser/scoped_allow_wait_for_legacy_web_view_api.h" |
| 10 #include "android_webview/common/aw_switches.h" | 10 #include "android_webview/common/aw_switches.h" |
| 11 #include "android_webview/lib/aw_browser_dependency_factory_impl.h" | 11 #include "android_webview/lib/aw_browser_dependency_factory_impl.h" |
| 12 #include "android_webview/native/aw_geolocation_permission_context.h" | 12 #include "android_webview/native/aw_geolocation_permission_context.h" |
| 13 #include "android_webview/native/aw_quota_manager_bridge_impl.h" | 13 #include "android_webview/native/aw_quota_manager_bridge_impl.h" |
| 14 #include "android_webview/native/aw_web_contents_view_delegate.h" | 14 #include "android_webview/native/aw_web_contents_view_delegate.h" |
| 15 #include "android_webview/renderer/aw_content_renderer_client.h" | 15 #include "android_webview/renderer/aw_content_renderer_client.h" |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
| 20 #include "base/threading/thread_restrictions.h" |
| 20 #include "content/public/browser/browser_main_runner.h" | 21 #include "content/public/browser/browser_main_runner.h" |
| 21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
| 23 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" | 24 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" |
| 24 | 25 |
| 25 namespace android_webview { | 26 namespace android_webview { |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 30 // TODO(boliu): Remove these global Allows once the underlying issues |
| 31 // are resolved. See AwMainDelegate::RunProcess below. |
| 32 |
| 29 base::LazyInstance<scoped_ptr<ScopedAllowWaitForLegacyWebViewApi> > | 33 base::LazyInstance<scoped_ptr<ScopedAllowWaitForLegacyWebViewApi> > |
| 30 g_allow_wait_in_ui_thread = LAZY_INSTANCE_INITIALIZER; | 34 g_allow_wait_in_ui_thread = LAZY_INSTANCE_INITIALIZER; |
| 31 | 35 |
| 36 base::LazyInstance<scoped_ptr<base::ThreadRestrictions::ScopedAllowIO> > |
| 37 g_allow_io_in_ui_thread = LAZY_INSTANCE_INITIALIZER; |
| 38 |
| 32 bool UIAndRendererCompositorThreadsNotMerged() { | 39 bool UIAndRendererCompositorThreadsNotMerged() { |
| 33 return CommandLine::ForCurrentProcess()->HasSwitch( | 40 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 34 switches::kNoMergeUIAndRendererCompositorThreads); | 41 switches::kNoMergeUIAndRendererCompositorThreads); |
| 35 } | 42 } |
| 36 } | 43 } |
| 37 | 44 |
| 38 AwMainDelegate::AwMainDelegate() { | 45 AwMainDelegate::AwMainDelegate() { |
| 39 } | 46 } |
| 40 | 47 |
| 41 AwMainDelegate::~AwMainDelegate() { | 48 AwMainDelegate::~AwMainDelegate() { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 69 int AwMainDelegate::RunProcess( | 76 int AwMainDelegate::RunProcess( |
| 70 const std::string& process_type, | 77 const std::string& process_type, |
| 71 const content::MainFunctionParams& main_function_params) { | 78 const content::MainFunctionParams& main_function_params) { |
| 72 if (process_type.empty()) { | 79 if (process_type.empty()) { |
| 73 AwBrowserDependencyFactoryImpl::InstallInstance(); | 80 AwBrowserDependencyFactoryImpl::InstallInstance(); |
| 74 | 81 |
| 75 browser_runner_.reset(content::BrowserMainRunner::Create()); | 82 browser_runner_.reset(content::BrowserMainRunner::Create()); |
| 76 int exit_code = browser_runner_->Initialize(main_function_params); | 83 int exit_code = browser_runner_->Initialize(main_function_params); |
| 77 DCHECK(exit_code < 0); | 84 DCHECK(exit_code < 0); |
| 78 | 85 |
| 79 // This is temporary until we remove the browser compositor | |
| 80 if (!UIAndRendererCompositorThreadsNotMerged()) { | 86 if (!UIAndRendererCompositorThreadsNotMerged()) { |
| 87 // This is temporary until we remove the browser compositor |
| 81 g_allow_wait_in_ui_thread.Get().reset( | 88 g_allow_wait_in_ui_thread.Get().reset( |
| 82 new ScopedAllowWaitForLegacyWebViewApi()); | 89 new ScopedAllowWaitForLegacyWebViewApi); |
| 90 |
| 91 // TODO(boliu): This is a HUGE hack to work around the fact that |
| 92 // cc::WorkerPool joins on worker threads on the UI thread. |
| 93 // See crbug.com/239423. |
| 94 g_allow_io_in_ui_thread.Get().reset( |
| 95 new base::ThreadRestrictions::ScopedAllowIO); |
| 83 } | 96 } |
| 84 | 97 |
| 85 // Return 0 so that we do NOT trigger the default behavior. On Android, the | 98 // Return 0 so that we do NOT trigger the default behavior. On Android, the |
| 86 // UI message loop is managed by the Java application. | 99 // UI message loop is managed by the Java application. |
| 87 return 0; | 100 return 0; |
| 88 } | 101 } |
| 89 | 102 |
| 90 return -1; | 103 return -1; |
| 91 } | 104 } |
| 92 | 105 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 AwBrowserContext* browser_context) { | 138 AwBrowserContext* browser_context) { |
| 126 return AwGeolocationPermissionContext::Create(browser_context); | 139 return AwGeolocationPermissionContext::Create(browser_context); |
| 127 } | 140 } |
| 128 | 141 |
| 129 content::WebContentsViewDelegate* AwMainDelegate::CreateViewDelegate( | 142 content::WebContentsViewDelegate* AwMainDelegate::CreateViewDelegate( |
| 130 content::WebContents* web_contents) { | 143 content::WebContents* web_contents) { |
| 131 return AwWebContentsViewDelegate::Create(web_contents); | 144 return AwWebContentsViewDelegate::Create(web_contents); |
| 132 } | 145 } |
| 133 | 146 |
| 134 } // namespace android_webview | 147 } // namespace android_webview |
| OLD | NEW |