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

Side by Side Diff: chrome/browser/debugger/devtools_sanity_unittest.cc

Issue 10113005: Remove EPM:all_hosts_ and use all_extension_views_ instead. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Comments addressed Created 8 years, 8 months 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
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/cancelable_callback.h" 6 #include "base/cancelable_callback.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
12 #include "base/test/test_timeouts.h" 12 #include "base/test/test_timeouts.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "chrome/browser/debugger/devtools_window.h" 14 #include "chrome/browser/debugger/devtools_window.h"
15 #include "chrome/browser/extensions/extension_host.h"
16 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/extensions/unpacked_installer.h" 16 #include "chrome/browser/extensions/unpacked_installer.h"
18 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
21 #include "chrome/common/chrome_notification_types.h" 20 #include "chrome/common/chrome_notification_types.h"
22 #include "chrome/common/chrome_paths.h" 21 #include "chrome/common/chrome_paths.h"
23 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
24 #include "chrome/test/base/in_process_browser_test.h" 23 #include "chrome/test/base/in_process_browser_test.h"
25 #include "chrome/test/base/ui_test_utils.h" 24 #include "chrome/test/base/ui_test_utils.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 MessageLoop::current()->PostDelayedTask( 205 MessageLoop::current()->PostDelayedTask(
207 FROM_HERE, timeout.callback(), base::TimeDelta::FromSeconds(4)); 206 FROM_HERE, timeout.callback(), base::TimeDelta::FromSeconds(4));
208 extensions::UnpackedInstaller::Create(service)->Load(path); 207 extensions::UnpackedInstaller::Create(service)->Load(path);
209 ui_test_utils::RunMessageLoop(); 208 ui_test_utils::RunMessageLoop();
210 timeout.Cancel(); 209 timeout.Cancel();
211 } 210 }
212 size_t num_after = service->extensions()->size(); 211 size_t num_after = service->extensions()->size();
213 if (num_after != (num_before + 1)) 212 if (num_after != (num_before + 1))
214 return false; 213 return false;
215 214
216 return WaitForExtensionHostsToLoad(); 215 return WaitForExtensionViewsToLoad();
217 } 216 }
218 217
219 bool WaitForExtensionHostsToLoad() { 218 bool WaitForExtensionViewsToLoad() {
220 // Wait for all the extension hosts that exist to finish loading. 219 // Wait for all the extension render views that exist to finish loading.
221 // NOTE: This assumes that the extension host list is not changing while 220 // NOTE: This assumes that the extension views list is not changing while
222 // this method is running. 221 // this method is running.
223 222
224 content::NotificationRegistrar registrar; 223 content::NotificationRegistrar registrar;
225 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, 224 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING,
226 content::NotificationService::AllSources()); 225 content::NotificationService::AllSources());
227 base::CancelableClosure timeout( 226 base::CancelableClosure timeout(
228 base::Bind(&TimeoutCallback, "Extension host load timed out.")); 227 base::Bind(&TimeoutCallback, "Extension host load timed out."));
229 MessageLoop::current()->PostDelayedTask( 228 MessageLoop::current()->PostDelayedTask(
230 FROM_HERE, timeout.callback(), base::TimeDelta::FromSeconds(4)); 229 FROM_HERE, timeout.callback(), base::TimeDelta::FromSeconds(4));
231 230
232 ExtensionProcessManager* manager = 231 ExtensionProcessManager* manager =
233 browser()->profile()->GetExtensionProcessManager(); 232 browser()->profile()->GetExtensionProcessManager();
234 for (ExtensionProcessManager::const_iterator iter = manager->begin(); 233 ExtensionProcessManager::ViewSet all_views = manager->GetAllViews();
235 iter != manager->end();) { 234 for (ExtensionProcessManager::ViewSet::const_iterator iter =
236 if ((*iter)->did_stop_loading()) 235 all_views.begin();
236 iter != all_views.end();) {
237 if (!(*iter)->IsLoading())
237 ++iter; 238 ++iter;
238 else 239 else
239 ui_test_utils::RunMessageLoop(); 240 ui_test_utils::RunMessageLoop();
240 } 241 }
241 242
242 timeout.Cancel(); 243 timeout.Cancel();
243 return true; 244 return true;
244 } 245 }
245 246
246 void Observe(int type, 247 void Observe(int type,
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 content::CONSOLE_MESSAGE_LEVEL_LOG, 608 content::CONSOLE_MESSAGE_LEVEL_LOG,
608 "log"); 609 "log");
609 devtools_manager->AddMessageToConsole(agent_host, 610 devtools_manager->AddMessageToConsole(agent_host,
610 content::CONSOLE_MESSAGE_LEVEL_ERROR, 611 content::CONSOLE_MESSAGE_LEVEL_ERROR,
611 "error"); 612 "error");
612 RunTestFunction(window_, "checkLogAndErrorMessages"); 613 RunTestFunction(window_, "checkLogAndErrorMessages");
613 CloseDevToolsWindow(); 614 CloseDevToolsWindow();
614 } 615 }
615 616
616 } // namespace 617 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698