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

Side by Side Diff: android_webview/lib/main/aw_main_delegate.cc

Issue 13907007: Replace merge-ui-and-compositor-threads flag with no-merge-ui-and-compositor-threads flag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Created 7 years, 7 months 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 | « android_webview/javatests/src/org/chromium/android_webview/test/AwZoomTest.java ('k') | 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) 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/common/aw_switches.h" 10 #include "android_webview/common/aw_switches.h"
10 #include "android_webview/lib/aw_browser_dependency_factory_impl.h" 11 #include "android_webview/lib/aw_browser_dependency_factory_impl.h"
11 #include "android_webview/native/aw_geolocation_permission_context.h" 12 #include "android_webview/native/aw_geolocation_permission_context.h"
12 #include "android_webview/native/aw_quota_manager_bridge_impl.h" 13 #include "android_webview/native/aw_quota_manager_bridge_impl.h"
13 #include "android_webview/native/aw_web_contents_view_delegate.h" 14 #include "android_webview/native/aw_web_contents_view_delegate.h"
14 #include "android_webview/renderer/aw_content_renderer_client.h" 15 #include "android_webview/renderer/aw_content_renderer_client.h"
15 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/lazy_instance.h"
16 #include "base/logging.h" 18 #include "base/logging.h"
17 #include "base/memory/scoped_ptr.h" 19 #include "base/memory/scoped_ptr.h"
18 #include "content/public/browser/browser_main_runner.h" 20 #include "content/public/browser/browser_main_runner.h"
19 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
20 #include "content/public/common/content_switches.h" 22 #include "content/public/common/content_switches.h"
21 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" 23 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
22 24
23 namespace android_webview { 25 namespace android_webview {
24 26
27 namespace {
28
29 base::LazyInstance<scoped_ptr<ScopedAllowWaitForLegacyWebViewApi> >
30 g_allow_wait_in_ui_thread = LAZY_INSTANCE_INITIALIZER;
31
32 bool UIAndRendererCompositorThreadsNotMerged() {
33 return CommandLine::ForCurrentProcess()->HasSwitch(
34 switches::kNoMergeUIAndRendererCompositorThreads);
35 }
36 }
37
25 AwMainDelegate::AwMainDelegate() { 38 AwMainDelegate::AwMainDelegate() {
26 } 39 }
27 40
28 AwMainDelegate::~AwMainDelegate() { 41 AwMainDelegate::~AwMainDelegate() {
29 } 42 }
30 43
31 bool AwMainDelegate::BasicStartupComplete(int* exit_code) { 44 bool AwMainDelegate::BasicStartupComplete(int* exit_code) {
32 content::SetContentClient(&content_client_); 45 content::SetContentClient(&content_client_);
33 46
34 webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl 47 webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl
35 ::EnableVirtualizedContext(); 48 ::EnableVirtualizedContext();
36 49
37 CommandLine* cl = CommandLine::ForCurrentProcess(); 50 CommandLine* cl = CommandLine::ForCurrentProcess();
38 // Set the command line to enable synchronous API compatibility. 51 if (UIAndRendererCompositorThreadsNotMerged()) {
39 if (cl->HasSwitch(switches::kMergeUIAndRendererCompositorThreads)) { 52 cl->AppendSwitch(switches::kEnableWebViewSynchronousAPIs);
53 } else {
54 // Set the command line to enable synchronous API compatibility.
40 cl->AppendSwitch(switches::kEnableSynchronousRendererCompositor); 55 cl->AppendSwitch(switches::kEnableSynchronousRendererCompositor);
41 } else {
42 cl->AppendSwitch(switches::kEnableWebViewSynchronousAPIs);
43 } 56 }
44
45 return false; 57 return false;
46 } 58 }
47 59
48 void AwMainDelegate::PreSandboxStartup() { 60 void AwMainDelegate::PreSandboxStartup() {
49 // TODO(torne): When we have a separate renderer process, we need to handle 61 // TODO(torne): When we have a separate renderer process, we need to handle
50 // being passed open FDs for the resource paks here. 62 // being passed open FDs for the resource paks here.
51 } 63 }
52 64
53 void AwMainDelegate::SandboxInitialized(const std::string& process_type) { 65 void AwMainDelegate::SandboxInitialized(const std::string& process_type) {
54 // TODO(torne): Adjust linux OOM score here. 66 // TODO(torne): Adjust linux OOM score here.
55 } 67 }
56 68
57 int AwMainDelegate::RunProcess( 69 int AwMainDelegate::RunProcess(
58 const std::string& process_type, 70 const std::string& process_type,
59 const content::MainFunctionParams& main_function_params) { 71 const content::MainFunctionParams& main_function_params) {
60 if (process_type.empty()) { 72 if (process_type.empty()) {
61 AwBrowserDependencyFactoryImpl::InstallInstance(); 73 AwBrowserDependencyFactoryImpl::InstallInstance();
62 74
63 browser_runner_.reset(content::BrowserMainRunner::Create()); 75 browser_runner_.reset(content::BrowserMainRunner::Create());
64 int exit_code = browser_runner_->Initialize(main_function_params); 76 int exit_code = browser_runner_->Initialize(main_function_params);
65 DCHECK(exit_code < 0); 77 DCHECK(exit_code < 0);
66 78
79 // This is temporary until we remove the browser compositor
80 if (!UIAndRendererCompositorThreadsNotMerged()) {
81 g_allow_wait_in_ui_thread.Get().reset(
82 new ScopedAllowWaitForLegacyWebViewApi());
83 }
84
67 // Return 0 so that we do NOT trigger the default behavior. On Android, the 85 // Return 0 so that we do NOT trigger the default behavior. On Android, the
68 // UI message loop is managed by the Java application. 86 // UI message loop is managed by the Java application.
69 return 0; 87 return 0;
70 } 88 }
71 89
72 return -1; 90 return -1;
73 } 91 }
74 92
75 void AwMainDelegate::ProcessExiting(const std::string& process_type) { 93 void AwMainDelegate::ProcessExiting(const std::string& process_type) {
76 // TODO(torne): Clean up resources when we handle them. 94 // TODO(torne): Clean up resources when we handle them.
77 95
78 logging::CloseLogFile(); 96 logging::CloseLogFile();
79 } 97 }
80 98
81 content::ContentBrowserClient* 99 content::ContentBrowserClient*
82 AwMainDelegate::CreateContentBrowserClient() { 100 AwMainDelegate::CreateContentBrowserClient() {
83 content_browser_client_.reset(new AwContentBrowserClient(this)); 101 content_browser_client_.reset(new AwContentBrowserClient(this));
84 return content_browser_client_.get(); 102 return content_browser_client_.get();
85 } 103 }
86 104
87 content::ContentRendererClient* 105 content::ContentRendererClient*
88 AwMainDelegate::CreateContentRendererClient() { 106 AwMainDelegate::CreateContentRendererClient() {
89 // None of this makes sense for multiprocess. 107 // None of this makes sense for multiprocess.
90 DCHECK(CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)); 108 DCHECK(CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess));
91 // During transition period allow running in either threading mode; eventually 109 // During transition period allow running in either threading mode; eventually
92 // only the compositor/UI thread merge mode will be supported. 110 // only the compositor/UI thread merge mode will be supported.
93 const bool merge_threads = 111 const bool no_merge_threads = UIAndRendererCompositorThreadsNotMerged();
94 CommandLine::ForCurrentProcess()->HasSwitch(
95 switches::kMergeUIAndRendererCompositorThreads);
96 content_renderer_client_.reset( 112 content_renderer_client_.reset(
97 merge_threads ? new InProcessRendererClient() : 113 no_merge_threads ? new AwContentRendererClient() :
98 new AwContentRendererClient()); 114 new InProcessRendererClient());
99 return content_renderer_client_.get(); 115 return content_renderer_client_.get();
100 } 116 }
101 117
102 AwQuotaManagerBridge* AwMainDelegate::CreateAwQuotaManagerBridge( 118 AwQuotaManagerBridge* AwMainDelegate::CreateAwQuotaManagerBridge(
103 AwBrowserContext* browser_context) { 119 AwBrowserContext* browser_context) {
104 return new AwQuotaManagerBridgeImpl(browser_context); 120 return new AwQuotaManagerBridgeImpl(browser_context);
105 } 121 }
106 122
107 content::GeolocationPermissionContext* 123 content::GeolocationPermissionContext*
108 AwMainDelegate::CreateGeolocationPermission( 124 AwMainDelegate::CreateGeolocationPermission(
109 AwBrowserContext* browser_context) { 125 AwBrowserContext* browser_context) {
110 return AwGeolocationPermissionContext::Create(browser_context); 126 return AwGeolocationPermissionContext::Create(browser_context);
111 } 127 }
112 128
113 content::WebContentsViewDelegate* AwMainDelegate::CreateViewDelegate( 129 content::WebContentsViewDelegate* AwMainDelegate::CreateViewDelegate(
114 content::WebContents* web_contents) { 130 content::WebContents* web_contents) {
115 return AwWebContentsViewDelegate::Create(web_contents); 131 return AwWebContentsViewDelegate::Create(web_contents);
116 } 132 }
117 133
118 } // namespace android_webview 134 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/javatests/src/org/chromium/android_webview/test/AwZoomTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698