Skip to content

Commit

Permalink
aw: Switch AwContents Handler to PostTask
Browse files Browse the repository at this point in the history
This some tests that relied on task ordering.

Bug: 944437
Change-Id: Idc33c949da3fef08d9a6fc23ae3e4e4e17d1a153
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1534037
Reviewed-by: Alex Clarke <alexclarke@chromium.org>
Reviewed-by: Karolina Soltys <ksolt@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#642929}
  • Loading branch information
Bo Liu authored and Commit Bot committed Mar 21, 2019
1 parent 8d6824c commit e9779f5
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,6 @@ public abstract static class VisualStateCallback {
// when in this state.
private boolean mTemporarilyDetached;

private Handler mHandler;

// True when this AwContents has been destroyed.
// Do not use directly, call isDestroyed() instead.
private boolean mIsDestroyed;
Expand Down Expand Up @@ -893,7 +891,6 @@ public AwContents(AwBrowserContext browserContext, ViewGroup containerView, Cont
mContainerView = containerView;
mContainerView.setWillNotDraw(false);

mHandler = new Handler();
mContext = context;
mAutofillProvider = dependencyFactory.createAutofillProvider(context, mContainerView);
mAppTargetSdkVersion = mContext.getApplicationInfo().targetSdkVersion;
Expand Down Expand Up @@ -1430,7 +1427,7 @@ public void destroy() {
}
mIsNoOperation = true;
mIsDestroyed = true;
mHandler.post(() -> destroyNatives());
PostTask.postTask(UiThreadTaskTraits.DEFAULT, () -> destroyNatives());
}

/**
Expand Down Expand Up @@ -2596,7 +2593,7 @@ public void evaluateJavaScript(String script, final Callback<String> callback) {
// application callback is executed without any native code on the stack. This
// so that any exception thrown by the application callback won't have to be
// propagated through a native call stack.
mHandler.post(() -> callback.onResult(jsonResult));
PostTask.postTask(UiThreadTaskTraits.DEFAULT, () -> callback.onResult(jsonResult));
};
}

Expand Down Expand Up @@ -2839,7 +2836,7 @@ private void postUpdateWebContentsVisibility() {
// To prevent this flip of CVC visibility, post the task to update CVC
// visibility during attach, detach and window visibility change.
mIsUpdateVisibilityTaskPending = true;
mHandler.post(mUpdateVisibilityRunnable);
PostTask.postTask(UiThreadTaskTraits.DEFAULT, mUpdateVisibilityRunnable);
}

private void updateWebContentsVisibility() {
Expand Down Expand Up @@ -3175,7 +3172,7 @@ public void invokeVisualStateCallback(
if (isDestroyedOrNoOperation(NO_WARN)) return;
// Posting avoids invoking the callback inside invoking_composite_
// (see synchronous_compositor_impl.cc and crbug/452530).
mHandler.post(() -> callback.onComplete(requestId));
PostTask.postTask(UiThreadTaskTraits.DEFAULT, () -> callback.onComplete(requestId));
}

// Called as a result of nativeUpdateLastHitTestData.
Expand Down

0 comments on commit e9779f5

Please sign in to comment.