Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7260)

Unified Diff: chrome/browser/sync/test/integration/apps_helper.cc

Issue 11117011: Keep browser process alive while there are platform apps with background pages running. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: And another test Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/test/integration/apps_helper.cc
diff --git a/chrome/browser/sync/test/integration/apps_helper.cc b/chrome/browser/sync/test/integration/apps_helper.cc
index fe9a37977afb1f9f34099924ee0d1042122c5311..77c83c9f6b419cc7911d47e288609899d6f43393 100644
--- a/chrome/browser/sync/test/integration/apps_helper.cc
+++ b/chrome/browser/sync/test/integration/apps_helper.cc
@@ -6,11 +6,14 @@
#include "base/logging.h"
#include "base/string_number_conversions.h"
+#include "chrome/browser/extensions/extension_process_manager.h"
+#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/test/integration/sync_app_helper.h"
#include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
#include "chrome/browser/sync/test/integration/sync_extension_helper.h"
#include "chrome/common/extensions/extension.h"
+#include "content/public/test/test_utils.h"
using sync_datatype_helper::test;
@@ -20,6 +23,19 @@ std::string CreateFakeAppName(int index) {
return "fakeapp" + base::IntToString(index);
}
+void WaitForPlatformAppsToUnloadForProfile(Profile* profile) {
+ // Note this will hang if there are extensions with persistent background
+ // pages loaded.
+ ExtensionProcessManager* pm =
+ extensions::ExtensionSystem::Get(profile)->process_manager();
+ while (!pm->background_hosts().empty()) {
+ content::WindowedNotificationObserver destroyed_observer(
+ chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
+ content::NotificationService::AllSources());
+ destroyed_observer.Wait();
+ }
+}
+
} // namespace
namespace apps_helper {
@@ -126,4 +142,13 @@ void FixNTPOrdinalCollisions(Profile* profile) {
SyncAppHelper::GetInstance()->FixNTPOrdinalCollisions(profile);
}
+void WaitForPlatformAppsToUnload() {
+ // First run any pending tasks to allow any about to load background
+ // pages to load.
+ MessageLoop::current()->RunUntilIdle();
+ for (int i = 0; i < test()->num_clients(); ++i)
+ WaitForPlatformAppsToUnloadForProfile(test()->GetProfile(i));
+ WaitForPlatformAppsToUnloadForProfile(test()->verifier());
+}
+
} // namespace apps_helper

Powered by Google App Engine
This is Rietveld 408576698