[reland] Unpack theme data from extensions off of UI thread.

Even on a beefy workstation, resizing theme images takes a long time
(>1s). This causes a painful hiccup in the UI. This patch addresses that
by moving the operation to a helper thread. The actual application of
the theme won't be any faster but it won't block interaction.

As a future area of investigation it might be worth changing the "theme
installed" infobar to show earlier with a message like "installing
theme..." until this operation is completed, since otherwise it can feel
like nothing is happening.

original review: https://codereview.chromium.org/2799003002/
[email protected],[email protected],[email protected],[email protected],[email protected]

Bug: 316070
Change-Id: I4e82bf144136cbaf3a3140ba39388bd8817e3ea9
Reviewed-on: https://chromium-review.googlesource.com/522912
Reviewed-by: Evan Stade <[email protected]>
Commit-Queue: Evan Stade <[email protected]>
Cr-Commit-Position: refs/heads/master@{#476802}
diff --git a/chrome/browser/extensions/extension_service_sync_unittest.cc b/chrome/browser/extensions/extension_service_sync_unittest.cc
index 1b810fa..8d91faa 100644
--- a/chrome/browser/extensions/extension_service_sync_unittest.cc
+++ b/chrome/browser/extensions/extension_service_sync_unittest.cc
@@ -18,6 +18,7 @@
 #include "base/metrics/field_trial.h"
 #include "base/test/mock_entropy_provider.h"
 #include "base/test/scoped_feature_list.h"
+#include "chrome/browser/chrome_notification_types.h"
 #include "chrome/browser/extensions/api/webstore_private/webstore_private_api.h"
 #include "chrome/browser/extensions/component_loader.h"
 #include "chrome/browser/extensions/extension_service.h"
@@ -28,6 +29,8 @@
 #include "chrome/browser/extensions/scripting_permissions_modifier.h"
 #include "chrome/browser/extensions/updater/extension_updater.h"
 #include "chrome/browser/sync/profile_sync_service_factory.h"
+#include "chrome/browser/themes/theme_service.h"
+#include "chrome/browser/themes/theme_service_factory.h"
 #include "chrome/common/chrome_constants.h"
 #include "chrome/common/chrome_switches.h"
 #include "chrome/common/extensions/sync_helper.h"
@@ -1563,6 +1566,11 @@
   // Installing a theme should not result in a sync change (themes are handled
   // separately by ThemeSyncableService).
   InstallCRX(data_dir().AppendASCII("theme.crx"), INSTALL_NEW);
+  content::WindowedNotificationObserver theme_change_observer(
+      chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
+      content::Source<ThemeService>(
+          ThemeServiceFactory::GetForProfile(profile())));
+  theme_change_observer.Wait();
   EXPECT_TRUE(processor->changes().empty());
 }