Fix race condition in sendSnapshotToPage_.

There are two asyncronous events that occur when a snapshot is
requested: the child window is opened, and the buffers are collected.
They can complete in either order, but currently if the page manages to
open and do the postMessage before the data is available, then we never
find out about the child.

This is fixed by introducing a Result for the child channel.
Add missing require.
Fix race condition in connectToParentWindow.

Previously there was time for a snapshot to come in after the "hello"
was sent but before the onmessage listener was attached. By moving the
channel create into the setImmediate callback we can avoid this, and
also unify code between the cases.
Merge pull request #515 from google/rsturgell

Fix race condition in sendSnapshotToPage_.