Bug 1258789 - Add synchronized & non-failing try to WhitespaceAround. r=grisha

MozReview-Commit-ID: EBnxF8j2eeY

--HG--
extra : rebase_source : e5f79e706f7ba63b484baf5b339581cdbeee626d
This commit is contained in:
Michael Comella 2016-04-12 18:20:51 -07:00
Родитель b7ca9be873
Коммит 536223b0e1
10 изменённых файлов: 21 добавлений и 21 удалений

Просмотреть файл

@ -55,7 +55,7 @@
</module> </module>
<module name="WhitespaceAround"> <module name="WhitespaceAround">
<property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN,
LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SWITCH"/> LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY"/>
</module> </module>
</module> </module>

Просмотреть файл

@ -1492,7 +1492,7 @@ public class GeckoAppShell
List<ResolveInfo> plugins = pm.queryIntentServices(new Intent(PLUGIN_ACTION), List<ResolveInfo> plugins = pm.queryIntentServices(new Intent(PLUGIN_ACTION),
PackageManager.GET_SERVICES | PackageManager.GET_META_DATA); PackageManager.GET_SERVICES | PackageManager.GET_META_DATA);
synchronized(mPackageInfoCache) { synchronized (mPackageInfoCache) {
// clear the list of existing packageInfo objects // clear the list of existing packageInfo objects
mPackageInfoCache.clear(); mPackageInfoCache.clear();
@ -1619,7 +1619,7 @@ public class GeckoAppShell
return null; return null;
} }
synchronized(mPackageInfoCache) { synchronized (mPackageInfoCache) {
for (PackageInfo pkgInfo : mPackageInfoCache) { for (PackageInfo pkgInfo : mPackageInfoCache) {
if (pluginLib.contains(pkgInfo.packageName)) { if (pluginLib.contains(pkgInfo.packageName)) {
return pkgInfo.packageName; return pkgInfo.packageName;

Просмотреть файл

@ -253,7 +253,7 @@ final class GeckoEditable extends JNIObject
if (mActions.isEmpty()) { if (mActions.isEmpty()) {
mActionsActive.acquireUninterruptibly(); mActionsActive.acquireUninterruptibly();
mActions.offer(action); mActions.offer(action);
} else synchronized(this) { } else synchronized (this) {
// tryAcquire here in case Gecko thread has just released it // tryAcquire here in case Gecko thread has just released it
mActionsActive.tryAcquire(); mActionsActive.tryAcquire();
mActions.offer(action); mActions.offer(action);
@ -350,7 +350,7 @@ final class GeckoEditable extends JNIObject
throw new IllegalStateException("empty actions queue"); throw new IllegalStateException("empty actions queue");
} }
synchronized(this) { synchronized (this) {
if (mActions.isEmpty()) { if (mActions.isEmpty()) {
mActionsActive.release(); mActionsActive.release();
} }

Просмотреть файл

@ -763,25 +763,25 @@ public class Tab {
} }
public void addPluginLayer(Object surfaceOrView, Layer layer) { public void addPluginLayer(Object surfaceOrView, Layer layer) {
synchronized(mPluginLayers) { synchronized (mPluginLayers) {
mPluginLayers.put(surfaceOrView, layer); mPluginLayers.put(surfaceOrView, layer);
} }
} }
public Layer getPluginLayer(Object surfaceOrView) { public Layer getPluginLayer(Object surfaceOrView) {
synchronized(mPluginLayers) { synchronized (mPluginLayers) {
return mPluginLayers.get(surfaceOrView); return mPluginLayers.get(surfaceOrView);
} }
} }
public Collection<Layer> getPluginLayers() { public Collection<Layer> getPluginLayers() {
synchronized(mPluginLayers) { synchronized (mPluginLayers) {
return new ArrayList<Layer>(mPluginLayers.values()); return new ArrayList<Layer>(mPluginLayers.values());
} }
} }
public Layer removePluginLayer(Object surfaceOrView) { public Layer removePluginLayer(Object surfaceOrView) {
synchronized(mPluginLayers) { synchronized (mPluginLayers) {
return mPluginLayers.remove(surfaceOrView); return mPluginLayers.remove(surfaceOrView);
} }
} }

Просмотреть файл

@ -296,7 +296,7 @@ public class Favicons {
final LoadFaviconTask task = final LoadFaviconTask task =
new LoadFaviconTask(context, pageURL, targetURL, 0, callback, targetSize, true); new LoadFaviconTask(context, pageURL, targetURL, 0, callback, targetSize, true);
final int taskId = task.getId(); final int taskId = task.getId();
synchronized(loadTasks) { synchronized (loadTasks) {
loadTasks.put(taskId, task); loadTasks.put(taskId, task);
} }
task.execute(); task.execute();
@ -369,7 +369,7 @@ public class Favicons {
final LoadFaviconTask task = final LoadFaviconTask task =
new LoadFaviconTask(context, pageURL, faviconURL, flags, listener, targetSize, false); new LoadFaviconTask(context, pageURL, faviconURL, flags, listener, targetSize, false);
final int taskId = task.getId(); final int taskId = task.getId();
synchronized(loadTasks) { synchronized (loadTasks) {
loadTasks.put(taskId, task); loadTasks.put(taskId, task);
} }
task.execute(); task.execute();
@ -567,7 +567,7 @@ public class Favicons {
} }
public static void removeLoadTask(int taskId) { public static void removeLoadTask(int taskId) {
synchronized(loadTasks) { synchronized (loadTasks) {
loadTasks.delete(taskId); loadTasks.delete(taskId);
} }
} }

Просмотреть файл

@ -381,7 +381,7 @@ public class LoadFaviconTask {
Bitmap image; Bitmap image;
// Determine if there is already an ongoing task to fetch the Favicon we desire. // Determine if there is already an ongoing task to fetch the Favicon we desire.
// If there is, just join the queue and wait for it to finish. If not, we carry on. // If there is, just join the queue and wait for it to finish. If not, we carry on.
synchronized(loadsInFlight) { synchronized (loadsInFlight) {
// Another load of the current Favicon is already underway // Another load of the current Favicon is already underway
LoadFaviconTask existingTask = loadsInFlight.get(faviconURL); LoadFaviconTask existingTask = loadsInFlight.get(faviconURL);
if (existingTask != null && !existingTask.isCancelled()) { if (existingTask != null && !existingTask.isCancelled()) {
@ -565,7 +565,7 @@ public class LoadFaviconTask {
void onCancelled() { void onCancelled() {
Favicons.removeLoadTask(id); Favicons.removeLoadTask(id);
synchronized(loadsInFlight) { synchronized (loadsInFlight) {
// Only remove from the hashmap if the task there is the one that's being canceled. // Only remove from the hashmap if the task there is the one that's being canceled.
// Cancellation of a task that would have chained is not interesting to the hashmap. // Cancellation of a task that would have chained is not interesting to the hashmap.
final LoadFaviconTask primary = loadsInFlight.get(faviconURL); final LoadFaviconTask primary = loadsInFlight.get(faviconURL);

Просмотреть файл

@ -451,7 +451,7 @@ public class FaviconCache {
* @return true if this element already existed in the list, false otherwise. (Useful for preventing multiple-insertion.) * @return true if this element already existed in the list, false otherwise. (Useful for preventing multiple-insertion.)
*/ */
private boolean setMostRecentlyUsedWithinRead(FaviconCacheElement element) { private boolean setMostRecentlyUsedWithinRead(FaviconCacheElement element) {
synchronized(reorderingLock) { synchronized (reorderingLock) {
boolean contained = ordering.remove(element); boolean contained = ordering.remove(element);
ordering.offer(element); ordering.offer(element);
return contained; return contained;

Просмотреть файл

@ -326,7 +326,7 @@ public class HomePanelsManager implements GeckoEventListener {
pm.requestPanelsById(ids, new RequestCallback() { pm.requestPanelsById(ids, new RequestCallback() {
@Override @Override
public void onComplete(List<PanelInfo> panelInfos) { public void onComplete(List<PanelInfo> panelInfos) {
synchronized(panelRequestLock) { synchronized (panelRequestLock) {
latestPanelInfos.addAll(panelInfos); latestPanelInfos.addAll(panelInfos);
Log.d(LOGTAG, "executeRefresh: fetched panel infos: " + panelInfos.size()); Log.d(LOGTAG, "executeRefresh: fetched panel infos: " + panelInfos.size());
@ -336,7 +336,7 @@ public class HomePanelsManager implements GeckoEventListener {
}); });
try { try {
synchronized(panelRequestLock) { synchronized (panelRequestLock) {
panelRequestLock.wait(PANEL_INFO_TIMEOUT_MSEC); panelRequestLock.wait(PANEL_INFO_TIMEOUT_MSEC);
Log.d(LOGTAG, "executeRefresh: done fetching panel infos"); Log.d(LOGTAG, "executeRefresh: done fetching panel infos");

Просмотреть файл

@ -75,7 +75,7 @@ public class PanelInfoManager implements GeckoEventListener {
public void requestPanelsById(Set<String> ids, RequestCallback callback) { public void requestPanelsById(Set<String> ids, RequestCallback callback) {
final int requestId = sRequestId.getAndIncrement(); final int requestId = sRequestId.getAndIncrement();
synchronized(sCallbacks) { synchronized (sCallbacks) {
// If there are no pending callbacks, register the event listener. // If there are no pending callbacks, register the event listener.
if (sCallbacks.size() == 0) { if (sCallbacks.size() == 0) {
EventDispatcher.getInstance().registerGeckoThreadListener(this, EventDispatcher.getInstance().registerGeckoThreadListener(this,
@ -131,7 +131,7 @@ public class PanelInfoManager implements GeckoEventListener {
final RequestCallback callback; final RequestCallback callback;
final int requestId = message.getInt("requestId"); final int requestId = message.getInt("requestId");
synchronized(sCallbacks) { synchronized (sCallbacks) {
callback = sCallbacks.get(requestId); callback = sCallbacks.get(requestId);
sCallbacks.delete(requestId); sCallbacks.delete(requestId);

Просмотреть файл

@ -39,7 +39,7 @@ public class JavaAddonManagerV1 implements NativeEventListener {
private final org.mozilla.gecko.EventDispatcher mDispatcher; private final org.mozilla.gecko.EventDispatcher mDispatcher;
// Protected by synchronized(this). // Protected by synchronized (this).
private final Map<String, EventDispatcherImpl> mGUIDToDispatcherMap = new HashMap<>(); private final Map<String, EventDispatcherImpl> mGUIDToDispatcherMap = new HashMap<>();
public static synchronized JavaAddonManagerV1 getInstance() { public static synchronized JavaAddonManagerV1 getInstance() {
@ -153,7 +153,7 @@ public class JavaAddonManagerV1 implements NativeEventListener {
private final String guid; private final String guid;
private final String dexFileName; private final String dexFileName;
// Protected by synchronized(this). // Protected by synchronized (this).
private final Map<JavaAddonInterfaceV1.EventListener, Pair<NativeEventListener, String[]>> mListenerToWrapperMap = new IdentityHashMap<>(); private final Map<JavaAddonInterfaceV1.EventListener, Pair<NativeEventListener, String[]>> mListenerToWrapperMap = new IdentityHashMap<>();
public EventDispatcherImpl(String guid, String dexFileName) { public EventDispatcherImpl(String guid, String dexFileName) {