Commit 734de1a6 authored by Sinan Sahin's avatar Sinan Sahin Committed by Chromium LUCI CQ

[Context menu] Clean up debugging statements

Clean-up work after crbug.com/1153706

Bug: 1154731
Change-Id: I27a1003541b1ce577ca28f92f0b8aa5f0705b9c4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2622734Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Sinan Sahin <sinansahin@google.com>
Cr-Commit-Position: refs/heads/master@{#842344}
parent 032f1a2b
......@@ -9,16 +9,12 @@ import android.view.View;
import androidx.annotation.VisibleForTesting;
import org.chromium.base.ApplicationStatus;
import org.chromium.base.Callback;
import org.chromium.base.Log;
import org.chromium.base.TimeUtilsJni;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.task.PostTask;
import org.chromium.base.task.TaskTraits;
import org.chromium.chrome.browser.crash.PureJavaExceptionReporter;
import org.chromium.chrome.browser.performance_hints.PerformanceHintsObserver;
import org.chromium.chrome.browser.share.LensUtils;
import org.chromium.components.embedder_support.contextmenu.ContextMenuParams;
......@@ -37,10 +33,6 @@ import java.util.concurrent.TimeUnit;
public class ContextMenuHelper {
private static Callback<RevampedContextMenuCoordinator> sMenuShownCallbackForTests;
private static final String TAG = "ContextMenuHelper";
private boolean mDismissedFromHere;
private final WebContents mWebContents;
private long mNativeContextMenuHelper;
......@@ -72,8 +64,6 @@ public class ContextMenuHelper {
@CalledByNative
private void destroy() {
if (mCurrentContextMenu != null) {
Log.i(TAG, "Dismissing context menu " + mCurrentContextMenu);
mDismissedFromHere = true;
mCurrentContextMenu.dismiss();
mCurrentContextMenu = null;
}
......@@ -85,11 +75,6 @@ public class ContextMenuHelper {
@CalledByNative
private void setPopulatorFactory(ContextMenuPopulatorFactory populatorFactory) {
if (mCurrentContextMenu != null) {
// TODO(crbug.com/1154731): Clean the debugging statements once we figure out the cause
// of the crash.
Log.i(TAG, "Dismissing context menu " + mCurrentContextMenu);
mDismissedFromHere = true;
mCurrentContextMenu.dismiss();
mCurrentContextMenu = null;
}
......@@ -127,41 +112,7 @@ public class ContextMenuHelper {
mCurrentContextMenuParams = params;
mWindow = windowAndroid;
mCallback = (result) -> {
if (mCurrentPopulator == null) {
Log.i(TAG, "mCurrentPopulator was null when mCallback was called.");
Log.i(TAG, "mCurrentContextMenu is " + mCurrentContextMenu);
Log.i(TAG,
"ContextMenuHelper is " + (mNativeContextMenuHelper == 0 ? "" : "NOT")
+ " destroyed.");
Log.i(TAG,
"Context menu was "
+ (mCurrentContextMenu != null && mCurrentContextMenu.isDismissed()
? ""
: "NOT")
+ " dismissed.");
Log.i(TAG, "Activity: " + mWindow.getActivity().get());
Log.i(TAG,
"Activity state: "
+ ApplicationStatus.getStateForActivity(
mWindow.getActivity().get()));
Throwable throwable = new Throwable(
"This is not a crash. See https://crbug.com/1153706 for details."
+ "\nmCurrentContextMenu is " + mCurrentContextMenu
+ "\nmCurrentPopulator was null when mCallback was called."
+ "\nContextMenuHelper is " + (mNativeContextMenuHelper == 0 ? "" : "NOT")
+ " destroyed."
+ "\nContext menu was "
+ (mCurrentContextMenu != null && mCurrentContextMenu.isDismissed() ? ""
: "NOT")
+ " dismissed."
+ "\nContext menu was " + (mDismissedFromHere ? "" : "NOT")
+ " dismissed by ContextMenuHelper.");
PostTask.postTask(TaskTraits.BEST_EFFORT_MAY_BLOCK,
() -> PureJavaExceptionReporter.reportJavaException(throwable));
return;
}
if (mCurrentPopulator == null) return;
mSelectedItemBeforeDismiss = true;
mCurrentPopulator.onItemSelected(result);
......@@ -177,12 +128,6 @@ public class ContextMenuHelper {
}
};
mOnMenuClosed = () -> {
Log.i(TAG, "mCurrentPopulator was " + mCurrentPopulator + " when the menu closed.");
Log.i(TAG, "mCurrentContextMenu was " + mCurrentContextMenu + " when the menu closed.");
Log.i(TAG,
"Activity: " + mWindow.getActivity().get() + ", activity state: "
+ ApplicationStatus.getStateForActivity(mWindow.getActivity().get()));
recordTimeToTakeActionHistogram(mSelectedItemBeforeDismiss);
mCurrentContextMenu = null;
if (mCurrentNativeDelegate != null) {
......@@ -221,9 +166,6 @@ public class ContextMenuHelper {
mCurrentContextMenu = menuCoordinator;
mChipDelegate = mCurrentPopulator.getChipDelegate();
Log.i(TAG, "Created mCurrentContextMenu: " + mCurrentContextMenu);
Log.i(TAG, "Activity was " + mWindow.getActivity().get() + " when the menu was created.");
// TODO(crbug/1158604): Remove leftover Lens dependencies.
LensUtils.startLensConnectionIfNecessary(mIsIncognito);
if (mChipDelegate != null) {
......
......@@ -43,10 +43,4 @@ public interface ContextMenuUi {
* Dismiss the context menu.
*/
void dismiss();
/**
* @return Whether the menu is dismissed. It may be dismissed but still be visible, e.g. hiding
* with an animation.
*/
boolean isDismissed();
}
......@@ -19,9 +19,7 @@ import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import org.chromium.base.ApplicationStatus;
import org.chromium.base.Callback;
import org.chromium.base.Log;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.performance_hints.PerformanceHintsObserver;
import org.chromium.chrome.browser.performance_hints.PerformanceHintsObserver.PerformanceClass;
......@@ -58,7 +56,6 @@ public class RevampedContextMenuCoordinator implements ContextMenuUi {
int CONTEXT_MENU_ITEM_WITH_ICON_BUTTON = 3;
}
private static final String TAG = "CMenuCoordinator";
private static final int INVALID_ITEM_ID = -1;
private WebContents mWebContents;
......@@ -71,7 +68,6 @@ public class RevampedContextMenuCoordinator implements ContextMenuUi {
private ContextMenuDialog mDialog;
private Runnable mOnMenuClosed;
private ContextMenuNativeDelegate mNativeDelegate;
private boolean mIsDismissed;
/**
* Constructor that also sets the content offset.
......@@ -100,11 +96,6 @@ public class RevampedContextMenuCoordinator implements ContextMenuUi {
dismissDialog();
}
@Override
public boolean isDismissed() {
return mIsDismissed;
}
// Shows the menu with chip.
void displayMenuWithChip(final WindowAndroid window, WebContents webContents,
ContextMenuParams params, List<Pair<Integer, ModelList>> items,
......@@ -229,10 +220,6 @@ public class RevampedContextMenuCoordinator implements ContextMenuUi {
// See https://crbug.com/990987
if (activity.isFinishing() || activity.isDestroyed()) return;
Log.i(TAG,
"#clickItem called for menu " + this + ", activity: " + activity
+ ", activity state: " + ApplicationStatus.getStateForActivity(activity));
onItemClicked.onResult((int) id);
dismissDialog();
}
......@@ -291,7 +278,6 @@ public class RevampedContextMenuCoordinator implements ContextMenuUi {
}
private void dismissDialog() {
mIsDismissed = true;
if (mWebContentsObserver != null) {
mWebContentsObserver.destroy();
}
......
......@@ -9,7 +9,6 @@ import android.app.Dialog;
import org.chromium.base.ActivityState;
import org.chromium.base.ApplicationStatus;
import org.chromium.base.Log;
/**
* Dialog subclass that ensures that dismiss() is called, even if the dialog is implicitly dismissed
......@@ -19,7 +18,6 @@ import org.chromium.base.Log;
*/
public class AlwaysDismissedDialog
extends Dialog implements ApplicationStatus.ActivityStateListener {
private static final String TAG = "AlwaysDisDialog";
public AlwaysDismissedDialog(Activity ownerActivity, int theme) {
super(ownerActivity, theme);
ApplicationStatus.registerStateListenerForActivity(this, ownerActivity);
......@@ -35,10 +33,6 @@ public class AlwaysDismissedDialog
@Override
public void onActivityStateChange(Activity activity, int newState) {
if (newState == ActivityState.DESTROYED) {
Thread.dumpStack();
Log.i(TAG, "Activity " + activity + " is destroyed. Dismissing dialog " + this);
dismiss();
}
if (newState == ActivityState.DESTROYED) dismiss();
}
}
......@@ -20,7 +20,6 @@ import android.view.animation.ScaleAnimation;
import android.widget.FrameLayout;
import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
import org.chromium.components.browser_ui.widget.animation.Interpolators;
import org.chromium.ui.widget.AnchoredPopupWindow;
import org.chromium.ui.widget.RectProvider;
......@@ -32,7 +31,6 @@ import org.chromium.ui.widget.RectProvider;
public class ContextMenuDialog extends AlwaysDismissedDialog {
public static final int NO_CUSTOM_MARGIN = -1;
private static final String TAG = "ContextMenuDialog";
private static final long ENTER_ANIMATION_DURATION_MS = 250;
// Exit animation duration should be set to 60% of the enter animation duration.
private static final long EXIT_ANIMATION_DURATION_MS = 150;
......@@ -159,9 +157,6 @@ public class ContextMenuDialog extends AlwaysDismissedDialog {
return;
}
Thread.dumpStack();
Log.i(TAG, "Dialog " + this + " is being dismissed.");
int[] contextMenuFinalLocationPx = new int[2];
mContentView.getLocationOnScreen(contextMenuFinalLocationPx);
// Recalculate mContextMenuDestinationY because the context menu's final location may not be
......@@ -180,7 +175,6 @@ public class ContextMenuDialog extends AlwaysDismissedDialog {
@Override
public void onAnimationEnd(Animation animation) {
Log.i(TAG, "Dismiss animation just ended for " + this);
ContextMenuDialog.super.dismiss();
}
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment