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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "base/string16.h" | 8 #include "base/string16.h" |
9 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" |
10 #include "content/browser/browsing_instance.h" | 10 #include "content/browser/browsing_instance.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 public: | 85 public: |
86 SiteInstanceTest() | 86 SiteInstanceTest() |
87 : ui_thread_(BrowserThread::UI, &message_loop_), | 87 : ui_thread_(BrowserThread::UI, &message_loop_), |
88 file_user_blocking_thread_(BrowserThread::FILE_USER_BLOCKING, | 88 file_user_blocking_thread_(BrowserThread::FILE_USER_BLOCKING, |
89 &message_loop_), | 89 &message_loop_), |
90 io_thread_(BrowserThread::IO, &message_loop_), | 90 io_thread_(BrowserThread::IO, &message_loop_), |
91 old_browser_client_(NULL) { | 91 old_browser_client_(NULL) { |
92 } | 92 } |
93 | 93 |
94 virtual void SetUp() { | 94 virtual void SetUp() { |
95 old_browser_client_ = GetContentClient()->browser(); | 95 old_browser_client_ = SetBrowserClientForTesting(&browser_client_); |
96 GetContentClient()->set_browser_for_testing(&browser_client_); | |
97 url_util::AddStandardScheme(kPrivilegedScheme); | 96 url_util::AddStandardScheme(kPrivilegedScheme); |
98 url_util::AddStandardScheme(chrome::kChromeUIScheme); | 97 url_util::AddStandardScheme(chrome::kChromeUIScheme); |
99 } | 98 } |
100 | 99 |
101 virtual void TearDown() { | 100 virtual void TearDown() { |
102 // Ensure that no RenderProcessHosts are left over after the tests. | 101 // Ensure that no RenderProcessHosts are left over after the tests. |
103 EXPECT_TRUE(RenderProcessHost::AllHostsIterator().IsAtEnd()); | 102 EXPECT_TRUE(RenderProcessHost::AllHostsIterator().IsAtEnd()); |
104 | 103 |
105 GetContentClient()->set_browser_for_testing(old_browser_client_); | 104 SetBrowserClientForTesting(old_browser_client_); |
106 | 105 |
107 // http://crbug.com/143565 found SiteInstanceTest leaking an | 106 // http://crbug.com/143565 found SiteInstanceTest leaking an |
108 // AppCacheDatabase. This happens because some part of the test indirectly | 107 // AppCacheDatabase. This happens because some part of the test indirectly |
109 // calls StoragePartitionImplMap::PostCreateInitialization(), which posts | 108 // calls StoragePartitionImplMap::PostCreateInitialization(), which posts |
110 // a task to the IO thread to create the AppCacheDatabase. Since the | 109 // a task to the IO thread to create the AppCacheDatabase. Since the |
111 // message loop is not running, the AppCacheDatabase ends up getting | 110 // message loop is not running, the AppCacheDatabase ends up getting |
112 // created when DrainMessageLoops() gets called at the end of a test case. | 111 // created when DrainMessageLoops() gets called at the end of a test case. |
113 // Immediately after, the test case ends and the AppCacheDatabase gets | 112 // Immediately after, the test case ends and the AppCacheDatabase gets |
114 // scheduled for deletion. Here, call DrainMessageLoops() again so the | 113 // scheduled for deletion. Here, call DrainMessageLoops() again so the |
115 // AppCacheDatabase actually gets deleted. | 114 // AppCacheDatabase actually gets deleted. |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 EXPECT_TRUE(instance->GetSiteURL().is_empty()); | 754 EXPECT_TRUE(instance->GetSiteURL().is_empty()); |
756 host.reset(instance->GetProcess()); | 755 host.reset(instance->GetProcess()); |
757 | 756 |
758 EXPECT_FALSE(RenderProcessHostImpl::GetProcessHostForSite( | 757 EXPECT_FALSE(RenderProcessHostImpl::GetProcessHostForSite( |
759 browser_context.get(), GURL())); | 758 browser_context.get(), GURL())); |
760 | 759 |
761 DrainMessageLoops(); | 760 DrainMessageLoops(); |
762 } | 761 } |
763 | 762 |
764 } // namespace content | 763 } // namespace content |
OLD | NEW |