OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 181 } |
182 | 182 |
183 private: | 183 private: |
184 bool LoadExtensionFromPath(const FilePath& path) { | 184 bool LoadExtensionFromPath(const FilePath& path) { |
185 ExtensionService* service = browser()->profile()->GetExtensionService(); | 185 ExtensionService* service = browser()->profile()->GetExtensionService(); |
186 size_t num_before = service->extensions()->size(); | 186 size_t num_before = service->extensions()->size(); |
187 { | 187 { |
188 content::NotificationRegistrar registrar; | 188 content::NotificationRegistrar registrar; |
189 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 189 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
190 content::NotificationService::AllSources()); | 190 content::NotificationService::AllSources()); |
191 base::CancelableCallback timeout( | 191 base::CancelableClosure timeout( |
192 base::Bind(&TimeoutCallback, "Extension load timed out.")); | 192 base::Bind(&TimeoutCallback, "Extension load timed out.")); |
193 MessageLoop::current()->PostDelayedTask( | 193 MessageLoop::current()->PostDelayedTask( |
194 FROM_HERE, timeout.callback(), 4 * 1000); | 194 FROM_HERE, timeout.callback(), 4 * 1000); |
195 extensions::UnpackedInstaller::Create(service)->Load(path); | 195 extensions::UnpackedInstaller::Create(service)->Load(path); |
196 ui_test_utils::RunMessageLoop(); | 196 ui_test_utils::RunMessageLoop(); |
197 timeout.Cancel(); | 197 timeout.Cancel(); |
198 } | 198 } |
199 size_t num_after = service->extensions()->size(); | 199 size_t num_after = service->extensions()->size(); |
200 if (num_after != (num_before + 1)) | 200 if (num_after != (num_before + 1)) |
201 return false; | 201 return false; |
202 | 202 |
203 return WaitForExtensionHostsToLoad(); | 203 return WaitForExtensionHostsToLoad(); |
204 } | 204 } |
205 | 205 |
206 bool WaitForExtensionHostsToLoad() { | 206 bool WaitForExtensionHostsToLoad() { |
207 // Wait for all the extension hosts that exist to finish loading. | 207 // Wait for all the extension hosts that exist to finish loading. |
208 // NOTE: This assumes that the extension host list is not changing while | 208 // NOTE: This assumes that the extension host list is not changing while |
209 // this method is running. | 209 // this method is running. |
210 | 210 |
211 content::NotificationRegistrar registrar; | 211 content::NotificationRegistrar registrar; |
212 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, | 212 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, |
213 content::NotificationService::AllSources()); | 213 content::NotificationService::AllSources()); |
214 base::CancelableCallback timeout( | 214 base::CancelableClosure timeout( |
215 base::Bind(&TimeoutCallback, "Extension host load timed out.")); | 215 base::Bind(&TimeoutCallback, "Extension host load timed out.")); |
216 MessageLoop::current()->PostDelayedTask( | 216 MessageLoop::current()->PostDelayedTask( |
217 FROM_HERE, timeout.callback(), 4 * 1000); | 217 FROM_HERE, timeout.callback(), 4 * 1000); |
218 | 218 |
219 ExtensionProcessManager* manager = | 219 ExtensionProcessManager* manager = |
220 browser()->profile()->GetExtensionProcessManager(); | 220 browser()->profile()->GetExtensionProcessManager(); |
221 for (ExtensionProcessManager::const_iterator iter = manager->begin(); | 221 for (ExtensionProcessManager::const_iterator iter = manager->begin(); |
222 iter != manager->end();) { | 222 iter != manager->end();) { |
223 if ((*iter)->did_stop_loading()) | 223 if ((*iter)->did_stop_loading()) |
224 ++iter; | 224 ++iter; |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 | 550 |
551 // Reload page to restart the worker. | 551 // Reload page to restart the worker. |
552 ui_test_utils::NavigateToURL(browser(), url); | 552 ui_test_utils::NavigateToURL(browser(), url); |
553 | 553 |
554 // Wait until worker script is paused on the debugger statement. | 554 // Wait until worker script is paused on the debugger statement. |
555 RunTestFuntion(window_, "testPauseInSharedWorkerInitialization"); | 555 RunTestFuntion(window_, "testPauseInSharedWorkerInitialization"); |
556 CloseDevToolsWindow(); | 556 CloseDevToolsWindow(); |
557 } | 557 } |
558 | 558 |
559 } // namespace | 559 } // namespace |
OLD | NEW |