Use synchronize methods instead of synchronized blocks in PacWebView.

No change in logic.

Bug: 148516710
Test: atest DeviceOwnerTest#testProxyPacProxyTest
Change-Id: Id8089ff4e93b6b6df6547c226610be99ae5dabb1
This commit is contained in:
Anna Malova
2020-02-12 12:55:53 +00:00
parent c228e1d88a
commit 23782a50ab

View File

@@ -19,8 +19,6 @@ package com.android.pacprocessor;
import android.util.Log;
import android.webkit.PacProcessor;
import com.android.internal.annotations.GuardedBy;
/**
* @hide
*/
@@ -28,10 +26,6 @@ public class PacWebView implements LibpacInterface {
private static final String TAG = "PacWebView";
private static final PacWebView sInstance = new PacWebView();
private Object mLock = new Object();
@GuardedBy("mLock")
private PacProcessor mProcessor = PacProcessor.getInstance();
public static PacWebView getInstance() {
@@ -39,20 +33,16 @@ public class PacWebView implements LibpacInterface {
}
@Override
public boolean setCurrentProxyScript(String script) {
synchronized (mLock) {
if (!mProcessor.setProxyScript(script)) {
Log.e(TAG, "Unable to parse proxy script.");
return false;
}
return true;
public synchronized boolean setCurrentProxyScript(String script) {
if (!mProcessor.setProxyScript(script)) {
Log.e(TAG, "Unable to parse proxy script.");
return false;
}
return true;
}
@Override
public String makeProxyRequest(String url, String host) {
synchronized (mLock) {
return mProcessor.findProxyForUrl(url);
}
public synchronized String makeProxyRequest(String url, String host) {
return mProcessor.findProxyForUrl(url);
}
}