OLD | NEW |
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" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 bool LoadExtensionFromPath(const FilePath& path) { | 196 bool LoadExtensionFromPath(const FilePath& path) { |
197 ExtensionService* service = browser()->profile()->GetExtensionService(); | 197 ExtensionService* service = browser()->profile()->GetExtensionService(); |
198 size_t num_before = service->extensions()->size(); | 198 size_t num_before = service->extensions()->size(); |
199 { | 199 { |
200 content::NotificationRegistrar registrar; | 200 content::NotificationRegistrar registrar; |
201 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 201 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
202 content::NotificationService::AllSources()); | 202 content::NotificationService::AllSources()); |
203 base::CancelableClosure timeout( | 203 base::CancelableClosure timeout( |
204 base::Bind(&TimeoutCallback, "Extension load timed out.")); | 204 base::Bind(&TimeoutCallback, "Extension load timed out.")); |
205 MessageLoop::current()->PostDelayedTask( | 205 MessageLoop::current()->PostDelayedTask( |
206 FROM_HERE, timeout.callback(), base::TimeDelta::FromSeconds(4)); | 206 FROM_HERE, timeout.callback(), 4 * 1000); |
207 extensions::UnpackedInstaller::Create(service)->Load(path); | 207 extensions::UnpackedInstaller::Create(service)->Load(path); |
208 ui_test_utils::RunMessageLoop(); | 208 ui_test_utils::RunMessageLoop(); |
209 timeout.Cancel(); | 209 timeout.Cancel(); |
210 } | 210 } |
211 size_t num_after = service->extensions()->size(); | 211 size_t num_after = service->extensions()->size(); |
212 if (num_after != (num_before + 1)) | 212 if (num_after != (num_before + 1)) |
213 return false; | 213 return false; |
214 | 214 |
215 return WaitForExtensionHostsToLoad(); | 215 return WaitForExtensionHostsToLoad(); |
216 } | 216 } |
217 | 217 |
218 bool WaitForExtensionHostsToLoad() { | 218 bool WaitForExtensionHostsToLoad() { |
219 // Wait for all the extension hosts that exist to finish loading. | 219 // Wait for all the extension hosts that exist to finish loading. |
220 // NOTE: This assumes that the extension host list is not changing while | 220 // NOTE: This assumes that the extension host list is not changing while |
221 // this method is running. | 221 // this method is running. |
222 | 222 |
223 content::NotificationRegistrar registrar; | 223 content::NotificationRegistrar registrar; |
224 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, | 224 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, |
225 content::NotificationService::AllSources()); | 225 content::NotificationService::AllSources()); |
226 base::CancelableClosure timeout( | 226 base::CancelableClosure timeout( |
227 base::Bind(&TimeoutCallback, "Extension host load timed out.")); | 227 base::Bind(&TimeoutCallback, "Extension host load timed out.")); |
228 MessageLoop::current()->PostDelayedTask( | 228 MessageLoop::current()->PostDelayedTask( |
229 FROM_HERE, timeout.callback(), base::TimeDelta::FromSeconds(4)); | 229 FROM_HERE, timeout.callback(), 4 * 1000); |
230 | 230 |
231 ExtensionProcessManager* manager = | 231 ExtensionProcessManager* manager = |
232 browser()->profile()->GetExtensionProcessManager(); | 232 browser()->profile()->GetExtensionProcessManager(); |
233 for (ExtensionProcessManager::const_iterator iter = manager->begin(); | 233 for (ExtensionProcessManager::const_iterator iter = manager->begin(); |
234 iter != manager->end();) { | 234 iter != manager->end();) { |
235 if ((*iter)->did_stop_loading()) | 235 if ((*iter)->did_stop_loading()) |
236 ++iter; | 236 ++iter; |
237 else | 237 else |
238 ui_test_utils::RunMessageLoop(); | 238 ui_test_utils::RunMessageLoop(); |
239 } | 239 } |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 | 576 |
577 // Reload page to restart the worker. | 577 // Reload page to restart the worker. |
578 ui_test_utils::NavigateToURL(browser(), url); | 578 ui_test_utils::NavigateToURL(browser(), url); |
579 | 579 |
580 // Wait until worker script is paused on the debugger statement. | 580 // Wait until worker script is paused on the debugger statement. |
581 RunTestFunction(window_, "testPauseInSharedWorkerInitialization"); | 581 RunTestFunction(window_, "testPauseInSharedWorkerInitialization"); |
582 CloseDevToolsWindow(); | 582 CloseDevToolsWindow(); |
583 } | 583 } |
584 | 584 |
585 } // namespace | 585 } // namespace |
OLD | NEW |