Address races in UserImageManagerImpl

UserImageManagerImpl uses background threads and delayed tasks to load
images, save images and schedule downloads. There are races in this
implementation so that an earlier operation can complete after a later
operation, clobbering its result. Delayed tasks using base::Unretained()
may cause crashes on shutdown if the unretained object no longer exists.
Some of the races were partially worked around with global state variables
that do not account for the fact that operations for multiple users may be
going on in parallel.

This CL is an almost complete rewrite of the UserImageManagerImpl that
addresses the races and thread safety issues. Pending tasks are
encapsulated by a Job class with at most one Job running per user at a
time.

Migration of old user images is simplified by this CL: There used to be a
delay between user login and migration, postponing the I/O-heavy operation
until after login is complete. However, the implementation was wrong and
migration of PNG images was actually carried out immediately. Only for
users who had selected one of the default images was the migration
delayed, which is unnecessary as it does not involve any file I/O or
transcoding. Since there have been no complaints about the performance
impact of migration during login, this CL removes the delay altogether.

The CL also updates the UserImageManagerImpl browser test, re-enabling the
previously flaky NonJPEGImageFromFile.

BUG=152957,152959,257009
TEST=Updated browser tests; manual tests with chromeos=1 and VM

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235645 0039d316-1c4b-4281-b951-d872f2087c98
Extract chrome.runtime API code from extensions::EventRouter

This is part of the AppShell extensions refactor project.

BUG=316367
TEST=unit_tests, browser_tests
TBR=dmazzoni@chromium.org for trivial fix to tts_extension_loader_chromeos.h

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235646 0039d316-1c4b-4281-b951-d872f2087c98
Add UMA for <webview> APIs: a. ClearData, b. when Permission request is allowed.

BUG=317084
Test=None

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235647 0039d316-1c4b-4281-b951-d872f2087c98
SVN changes up to revision 235646
Delete IBusEngineService.

This patch focuses on the deletion of IBusEngineService keeping the logic as-is.


BUG=275262

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235648 0039d316-1c4b-4281-b951-d872f2087c98
SVN changes up to revision 235648