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

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

Issue 16431010: Refactor RenderProcessHost to use IPC::Listener instead of RenderWidgetHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase on top of hash_pair move. Created 7 years, 6 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/renderer_host/render_view_host_impl.h" 5 #include "content/browser/renderer_host/render_view_host_impl.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 g_created_callbacks = LAZY_INSTANCE_INITIALIZER; 111 g_created_callbacks = LAZY_INSTANCE_INITIALIZER;
112 112
113 } // namespace 113 } // namespace
114 114
115 /////////////////////////////////////////////////////////////////////////////// 115 ///////////////////////////////////////////////////////////////////////////////
116 // RenderViewHost, public: 116 // RenderViewHost, public:
117 117
118 // static 118 // static
119 RenderViewHost* RenderViewHost::FromID(int render_process_id, 119 RenderViewHost* RenderViewHost::FromID(int render_process_id,
120 int render_view_id) { 120 int render_view_id) {
121 RenderProcessHost* process = RenderProcessHost::FromID(render_process_id); 121 RenderWidgetHost* widget =
122 if (!process) 122 RenderWidgetHost::FromID(render_process_id, render_view_id);
123 return NULL;
124 RenderWidgetHost* widget = process->GetRenderWidgetHostByID(render_view_id);
125 if (!widget || !widget->IsRenderView()) 123 if (!widget || !widget->IsRenderView())
126 return NULL; 124 return NULL;
127 return static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(widget)); 125 return static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(widget));
128 } 126 }
129 127
130 // static 128 // static
131 RenderViewHost* RenderViewHost::From(RenderWidgetHost* rwh) { 129 RenderViewHost* RenderViewHost::From(RenderWidgetHost* rwh) {
132 DCHECK(rwh->IsRenderView()); 130 DCHECK(rwh->IsRenderView());
133 return static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(rwh)); 131 return static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(rwh));
134 } 132 }
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 471
474 // If we are not running the renderer in process and no other tab is using 472 // If we are not running the renderer in process and no other tab is using
475 // the hung process, consider it eligible to be killed, assuming it is a real 473 // the hung process, consider it eligible to be killed, assuming it is a real
476 // process (unit tests don't have real processes). 474 // process (unit tests don't have real processes).
477 if (hung) { 475 if (hung) {
478 base::ProcessHandle process_handle = GetProcess()->GetHandle(); 476 base::ProcessHandle process_handle = GetProcess()->GetHandle();
479 int views = 0; 477 int views = 0;
480 478
481 // Count the number of widget hosts for the process, which is equivalent to 479 // Count the number of widget hosts for the process, which is equivalent to
482 // views using the process as of this writing. 480 // views using the process as of this writing.
483 RenderProcessHost::RenderWidgetHostsIterator iter( 481 RenderWidgetHost::List widgets = RenderWidgetHost::GetRenderWidgetHosts();
484 GetProcess()->GetRenderWidgetHostsIterator()); 482 for (size_t i = 0; i < widgets.size(); ++i) {
485 for (; !iter.IsAtEnd(); iter.Advance()) 483 if (widgets[i]->GetProcess()->GetID() == GetProcess()->GetID())
486 ++views; 484 ++views;
485 }
487 486
488 if (!RenderProcessHost::run_renderer_in_process() && 487 if (!RenderProcessHost::run_renderer_in_process() &&
489 process_handle && views <= 1) { 488 process_handle && views <= 1) {
490 // The process can safely be terminated, only if WebContents sets 489 // The process can safely be terminated, only if WebContents sets
491 // SuddenTerminationAllowed, which indicates that the timer has expired. 490 // SuddenTerminationAllowed, which indicates that the timer has expired.
492 // This is not the case if we load data URLs or about:blank. The reason 491 // This is not the case if we load data URLs or about:blank. The reason
493 // is that those have no network requests and this code is hit without 492 // is that those have no network requests and this code is hit without
494 // setting the unresponsiveness timer. This allows a corner case where a 493 // setting the unresponsiveness timer. This allows a corner case where a
495 // navigation to a data URL will leave a process running, if the 494 // navigation to a data URL will leave a process running, if the
496 // beforeunload handler completes fine, but the unload handler hangs. 495 // beforeunload handler completes fine, but the unload handler hangs.
(...skipping 1574 matching lines...) Expand 10 before | Expand all | Expand 10 after
2071 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles(); 2070 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles();
2072 for (std::vector<base::FilePath>::const_iterator file = file_paths.begin(); 2071 for (std::vector<base::FilePath>::const_iterator file = file_paths.begin();
2073 file != file_paths.end(); ++file) { 2072 file != file_paths.end(); ++file) {
2074 if (!policy->CanReadFile(GetProcess()->GetID(), *file)) 2073 if (!policy->CanReadFile(GetProcess()->GetID(), *file))
2075 return false; 2074 return false;
2076 } 2075 }
2077 return true; 2076 return true;
2078 } 2077 }
2079 2078
2080 } // namespace content 2079 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | content/browser/renderer_host/render_widget_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698