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

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

Issue 8515027: Define the public version of the browser side RenderProcessHost interface. This interface is not ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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) 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/process_util.h" 5 #include "base/process_util.h"
6 #include "chrome/browser/browser_process.h" 6 #include "chrome/browser/browser_process.h"
7 #include "chrome/browser/extensions/extension_browsertest.h" 7 #include "chrome/browser/extensions/extension_browsertest.h"
8 #include "chrome/browser/extensions/extension_host.h" 8 #include "chrome/browser/extensions/extension_host.h"
9 #include "chrome/browser/extensions/extension_process_manager.h" 9 #include "chrome/browser/extensions/extension_process_manager.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/notifications/balloon_host.h" 11 #include "chrome/browser/notifications/balloon_host.h"
12 #include "chrome/browser/notifications/notification.h" 12 #include "chrome/browser/notifications/notification.h"
13 #include "chrome/browser/notifications/notification_delegate.h" 13 #include "chrome/browser/notifications/notification_delegate.h"
14 #include "chrome/browser/notifications/notification_ui_manager.h" 14 #include "chrome/browser/notifications/notification_ui_manager.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/tabs/tab_strip_model.h" 16 #include "chrome/browser/tabs/tab_strip_model.h"
17 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
19 #include "chrome/test/base/ui_test_utils.h" 19 #include "chrome/test/base/ui_test_utils.h"
20 #include "content/browser/renderer_host/render_process_host.h"
21 #include "content/browser/renderer_host/render_view_host.h" 20 #include "content/browser/renderer_host/render_view_host.h"
22 #include "content/browser/tab_contents/tab_contents.h" 21 #include "content/browser/tab_contents/tab_contents.h"
22 #include "content/public/browser/render_process_host.h"
23 #include "content/public/common/result_codes.h" 23 #include "content/public/common/result_codes.h"
24 24
25 class ExtensionCrashRecoveryTest : public ExtensionBrowserTest { 25 class ExtensionCrashRecoveryTest : public ExtensionBrowserTest {
26 protected: 26 protected:
27 ExtensionService* GetExtensionService() { 27 ExtensionService* GetExtensionService() {
28 return browser()->profile()->GetExtensionService(); 28 return browser()->profile()->GetExtensionService();
29 } 29 }
30 30
31 ExtensionProcessManager* GetExtensionProcessManager() { 31 ExtensionProcessManager* GetExtensionProcessManager() {
32 return browser()->profile()->GetExtensionProcessManager(); 32 return browser()->profile()->GetExtensionProcessManager();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 void CrashExtension(size_t index) { 65 void CrashExtension(size_t index) {
66 ASSERT_LT(index, GetExtensionService()->extensions()->size()); 66 ASSERT_LT(index, GetExtensionService()->extensions()->size());
67 const Extension* extension = 67 const Extension* extension =
68 GetExtensionService()->extensions()->at(index); 68 GetExtensionService()->extensions()->at(index);
69 ASSERT_TRUE(extension); 69 ASSERT_TRUE(extension);
70 std::string extension_id(extension->id()); 70 std::string extension_id(extension->id());
71 ExtensionHost* extension_host = GetExtensionProcessManager()-> 71 ExtensionHost* extension_host = GetExtensionProcessManager()->
72 GetBackgroundHostForExtension(extension_id); 72 GetBackgroundHostForExtension(extension_id);
73 ASSERT_TRUE(extension_host); 73 ASSERT_TRUE(extension_host);
74 74
75 RenderProcessHost* extension_rph = 75 content::RenderProcessHost* extension_rph =
76 extension_host->render_view_host()->process(); 76 extension_host->render_view_host()->process();
77 base::KillProcess(extension_rph->GetHandle(), content::RESULT_CODE_KILLED, 77 base::KillProcess(extension_rph->GetHandle(), content::RESULT_CODE_KILLED,
78 false); 78 false);
79 ASSERT_TRUE(WaitForExtensionCrash(extension_id)); 79 ASSERT_TRUE(WaitForExtensionCrash(extension_id));
80 ASSERT_FALSE(GetExtensionProcessManager()-> 80 ASSERT_FALSE(GetExtensionProcessManager()->
81 GetBackgroundHostForExtension(extension_id)); 81 GetBackgroundHostForExtension(extension_id));
82 } 82 }
83 83
84 void CheckExtensionConsistency(size_t index) { 84 void CheckExtensionConsistency(size_t index) {
85 ASSERT_LT(index, GetExtensionService()->extensions()->size()); 85 ASSERT_LT(index, GetExtensionService()->extensions()->size());
86 const Extension* extension = 86 const Extension* extension =
87 GetExtensionService()->extensions()->at(index); 87 GetExtensionService()->extensions()->at(index);
88 ASSERT_TRUE(extension); 88 ASSERT_TRUE(extension);
89 ExtensionHost* extension_host = GetExtensionProcessManager()-> 89 ExtensionHost* extension_host = GetExtensionProcessManager()->
90 GetBackgroundHostForExtension(extension->id()); 90 GetBackgroundHostForExtension(extension->id());
91 ASSERT_TRUE(extension_host); 91 ASSERT_TRUE(extension_host);
92 ASSERT_TRUE(GetExtensionProcessManager()->HasExtensionHost(extension_host)); 92 ASSERT_TRUE(GetExtensionProcessManager()->HasExtensionHost(extension_host));
93 ASSERT_TRUE(extension_host->IsRenderViewLive()); 93 ASSERT_TRUE(extension_host->IsRenderViewLive());
94 extensions::ProcessMap* process_map = 94 extensions::ProcessMap* process_map =
95 browser()->profile()->GetExtensionService()->process_map(); 95 browser()->profile()->GetExtensionService()->process_map();
96 ASSERT_TRUE(process_map->Contains( 96 ASSERT_TRUE(process_map->Contains(
97 extension->id(), extension_host->render_view_host()->process()->id())); 97 extension->id(), extension_host->render_view_host()->process()->
98 GetID()));
98 } 99 }
99 100
100 void LoadTestExtension() { 101 void LoadTestExtension() {
101 ExtensionBrowserTest::SetUpInProcessBrowserTestFixture(); 102 ExtensionBrowserTest::SetUpInProcessBrowserTestFixture();
102 const size_t size_before = GetExtensionService()->extensions()->size(); 103 const size_t size_before = GetExtensionService()->extensions()->size();
103 ASSERT_TRUE(LoadExtension( 104 ASSERT_TRUE(LoadExtension(
104 test_data_dir_.AppendASCII("common").AppendASCII("background_page"))); 105 test_data_dir_.AppendASCII("common").AppendASCII("background_page")));
105 const Extension* extension = GetExtensionService()->extensions()->back(); 106 const Extension* extension = GetExtensionService()->extensions()->back();
106 ASSERT_TRUE(extension); 107 ASSERT_TRUE(extension);
107 first_extension_id_ = extension->id(); 108 first_extension_id_ = extension->id();
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 content::NOTIFICATION_LOAD_STOP, 487 content::NOTIFICATION_LOAD_STOP,
487 content::Source<NavigationController>( 488 content::Source<NavigationController>(
488 &browser()->GetSelectedTabContentsWrapper()->controller())); 489 &browser()->GetSelectedTabContentsWrapper()->controller()));
489 browser()->Reload(CURRENT_TAB); 490 browser()->Reload(CURRENT_TAB);
490 observer.Wait(); 491 observer.Wait();
491 } 492 }
492 // Extension should now be loaded. 493 // Extension should now be loaded.
493 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); 494 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
494 ASSERT_EQ(0U, CountBalloons()); 495 ASSERT_EQ(0U, CountBalloons());
495 } 496 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/app_process_apitest.cc ('k') | chrome/browser/extensions/extension_event_router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698