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

Side by Side Diff: chrome/browser/devtools/devtools_sanity_browsertest.cc

Issue 425303002: Move extension notifications to extensions/browser/notification_types.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (extension-notifications) rebase Created 6 years, 4 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 | 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 "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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "content/public/browser/devtools_manager.h" 42 #include "content/public/browser/devtools_manager.h"
43 #include "content/public/browser/notification_registrar.h" 43 #include "content/public/browser/notification_registrar.h"
44 #include "content/public/browser/notification_service.h" 44 #include "content/public/browser/notification_service.h"
45 #include "content/public/browser/render_view_host.h" 45 #include "content/public/browser/render_view_host.h"
46 #include "content/public/browser/web_contents.h" 46 #include "content/public/browser/web_contents.h"
47 #include "content/public/browser/worker_service.h" 47 #include "content/public/browser/worker_service.h"
48 #include "content/public/browser/worker_service_observer.h" 48 #include "content/public/browser/worker_service_observer.h"
49 #include "content/public/common/content_switches.h" 49 #include "content/public/common/content_switches.h"
50 #include "content/public/test/browser_test_utils.h" 50 #include "content/public/test/browser_test_utils.h"
51 #include "extensions/browser/extension_system.h" 51 #include "extensions/browser/extension_system.h"
52 #include "extensions/browser/notification_types.h"
52 #include "extensions/common/switches.h" 53 #include "extensions/common/switches.h"
53 #include "net/socket/tcp_listen_socket.h" 54 #include "net/socket/tcp_listen_socket.h"
54 #include "net/test/spawned_test_server/spawned_test_server.h" 55 #include "net/test/spawned_test_server/spawned_test_server.h"
55 56
56 using content::BrowserThread; 57 using content::BrowserThread;
57 using content::DevToolsManager; 58 using content::DevToolsManager;
58 using content::DevToolsAgentHost; 59 using content::DevToolsAgentHost;
59 using content::NavigationController; 60 using content::NavigationController;
60 using content::RenderViewHost; 61 using content::RenderViewHost;
61 using content::WebContents; 62 using content::WebContents;
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } 316 }
316 317
317 private: 318 private:
318 bool LoadExtensionFromPath(const base::FilePath& path) { 319 bool LoadExtensionFromPath(const base::FilePath& path) {
319 ExtensionService* service = extensions::ExtensionSystem::Get( 320 ExtensionService* service = extensions::ExtensionSystem::Get(
320 browser()->profile())->extension_service(); 321 browser()->profile())->extension_service();
321 size_t num_before = service->extensions()->size(); 322 size_t num_before = service->extensions()->size();
322 { 323 {
323 content::NotificationRegistrar registrar; 324 content::NotificationRegistrar registrar;
324 registrar.Add(this, 325 registrar.Add(this,
325 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, 326 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
326 content::NotificationService::AllSources()); 327 content::NotificationService::AllSources());
327 base::CancelableClosure timeout( 328 base::CancelableClosure timeout(
328 base::Bind(&TimeoutCallback, "Extension load timed out.")); 329 base::Bind(&TimeoutCallback, "Extension load timed out."));
329 base::MessageLoop::current()->PostDelayedTask( 330 base::MessageLoop::current()->PostDelayedTask(
330 FROM_HERE, timeout.callback(), TestTimeouts::action_timeout()); 331 FROM_HERE, timeout.callback(), TestTimeouts::action_timeout());
331 extensions::UnpackedInstaller::Create(service)->Load(path); 332 extensions::UnpackedInstaller::Create(service)->Load(path);
332 content::RunMessageLoop(); 333 content::RunMessageLoop();
333 timeout.Cancel(); 334 timeout.Cancel();
334 } 335 }
335 size_t num_after = service->extensions()->size(); 336 size_t num_after = service->extensions()->size();
336 if (num_after != (num_before + 1)) 337 if (num_after != (num_before + 1))
337 return false; 338 return false;
338 339
339 return WaitForExtensionViewsToLoad(); 340 return WaitForExtensionViewsToLoad();
340 } 341 }
341 342
342 bool WaitForExtensionViewsToLoad() { 343 bool WaitForExtensionViewsToLoad() {
343 // Wait for all the extension render views that exist to finish loading. 344 // Wait for all the extension render views that exist to finish loading.
344 // NOTE: This assumes that the extension views list is not changing while 345 // NOTE: This assumes that the extension views list is not changing while
345 // this method is running. 346 // this method is running.
346 347
347 content::NotificationRegistrar registrar; 348 content::NotificationRegistrar registrar;
348 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, 349 registrar.Add(this,
350 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING,
349 content::NotificationService::AllSources()); 351 content::NotificationService::AllSources());
350 base::CancelableClosure timeout( 352 base::CancelableClosure timeout(
351 base::Bind(&TimeoutCallback, "Extension host load timed out.")); 353 base::Bind(&TimeoutCallback, "Extension host load timed out."));
352 base::MessageLoop::current()->PostDelayedTask( 354 base::MessageLoop::current()->PostDelayedTask(
353 FROM_HERE, timeout.callback(), TestTimeouts::action_timeout()); 355 FROM_HERE, timeout.callback(), TestTimeouts::action_timeout());
354 356
355 extensions::ProcessManager* manager = 357 extensions::ProcessManager* manager =
356 extensions::ExtensionSystem::Get(browser()->profile())-> 358 extensions::ExtensionSystem::Get(browser()->profile())->
357 process_manager(); 359 process_manager();
358 extensions::ProcessManager::ViewSet all_views = manager->GetAllViews(); 360 extensions::ProcessManager::ViewSet all_views = manager->GetAllViews();
359 for (extensions::ProcessManager::ViewSet::const_iterator iter = 361 for (extensions::ProcessManager::ViewSet::const_iterator iter =
360 all_views.begin(); 362 all_views.begin();
361 iter != all_views.end();) { 363 iter != all_views.end();) {
362 if (!(*iter)->IsLoading()) 364 if (!(*iter)->IsLoading())
363 ++iter; 365 ++iter;
364 else 366 else
365 content::RunMessageLoop(); 367 content::RunMessageLoop();
366 } 368 }
367 369
368 timeout.Cancel(); 370 timeout.Cancel();
369 return true; 371 return true;
370 } 372 }
371 373
372 virtual void Observe(int type, 374 virtual void Observe(int type,
373 const content::NotificationSource& source, 375 const content::NotificationSource& source,
374 const content::NotificationDetails& details) OVERRIDE { 376 const content::NotificationDetails& details) OVERRIDE {
375 switch (type) { 377 switch (type) {
376 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: 378 case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED:
377 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: 379 case extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING:
378 base::MessageLoopForUI::current()->Quit(); 380 base::MessageLoopForUI::current()->Quit();
379 break; 381 break;
380 default: 382 default:
381 NOTREACHED(); 383 NOTREACHED();
382 break; 384 break;
383 } 385 }
384 } 386 }
385 387
386 base::FilePath test_extensions_dir_; 388 base::FilePath test_extensions_dir_;
387 }; 389 };
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 927
926 IN_PROC_BROWSER_TEST_F(RemoteDebuggingTest, RemoteDebugger) { 928 IN_PROC_BROWSER_TEST_F(RemoteDebuggingTest, RemoteDebugger) {
927 #if defined(OS_WIN) && defined(USE_ASH) 929 #if defined(OS_WIN) && defined(USE_ASH)
928 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 930 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
929 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 931 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
930 return; 932 return;
931 #endif 933 #endif
932 934
933 ASSERT_TRUE(RunExtensionTest("target_list")) << message_; 935 ASSERT_TRUE(RunExtensionTest("target_list")) << message_;
934 } 936 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698