Convert Google Now's Authentication Manager to use Promises

Also add support for Promises by tracking the "then" and "catch" callbacks.
The Task manager assumes that all callbacks will fire. With promises, this
is no longer the case. Either "then" or "catch" will call back, not always
both.

To account for this, the promise adapter will make sure all callbacks call
back while preserving when 'then' or 'catch' callbacks should execute.

To do this, it wraps all 'then' and 'catch' callbacks that check if
the actual callback should occur. Once a 'then' happens, it updates state
to make 'catch' callbacks a no-op and vice versa. The no-op'ed callbacks
are manually executed to update the task manager state.

BUG=164227
R=rgustafson@chromium.org, skare@chromium.org, vadimt@chromium.org

Review URL: https://codereview.chromium.org/162273002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253683 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed