| OLD | NEW |
| 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 "content/browser/renderer_host/render_process_host.h" | 5 #include "content/browser/renderer_host/render_process_host.h" |
| 6 | 6 |
| 7 #include "base/rand_util.h" | 7 #include "base/rand_util.h" |
| 8 #include "base/sys_info.h" | 8 #include "base/sys_info.h" |
| 9 #include "chrome/common/chrome_constants.h" | 9 #include "chrome/common/chrome_constants.h" |
| 10 #include "content/browser/browser_thread.h" | 10 #include "content/browser/browser_thread.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 // static | 88 // static |
| 89 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) { | 89 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) { |
| 90 max_renderer_count_override = count; | 90 max_renderer_count_override = count; |
| 91 } | 91 } |
| 92 | 92 |
| 93 RenderProcessHost::RenderProcessHost(Profile* profile) | 93 RenderProcessHost::RenderProcessHost(Profile* profile) |
| 94 : max_page_id_(-1), | 94 : max_page_id_(-1), |
| 95 fast_shutdown_started_(false), | 95 fast_shutdown_started_(false), |
| 96 deleting_soon_(false), | 96 deleting_soon_(false), |
| 97 pending_views_(0), |
| 97 id_(ChildProcessInfo::GenerateChildProcessUniqueId()), | 98 id_(ChildProcessInfo::GenerateChildProcessUniqueId()), |
| 98 profile_(profile), | 99 profile_(profile), |
| 99 sudden_termination_allowed_(true), | 100 sudden_termination_allowed_(true), |
| 100 ignore_input_events_(false) { | 101 ignore_input_events_(false) { |
| 101 all_hosts.AddWithID(this, id()); | 102 all_hosts.AddWithID(this, id()); |
| 102 all_hosts.set_check_on_null_data(true); | 103 all_hosts.set_check_on_null_data(true); |
| 103 // Initialize |child_process_activity_time_| to a reasonable value. | 104 // Initialize |child_process_activity_time_| to a reasonable value. |
| 104 mark_child_process_activity_time(); | 105 mark_child_process_activity_time(); |
| 105 } | 106 } |
| 106 | 107 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 136 // Remove ourself from the list of renderer processes so that we can't be | 137 // Remove ourself from the list of renderer processes so that we can't be |
| 137 // reused in between now and when the Delete task runs. | 138 // reused in between now and when the Delete task runs. |
| 138 all_hosts.Remove(id()); | 139 all_hosts.Remove(id()); |
| 139 } | 140 } |
| 140 } | 141 } |
| 141 | 142 |
| 142 void RenderProcessHost::ReportExpectingClose(int32 listener_id) { | 143 void RenderProcessHost::ReportExpectingClose(int32 listener_id) { |
| 143 listeners_expecting_close_.insert(listener_id); | 144 listeners_expecting_close_.insert(listener_id); |
| 144 } | 145 } |
| 145 | 146 |
| 147 void RenderProcessHost::AddPendingView() { |
| 148 pending_views_++; |
| 149 } |
| 150 |
| 151 void RenderProcessHost::RemovePendingView() { |
| 152 DCHECK(pending_views_); |
| 153 pending_views_--; |
| 154 } |
| 155 |
| 146 void RenderProcessHost::UpdateMaxPageID(int32 page_id) { | 156 void RenderProcessHost::UpdateMaxPageID(int32 page_id) { |
| 147 if (page_id > max_page_id_) | 157 if (page_id > max_page_id_) |
| 148 max_page_id_ = page_id; | 158 max_page_id_ = page_id; |
| 149 } | 159 } |
| 150 | 160 |
| 151 bool RenderProcessHost::FastShutdownForPageCount(size_t count) { | 161 bool RenderProcessHost::FastShutdownForPageCount(size_t count) { |
| 152 if (listeners_.size() == count) | 162 if (listeners_.size() == count) |
| 153 return FastShutdownIfPossible(); | 163 return FastShutdownIfPossible(); |
| 154 return false; | 164 return false; |
| 155 } | 165 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 208 |
| 199 // Now pick a random suitable renderer, if we have any. | 209 // Now pick a random suitable renderer, if we have any. |
| 200 if (!suitable_renderers.empty()) { | 210 if (!suitable_renderers.empty()) { |
| 201 int suitable_count = static_cast<int>(suitable_renderers.size()); | 211 int suitable_count = static_cast<int>(suitable_renderers.size()); |
| 202 int random_index = base::RandInt(0, suitable_count - 1); | 212 int random_index = base::RandInt(0, suitable_count - 1); |
| 203 return suitable_renderers[random_index]; | 213 return suitable_renderers[random_index]; |
| 204 } | 214 } |
| 205 | 215 |
| 206 return NULL; | 216 return NULL; |
| 207 } | 217 } |
| OLD | NEW |