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

Side by Side Diff: content/browser/renderer_host/test_render_view_host.cc

Issue 9473001: Extract minimal RenderViewHost interface for embedders, leaving (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to LKGR. Created 8 years, 9 months 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 "content/browser/browser_url_handler.h" 5 #include "content/browser/browser_url_handler.h"
6 #include "content/browser/renderer_host/test_backing_store.h" 6 #include "content/browser/renderer_host/test_backing_store.h"
7 #include "content/browser/renderer_host/test_render_view_host.h" 7 #include "content/browser/renderer_host/test_render_view_host.h"
8 #include "content/browser/site_instance_impl.h" 8 #include "content/browser/site_instance_impl.h"
9 #include "content/browser/tab_contents/navigation_controller_impl.h" 9 #include "content/browser/tab_contents/navigation_controller_impl.h"
10 #include "content/browser/tab_contents/navigation_entry_impl.h" 10 #include "content/browser/tab_contents/navigation_entry_impl.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 content::NavigationController* controller) { 55 content::NavigationController* controller) {
56 TabContents* tab_contents = static_cast<TabContents*>( 56 TabContents* tab_contents = static_cast<TabContents*>(
57 controller->GetWebContents()); 57 controller->GetWebContents());
58 return static_cast<TestRenderViewHost*>( 58 return static_cast<TestRenderViewHost*>(
59 tab_contents->GetRenderManagerForTesting()->pending_render_view_host()); 59 tab_contents->GetRenderManagerForTesting()->pending_render_view_host());
60 } 60 }
61 61
62 TestRenderViewHost::TestRenderViewHost(SiteInstance* instance, 62 TestRenderViewHost::TestRenderViewHost(SiteInstance* instance,
63 RenderViewHostDelegate* delegate, 63 RenderViewHostDelegate* delegate,
64 int routing_id) 64 int routing_id)
65 : RenderViewHost(instance, delegate, routing_id, 65 : RenderViewHostImpl(instance,
66 kInvalidSessionStorageNamespaceId), 66 delegate,
67 routing_id,
68 kInvalidSessionStorageNamespaceId),
67 render_view_created_(false), 69 render_view_created_(false),
68 delete_counter_(NULL), 70 delete_counter_(NULL),
69 simulate_fetch_via_proxy_(false), 71 simulate_fetch_via_proxy_(false),
70 contents_mime_type_("text/html") { 72 contents_mime_type_("text/html") {
71 // For normal RenderViewHosts, this is freed when |Shutdown()| is called. 73 // For normal RenderViewHosts, this is freed when |Shutdown()| is called.
72 // For TestRenderViewHost, the view is explicitly deleted in the destructor 74 // For TestRenderViewHost, the view is explicitly deleted in the destructor
73 // below, because TestRenderWidgetHostView::Destroy() doesn't |delete this|. 75 // below, because TestRenderWidgetHostView::Destroy() doesn't |delete this|.
74 SetView(new content::TestRenderWidgetHostView(this)); 76 SetView(new content::TestRenderWidgetHostView(this));
75 } 77 }
76 78
77 TestRenderViewHost::~TestRenderViewHost() { 79 TestRenderViewHost::~TestRenderViewHost() {
78 if (delete_counter_) 80 if (delete_counter_)
79 ++*delete_counter_; 81 ++*delete_counter_;
80 82
81 // Since this isn't a traditional view, we have to delete it. 83 // Since this isn't a traditional view, we have to delete it.
82 delete view(); 84 delete GetView();
83 } 85 }
84 86
85 bool TestRenderViewHost::CreateRenderView(const string16& frame_name, 87 bool TestRenderViewHost::CreateRenderView(const string16& frame_name,
86 int32 max_page_id) { 88 int32 max_page_id) {
87 DCHECK(!render_view_created_); 89 DCHECK(!render_view_created_);
88 render_view_created_ = true; 90 render_view_created_ = true;
89 return true; 91 return true;
90 } 92 }
91 93
92 bool TestRenderViewHost::IsRenderViewLive() const { 94 bool TestRenderViewHost::IsRenderViewLive() const {
93 return render_view_created_; 95 return render_view_created_;
94 } 96 }
95 97
98 // static
99 bool TestRenderViewHost::IsRenderViewHostSwappedOut(RenderViewHost* rwh) {
100 return static_cast<RenderViewHostImpl*>(rwh)->is_swapped_out();
101 }
102
96 bool TestRenderViewHost::TestOnMessageReceived(const IPC::Message& msg) { 103 bool TestRenderViewHost::TestOnMessageReceived(const IPC::Message& msg) {
97 return OnMessageReceived(msg); 104 return OnMessageReceived(msg);
98 } 105 }
99 106
100 void TestRenderViewHost::SendNavigate(int page_id, const GURL& url) { 107 void TestRenderViewHost::SendNavigate(int page_id, const GURL& url) {
101 SendNavigateWithTransition(page_id, url, content::PAGE_TRANSITION_LINK); 108 SendNavigateWithTransition(page_id, url, content::PAGE_TRANSITION_LINK);
102 } 109 }
103 110
104 void TestRenderViewHost::SendNavigateWithTransition( 111 void TestRenderViewHost::SendNavigateWithTransition(
105 int page_id, const GURL& url, content::PageTransition transition) { 112 int page_id, const GURL& url, content::PageTransition transition) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 simulate_fetch_via_proxy_ = proxy; 149 simulate_fetch_via_proxy_ = proxy;
143 } 150 }
144 151
145 void TestRenderViewHost::set_contents_mime_type(const std::string& mime_type) { 152 void TestRenderViewHost::set_contents_mime_type(const std::string& mime_type) {
146 contents_mime_type_ = mime_type; 153 contents_mime_type_ = mime_type;
147 } 154 }
148 155
149 namespace content { 156 namespace content {
150 157
151 TestRenderWidgetHostView::TestRenderWidgetHostView(RenderWidgetHost* rwh) 158 TestRenderWidgetHostView::TestRenderWidgetHostView(RenderWidgetHost* rwh)
152 : is_showing_(false) { 159 : rwh_(RenderWidgetHostImpl::From(rwh)),
153 rwh_ = static_cast<RenderWidgetHostImpl*>(rwh); 160 is_showing_(false) {
154 } 161 }
155 162
156 TestRenderWidgetHostView::~TestRenderWidgetHostView() { 163 TestRenderWidgetHostView::~TestRenderWidgetHostView() {
157 } 164 }
158 165
159 RenderWidgetHost* TestRenderWidgetHostView::GetRenderWidgetHost() const { 166 RenderWidgetHost* TestRenderWidgetHostView::GetRenderWidgetHost() const {
160 return NULL; 167 return NULL;
161 } 168 }
162 169
163 gfx::NativeView TestRenderWidgetHostView::GetNativeView() const { 170 gfx::NativeView TestRenderWidgetHostView::GetNativeView() const {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 TestRenderViewHost* RenderViewHostTestHarness::active_rvh() { 364 TestRenderViewHost* RenderViewHostTestHarness::active_rvh() {
358 return pending_rvh() ? pending_rvh() : rvh(); 365 return pending_rvh() ? pending_rvh() : rvh();
359 } 366 }
360 367
361 content::BrowserContext* RenderViewHostTestHarness::browser_context() { 368 content::BrowserContext* RenderViewHostTestHarness::browser_context() {
362 return browser_context_.get(); 369 return browser_context_.get();
363 } 370 }
364 371
365 MockRenderProcessHost* RenderViewHostTestHarness::process() { 372 MockRenderProcessHost* RenderViewHostTestHarness::process() {
366 if (pending_rvh()) 373 if (pending_rvh())
367 return static_cast<MockRenderProcessHost*>(pending_rvh()->process()); 374 return static_cast<MockRenderProcessHost*>(pending_rvh()->GetProcess());
368 return static_cast<MockRenderProcessHost*>(rvh()->process()); 375 return static_cast<MockRenderProcessHost*>(rvh()->GetProcess());
369 } 376 }
370 377
371 void RenderViewHostTestHarness::DeleteContents() { 378 void RenderViewHostTestHarness::DeleteContents() {
372 SetContents(NULL); 379 SetContents(NULL);
373 } 380 }
374 381
375 void RenderViewHostTestHarness::SetContents(TestTabContents* contents) { 382 void RenderViewHostTestHarness::SetContents(TestTabContents* contents) {
376 contents_.reset(contents); 383 contents_.reset(contents);
377 } 384 }
378 385
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 #endif 422 #endif
416 423
417 // Make sure that we flush any messages related to TabContents destruction 424 // Make sure that we flush any messages related to TabContents destruction
418 // before we destroy the browser context. 425 // before we destroy the browser context.
419 MessageLoop::current()->RunAllPending(); 426 MessageLoop::current()->RunAllPending();
420 427
421 // Release the browser context on the UI thread. 428 // Release the browser context on the UI thread.
422 message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); 429 message_loop_.DeleteSoon(FROM_HERE, browser_context_.release());
423 message_loop_.RunAllPending(); 430 message_loop_.RunAllPending();
424 } 431 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/test_render_view_host.h ('k') | content/browser/renderer_host/text_input_client_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698