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

Side by Side Diff: chrome/browser/renderer_host/render_process_host.cc

Issue 6551019: Trace_event upgrades (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More gooder js thanks to arv. Created 9 years, 10 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) 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 "chrome/browser/renderer_host/render_process_host.h" 5 #include "chrome/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/browser/child_process_security_policy.h" 9 #include "chrome/browser/child_process_security_policy.h"
10 #include "chrome/common/child_process_info.h" 10 #include "chrome/common/child_process_info.h"
11 #include "chrome/common/chrome_constants.h" 11 #include "chrome/common/chrome_constants.h"
12 #include "chrome/common/notification_service.h" 12 #include "chrome/common/notification_service.h"
13 #include "chrome/common/render_messages.h"
13 14
14 namespace { 15 namespace {
15 16
16 size_t max_renderer_count_override = 0; 17 size_t max_renderer_count_override = 0;
17 18
18 size_t GetMaxRendererProcessCount() { 19 size_t GetMaxRendererProcessCount() {
19 if (max_renderer_count_override) 20 if (max_renderer_count_override)
20 return max_renderer_count_override; 21 return max_renderer_count_override;
21 22
22 // Defines the maximum number of renderer processes according to the 23 // Defines the maximum number of renderer processes according to the
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 if (ChildProcessSecurityPolicy::GetInstance()-> 71 if (ChildProcessSecurityPolicy::GetInstance()->
71 HasExtensionBindings(host->id())) 72 HasExtensionBindings(host->id()))
72 host_type = RenderProcessHost::TYPE_EXTENSION; 73 host_type = RenderProcessHost::TYPE_EXTENSION;
73 74
74 return host_type == type; 75 return host_type == type;
75 } 76 }
76 77
77 // the global list of all renderer processes 78 // the global list of all renderer processes
78 IDMap<RenderProcessHost> all_hosts; 79 IDMap<RenderProcessHost> all_hosts;
79 80
81 // Whether tracing is enabled on render processes.
82 bool trace_enabled = false;
83
80 } // namespace 84 } // namespace
81 85
82 extern bool g_log_bug53991; 86 extern bool g_log_bug53991;
83 87
84 // static 88 // static
85 bool RenderProcessHost::run_renderer_in_process_ = false; 89 bool RenderProcessHost::run_renderer_in_process_ = false;
86 90
87 // static 91 // static
88 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) { 92 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) {
89 max_renderer_count_override = count; 93 max_renderer_count_override = count;
90 } 94 }
91 95
96 // TODO(nduca): if a process is crated while enabled,
Ken Russell (switch to Gerrit) 2011/02/25 00:56:36 crated -> created
97 // send enabled flag to child process
98 int RenderProcessHost::SetTraceEnabled(bool enabled) {
99 int count = 0;
100 trace_enabled = enabled;
101 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator());
102 !i.IsAtEnd(); i.Advance()) {
103 i.GetCurrentValue()->Send(new ViewMsg_SetTraceEnabled(enabled));
104 count += 1;
105 }
106 return count;
107 }
108
92 RenderProcessHost::RenderProcessHost(Profile* profile) 109 RenderProcessHost::RenderProcessHost(Profile* profile)
93 : max_page_id_(-1), 110 : max_page_id_(-1),
94 fast_shutdown_started_(false), 111 fast_shutdown_started_(false),
95 deleting_soon_(false), 112 deleting_soon_(false),
96 id_(ChildProcessInfo::GenerateChildProcessUniqueId()), 113 id_(ChildProcessInfo::GenerateChildProcessUniqueId()),
97 profile_(profile), 114 profile_(profile),
98 sudden_termination_allowed_(true), 115 sudden_termination_allowed_(true),
99 ignore_input_events_(false) { 116 ignore_input_events_(false) {
100 all_hosts.AddWithID(this, id()); 117 all_hosts.AddWithID(this, id());
101 all_hosts.set_check_on_null_data(true); 118 all_hosts.set_check_on_null_data(true);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 212
196 // Now pick a random suitable renderer, if we have any. 213 // Now pick a random suitable renderer, if we have any.
197 if (!suitable_renderers.empty()) { 214 if (!suitable_renderers.empty()) {
198 int suitable_count = static_cast<int>(suitable_renderers.size()); 215 int suitable_count = static_cast<int>(suitable_renderers.size());
199 int random_index = base::RandInt(0, suitable_count - 1); 216 int random_index = base::RandInt(0, suitable_count - 1);
200 return suitable_renderers[random_index]; 217 return suitable_renderers[random_index];
201 } 218 }
202 219
203 return NULL; 220 return NULL;
204 } 221 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698