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

Side by Side 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: Update new sync tests 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sync/test/integration/apps_helper.h" 5 #include "chrome/browser/sync/test/integration/apps_helper.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "chrome/browser/extensions/extension_process_manager.h"
10 #include "chrome/browser/extensions/extension_system.h"
9 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sync/test/integration/sync_app_helper.h" 12 #include "chrome/browser/sync/test/integration/sync_app_helper.h"
11 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" 13 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
12 #include "chrome/browser/sync/test/integration/sync_extension_helper.h" 14 #include "chrome/browser/sync/test/integration/sync_extension_helper.h"
13 #include "chrome/common/extensions/extension.h" 15 #include "chrome/common/extensions/extension.h"
16 #include "content/public/test/test_utils.h"
14 17
15 using sync_datatype_helper::test; 18 using sync_datatype_helper::test;
16 19
17 namespace { 20 namespace {
18 21
19 std::string CreateFakeAppName(int index) { 22 std::string CreateFakeAppName(int index) {
20 return "fakeapp" + base::IntToString(index); 23 return "fakeapp" + base::IntToString(index);
21 } 24 }
22 25
26 void WaitForPlatformAppsToUnloadForProfile(Profile* profile) {
27 // Note this will hang if there are extensions with persistent background
28 // pages loaded.
29 ExtensionProcessManager* pm =
30 extensions::ExtensionSystem::Get(profile)->process_manager();
31 while (!pm->background_hosts().empty()) {
32 content::WindowedNotificationObserver destroyed_observer(
33 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
34 content::NotificationService::AllSources());
35 destroyed_observer.Wait();
36 }
37 }
38
23 } // namespace 39 } // namespace
24 40
25 namespace apps_helper { 41 namespace apps_helper {
26 42
27 bool HasSameAppsAsVerifier(int index) { 43 bool HasSameAppsAsVerifier(int index) {
28 return SyncAppHelper::GetInstance()->AppStatesMatch( 44 return SyncAppHelper::GetInstance()->AppStatesMatch(
29 test()->GetProfile(index), test()->verifier()); 45 test()->GetProfile(index), test()->verifier());
30 } 46 }
31 47
32 bool AllProfilesHaveSameAppsAsVerifier() { 48 bool AllProfilesHaveSameAppsAsVerifier() {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 void CopyNTPOrdinals(Profile* source, Profile* destination, int index) { 135 void CopyNTPOrdinals(Profile* source, Profile* destination, int index) {
120 SetPageOrdinalForApp(destination, index, GetPageOrdinalForApp(source, index)); 136 SetPageOrdinalForApp(destination, index, GetPageOrdinalForApp(source, index));
121 SetAppLaunchOrdinalForApp( 137 SetAppLaunchOrdinalForApp(
122 destination, index, GetAppLaunchOrdinalForApp(source, index)); 138 destination, index, GetAppLaunchOrdinalForApp(source, index));
123 } 139 }
124 140
125 void FixNTPOrdinalCollisions(Profile* profile) { 141 void FixNTPOrdinalCollisions(Profile* profile) {
126 SyncAppHelper::GetInstance()->FixNTPOrdinalCollisions(profile); 142 SyncAppHelper::GetInstance()->FixNTPOrdinalCollisions(profile);
127 } 143 }
128 144
145 void WaitForPlatformAppsToUnload() {
146 // First run any pending tasks to allow any about to load background
147 // pages to load.
148 MessageLoop::current()->RunUntilIdle();
149 for (int i = 0; i < test()->num_clients(); ++i)
150 WaitForPlatformAppsToUnloadForProfile(test()->GetProfile(i));
151 WaitForPlatformAppsToUnloadForProfile(test()->verifier());
152 }
153
129 } // namespace apps_helper 154 } // namespace apps_helper
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698