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

Side by Side Diff: android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java

Issue 1934623002: Revert of patch suspect of causing Android GPU builds to start failing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 package com.android.webview.chromium; 5 package com.android.webview.chromium;
6 6
7 import android.Manifest; 7 import android.Manifest;
8 import android.app.ActivityManager; 8 import android.app.ActivityManager;
9 import android.content.ComponentCallbacks2; 9 import android.content.ComponentCallbacks2;
10 import android.content.Context; 10 import android.content.Context;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 // Initialization guarded by mLock. 81 // Initialization guarded by mLock.
82 private AwBrowserContext mBrowserContext; 82 private AwBrowserContext mBrowserContext;
83 private Statics mStaticMethods; 83 private Statics mStaticMethods;
84 private GeolocationPermissionsAdapter mGeolocationPermissions; 84 private GeolocationPermissionsAdapter mGeolocationPermissions;
85 private CookieManagerAdapter mCookieManager; 85 private CookieManagerAdapter mCookieManager;
86 private WebIconDatabaseAdapter mWebIconDatabase; 86 private WebIconDatabaseAdapter mWebIconDatabase;
87 private WebStorageAdapter mWebStorage; 87 private WebStorageAdapter mWebStorage;
88 private WebViewDatabaseAdapter mWebViewDatabase; 88 private WebViewDatabaseAdapter mWebViewDatabase;
89 private AwDevToolsServer mDevToolsServer; 89 private AwDevToolsServer mDevToolsServer;
90 private Context mWrappedAppContext;
90 91
91 private ArrayList<WeakReference<WebViewChromium>> mWebViewsToStart = 92 private ArrayList<WeakReference<WebViewChromium>> mWebViewsToStart =
92 new ArrayList<WeakReference<WebViewChromium>>(); 93 new ArrayList<WeakReference<WebViewChromium>>();
93 94
94 // Read/write protected by mLock. 95 // Read/write protected by mLock.
95 private boolean mStarted; 96 private boolean mStarted;
96 private AwDataReductionProxyManager mProxyManager; 97 private AwDataReductionProxyManager mProxyManager;
97 98
98 private SharedPreferences mWebViewPrefs; 99 private SharedPreferences mWebViewPrefs;
99 private WebViewDelegate mWebViewDelegate; 100 private WebViewDelegate mWebViewDelegate;
100 101
101 /** 102 /**
102 * Constructor called by the API 21 version of {@link WebViewFactory} and ea rlier. 103 * Constructor called by the API 21 version of {@link WebViewFactory} and ea rlier.
103 */ 104 */
104 public WebViewChromiumFactoryProvider() { 105 public WebViewChromiumFactoryProvider() {
105 initialize(WebViewDelegateFactory.createApi21CompatibilityDelegate()); 106 initialize(WebViewDelegateFactory.createApi21CompatibilityDelegate());
106 } 107 }
107 108
108 /** 109 /**
109 * Constructor called by the API 22 version of {@link WebViewFactory} and la ter. 110 * Constructor called by the API 22 version of {@link WebViewFactory} and la ter.
110 */ 111 */
111 public WebViewChromiumFactoryProvider(android.webkit.WebViewDelegate delegat e) { 112 public WebViewChromiumFactoryProvider(android.webkit.WebViewDelegate delegat e) {
112 initialize(WebViewDelegateFactory.createProxyDelegate(delegate)); 113 initialize(WebViewDelegateFactory.createProxyDelegate(delegate));
113 } 114 }
114 115
115 @SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME") 116 @SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME")
116 private void initialize(WebViewDelegate webViewDelegate) { 117 private void initialize(WebViewDelegate webViewDelegate) {
117 mWebViewDelegate = webViewDelegate; 118 mWebViewDelegate = webViewDelegate;
118
119 // WebView needs to make sure to always use the wrapped application cont ext.
120 ContextUtils.initApplicationContext(
121 ResourcesContextWrapperFactory.get(mWebViewDelegate.getApplicati on()));
122
123 if (isBuildDebuggable()) { 119 if (isBuildDebuggable()) {
124 // Suppress the StrictMode violation as this codepath is only hit on debugglable builds. 120 // Suppress the StrictMode violation as this codepath is only hit on debugglable builds.
125 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads( ); 121 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads( );
126 CommandLine.initFromFile(COMMAND_LINE_FILE); 122 CommandLine.initFromFile(COMMAND_LINE_FILE);
127 StrictMode.setThreadPolicy(oldPolicy); 123 StrictMode.setThreadPolicy(oldPolicy);
128 } else { 124 } else {
129 CommandLine.init(null); 125 CommandLine.init(null);
130 } 126 }
131 127
132 ThreadUtils.setWillOverrideUiThread(); 128 ThreadUtils.setWillOverrideUiThread();
133 // Load chromium library. 129 // Load chromium library.
134 AwBrowserProcess.loadLibrary(ContextUtils.getApplicationContext()); 130 AwBrowserProcess.loadLibrary(getWrappedCurrentApplicationContext());
135 131
136 final PackageInfo packageInfo = WebViewFactory.getLoadedPackageInfo(); 132 final PackageInfo packageInfo = WebViewFactory.getLoadedPackageInfo();
137 133
138 // Load glue-layer support library. 134 // Load glue-layer support library.
139 System.loadLibrary("webviewchromium_plat_support"); 135 System.loadLibrary("webviewchromium_plat_support");
140 136
141 // Use shared preference to check for package downgrade. 137 // Use shared preference to check for package downgrade.
142 mWebViewPrefs = mWebViewDelegate.getApplication().getSharedPreferences( 138 mWebViewPrefs = mWebViewDelegate.getApplication().getSharedPreferences(
143 CHROMIUM_PREFS_NAME, Context.MODE_PRIVATE); 139 CHROMIUM_PREFS_NAME, Context.MODE_PRIVATE);
144 int lastVersion = mWebViewPrefs.getInt(VERSION_CODE_PREF, 0); 140 int lastVersion = mWebViewPrefs.getInt(VERSION_CODE_PREF, 0);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 assert Thread.holdsLock(mLock) && ThreadUtils.runningOnUiThread(); 257 assert Thread.holdsLock(mLock) && ThreadUtils.runningOnUiThread();
262 258
263 // The post-condition of this method is everything is ready, so notify n ow to cover all 259 // The post-condition of this method is everything is ready, so notify n ow to cover all
264 // return paths. (Other threads will not wake-up until we release |mLock |, whatever). 260 // return paths. (Other threads will not wake-up until we release |mLock |, whatever).
265 mLock.notifyAll(); 261 mLock.notifyAll();
266 262
267 if (mStarted) { 263 if (mStarted) {
268 return; 264 return;
269 } 265 }
270 266
271 Context context = ContextUtils.getApplicationContext(); 267 Context context = getWrappedCurrentApplicationContext();
272 try { 268 try {
273 LibraryLoader.get(LibraryProcessType.PROCESS_WEBVIEW).ensureInitiali zed(context); 269 LibraryLoader.get(LibraryProcessType.PROCESS_WEBVIEW).ensureInitiali zed(context);
274 } catch (ProcessInitException e) { 270 } catch (ProcessInitException e) {
275 throw new RuntimeException("Error initializing WebView library", e); 271 throw new RuntimeException("Error initializing WebView library", e);
276 } 272 }
277 273
278 PathService.override(PathService.DIR_MODULE, "/system/lib/"); 274 PathService.override(PathService.DIR_MODULE, "/system/lib/");
279 PathService.override(DIR_RESOURCE_PAKS_ANDROID, "/system/framework/webvi ew/paks"); 275 PathService.override(DIR_RESOURCE_PAKS_ANDROID, "/system/framework/webvi ew/paks");
280 276
281 // Make sure that ResourceProvider is initialized before starting the br owser process. 277 // Make sure that ResourceProvider is initialized before starting the br owser process.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 boolean hasStarted() { 315 boolean hasStarted() {
320 return mStarted; 316 return mStarted;
321 } 317 }
322 318
323 void startYourEngines(boolean onMainThread) { 319 void startYourEngines(boolean onMainThread) {
324 synchronized (mLock) { 320 synchronized (mLock) {
325 ensureChromiumStartedLocked(onMainThread); 321 ensureChromiumStartedLocked(onMainThread);
326 } 322 }
327 } 323 }
328 324
325 private Context getWrappedCurrentApplicationContext() {
326 if (mWrappedAppContext == null) {
327 mWrappedAppContext = ResourcesContextWrapperFactory.get(
328 mWebViewDelegate.getApplication());
329 }
330 return mWrappedAppContext;
331 }
332
329 AwBrowserContext getBrowserContext() { 333 AwBrowserContext getBrowserContext() {
330 synchronized (mLock) { 334 synchronized (mLock) {
331 return getBrowserContextLocked(); 335 return getBrowserContextLocked();
332 } 336 }
333 } 337 }
334 338
335 private AwBrowserContext getBrowserContextLocked() { 339 private AwBrowserContext getBrowserContextLocked() {
336 assert Thread.holdsLock(mLock); 340 assert Thread.holdsLock(mLock);
337 assert mStarted; 341 assert mStarted;
338 if (mBrowserContext == null) { 342 if (mBrowserContext == null) {
339 mBrowserContext = 343 mBrowserContext =
340 new AwBrowserContext(mWebViewPrefs, ContextUtils.getApplicat ionContext()); 344 new AwBrowserContext(mWebViewPrefs, getWrappedCurrentApplica tionContext());
341 } 345 }
342 return mBrowserContext; 346 return mBrowserContext;
343 } 347 }
344 348
345 private void setWebContentsDebuggingEnabled(boolean enable) { 349 private void setWebContentsDebuggingEnabled(boolean enable) {
346 if (Looper.myLooper() != ThreadUtils.getUiThreadLooper()) { 350 if (Looper.myLooper() != ThreadUtils.getUiThreadLooper()) {
347 throw new RuntimeException( 351 throw new RuntimeException(
348 "Toggling of Web Contents Debugging must be done on the UI t hread"); 352 "Toggling of Web Contents Debugging must be done on the UI t hread");
349 } 353 }
350 if (mDevToolsServer == null) { 354 if (mDevToolsServer == null) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 getBrowserContextLocked().getGeolocationPermissions()); 444 getBrowserContextLocked().getGeolocationPermissions());
441 } 445 }
442 } 446 }
443 return mGeolocationPermissions; 447 return mGeolocationPermissions;
444 } 448 }
445 449
446 @Override 450 @Override
447 public CookieManager getCookieManager() { 451 public CookieManager getCookieManager() {
448 synchronized (mLock) { 452 synchronized (mLock) {
449 if (mCookieManager == null) { 453 if (mCookieManager == null) {
454 if (!mStarted) {
455 // We can use CookieManager without starting Chromium; the n ative code
456 // will bring up just the parts it needs to make this work o n a temporary
457 // basis until Chromium is started for real. The temporary c ookie manager
458 // needs the application context to have been set.
459 ContextUtils.initApplicationContext(getWrappedCurrentApplica tionContext());
460 }
450 mCookieManager = new CookieManagerAdapter(new AwCookieManager()) ; 461 mCookieManager = new CookieManagerAdapter(new AwCookieManager()) ;
451 } 462 }
452 } 463 }
453 return mCookieManager; 464 return mCookieManager;
454 } 465 }
455 466
456 @Override 467 @Override
457 public android.webkit.WebIconDatabase getWebIconDatabase() { 468 public android.webkit.WebIconDatabase getWebIconDatabase() {
458 synchronized (mLock) { 469 synchronized (mLock) {
459 if (mWebIconDatabase == null) { 470 if (mWebIconDatabase == null) {
(...skipping 25 matching lines...) Expand all
485 browserContext.getHttpAuthDatabase(context)); 496 browserContext.getHttpAuthDatabase(context));
486 } 497 }
487 } 498 }
488 return mWebViewDatabase; 499 return mWebViewDatabase;
489 } 500 }
490 501
491 WebViewDelegate getWebViewDelegate() { 502 WebViewDelegate getWebViewDelegate() {
492 return mWebViewDelegate; 503 return mWebViewDelegate;
493 } 504 }
494 } 505 }
OLDNEW
« no previous file with comments | « no previous file | android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698