mac: Fix WebContentsImpl::UpdateWebContentsVisibility calling RWHVMac

We encounter the following stack when destroying the RWHVMac
  RenderWidgetHostViewMac::Show
  WebContentsImpl::WasShown
  WebContentsImpl::UpdateWebContentsVisibility
  ...
  -[NSView removeFromSuperview]
  RenderWidgetHostViewNSViewBridgeLocal::~(dtor)
  RenderWidgetHostViewMac::Destroy

This is problematic, as WebContentsImpl::UpdateWebContentsVisibility
will make a bunch of calls on RenderWidgetHostViewMac that all assume
that we are not mid-tear-down.

To avoid this, make the call to -[NSView removeFromSuperview] be a
delayed callback. That way the call will happen after the RWHVMac has
been entirely destroyed, and UpdateWebContentsVisibility will no longer
have a RWHVMac to call back into.

Bug: 834931
Change-Id: I88412173b005dfdc26026db6b4c12b31e6541e7c
Reviewed-on: https://chromium-review.googlesource.com/1025396
Reviewed-by: Sidney San Martín <sdy@chromium.org>
Commit-Queue: ccameron <ccameron@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553941}
2 files changed