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

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: Fixing Windows compile error. 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 g_created_callbacks = LAZY_INSTANCE_INITIALIZER; 114 g_created_callbacks = LAZY_INSTANCE_INITIALIZER;
115 115
116 } // namespace 116 } // namespace
117 117
118 /////////////////////////////////////////////////////////////////////////////// 118 ///////////////////////////////////////////////////////////////////////////////
119 // RenderViewHost, public: 119 // RenderViewHost, public:
120 120
121 // static 121 // static
122 RenderViewHost* RenderViewHost::FromID(int render_process_id, 122 RenderViewHost* RenderViewHost::FromID(int render_process_id,
123 int render_view_id) { 123 int render_view_id) {
124 RenderProcessHost* process = RenderProcessHost::FromID(render_process_id); 124 RenderWidgetHost* widget =
125 if (!process) 125 RenderWidgetHost::FromID(render_process_id, render_view_id);
126 return NULL;
127 RenderWidgetHost* widget = process->GetRenderWidgetHostByID(render_view_id);
128 if (!widget || !widget->IsRenderView()) 126 if (!widget || !widget->IsRenderView())
129 return NULL; 127 return NULL;
130 return static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(widget)); 128 return static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(widget));
131 } 129 }
132 130
133 // static 131 // static
134 RenderViewHost* RenderViewHost::From(RenderWidgetHost* rwh) { 132 RenderViewHost* RenderViewHost::From(RenderWidgetHost* rwh) {
135 DCHECK(rwh->IsRenderView()); 133 DCHECK(rwh->IsRenderView());
136 return static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(rwh)); 134 return static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(rwh));
137 } 135 }
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 481
484 // If we are not running the renderer in process and no other tab is using 482 // If we are not running the renderer in process and no other tab is using
485 // the hung process, consider it eligible to be killed, assuming it is a real 483 // the hung process, consider it eligible to be killed, assuming it is a real
486 // process (unit tests don't have real processes). 484 // process (unit tests don't have real processes).
487 if (hung) { 485 if (hung) {
488 base::ProcessHandle process_handle = GetProcess()->GetHandle(); 486 base::ProcessHandle process_handle = GetProcess()->GetHandle();
489 int views = 0; 487 int views = 0;
490 488
491 // Count the number of widget hosts for the process, which is equivalent to 489 // Count the number of widget hosts for the process, which is equivalent to
492 // views using the process as of this writing. 490 // views using the process as of this writing.
493 RenderProcessHost::RenderWidgetHostsIterator iter( 491 RenderWidgetHost::List widgets = RenderWidgetHost::GetRenderWidgetHosts();
494 GetProcess()->GetRenderWidgetHostsIterator()); 492 for (RenderWidgetHost::List::const_iterator it = widgets.begin();
jam 2013/06/12 19:59:59 ditto re size_t
nasko 2013/06/12 21:18:59 Done.
495 for (; !iter.IsAtEnd(); iter.Advance()) 493 it != widgets.end(); ++it) {
496 ++views; 494 const RenderWidgetHost* widget = *it;
495 if (widget->GetProcess()->GetID() == GetProcess()->GetID())
496 ++views;
497 }
497 498
498 if (!RenderProcessHost::run_renderer_in_process() && 499 if (!RenderProcessHost::run_renderer_in_process() &&
499 process_handle && views <= 1) { 500 process_handle && views <= 1) {
500 // The process can safely be terminated, only if WebContents sets 501 // The process can safely be terminated, only if WebContents sets
501 // SuddenTerminationAllowed, which indicates that the timer has expired. 502 // SuddenTerminationAllowed, which indicates that the timer has expired.
502 // This is not the case if we load data URLs or about:blank. The reason 503 // This is not the case if we load data URLs or about:blank. The reason
503 // is that those have no network requests and this code is hit without 504 // is that those have no network requests and this code is hit without
504 // setting the unresponsiveness timer. This allows a corner case where a 505 // setting the unresponsiveness timer. This allows a corner case where a
505 // navigation to a data URL will leave a process running, if the 506 // navigation to a data URL will leave a process running, if the
506 // beforeunload handler completes fine, but the unload handler hangs. 507 // beforeunload handler completes fine, but the unload handler hangs.
(...skipping 1594 matching lines...) Expand 10 before | Expand all | Expand 10 after
2101 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles(); 2102 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles();
2102 for (std::vector<base::FilePath>::const_iterator file = file_paths.begin(); 2103 for (std::vector<base::FilePath>::const_iterator file = file_paths.begin();
2103 file != file_paths.end(); ++file) { 2104 file != file_paths.end(); ++file) {
2104 if (!policy->CanReadFile(GetProcess()->GetID(), *file)) 2105 if (!policy->CanReadFile(GetProcess()->GetID(), *file))
2105 return false; 2106 return false;
2106 } 2107 }
2107 return true; 2108 return true;
2108 } 2109 }
2109 2110
2110 } // namespace content 2111 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698