Chromium Code Reviews| 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 <string> | |
|
jam
2012/09/06 16:58:03
including string is quite unnecessary.. i would sa
Lei Zhang
2012/09/06 18:16:43
Ok, maybe we should take it out of the linter...
| |
| 6 #include <vector> | |
| 7 | |
| 5 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 6 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 7 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 8 #include "base/string16.h" | 11 #include "base/string16.h" |
| 9 #include "content/browser/browser_thread_impl.h" | 12 #include "content/browser/browser_thread_impl.h" |
| 10 #include "content/browser/browsing_instance.h" | 13 #include "content/browser/browsing_instance.h" |
| 11 #include "content/browser/child_process_security_policy_impl.h" | 14 #include "content/browser/child_process_security_policy_impl.h" |
| 12 #include "content/browser/renderer_host/render_process_host_impl.h" | 15 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 13 #include "content/browser/renderer_host/render_view_host_impl.h" | 16 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 14 #include "content/browser/renderer_host/test_render_view_host.h" | 17 #include "content/browser/renderer_host/test_render_view_host.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 class SiteInstanceTestClient : public TestContentClient { | 78 class SiteInstanceTestClient : public TestContentClient { |
| 76 public: | 79 public: |
| 77 SiteInstanceTestClient() { | 80 SiteInstanceTestClient() { |
| 78 } | 81 } |
| 79 | 82 |
| 80 virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE { | 83 virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE { |
| 81 return url.SchemeIs(chrome::kChromeUIScheme); | 84 return url.SchemeIs(chrome::kChromeUIScheme); |
| 82 } | 85 } |
| 83 }; | 86 }; |
| 84 | 87 |
| 85 class SiteInstanceTestBrowserClient : | 88 class SiteInstanceTestBrowserClient : public content::TestContentBrowserClient { |
| 86 public content::TestContentBrowserClient { | |
| 87 public: | 89 public: |
| 88 SiteInstanceTestBrowserClient() | 90 SiteInstanceTestBrowserClient() |
| 89 : privileged_process_id_(-1) { | 91 : privileged_process_id_(-1) { |
| 90 } | 92 } |
| 91 | 93 |
| 92 virtual content::WebUIControllerFactory* | 94 virtual content::WebUIControllerFactory* |
| 93 GetWebUIControllerFactory() OVERRIDE { | 95 GetWebUIControllerFactory() OVERRIDE { |
| 94 return &factory_; | 96 return &factory_; |
| 95 } | 97 } |
| 96 | 98 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 url_util::AddStandardScheme(kPrivilegedScheme); | 130 url_util::AddStandardScheme(kPrivilegedScheme); |
| 129 url_util::AddStandardScheme(chrome::kChromeUIScheme); | 131 url_util::AddStandardScheme(chrome::kChromeUIScheme); |
| 130 } | 132 } |
| 131 | 133 |
| 132 virtual void TearDown() { | 134 virtual void TearDown() { |
| 133 // Ensure that no RenderProcessHosts are left over after the tests. | 135 // Ensure that no RenderProcessHosts are left over after the tests. |
| 134 EXPECT_TRUE(content::RenderProcessHost::AllHostsIterator().IsAtEnd()); | 136 EXPECT_TRUE(content::RenderProcessHost::AllHostsIterator().IsAtEnd()); |
| 135 | 137 |
| 136 content::GetContentClient()->set_browser_for_testing(old_browser_client_); | 138 content::GetContentClient()->set_browser_for_testing(old_browser_client_); |
| 137 content::SetContentClient(old_client_); | 139 content::SetContentClient(old_client_); |
| 140 | |
| 141 // http://crbug.com/143565 found SiteInstanceTest leaking an | |
| 142 // AppCacheDatabase. This happens because some part of the test indirectly | |
| 143 // calls StoragePartitionImplMap::PostCreateInitialization(), which posts | |
| 144 // a task to the IO thread to create the AppCacheDatabase. Since the | |
| 145 // message loop is not running, the AppCacheDatabase ends up getting | |
| 146 // created when DrainMessageLoops() gets called at the end of a test case. | |
| 147 // Immediately after, the test case ends and the AppCacheDatabase gets | |
| 148 // scheduled for deletion. Here, call DrainMessageLoops() again so the | |
| 149 // AppCacheDatabase actually gets deleted. | |
| 150 DrainMessageLoops(); | |
| 138 } | 151 } |
| 139 | 152 |
| 140 void set_privileged_process_id(int process_id) { | 153 void set_privileged_process_id(int process_id) { |
| 141 browser_client_.set_privileged_process_id(process_id); | 154 browser_client_.set_privileged_process_id(process_id); |
| 142 } | 155 } |
| 143 | 156 |
| 144 void DrainMessageLoops() { | 157 void DrainMessageLoops() { |
| 145 // We don't just do this in TearDown() because we create TestBrowserContext | 158 // We don't just do this in TearDown() because we create TestBrowserContext |
| 146 // objects in each test, which will be destructed before | 159 // objects in each test, which will be destructed before |
| 147 // TearDown() is called. | 160 // TearDown() is called. |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 668 EXPECT_TRUE(instance->HasProcess()); | 681 EXPECT_TRUE(instance->HasProcess()); |
| 669 | 682 |
| 670 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://evernote.com"))); | 683 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://evernote.com"))); |
| 671 EXPECT_FALSE(instance->HasWrongProcessForURL( | 684 EXPECT_FALSE(instance->HasWrongProcessForURL( |
| 672 GURL("javascript:alert(document.location.href);"))); | 685 GURL("javascript:alert(document.location.href);"))); |
| 673 | 686 |
| 674 EXPECT_TRUE(instance->HasWrongProcessForURL(GURL("chrome://settings"))); | 687 EXPECT_TRUE(instance->HasWrongProcessForURL(GURL("chrome://settings"))); |
| 675 | 688 |
| 676 DrainMessageLoops(); | 689 DrainMessageLoops(); |
| 677 } | 690 } |
| OLD | NEW |