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

Side by Side Diff: chrome/browser/extensions/extension_crash_recovery_browsertest.cc

Issue 62713003: Move ExtensionProcessManager to src/extensions, part 4 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 1 month 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/browser_process.h" 5 #include "chrome/browser/browser_process.h"
6 #include "chrome/browser/extensions/extension_browsertest.h" 6 #include "chrome/browser/extensions/extension_browsertest.h"
7 #include "chrome/browser/extensions/extension_host.h" 7 #include "chrome/browser/extensions/extension_host.h"
8 #include "chrome/browser/extensions/extension_process_manager.h"
9 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_system.h" 9 #include "chrome/browser/extensions/extension_system.h"
11 #include "chrome/browser/notifications/balloon.h" 10 #include "chrome/browser/notifications/balloon.h"
12 #include "chrome/browser/notifications/balloon_collection.h" 11 #include "chrome/browser/notifications/balloon_collection.h"
13 #include "chrome/browser/notifications/balloon_host.h" 12 #include "chrome/browser/notifications/balloon_host.h"
14 #include "chrome/browser/notifications/balloon_notification_ui_manager.h" 13 #include "chrome/browser/notifications/balloon_notification_ui_manager.h"
15 #include "chrome/browser/notifications/notification.h" 14 #include "chrome/browser/notifications/notification.h"
16 #include "chrome/browser/notifications/notification_delegate.h" 15 #include "chrome/browser/notifications/notification_delegate.h"
17 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/browser_commands.h" 18 #include "chrome/browser/ui/browser_commands.h"
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" 19 #include "chrome/browser/ui/tabs/tab_strip_model.h"
21 #include "chrome/test/base/ui_test_utils.h" 20 #include "chrome/test/base/ui_test_utils.h"
22 #include "content/public/browser/navigation_controller.h" 21 #include "content/public/browser/navigation_controller.h"
23 #include "content/public/browser/render_process_host.h" 22 #include "content/public/browser/render_process_host.h"
24 #include "content/public/browser/render_view_host.h" 23 #include "content/public/browser/render_view_host.h"
25 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
26 #include "content/public/common/result_codes.h" 25 #include "content/public/common/result_codes.h"
26 #include "extensions/browser/process_manager.h"
27 #include "ui/message_center/message_center.h" 27 #include "ui/message_center/message_center.h"
28 #include "ui/message_center/message_center_switches.h" 28 #include "ui/message_center/message_center_switches.h"
29 #include "ui/message_center/message_center_util.h" 29 #include "ui/message_center/message_center_util.h"
30 #include "ui/message_center/notification_list.h" 30 #include "ui/message_center/notification_list.h"
31 31
32 using content::NavigationController; 32 using content::NavigationController;
33 using content::WebContents; 33 using content::WebContents;
34 using extensions::Extension; 34 using extensions::Extension;
35 35
36 // Tests are timing out waiting for extension to crash. 36 // Tests are timing out waiting for extension to crash.
37 // http://crbug.com/174705 37 // http://crbug.com/174705
38 #if defined(OS_MACOSX) || defined(USE_AURA) || defined(OS_LINUX) 38 #if defined(OS_MACOSX) || defined(USE_AURA) || defined(OS_LINUX)
39 #define MAYBE_ExtensionCrashRecoveryTest DISABLED_ExtensionCrashRecoveryTest 39 #define MAYBE_ExtensionCrashRecoveryTest DISABLED_ExtensionCrashRecoveryTest
40 #else 40 #else
41 #define MAYBE_ExtensionCrashRecoveryTest ExtensionCrashRecoveryTest 41 #define MAYBE_ExtensionCrashRecoveryTest ExtensionCrashRecoveryTest
42 #endif // defined(OS_MACOSX) || defined(USE_AURA) || defined(OS_LINUX) 42 #endif // defined(OS_MACOSX) || defined(USE_AURA) || defined(OS_LINUX)
43 43
44 class ExtensionCrashRecoveryTestBase : public ExtensionBrowserTest { 44 class ExtensionCrashRecoveryTestBase : public ExtensionBrowserTest {
45 protected: 45 protected:
46 virtual void AcceptNotification(size_t index) = 0; 46 virtual void AcceptNotification(size_t index) = 0;
47 virtual void CancelNotification(size_t index) = 0; 47 virtual void CancelNotification(size_t index) = 0;
48 virtual size_t CountBalloons() = 0; 48 virtual size_t CountBalloons() = 0;
49 49
50 ExtensionService* GetExtensionService() { 50 ExtensionService* GetExtensionService() {
51 return browser()->profile()->GetExtensionService(); 51 return browser()->profile()->GetExtensionService();
52 } 52 }
53 53
54 ExtensionProcessManager* GetExtensionProcessManager() { 54 extensions::ProcessManager* GetProcessManager() {
55 return extensions::ExtensionSystem::Get(browser()->profile())-> 55 return extensions::ExtensionSystem::Get(browser()->profile())->
56 process_manager(); 56 process_manager();
57 } 57 }
58 58
59 void CrashExtension(std::string extension_id) { 59 void CrashExtension(std::string extension_id) {
60 const Extension* extension = 60 const Extension* extension =
61 GetExtensionService()->GetExtensionById(extension_id, false); 61 GetExtensionService()->GetExtensionById(extension_id, false);
62 ASSERT_TRUE(extension); 62 ASSERT_TRUE(extension);
63 extensions::ExtensionHost* extension_host = GetExtensionProcessManager()-> 63 extensions::ExtensionHost* extension_host = GetProcessManager()->
64 GetBackgroundHostForExtension(extension_id); 64 GetBackgroundHostForExtension(extension_id);
65 ASSERT_TRUE(extension_host); 65 ASSERT_TRUE(extension_host);
66 66
67 base::KillProcess(extension_host->render_process_host()->GetHandle(), 67 base::KillProcess(extension_host->render_process_host()->GetHandle(),
68 content::RESULT_CODE_KILLED, false); 68 content::RESULT_CODE_KILLED, false);
69 ASSERT_TRUE(WaitForExtensionCrash(extension_id)); 69 ASSERT_TRUE(WaitForExtensionCrash(extension_id));
70 ASSERT_FALSE(GetExtensionProcessManager()-> 70 ASSERT_FALSE(GetProcessManager()->
71 GetBackgroundHostForExtension(extension_id)); 71 GetBackgroundHostForExtension(extension_id));
72 72
73 // Wait for extension crash balloon to appear. 73 // Wait for extension crash balloon to appear.
74 base::MessageLoop::current()->RunUntilIdle(); 74 base::MessageLoop::current()->RunUntilIdle();
75 } 75 }
76 76
77 void CheckExtensionConsistency(std::string extension_id) { 77 void CheckExtensionConsistency(std::string extension_id) {
78 const Extension* extension = 78 const Extension* extension =
79 GetExtensionService()->extensions()->GetByID(extension_id); 79 GetExtensionService()->extensions()->GetByID(extension_id);
80 ASSERT_TRUE(extension); 80 ASSERT_TRUE(extension);
81 extensions::ExtensionHost* extension_host = GetExtensionProcessManager()-> 81 extensions::ExtensionHost* extension_host = GetProcessManager()->
82 GetBackgroundHostForExtension(extension_id); 82 GetBackgroundHostForExtension(extension_id);
83 ASSERT_TRUE(extension_host); 83 ASSERT_TRUE(extension_host);
84 ExtensionProcessManager::ViewSet all_views = 84 extensions::ProcessManager::ViewSet all_views =
85 GetExtensionProcessManager()->GetAllViews(); 85 GetProcessManager()->GetAllViews();
86 ExtensionProcessManager::ViewSet::const_iterator it = 86 extensions::ProcessManager::ViewSet::const_iterator it =
87 all_views.find(extension_host->host_contents()->GetRenderViewHost()); 87 all_views.find(extension_host->host_contents()->GetRenderViewHost());
88 ASSERT_FALSE(it == all_views.end()); 88 ASSERT_FALSE(it == all_views.end());
89 ASSERT_TRUE(extension_host->IsRenderViewLive()); 89 ASSERT_TRUE(extension_host->IsRenderViewLive());
90 extensions::ProcessMap* process_map = 90 extensions::ProcessMap* process_map =
91 browser()->profile()->GetExtensionService()->process_map(); 91 browser()->profile()->GetExtensionService()->process_map();
92 ASSERT_TRUE(process_map->Contains( 92 ASSERT_TRUE(process_map->Contains(
93 extension_id, 93 extension_id,
94 extension_host->render_view_host()->GetProcess()->GetID())); 94 extension_host->render_view_host()->GetProcess()->GetID()));
95 } 95 }
96 96
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 GetController())); 581 GetController()));
582 chrome::Reload(browser(), CURRENT_TAB); 582 chrome::Reload(browser(), CURRENT_TAB);
583 observer.Wait(); 583 observer.Wait();
584 } 584 }
585 // Extension should now be loaded. 585 // Extension should now be loaded.
586 SCOPED_TRACE("after reloading the tab"); 586 SCOPED_TRACE("after reloading the tab");
587 CheckExtensionConsistency(first_extension_id_); 587 CheckExtensionConsistency(first_extension_id_);
588 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); 588 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
589 ASSERT_EQ(0U, CountBalloons()); 589 ASSERT_EQ(0U, CountBalloons());
590 } 590 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_browsertest.cc ('k') | chrome/browser/extensions/extension_function_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698