[iOS] Create safe WebKit completion block utility functions.

Completion blocks provided by WebKit to the WKUIDelegate contain a
helper object that will throw an exception if the block is deallocated
before being executed.  This CL adds helper functions that add a
similar mechanism that ensures that these blocks are executed before
deallocation.

Internally, these functions use wrapper objects that call the WebKit
blocks upon deallocation.  These wrapper objects are not exposed
externally in an attempt to ensure that their lifetime is tightly
coupled with the lifetime of the block.  Exposing the wrappers
publicly allows for the possibility of mistakenly extending the
lifetime of the WebKit blocks due to being erroneously retained.

Once the C++14 move semantics for lambda introducers are allowed by
the style guide, we can instead construct these call checker objects
using C++ objects whose destruction can be guaranteed to occur at a
certain time.

Bug: 915119
Change-Id: Ifeac4359f5436ede281def418eb81b1620ba2198
Reviewed-on: https://chromium-review.googlesource.com/c/1392356
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#621424}
5 files changed