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

Side by Side Diff: content/browser/site_instance_unittest.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/compiler_specific.h" 5 #include "base/compiler_specific.h"
6 #include "base/stl_util.h" 6 #include "base/stl_util.h"
7 #include "base/string16.h" 7 #include "base/string16.h"
8 #include "content/browser/browser_thread_impl.h" 8 #include "content/browser/browser_thread_impl.h"
9 #include "content/browser/browsing_instance.h" 9 #include "content/browser/browsing_instance.h"
10 #include "content/browser/child_process_security_policy.h" 10 #include "content/browser/child_process_security_policy.h"
11 #include "content/browser/mock_content_browser_client.h" 11 #include "content/browser/mock_content_browser_client.h"
12 #include "content/browser/renderer_host/browser_render_process_host.h" 12 #include "content/browser/renderer_host/render_process_host_impl.h"
13 #include "content/browser/renderer_host/render_view_host.h" 13 #include "content/browser/renderer_host/render_view_host.h"
14 #include "content/browser/renderer_host/test_render_view_host.h" 14 #include "content/browser/renderer_host/test_render_view_host.h"
15 #include "content/browser/site_instance.h" 15 #include "content/browser/site_instance.h"
16 #include "content/browser/tab_contents/navigation_entry.h" 16 #include "content/browser/tab_contents/navigation_entry.h"
17 #include "content/browser/tab_contents/tab_contents.h" 17 #include "content/browser/tab_contents/tab_contents.h"
18 #include "content/browser/webui/empty_web_ui_factory.h" 18 #include "content/browser/webui/empty_web_ui_factory.h"
19 #include "content/public/common/content_client.h" 19 #include "content/public/common/content_client.h"
20 #include "content/public/common/content_constants.h" 20 #include "content/public/common/content_constants.h"
21 #include "content/public/common/url_constants.h" 21 #include "content/public/common/url_constants.h"
22 #include "content/test/test_browser_context.h" 22 #include "content/test/test_browser_context.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return false; 63 return false;
64 } 64 }
65 65
66 virtual bool IsURLSameAsAnySiteInstance(const GURL& url) OVERRIDE { 66 virtual bool IsURLSameAsAnySiteInstance(const GURL& url) OVERRIDE {
67 return url == GURL(kSameAsAnyInstanceURL) || 67 return url == GURL(kSameAsAnyInstanceURL) ||
68 url == GURL(chrome::kAboutCrashURL); 68 url == GURL(chrome::kAboutCrashURL);
69 } 69 }
70 70
71 virtual bool IsSuitableHost(RenderProcessHost* process_host, 71 virtual bool IsSuitableHost(RenderProcessHost* process_host,
72 const GURL& site_url) OVERRIDE { 72 const GURL& site_url) OVERRIDE {
73 return (privileged_process_id_ == process_host->id()) == 73 return (privileged_process_id_ == process_host->GetID()) ==
74 site_url.SchemeIs(kPrivilegedScheme); 74 site_url.SchemeIs(kPrivilegedScheme);
75 } 75 }
76 76
77 virtual GURL GetEffectiveURL(content::BrowserContext* browser_context, 77 virtual GURL GetEffectiveURL(content::BrowserContext* browser_context,
78 const GURL& url) OVERRIDE { 78 const GURL& url) OVERRIDE {
79 return url; 79 return url;
80 } 80 }
81 81
82 void SetOriginalClient(content::ContentBrowserClient* old_browser_client) { 82 void SetOriginalClient(content::ContentBrowserClient* old_browser_client) {
83 old_browser_client_ = old_browser_client; 83 old_browser_client_ = old_browser_client;
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 530
531 // Make a bunch of mock renderers so that we hit the limit. 531 // Make a bunch of mock renderers so that we hit the limit.
532 std::vector<MockRenderProcessHost*> hosts; 532 std::vector<MockRenderProcessHost*> hosts;
533 for (size_t i = 0; i < content::kMaxRendererProcessCount; ++i) 533 for (size_t i = 0; i < content::kMaxRendererProcessCount; ++i)
534 hosts.push_back(new MockRenderProcessHost(NULL)); 534 hosts.push_back(new MockRenderProcessHost(NULL));
535 535
536 // Create some extension instances and make sure they share a process. 536 // Create some extension instances and make sure they share a process.
537 scoped_refptr<SiteInstance> extension1_instance( 537 scoped_refptr<SiteInstance> extension1_instance(
538 CreateSiteInstance(&rph_factory, 538 CreateSiteInstance(&rph_factory,
539 GURL(kPrivilegedScheme + std::string("://foo/bar")))); 539 GURL(kPrivilegedScheme + std::string("://foo/bar"))));
540 SetPrivilegedProcessId(extension1_instance->GetProcess()->id()); 540 SetPrivilegedProcessId(extension1_instance->GetProcess()->GetID());
541 541
542 scoped_refptr<SiteInstance> extension2_instance( 542 scoped_refptr<SiteInstance> extension2_instance(
543 CreateSiteInstance(&rph_factory, 543 CreateSiteInstance(&rph_factory,
544 GURL(kPrivilegedScheme + std::string("://baz/bar")))); 544 GURL(kPrivilegedScheme + std::string("://baz/bar"))));
545 545
546 scoped_ptr<RenderProcessHost> extension_host( 546 scoped_ptr<RenderProcessHost> extension_host(
547 extension1_instance->GetProcess()); 547 extension1_instance->GetProcess());
548 EXPECT_EQ(extension1_instance->GetProcess(), 548 EXPECT_EQ(extension1_instance->GetProcess(),
549 extension2_instance->GetProcess()); 549 extension2_instance->GetProcess());
550 550
551 // Create some WebUI instances and make sure they share a process. 551 // Create some WebUI instances and make sure they share a process.
552 scoped_refptr<SiteInstance> webui1_instance(CreateSiteInstance(&rph_factory, 552 scoped_refptr<SiteInstance> webui1_instance(CreateSiteInstance(&rph_factory,
553 GURL(chrome::kChromeUIScheme + std::string("://newtab")))); 553 GURL(chrome::kChromeUIScheme + std::string("://newtab"))));
554 policy->GrantWebUIBindings(webui1_instance->GetProcess()->id()); 554 policy->GrantWebUIBindings(webui1_instance->GetProcess()->GetID());
555 555
556 scoped_refptr<SiteInstance> webui2_instance( CreateSiteInstance(&rph_factory, 556 scoped_refptr<SiteInstance> webui2_instance( CreateSiteInstance(&rph_factory,
557 GURL(chrome::kChromeUIScheme + std::string("://history")))); 557 GURL(chrome::kChromeUIScheme + std::string("://history"))));
558 558
559 scoped_ptr<RenderProcessHost> dom_host(webui1_instance->GetProcess()); 559 scoped_ptr<RenderProcessHost> dom_host(webui1_instance->GetProcess());
560 EXPECT_EQ(webui1_instance->GetProcess(), webui2_instance->GetProcess()); 560 EXPECT_EQ(webui1_instance->GetProcess(), webui2_instance->GetProcess());
561 561
562 // Make sure none of differing privilege processes are mixed. 562 // Make sure none of differing privilege processes are mixed.
563 EXPECT_NE(extension1_instance->GetProcess(), webui1_instance->GetProcess()); 563 EXPECT_NE(extension1_instance->GetProcess(), webui1_instance->GetProcess());
564 564
565 for (size_t i = 0; i < content::kMaxRendererProcessCount; ++i) { 565 for (size_t i = 0; i < content::kMaxRendererProcessCount; ++i) {
566 EXPECT_NE(extension1_instance->GetProcess(), hosts[i]); 566 EXPECT_NE(extension1_instance->GetProcess(), hosts[i]);
567 EXPECT_NE(webui1_instance->GetProcess(), hosts[i]); 567 EXPECT_NE(webui1_instance->GetProcess(), hosts[i]);
568 } 568 }
569 569
570 STLDeleteContainerPointers(hosts.begin(), hosts.end()); 570 STLDeleteContainerPointers(hosts.begin(), hosts.end());
571 } 571 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698