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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
7 | 7 |
8 #include "content/browser/renderer_host/browser_render_process_host.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <limits> | 11 #include <limits> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #if defined(OS_POSIX) | 14 #if defined(OS_POSIX) |
15 #include <utility> // for pair<> | 15 #include <utility> // for pair<> |
16 #endif | 16 #endif |
17 | 17 |
18 #include "base/base_switches.h" | 18 #include "base/base_switches.h" |
19 #include "base/bind.h" | 19 #include "base/bind.h" |
20 #include "base/bind_helpers.h" | 20 #include "base/bind_helpers.h" |
21 #include "base/callback.h" | 21 #include "base/callback.h" |
22 #include "base/command_line.h" | 22 #include "base/command_line.h" |
| 23 #include "base/lazy_instance.h" |
23 #include "base/logging.h" | 24 #include "base/logging.h" |
24 #include "base/metrics/field_trial.h" | 25 #include "base/metrics/field_trial.h" |
25 #include "base/metrics/histogram.h" | 26 #include "base/metrics/histogram.h" |
26 #include "base/path_service.h" | 27 #include "base/path_service.h" |
27 #include "base/platform_file.h" | 28 #include "base/platform_file.h" |
| 29 #include "base/rand_util.h" |
28 #include "base/stl_util.h" | 30 #include "base/stl_util.h" |
29 #include "base/string_util.h" | 31 #include "base/string_util.h" |
| 32 #include "base/sys_info.h" |
30 #include "base/threading/thread.h" | 33 #include "base/threading/thread.h" |
31 #include "base/threading/thread_restrictions.h" | 34 #include "base/threading/thread_restrictions.h" |
32 #include "content/browser/appcache/appcache_dispatcher_host.h" | 35 #include "content/browser/appcache/appcache_dispatcher_host.h" |
33 #include "content/browser/browser_child_process_host.h" | 36 #include "content/browser/browser_child_process_host.h" |
34 #include "content/browser/browser_context.h" | 37 #include "content/browser/browser_context.h" |
| 38 #include "content/browser/browser_main.h" |
35 #include "content/browser/child_process_security_policy.h" | 39 #include "content/browser/child_process_security_policy.h" |
36 #include "content/browser/device_orientation/message_filter.h" | 40 #include "content/browser/device_orientation/message_filter.h" |
37 #include "content/browser/download/mhtml_generation_manager.h" | 41 #include "content/browser/download/mhtml_generation_manager.h" |
38 #include "content/browser/file_system/file_system_dispatcher_host.h" | 42 #include "content/browser/file_system/file_system_dispatcher_host.h" |
39 #include "content/browser/geolocation/geolocation_dispatcher_host.h" | 43 #include "content/browser/geolocation/geolocation_dispatcher_host.h" |
40 #include "content/browser/gpu/gpu_data_manager.h" | 44 #include "content/browser/gpu/gpu_data_manager.h" |
41 #include "content/browser/gpu/gpu_process_host.h" | 45 #include "content/browser/gpu/gpu_process_host.h" |
42 #include "content/browser/in_process_webkit/dom_storage_message_filter.h" | 46 #include "content/browser/in_process_webkit/dom_storage_message_filter.h" |
43 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h" | 47 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h" |
44 #include "content/browser/mime_registry_message_filter.h" | 48 #include "content/browser/mime_registry_message_filter.h" |
(...skipping 16 matching lines...) Expand all Loading... |
61 #include "content/browser/renderer_host/render_view_host_delegate.h" | 65 #include "content/browser/renderer_host/render_view_host_delegate.h" |
62 #include "content/browser/renderer_host/render_widget_helper.h" | 66 #include "content/browser/renderer_host/render_widget_helper.h" |
63 #include "content/browser/renderer_host/render_widget_host.h" | 67 #include "content/browser/renderer_host/render_widget_host.h" |
64 #include "content/browser/renderer_host/resource_message_filter.h" | 68 #include "content/browser/renderer_host/resource_message_filter.h" |
65 #include "content/browser/renderer_host/socket_stream_dispatcher_host.h" | 69 #include "content/browser/renderer_host/socket_stream_dispatcher_host.h" |
66 #include "content/browser/renderer_host/text_input_client_message_filter.h" | 70 #include "content/browser/renderer_host/text_input_client_message_filter.h" |
67 #include "content/browser/resolve_proxy_msg_helper.h" | 71 #include "content/browser/resolve_proxy_msg_helper.h" |
68 #include "content/browser/speech/speech_input_dispatcher_host.h" | 72 #include "content/browser/speech/speech_input_dispatcher_host.h" |
69 #include "content/browser/trace_message_filter.h" | 73 #include "content/browser/trace_message_filter.h" |
70 #include "content/browser/user_metrics.h" | 74 #include "content/browser/user_metrics.h" |
| 75 #include "content/browser/webui/web_ui_factory.h" |
71 #include "content/browser/worker_host/worker_message_filter.h" | 76 #include "content/browser/worker_host/worker_message_filter.h" |
72 #include "content/common/child_process_info.h" | 77 #include "content/common/child_process_info.h" |
73 #include "content/common/child_process_messages.h" | 78 #include "content/common/child_process_messages.h" |
74 #include "content/common/gpu/gpu_messages.h" | 79 #include "content/common/gpu/gpu_messages.h" |
75 #include "content/public/browser/notification_service.h" | 80 #include "content/public/browser/notification_service.h" |
76 #include "content/common/process_watcher.h" | 81 #include "content/common/process_watcher.h" |
77 #include "content/common/resource_messages.h" | 82 #include "content/common/resource_messages.h" |
78 #include "content/common/view_messages.h" | 83 #include "content/common/view_messages.h" |
79 #include "content/public/browser/content_browser_client.h" | 84 #include "content/public/browser/content_browser_client.h" |
| 85 #include "content/public/common/content_constants.h" |
80 #include "content/public/common/content_switches.h" | 86 #include "content/public/common/content_switches.h" |
81 #include "content/public/common/result_codes.h" | 87 #include "content/public/common/result_codes.h" |
82 #include "content/renderer/render_process_impl.h" | 88 #include "content/renderer/render_process_impl.h" |
83 #include "content/renderer/render_thread_impl.h" | 89 #include "content/renderer/render_thread_impl.h" |
84 #include "ipc/ipc_logging.h" | 90 #include "ipc/ipc_logging.h" |
85 #include "ipc/ipc_platform_file.h" | 91 #include "ipc/ipc_platform_file.h" |
86 #include "ipc/ipc_switches.h" | 92 #include "ipc/ipc_switches.h" |
87 #include "media/base/media_switches.h" | 93 #include "media/base/media_switches.h" |
88 #include "net/url_request/url_request_context_getter.h" | 94 #include "net/url_request/url_request_context_getter.h" |
89 #include "ui/base/ui_base_switches.h" | 95 #include "ui/base/ui_base_switches.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 return request_context->GetURLRequestContext(); | 182 return request_context->GetURLRequestContext(); |
177 } | 183 } |
178 | 184 |
179 private: | 185 private: |
180 virtual ~RendererURLRequestContextSelector() {} | 186 virtual ~RendererURLRequestContextSelector() {} |
181 | 187 |
182 scoped_refptr<net::URLRequestContextGetter> request_context_; | 188 scoped_refptr<net::URLRequestContextGetter> request_context_; |
183 scoped_refptr<net::URLRequestContextGetter> media_request_context_; | 189 scoped_refptr<net::URLRequestContextGetter> media_request_context_; |
184 }; | 190 }; |
185 | 191 |
| 192 size_t max_renderer_count_override = 0; |
| 193 |
| 194 size_t GetMaxRendererProcessCount() { |
| 195 if (max_renderer_count_override) |
| 196 return max_renderer_count_override; |
| 197 |
| 198 // Defines the maximum number of renderer processes according to the |
| 199 // amount of installed memory as reported by the OS. The table |
| 200 // values are calculated by assuming that you want the renderers to |
| 201 // use half of the installed ram and assuming that each tab uses |
| 202 // ~40MB, however the curve is not linear but piecewise linear with |
| 203 // interleaved slopes of 3 and 2. |
| 204 // If you modify this table you need to adjust browser\browser_uitest.cc |
| 205 // to match the expected number of processes. |
| 206 |
| 207 static const size_t kMaxRenderersByRamTier[] = { |
| 208 3, // less than 256MB |
| 209 6, // 256MB |
| 210 9, // 512MB |
| 211 12, // 768MB |
| 212 14, // 1024MB |
| 213 18, // 1280MB |
| 214 20, // 1536MB |
| 215 22, // 1792MB |
| 216 24, // 2048MB |
| 217 26, // 2304MB |
| 218 29, // 2560MB |
| 219 32, // 2816MB |
| 220 35, // 3072MB |
| 221 38, // 3328MB |
| 222 40 // 3584MB |
| 223 }; |
| 224 |
| 225 static size_t max_count = 0; |
| 226 if (!max_count) { |
| 227 size_t memory_tier = base::SysInfo::AmountOfPhysicalMemoryMB() / 256; |
| 228 if (memory_tier >= arraysize(kMaxRenderersByRamTier)) |
| 229 max_count = content::kMaxRendererProcessCount; |
| 230 else |
| 231 max_count = kMaxRenderersByRamTier[memory_tier]; |
| 232 } |
| 233 return max_count; |
| 234 } |
| 235 |
| 236 // Returns true if the given host is suitable for launching a new view |
| 237 // associated with the given browser context. |
| 238 static bool IsSuitableHost(content::RenderProcessHost* host, |
| 239 content::BrowserContext* browser_context, |
| 240 const GURL& site_url) { |
| 241 if (host->GetBrowserContext() != browser_context) |
| 242 return false; |
| 243 |
| 244 if (ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings( |
| 245 host->GetID()) != |
| 246 content::WebUIFactory::Get()->HasWebUIScheme(site_url)) |
| 247 return false; |
| 248 |
| 249 return content::GetContentClient()->browser()->IsSuitableHost(host, site_url); |
| 250 } |
| 251 |
186 } // namespace | 252 } // namespace |
187 | 253 |
188 BrowserRenderProcessHost::BrowserRenderProcessHost( | 254 // the global list of all renderer processes |
| 255 base::LazyInstance< |
| 256 IDMap<content::RenderProcessHost>, |
| 257 base::LeakyLazyInstanceTraits<IDMap<content::RenderProcessHost> > > |
| 258 g_all_hosts = LAZY_INSTANCE_INITIALIZER; |
| 259 |
| 260 // static |
| 261 bool g_run_renderer_in_process_ = false; |
| 262 |
| 263 // static |
| 264 void content::RenderProcessHost::SetMaxRendererProcessCountForTest( |
| 265 size_t count) { |
| 266 max_renderer_count_override = count; |
| 267 } |
| 268 |
| 269 RenderProcessHostImpl::RenderProcessHostImpl( |
189 content::BrowserContext* browser_context) | 270 content::BrowserContext* browser_context) |
190 : RenderProcessHost(browser_context), | 271 : max_page_id_(-1), |
| 272 fast_shutdown_started_(false), |
| 273 deleting_soon_(false), |
| 274 pending_views_(0), |
191 visible_widgets_(0), | 275 visible_widgets_(0), |
192 backgrounded_(true), | 276 backgrounded_(true), |
193 ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_( | 277 ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_( |
194 FROM_HERE, base::TimeDelta::FromSeconds(5), | 278 FROM_HERE, base::TimeDelta::FromSeconds(5), |
195 this, &BrowserRenderProcessHost::ClearTransportDIBCache)), | 279 this, &RenderProcessHostImpl::ClearTransportDIBCache)), |
196 accessibility_enabled_(false), | 280 accessibility_enabled_(false), |
197 is_initialized_(false) { | 281 is_initialized_(false), |
| 282 id_(ChildProcessInfo::GenerateChildProcessUniqueId()), |
| 283 browser_context_(browser_context), |
| 284 sudden_termination_allowed_(true), |
| 285 ignore_input_events_(false) { |
198 widget_helper_ = new RenderWidgetHelper(); | 286 widget_helper_ = new RenderWidgetHelper(); |
199 | 287 |
200 ChildProcessSecurityPolicy::GetInstance()->Add(id()); | 288 ChildProcessSecurityPolicy::GetInstance()->Add(GetID()); |
201 | 289 |
202 // Grant most file permissions to this renderer. | 290 // Grant most file permissions to this renderer. |
203 // PLATFORM_FILE_TEMPORARY, PLATFORM_FILE_HIDDEN and | 291 // PLATFORM_FILE_TEMPORARY, PLATFORM_FILE_HIDDEN and |
204 // PLATFORM_FILE_DELETE_ON_CLOSE are not granted, because no existing API | 292 // PLATFORM_FILE_DELETE_ON_CLOSE are not granted, because no existing API |
205 // requests them. | 293 // requests them. |
206 // This is for the filesystem sandbox. | 294 // This is for the filesystem sandbox. |
207 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( | 295 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( |
208 id(), browser_context->GetPath().Append( | 296 GetID(), browser_context->GetPath().Append( |
209 fileapi::SandboxMountPointProvider::kNewFileSystemDirectory), | 297 fileapi::SandboxMountPointProvider::kNewFileSystemDirectory), |
210 base::PLATFORM_FILE_OPEN | | 298 base::PLATFORM_FILE_OPEN | |
211 base::PLATFORM_FILE_CREATE | | 299 base::PLATFORM_FILE_CREATE | |
212 base::PLATFORM_FILE_OPEN_ALWAYS | | 300 base::PLATFORM_FILE_OPEN_ALWAYS | |
213 base::PLATFORM_FILE_CREATE_ALWAYS | | 301 base::PLATFORM_FILE_CREATE_ALWAYS | |
214 base::PLATFORM_FILE_OPEN_TRUNCATED | | 302 base::PLATFORM_FILE_OPEN_TRUNCATED | |
215 base::PLATFORM_FILE_READ | | 303 base::PLATFORM_FILE_READ | |
216 base::PLATFORM_FILE_WRITE | | 304 base::PLATFORM_FILE_WRITE | |
217 base::PLATFORM_FILE_EXCLUSIVE_READ | | 305 base::PLATFORM_FILE_EXCLUSIVE_READ | |
218 base::PLATFORM_FILE_EXCLUSIVE_WRITE | | 306 base::PLATFORM_FILE_EXCLUSIVE_WRITE | |
219 base::PLATFORM_FILE_ASYNC | | 307 base::PLATFORM_FILE_ASYNC | |
220 base::PLATFORM_FILE_WRITE_ATTRIBUTES | | 308 base::PLATFORM_FILE_WRITE_ATTRIBUTES | |
221 base::PLATFORM_FILE_ENUMERATE); | 309 base::PLATFORM_FILE_ENUMERATE); |
222 // This is so that we can read and move stuff out of the old filesystem | 310 // This is so that we can read and move stuff out of the old filesystem |
223 // sandbox. | 311 // sandbox. |
224 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( | 312 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( |
225 id(), browser_context->GetPath().Append( | 313 GetID(), browser_context->GetPath().Append( |
226 fileapi::SandboxMountPointProvider::kOldFileSystemDirectory), | 314 fileapi::SandboxMountPointProvider::kOldFileSystemDirectory), |
227 base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE | | 315 base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE | |
228 base::PLATFORM_FILE_WRITE_ATTRIBUTES | base::PLATFORM_FILE_ENUMERATE); | 316 base::PLATFORM_FILE_WRITE_ATTRIBUTES | base::PLATFORM_FILE_ENUMERATE); |
229 // This is so that we can rename the old sandbox out of the way so that we | 317 // This is so that we can rename the old sandbox out of the way so that we |
230 // know we've taken care of it. | 318 // know we've taken care of it. |
231 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( | 319 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( |
232 id(), browser_context->GetPath().Append( | 320 GetID(), browser_context->GetPath().Append( |
233 fileapi::SandboxMountPointProvider::kRenamedOldFileSystemDirectory), | 321 fileapi::SandboxMountPointProvider::kRenamedOldFileSystemDirectory), |
234 base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_CREATE_ALWAYS | | 322 base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_CREATE_ALWAYS | |
235 base::PLATFORM_FILE_WRITE); | 323 base::PLATFORM_FILE_WRITE); |
236 | 324 |
237 // Note: When we create the BrowserRenderProcessHost, it's technically | 325 CHECK(!content::ExitedMainMessageLoop()); |
| 326 g_all_hosts.Get().AddWithID(this, GetID()); |
| 327 g_all_hosts.Get().set_check_on_null_data(true); |
| 328 // Initialize |child_process_activity_time_| to a reasonable value. |
| 329 mark_child_process_activity_time(); |
| 330 // Note: When we create the RenderProcessHostImpl, it's technically |
238 // backgrounded, because it has no visible listeners. But the process | 331 // backgrounded, because it has no visible listeners. But the process |
239 // doesn't actually exist yet, so we'll Background it later, after | 332 // doesn't actually exist yet, so we'll Background it later, after |
240 // creation. | 333 // creation. |
241 } | 334 } |
242 | 335 |
243 BrowserRenderProcessHost::~BrowserRenderProcessHost() { | 336 RenderProcessHostImpl::~RenderProcessHostImpl() { |
244 ChildProcessSecurityPolicy::GetInstance()->Remove(id()); | 337 ChildProcessSecurityPolicy::GetInstance()->Remove(GetID()); |
245 | 338 |
246 // We may have some unsent messages at this point, but that's OK. | 339 // We may have some unsent messages at this point, but that's OK. |
247 channel_.reset(); | 340 channel_.reset(); |
248 while (!queued_messages_.empty()) { | 341 while (!queued_messages_.empty()) { |
249 delete queued_messages_.front(); | 342 delete queued_messages_.front(); |
250 queued_messages_.pop(); | 343 queued_messages_.pop(); |
251 } | 344 } |
252 | 345 |
253 ClearTransportDIBCache(); | 346 ClearTransportDIBCache(); |
| 347 if (g_all_hosts.Get().Lookup(GetID())) |
| 348 g_all_hosts.Get().Remove(GetID()); |
254 } | 349 } |
255 | 350 |
256 void BrowserRenderProcessHost::EnableSendQueue() { | 351 void RenderProcessHostImpl::EnableSendQueue() { |
257 is_initialized_ = false; | 352 is_initialized_ = false; |
258 } | 353 } |
259 | 354 |
260 bool BrowserRenderProcessHost::Init(bool is_accessibility_enabled) { | 355 bool RenderProcessHostImpl::Init(bool is_accessibility_enabled) { |
261 // calling Init() more than once does nothing, this makes it more convenient | 356 // calling Init() more than once does nothing, this makes it more convenient |
262 // for the view host which may not be sure in some cases | 357 // for the view host which may not be sure in some cases |
263 if (channel_.get()) | 358 if (channel_.get()) |
264 return true; | 359 return true; |
265 | 360 |
266 accessibility_enabled_ = is_accessibility_enabled; | 361 accessibility_enabled_ = is_accessibility_enabled; |
267 | 362 |
268 CommandLine::StringType renderer_prefix; | 363 CommandLine::StringType renderer_prefix; |
269 #if defined(OS_POSIX) | 364 #if defined(OS_POSIX) |
270 // A command prefix is something prepended to the command line of the spawned | 365 // A command prefix is something prepended to the command line of the spawned |
(...skipping 17 matching lines...) Expand all Loading... |
288 return false; | 383 return false; |
289 | 384 |
290 // Setup the IPC channel. | 385 // Setup the IPC channel. |
291 const std::string channel_id = | 386 const std::string channel_id = |
292 ChildProcessInfo::GenerateRandomChannelID(this); | 387 ChildProcessInfo::GenerateRandomChannelID(this); |
293 channel_.reset(new IPC::ChannelProxy( | 388 channel_.reset(new IPC::ChannelProxy( |
294 channel_id, IPC::Channel::MODE_SERVER, this, | 389 channel_id, IPC::Channel::MODE_SERVER, this, |
295 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | 390 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); |
296 | 391 |
297 // Call the embedder first so that their IPC filters have priority. | 392 // Call the embedder first so that their IPC filters have priority. |
298 content::GetContentClient()->browser()->BrowserRenderProcessHostCreated(this); | 393 content::GetContentClient()->browser()->RenderProcessHostCreated( |
| 394 this); |
299 | 395 |
300 CreateMessageFilters(); | 396 CreateMessageFilters(); |
301 | 397 |
302 if (run_renderer_in_process()) { | 398 if (run_renderer_in_process()) { |
303 // Crank up a thread and run the initialization there. With the way that | 399 // Crank up a thread and run the initialization there. With the way that |
304 // messages flow between the browser and renderer, this thread is required | 400 // messages flow between the browser and renderer, this thread is required |
305 // to prevent a deadlock in single-process mode. Since the primordial | 401 // to prevent a deadlock in single-process mode. Since the primordial |
306 // thread in the renderer process runs the WebKit code and can sometimes | 402 // thread in the renderer process runs the WebKit code and can sometimes |
307 // make blocking calls to the UI thread (i.e. this thread), they need to run | 403 // make blocking calls to the UI thread (i.e. this thread), they need to run |
308 // on separate threads. | 404 // on separate threads. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 cmd_line, | 439 cmd_line, |
344 this)); | 440 this)); |
345 | 441 |
346 fast_shutdown_started_ = false; | 442 fast_shutdown_started_ = false; |
347 } | 443 } |
348 | 444 |
349 is_initialized_ = true; | 445 is_initialized_ = true; |
350 return true; | 446 return true; |
351 } | 447 } |
352 | 448 |
353 void BrowserRenderProcessHost::CreateMessageFilters() { | 449 void RenderProcessHostImpl::CreateMessageFilters() { |
354 scoped_refptr<RenderMessageFilter> render_message_filter( | 450 scoped_refptr<RenderMessageFilter> render_message_filter( |
355 new RenderMessageFilter( | 451 new RenderMessageFilter( |
356 id(), | 452 GetID(), |
357 PluginService::GetInstance(), | 453 PluginService::GetInstance(), |
358 browser_context(), | 454 GetBrowserContext(), |
359 browser_context()->GetRequestContextForRenderProcess(id()), | 455 GetBrowserContext()->GetRequestContextForRenderProcess(GetID()), |
360 widget_helper_)); | 456 widget_helper_)); |
361 channel_->AddFilter(render_message_filter); | 457 channel_->AddFilter(render_message_filter); |
362 | 458 |
363 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( | 459 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( |
364 id(), ChildProcessInfo::RENDER_PROCESS, | 460 GetID(), ChildProcessInfo::RENDER_PROCESS, |
365 &browser_context()->GetResourceContext(), | 461 &GetBrowserContext()->GetResourceContext(), |
366 new RendererURLRequestContextSelector(browser_context(), id()), | 462 new RendererURLRequestContextSelector(GetBrowserContext(), GetID()), |
367 content::GetContentClient()->browser()->GetResourceDispatcherHost()); | 463 content::GetContentClient()->browser()->GetResourceDispatcherHost()); |
368 | 464 |
369 channel_->AddFilter(resource_message_filter); | 465 channel_->AddFilter(resource_message_filter); |
370 channel_->AddFilter(new AudioInputRendererHost( | 466 channel_->AddFilter(new AudioInputRendererHost( |
371 &browser_context()->GetResourceContext())); | 467 &GetBrowserContext()->GetResourceContext())); |
372 channel_->AddFilter( | 468 channel_->AddFilter( |
373 new AudioRendererHost(&browser_context()->GetResourceContext())); | 469 new AudioRendererHost(&GetBrowserContext()->GetResourceContext())); |
374 channel_->AddFilter( | 470 channel_->AddFilter( |
375 new VideoCaptureHost(&browser_context()->GetResourceContext())); | 471 new VideoCaptureHost(&GetBrowserContext()->GetResourceContext())); |
376 channel_->AddFilter( | 472 channel_->AddFilter( |
377 new AppCacheDispatcherHost(browser_context()->GetAppCacheService(), | 473 new AppCacheDispatcherHost(GetBrowserContext()->GetAppCacheService(), |
378 id())); | 474 GetID())); |
379 channel_->AddFilter(new ClipboardMessageFilter()); | 475 channel_->AddFilter(new ClipboardMessageFilter()); |
380 channel_->AddFilter( | 476 channel_->AddFilter( |
381 new DOMStorageMessageFilter(id(), browser_context()->GetWebKitContext())); | 477 new DOMStorageMessageFilter(GetID(), |
| 478 GetBrowserContext()->GetWebKitContext())); |
382 channel_->AddFilter( | 479 channel_->AddFilter( |
383 new IndexedDBDispatcherHost(id(), browser_context()->GetWebKitContext())); | 480 new IndexedDBDispatcherHost(GetID(), |
| 481 GetBrowserContext()->GetWebKitContext())); |
384 channel_->AddFilter( | 482 channel_->AddFilter( |
385 GeolocationDispatcherHost::New( | 483 GeolocationDispatcherHost::New( |
386 id(), browser_context()->GetGeolocationPermissionContext())); | 484 GetID(), GetBrowserContext()->GetGeolocationPermissionContext())); |
387 channel_->AddFilter(new GpuMessageFilter(id(), widget_helper_.get())); | 485 channel_->AddFilter(new GpuMessageFilter(GetID(), widget_helper_.get())); |
388 channel_->AddFilter(new media_stream::MediaStreamDispatcherHost( | 486 channel_->AddFilter(new media_stream::MediaStreamDispatcherHost( |
389 &browser_context()->GetResourceContext(), id())); | 487 &GetBrowserContext()->GetResourceContext(), GetID())); |
390 channel_->AddFilter(new PepperFileMessageFilter(id(), browser_context())); | 488 channel_->AddFilter(new PepperFileMessageFilter(GetID(), |
| 489 GetBrowserContext())); |
391 channel_->AddFilter( | 490 channel_->AddFilter( |
392 new PepperMessageFilter(&browser_context()->GetResourceContext())); | 491 new PepperMessageFilter(&GetBrowserContext()->GetResourceContext())); |
393 channel_->AddFilter(new speech_input::SpeechInputDispatcherHost( | 492 channel_->AddFilter(new speech_input::SpeechInputDispatcherHost( |
394 id(), browser_context()->GetRequestContext(), | 493 GetID(), GetBrowserContext()->GetRequestContext(), |
395 browser_context()->GetSpeechInputPreferences())); | 494 GetBrowserContext()->GetSpeechInputPreferences())); |
396 channel_->AddFilter( | 495 channel_->AddFilter( |
397 new FileSystemDispatcherHost(browser_context()->GetRequestContext(), | 496 new FileSystemDispatcherHost( |
398 browser_context()->GetFileSystemContext())); | 497 GetBrowserContext()->GetRequestContext(), |
| 498 GetBrowserContext()->GetFileSystemContext())); |
399 channel_->AddFilter(new device_orientation::MessageFilter()); | 499 channel_->AddFilter(new device_orientation::MessageFilter()); |
400 channel_->AddFilter( | 500 channel_->AddFilter( |
401 new BlobMessageFilter(id(), browser_context()->GetBlobStorageContext())); | 501 new BlobMessageFilter(GetID(), |
402 channel_->AddFilter(new FileUtilitiesMessageFilter(id())); | 502 GetBrowserContext()->GetBlobStorageContext())); |
| 503 channel_->AddFilter(new FileUtilitiesMessageFilter(GetID())); |
403 channel_->AddFilter(new MimeRegistryMessageFilter()); | 504 channel_->AddFilter(new MimeRegistryMessageFilter()); |
404 channel_->AddFilter(new DatabaseMessageFilter( | 505 channel_->AddFilter(new DatabaseMessageFilter( |
405 browser_context()->GetDatabaseTracker())); | 506 GetBrowserContext()->GetDatabaseTracker())); |
406 #if defined(OS_MACOSX) | 507 #if defined(OS_MACOSX) |
407 channel_->AddFilter(new TextInputClientMessageFilter(id())); | 508 channel_->AddFilter(new TextInputClientMessageFilter(GetID())); |
408 #endif | 509 #endif |
409 | 510 |
410 SocketStreamDispatcherHost* socket_stream_dispatcher_host = | 511 SocketStreamDispatcherHost* socket_stream_dispatcher_host = |
411 new SocketStreamDispatcherHost( | 512 new SocketStreamDispatcherHost( |
412 new RendererURLRequestContextSelector(browser_context(), id()), | 513 new RendererURLRequestContextSelector(GetBrowserContext(), GetID()), |
413 &browser_context()->GetResourceContext()); | 514 &GetBrowserContext()->GetResourceContext()); |
414 channel_->AddFilter(socket_stream_dispatcher_host); | 515 channel_->AddFilter(socket_stream_dispatcher_host); |
415 | 516 |
416 channel_->AddFilter( | 517 channel_->AddFilter( |
417 new WorkerMessageFilter( | 518 new WorkerMessageFilter( |
418 id(), | 519 GetID(), |
419 &browser_context()->GetResourceContext(), | 520 &GetBrowserContext()->GetResourceContext(), |
420 content::GetContentClient()->browser()->GetResourceDispatcherHost(), | 521 content::GetContentClient()->browser()->GetResourceDispatcherHost(), |
421 base::Bind(&RenderWidgetHelper::GetNextRoutingID, | 522 base::Bind(&RenderWidgetHelper::GetNextRoutingID, |
422 base::Unretained(widget_helper_.get())))); | 523 base::Unretained(widget_helper_.get())))); |
423 | 524 |
424 #if defined(ENABLE_P2P_APIS) | 525 #if defined(ENABLE_P2P_APIS) |
425 channel_->AddFilter(new content::P2PSocketDispatcherHost( | 526 channel_->AddFilter(new content::P2PSocketDispatcherHost( |
426 &browser_context()->GetResourceContext())); | 527 &GetBrowserContext()->GetResourceContext())); |
427 #endif | 528 #endif |
428 | 529 |
429 channel_->AddFilter(new TraceMessageFilter()); | 530 channel_->AddFilter(new TraceMessageFilter()); |
430 channel_->AddFilter(new ResolveProxyMsgHelper( | 531 channel_->AddFilter(new ResolveProxyMsgHelper( |
431 browser_context()->GetRequestContextForRenderProcess(id()))); | 532 GetBrowserContext()->GetRequestContextForRenderProcess(GetID()))); |
432 channel_->AddFilter(new QuotaDispatcherHost( | 533 channel_->AddFilter(new QuotaDispatcherHost( |
433 id(), browser_context()->GetQuotaManager(), | 534 GetID(), GetBrowserContext()->GetQuotaManager(), |
434 content::GetContentClient()->browser()->CreateQuotaPermissionContext())); | 535 content::GetContentClient()->browser()->CreateQuotaPermissionContext())); |
435 } | 536 } |
436 | 537 |
437 int BrowserRenderProcessHost::GetNextRoutingID() { | 538 int RenderProcessHostImpl::GetNextRoutingID() { |
438 return widget_helper_->GetNextRoutingID(); | 539 return widget_helper_->GetNextRoutingID(); |
439 } | 540 } |
440 | 541 |
441 void BrowserRenderProcessHost::CancelResourceRequests(int render_widget_id) { | 542 void RenderProcessHostImpl::UpdateAndSendMaxPageID(int32 page_id) { |
| 543 if (page_id > max_page_id_) |
| 544 Send(new ViewMsg_SetNextPageID(page_id + 1)); |
| 545 UpdateMaxPageID(page_id); |
| 546 } |
| 547 |
| 548 void RenderProcessHostImpl::CancelResourceRequests(int render_widget_id) { |
442 widget_helper_->CancelResourceRequests(render_widget_id); | 549 widget_helper_->CancelResourceRequests(render_widget_id); |
443 } | 550 } |
444 | 551 |
445 void BrowserRenderProcessHost::CrossSiteSwapOutACK( | 552 void RenderProcessHostImpl::CrossSiteSwapOutACK( |
446 const ViewMsg_SwapOut_Params& params) { | 553 const ViewMsg_SwapOut_Params& params) { |
447 widget_helper_->CrossSiteSwapOutACK(params); | 554 widget_helper_->CrossSiteSwapOutACK(params); |
448 } | 555 } |
449 | 556 |
450 bool BrowserRenderProcessHost::WaitForUpdateMsg( | 557 bool RenderProcessHostImpl::WaitForUpdateMsg( |
451 int render_widget_id, | 558 int render_widget_id, |
452 const base::TimeDelta& max_delay, | 559 const base::TimeDelta& max_delay, |
453 IPC::Message* msg) { | 560 IPC::Message* msg) { |
454 // The post task to this thread with the process id could be in queue, and we | 561 // The post task to this thread with the process id could be in queue, and we |
455 // don't want to dispatch a message before then since it will need the handle. | 562 // don't want to dispatch a message before then since it will need the handle. |
456 if (child_process_launcher_.get() && child_process_launcher_->IsStarting()) | 563 if (child_process_launcher_.get() && child_process_launcher_->IsStarting()) |
457 return false; | 564 return false; |
458 | 565 |
459 return widget_helper_->WaitForUpdateMsg(render_widget_id, max_delay, msg); | 566 return widget_helper_->WaitForUpdateMsg(render_widget_id, max_delay, msg); |
460 } | 567 } |
461 | 568 |
462 void BrowserRenderProcessHost::ReceivedBadMessage() { | 569 void RenderProcessHostImpl::ReceivedBadMessage() { |
463 if (run_renderer_in_process()) { | 570 if (run_renderer_in_process()) { |
464 // In single process mode it is better if we don't suicide but just | 571 // In single process mode it is better if we don't suicide but just |
465 // crash. | 572 // crash. |
466 CHECK(false); | 573 CHECK(false); |
467 } | 574 } |
468 NOTREACHED(); | 575 NOTREACHED(); |
469 base::KillProcess(GetHandle(), content::RESULT_CODE_KILLED_BAD_MESSAGE, | 576 base::KillProcess(GetHandle(), content::RESULT_CODE_KILLED_BAD_MESSAGE, |
470 false); | 577 false); |
471 } | 578 } |
472 | 579 |
473 void BrowserRenderProcessHost::WidgetRestored() { | 580 void RenderProcessHostImpl::WidgetRestored() { |
474 // Verify we were properly backgrounded. | 581 // Verify we were properly backgrounded. |
475 DCHECK_EQ(backgrounded_, (visible_widgets_ == 0)); | 582 DCHECK_EQ(backgrounded_, (visible_widgets_ == 0)); |
476 visible_widgets_++; | 583 visible_widgets_++; |
477 SetBackgrounded(false); | 584 SetBackgrounded(false); |
478 } | 585 } |
479 | 586 |
480 void BrowserRenderProcessHost::WidgetHidden() { | 587 void RenderProcessHostImpl::WidgetHidden() { |
481 // On startup, the browser will call Hide | 588 // On startup, the browser will call Hide |
482 if (backgrounded_) | 589 if (backgrounded_) |
483 return; | 590 return; |
484 | 591 |
485 DCHECK_EQ(backgrounded_, (visible_widgets_ == 0)); | 592 DCHECK_EQ(backgrounded_, (visible_widgets_ == 0)); |
486 visible_widgets_--; | 593 visible_widgets_--; |
487 DCHECK_GE(visible_widgets_, 0); | 594 DCHECK_GE(visible_widgets_, 0); |
488 if (visible_widgets_ == 0) { | 595 if (visible_widgets_ == 0) { |
489 DCHECK(!backgrounded_); | 596 DCHECK(!backgrounded_); |
490 SetBackgrounded(true); | 597 SetBackgrounded(true); |
491 } | 598 } |
492 } | 599 } |
493 | 600 |
494 int BrowserRenderProcessHost::VisibleWidgetCount() const { | 601 int RenderProcessHostImpl::VisibleWidgetCount() const { |
495 return visible_widgets_; | 602 return visible_widgets_; |
496 } | 603 } |
497 | 604 |
498 void BrowserRenderProcessHost::AppendRendererCommandLine( | 605 void RenderProcessHostImpl::AppendRendererCommandLine( |
499 CommandLine* command_line) const { | 606 CommandLine* command_line) const { |
500 // Pass the process type first, so it shows first in process listings. | 607 // Pass the process type first, so it shows first in process listings. |
501 command_line->AppendSwitchASCII(switches::kProcessType, | 608 command_line->AppendSwitchASCII(switches::kProcessType, |
502 switches::kRendererProcess); | 609 switches::kRendererProcess); |
503 | 610 |
504 if (accessibility_enabled_) | 611 if (accessibility_enabled_) |
505 command_line->AppendSwitch(switches::kEnableAccessibility); | 612 command_line->AppendSwitch(switches::kEnableAccessibility); |
506 | 613 |
507 // Now send any options from our own command line we want to propagate. | 614 // Now send any options from our own command line we want to propagate. |
508 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 615 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
509 PropagateBrowserCommandLineToRenderer(browser_command_line, command_line); | 616 PropagateBrowserCommandLineToRenderer(browser_command_line, command_line); |
510 | 617 |
511 // Pass on the browser locale. | 618 // Pass on the browser locale. |
512 const std::string locale = | 619 const std::string locale = |
513 content::GetContentClient()->browser()->GetApplicationLocale(); | 620 content::GetContentClient()->browser()->GetApplicationLocale(); |
514 command_line->AppendSwitchASCII(switches::kLang, locale); | 621 command_line->AppendSwitchASCII(switches::kLang, locale); |
515 | 622 |
516 // If we run base::FieldTrials, we want to pass to their state to the | 623 // If we run base::FieldTrials, we want to pass to their state to the |
517 // renderer so that it can act in accordance with each state, or record | 624 // renderer so that it can act in accordance with each state, or record |
518 // histograms relating to the base::FieldTrial states. | 625 // histograms relating to the base::FieldTrial states. |
519 std::string field_trial_states; | 626 std::string field_trial_states; |
520 base::FieldTrialList::StatesToString(&field_trial_states); | 627 base::FieldTrialList::StatesToString(&field_trial_states); |
521 if (!field_trial_states.empty()) { | 628 if (!field_trial_states.empty()) { |
522 command_line->AppendSwitchASCII(switches::kForceFieldTestNameAndValue, | 629 command_line->AppendSwitchASCII(switches::kForceFieldTestNameAndValue, |
523 field_trial_states); | 630 field_trial_states); |
524 } | 631 } |
525 | 632 |
526 content::GetContentClient()->browser()->AppendExtraCommandLineSwitches( | 633 content::GetContentClient()->browser()->AppendExtraCommandLineSwitches( |
527 command_line, id()); | 634 command_line, GetID()); |
528 | 635 |
529 // Appending disable-gpu-feature switches due to software rendering list. | 636 // Appending disable-gpu-feature switches due to software rendering list. |
530 GpuDataManager* gpu_data_manager = GpuDataManager::GetInstance(); | 637 GpuDataManager* gpu_data_manager = GpuDataManager::GetInstance(); |
531 DCHECK(gpu_data_manager); | 638 DCHECK(gpu_data_manager); |
532 gpu_data_manager->AppendRendererCommandLine(command_line); | 639 gpu_data_manager->AppendRendererCommandLine(command_line); |
533 } | 640 } |
534 | 641 |
535 void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer( | 642 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( |
536 const CommandLine& browser_cmd, | 643 const CommandLine& browser_cmd, |
537 CommandLine* renderer_cmd) const { | 644 CommandLine* renderer_cmd) const { |
538 // Propagate the following switches to the renderer command line (along | 645 // Propagate the following switches to the renderer command line (along |
539 // with any associated values) if present in the browser command line. | 646 // with any associated values) if present in the browser command line. |
540 static const char* const kSwitchNames[] = { | 647 static const char* const kSwitchNames[] = { |
541 // We propagate the Chrome Frame command line here as well in case the | 648 // We propagate the Chrome Frame command line here as well in case the |
542 // renderer is not run in the sandbox. | 649 // renderer is not run in the sandbox. |
543 switches::kAuditAllHandles, | 650 switches::kAuditAllHandles, |
544 switches::kAuditHandles, | 651 switches::kAuditHandles, |
545 switches::kChromeFrame, | 652 switches::kChromeFrame, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 switches::kUserAgent, | 730 switches::kUserAgent, |
624 switches::kV, | 731 switches::kV, |
625 switches::kVideoThreads, | 732 switches::kVideoThreads, |
626 switches::kVModule, | 733 switches::kVModule, |
627 switches::kWebCoreLogChannels, | 734 switches::kWebCoreLogChannels, |
628 }; | 735 }; |
629 renderer_cmd->CopySwitchesFrom(browser_cmd, kSwitchNames, | 736 renderer_cmd->CopySwitchesFrom(browser_cmd, kSwitchNames, |
630 arraysize(kSwitchNames)); | 737 arraysize(kSwitchNames)); |
631 | 738 |
632 // Disable databases in incognito mode. | 739 // Disable databases in incognito mode. |
633 if (browser_context()->IsOffTheRecord() && | 740 if (GetBrowserContext()->IsOffTheRecord() && |
634 !browser_cmd.HasSwitch(switches::kDisableDatabases)) { | 741 !browser_cmd.HasSwitch(switches::kDisableDatabases)) { |
635 renderer_cmd->AppendSwitch(switches::kDisableDatabases); | 742 renderer_cmd->AppendSwitch(switches::kDisableDatabases); |
636 } | 743 } |
637 } | 744 } |
638 | 745 |
639 base::ProcessHandle BrowserRenderProcessHost::GetHandle() { | 746 base::ProcessHandle RenderProcessHostImpl::GetHandle() { |
640 // child_process_launcher_ is null either because we're in single process | 747 // child_process_launcher_ is null either because we're in single process |
641 // mode, we have done fast termination, or the process has crashed. | 748 // mode, we have done fast termination, or the process has crashed. |
642 if (run_renderer_in_process() || !child_process_launcher_.get()) | 749 if (run_renderer_in_process() || !child_process_launcher_.get()) |
643 return base::Process::Current().handle(); | 750 return base::Process::Current().handle(); |
644 | 751 |
645 if (child_process_launcher_->IsStarting()) | 752 if (child_process_launcher_->IsStarting()) |
646 return base::kNullProcessHandle; | 753 return base::kNullProcessHandle; |
647 | 754 |
648 return child_process_launcher_->GetHandle(); | 755 return child_process_launcher_->GetHandle(); |
649 } | 756 } |
650 | 757 |
651 bool BrowserRenderProcessHost::FastShutdownIfPossible() { | 758 bool RenderProcessHostImpl::FastShutdownIfPossible() { |
652 if (run_renderer_in_process()) | 759 if (run_renderer_in_process()) |
653 return false; // Single process mode can't do fast shutdown. | 760 return false; // Single process mode can't do fast shutdown. |
654 | 761 |
655 if (!content::GetContentClient()->browser()->IsFastShutdownPossible()) | 762 if (!content::GetContentClient()->browser()->IsFastShutdownPossible()) |
656 return false; | 763 return false; |
657 | 764 |
658 if (!child_process_launcher_.get() || | 765 if (!child_process_launcher_.get() || |
659 child_process_launcher_->IsStarting() || | 766 child_process_launcher_->IsStarting() || |
660 !GetHandle()) | 767 !GetHandle()) |
661 return false; // Render process hasn't started or is probably crashed. | 768 return false; // Render process hasn't started or is probably crashed. |
662 | 769 |
663 // Test if there's an unload listener. | 770 // Test if there's an unload listener. |
664 // NOTE: It's possible that an onunload listener may be installed | 771 // NOTE: It's possible that an onunload listener may be installed |
665 // while we're shutting down, so there's a small race here. Given that | 772 // while we're shutting down, so there's a small race here. Given that |
666 // the window is small, it's unlikely that the web page has much | 773 // the window is small, it's unlikely that the web page has much |
667 // state that will be lost by not calling its unload handlers properly. | 774 // state that will be lost by not calling its unload handlers properly. |
668 if (!sudden_termination_allowed()) | 775 if (!SuddenTerminationAllowed()) |
669 return false; | 776 return false; |
670 | 777 |
671 // Store the handle before it gets changed. | 778 // Store the handle before it gets changed. |
672 base::ProcessHandle handle = GetHandle(); | 779 base::ProcessHandle handle = GetHandle(); |
673 ProcessDied(handle, base::TERMINATION_STATUS_NORMAL_TERMINATION, 0, false); | 780 ProcessDied(handle, base::TERMINATION_STATUS_NORMAL_TERMINATION, 0, false); |
674 fast_shutdown_started_ = true; | 781 fast_shutdown_started_ = true; |
675 return true; | 782 return true; |
676 } | 783 } |
677 | 784 |
678 void BrowserRenderProcessHost::DumpHandles() { | 785 void RenderProcessHostImpl::DumpHandles() { |
679 #if defined(OS_WIN) | 786 #if defined(OS_WIN) |
680 Send(new ChildProcessMsg_DumpHandles()); | 787 Send(new ChildProcessMsg_DumpHandles()); |
681 return; | 788 return; |
682 #endif | 789 #endif |
683 | 790 |
684 NOTIMPLEMENTED(); | 791 NOTIMPLEMENTED(); |
685 } | 792 } |
686 | 793 |
687 // This is a platform specific function for mapping a transport DIB given its id | 794 // This is a platform specific function for mapping a transport DIB given its id |
688 TransportDIB* BrowserRenderProcessHost::MapTransportDIB( | 795 TransportDIB* RenderProcessHostImpl::MapTransportDIB( |
689 TransportDIB::Id dib_id) { | 796 TransportDIB::Id dib_id) { |
690 #if defined(OS_WIN) | 797 #if defined(OS_WIN) |
691 // On Windows we need to duplicate the handle from the remote process | 798 // On Windows we need to duplicate the handle from the remote process |
692 HANDLE section = chrome::GetSectionFromProcess( | 799 HANDLE section = chrome::GetSectionFromProcess( |
693 dib_id.handle, GetHandle(), false /* read write */); | 800 dib_id.handle, GetHandle(), false /* read write */); |
694 return TransportDIB::Map(section); | 801 return TransportDIB::Map(section); |
695 #elif defined(OS_MACOSX) | 802 #elif defined(OS_MACOSX) |
696 // On OSX, the browser allocates all DIBs and keeps a file descriptor around | 803 // On OSX, the browser allocates all DIBs and keeps a file descriptor around |
697 // for each. | 804 // for each. |
698 return widget_helper_->MapTransportDIB(dib_id); | 805 return widget_helper_->MapTransportDIB(dib_id); |
699 #elif defined(OS_POSIX) | 806 #elif defined(OS_POSIX) |
700 return TransportDIB::Map(dib_id.shmkey); | 807 return TransportDIB::Map(dib_id.shmkey); |
701 #endif // defined(OS_POSIX) | 808 #endif // defined(OS_POSIX) |
702 } | 809 } |
703 | 810 |
704 TransportDIB* BrowserRenderProcessHost::GetTransportDIB( | 811 TransportDIB* RenderProcessHostImpl::GetTransportDIB( |
705 TransportDIB::Id dib_id) { | 812 TransportDIB::Id dib_id) { |
706 if (!TransportDIB::is_valid_id(dib_id)) | 813 if (!TransportDIB::is_valid_id(dib_id)) |
707 return NULL; | 814 return NULL; |
708 | 815 |
709 const std::map<TransportDIB::Id, TransportDIB*>::iterator | 816 const std::map<TransportDIB::Id, TransportDIB*>::iterator |
710 i = cached_dibs_.find(dib_id); | 817 i = cached_dibs_.find(dib_id); |
711 if (i != cached_dibs_.end()) { | 818 if (i != cached_dibs_.end()) { |
712 cached_dibs_cleaner_.Reset(); | 819 cached_dibs_cleaner_.Reset(); |
713 return i->second; | 820 return i->second; |
714 } | 821 } |
(...skipping 17 matching lines...) Expand all Loading... |
732 | 839 |
733 delete smallest_iterator->second; | 840 delete smallest_iterator->second; |
734 cached_dibs_.erase(smallest_iterator); | 841 cached_dibs_.erase(smallest_iterator); |
735 } | 842 } |
736 | 843 |
737 cached_dibs_[dib_id] = dib; | 844 cached_dibs_[dib_id] = dib; |
738 cached_dibs_cleaner_.Reset(); | 845 cached_dibs_cleaner_.Reset(); |
739 return dib; | 846 return dib; |
740 } | 847 } |
741 | 848 |
742 void BrowserRenderProcessHost::ClearTransportDIBCache() { | 849 void RenderProcessHostImpl::ClearTransportDIBCache() { |
743 STLDeleteContainerPairSecondPointers( | 850 STLDeleteContainerPairSecondPointers( |
744 cached_dibs_.begin(), cached_dibs_.end()); | 851 cached_dibs_.begin(), cached_dibs_.end()); |
745 cached_dibs_.clear(); | 852 cached_dibs_.clear(); |
746 } | 853 } |
747 | 854 |
748 void BrowserRenderProcessHost::SetCompositingSurface( | 855 void RenderProcessHostImpl::SetCompositingSurface( |
749 int render_widget_id, | 856 int render_widget_id, |
750 gfx::PluginWindowHandle compositing_surface) { | 857 gfx::PluginWindowHandle compositing_surface) { |
751 widget_helper_->SetCompositingSurface(render_widget_id, compositing_surface); | 858 widget_helper_->SetCompositingSurface(render_widget_id, compositing_surface); |
752 } | 859 } |
753 | 860 |
754 bool BrowserRenderProcessHost::Send(IPC::Message* msg) { | 861 bool RenderProcessHostImpl::Send(IPC::Message* msg) { |
755 if (!channel_.get()) { | 862 if (!channel_.get()) { |
756 if (!is_initialized_) { | 863 if (!is_initialized_) { |
757 queued_messages_.push(msg); | 864 queued_messages_.push(msg); |
758 return true; | 865 return true; |
759 } else { | 866 } else { |
760 delete msg; | 867 delete msg; |
761 return false; | 868 return false; |
762 } | 869 } |
763 } | 870 } |
764 | 871 |
765 if (child_process_launcher_.get() && child_process_launcher_->IsStarting()) { | 872 if (child_process_launcher_.get() && child_process_launcher_->IsStarting()) { |
766 queued_messages_.push(msg); | 873 queued_messages_.push(msg); |
767 return true; | 874 return true; |
768 } | 875 } |
769 | 876 |
770 return channel_->Send(msg); | 877 return channel_->Send(msg); |
771 } | 878 } |
772 | 879 |
773 bool BrowserRenderProcessHost::OnMessageReceived(const IPC::Message& msg) { | 880 bool RenderProcessHostImpl::OnMessageReceived(const IPC::Message& msg) { |
774 // If we're about to be deleted, or have initiated the fast shutdown sequence, | 881 // If we're about to be deleted, or have initiated the fast shutdown sequence, |
775 // we ignore incoming messages. | 882 // we ignore incoming messages. |
776 | 883 |
777 if (deleting_soon_ || fast_shutdown_started_) | 884 if (deleting_soon_ || fast_shutdown_started_) |
778 return false; | 885 return false; |
779 | 886 |
780 mark_child_process_activity_time(); | 887 mark_child_process_activity_time(); |
781 if (msg.routing_id() == MSG_ROUTING_CONTROL) { | 888 if (msg.routing_id() == MSG_ROUTING_CONTROL) { |
782 // Dispatch control messages. | 889 // Dispatch control messages. |
783 bool msg_is_ok = true; | 890 bool msg_is_ok = true; |
784 IPC_BEGIN_MESSAGE_MAP_EX(BrowserRenderProcessHost, msg, msg_is_ok) | 891 IPC_BEGIN_MESSAGE_MAP_EX(RenderProcessHostImpl, msg, msg_is_ok) |
785 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest, | 892 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest, |
786 OnShutdownRequest) | 893 OnShutdownRequest) |
787 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DumpHandlesDone, | 894 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DumpHandlesDone, |
788 OnDumpHandlesDone) | 895 OnDumpHandlesDone) |
789 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged, | 896 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged, |
790 SuddenTerminationChanged) | 897 SuddenTerminationChanged) |
791 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, | 898 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, |
792 OnUserMetricsRecordAction) | 899 OnUserMetricsRecordAction) |
793 IPC_MESSAGE_HANDLER(ViewHostMsg_RevealFolderInOS, OnRevealFolderInOS) | 900 IPC_MESSAGE_HANDLER(ViewHostMsg_RevealFolderInOS, OnRevealFolderInOS) |
794 IPC_MESSAGE_HANDLER(ViewHostMsg_SavedPageAsMHTML, OnSavedPageAsMHTML) | 901 IPC_MESSAGE_HANDLER(ViewHostMsg_SavedPageAsMHTML, OnSavedPageAsMHTML) |
(...skipping 18 matching lines...) Expand all Loading... |
813 // hang waiting for a reply. | 920 // hang waiting for a reply. |
814 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); | 921 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); |
815 reply->set_reply_error(); | 922 reply->set_reply_error(); |
816 Send(reply); | 923 Send(reply); |
817 } | 924 } |
818 return true; | 925 return true; |
819 } | 926 } |
820 return listener->OnMessageReceived(msg); | 927 return listener->OnMessageReceived(msg); |
821 } | 928 } |
822 | 929 |
823 void BrowserRenderProcessHost::OnChannelConnected(int32 peer_pid) { | 930 void RenderProcessHostImpl::OnChannelConnected(int32 peer_pid) { |
824 #if defined(IPC_MESSAGE_LOG_ENABLED) | 931 #if defined(IPC_MESSAGE_LOG_ENABLED) |
825 Send(new ChildProcessMsg_SetIPCLoggingEnabled( | 932 Send(new ChildProcessMsg_SetIPCLoggingEnabled( |
826 IPC::Logging::GetInstance()->Enabled())); | 933 IPC::Logging::GetInstance()->Enabled())); |
827 #endif | 934 #endif |
828 | 935 |
829 // Make sure the child checks with us before exiting, so that we do not try | 936 // Make sure the child checks with us before exiting, so that we do not try |
830 // to schedule a new navigation in a swapped out and exiting renderer. | 937 // to schedule a new navigation in a swapped out and exiting renderer. |
831 Send(new ChildProcessMsg_AskBeforeShutdown()); | 938 Send(new ChildProcessMsg_AskBeforeShutdown()); |
832 } | 939 } |
833 | 940 |
834 void BrowserRenderProcessHost::OnChannelError() { | 941 void RenderProcessHostImpl::OnChannelError() { |
835 if (!channel_.get()) | 942 if (!channel_.get()) |
836 return; | 943 return; |
837 | 944 |
838 // Store the handle before it gets changed. | 945 // Store the handle before it gets changed. |
839 base::ProcessHandle handle = GetHandle(); | 946 base::ProcessHandle handle = GetHandle(); |
840 | 947 |
841 // child_process_launcher_ can be NULL in single process mode or if fast | 948 // child_process_launcher_ can be NULL in single process mode or if fast |
842 // termination happened. | 949 // termination happened. |
843 int exit_code = 0; | 950 int exit_code = 0; |
844 base::TerminationStatus status = | 951 base::TerminationStatus status = |
845 child_process_launcher_.get() ? | 952 child_process_launcher_.get() ? |
846 child_process_launcher_->GetChildTerminationStatus(&exit_code) : | 953 child_process_launcher_->GetChildTerminationStatus(&exit_code) : |
847 base::TERMINATION_STATUS_NORMAL_TERMINATION; | 954 base::TERMINATION_STATUS_NORMAL_TERMINATION; |
848 | 955 |
849 #if defined(OS_WIN) | 956 #if defined(OS_WIN) |
850 if (!run_renderer_in_process()) { | 957 if (!run_renderer_in_process()) { |
851 if (status == base::TERMINATION_STATUS_STILL_RUNNING) { | 958 if (status == base::TERMINATION_STATUS_STILL_RUNNING) { |
852 HANDLE process = child_process_launcher_->GetHandle(); | 959 HANDLE process = child_process_launcher_->GetHandle(); |
853 child_process_watcher_.StartWatching( | 960 child_process_watcher_.StartWatching( |
854 new base::WaitableEvent(process), this); | 961 new base::WaitableEvent(process), this); |
855 return; | 962 return; |
856 } | 963 } |
857 } | 964 } |
858 #endif | 965 #endif |
859 ProcessDied(handle, status, exit_code, false); | 966 ProcessDied(handle, status, exit_code, false); |
860 } | 967 } |
861 | 968 |
862 // Called when the renderer process handle has been signaled. | 969 // Called when the renderer process handle has been signaled. |
863 void BrowserRenderProcessHost::OnWaitableEventSignaled( | 970 void RenderProcessHostImpl::OnWaitableEventSignaled( |
864 base::WaitableEvent* waitable_event) { | 971 base::WaitableEvent* waitable_event) { |
865 #if defined (OS_WIN) | 972 #if defined (OS_WIN) |
866 base::ProcessHandle handle = GetHandle(); | 973 base::ProcessHandle handle = GetHandle(); |
867 int exit_code = 0; | 974 int exit_code = 0; |
868 base::TerminationStatus status = | 975 base::TerminationStatus status = |
869 base::GetTerminationStatus(waitable_event->Release(), &exit_code); | 976 base::GetTerminationStatus(waitable_event->Release(), &exit_code); |
870 delete waitable_event; | 977 delete waitable_event; |
871 ProcessDied(handle, status, exit_code, true); | 978 ProcessDied(handle, status, exit_code, true); |
872 #endif | 979 #endif |
873 } | 980 } |
874 | 981 |
875 void BrowserRenderProcessHost::ProcessDied(base::ProcessHandle handle, | 982 content::BrowserContext* RenderProcessHostImpl::GetBrowserContext() const { |
| 983 return browser_context_; |
| 984 } |
| 985 |
| 986 int RenderProcessHostImpl::GetID() const { |
| 987 return id_; |
| 988 } |
| 989 |
| 990 bool RenderProcessHostImpl::HasConnection() const { |
| 991 return channel_.get() != NULL; |
| 992 } |
| 993 |
| 994 IPC::Channel::Listener* RenderProcessHostImpl::GetListenerByID( |
| 995 int routing_id) { |
| 996 return listeners_.Lookup(routing_id); |
| 997 } |
| 998 |
| 999 void RenderProcessHostImpl::SetIgnoreInputEvents(bool ignore_input_events) { |
| 1000 ignore_input_events_ = ignore_input_events; |
| 1001 } |
| 1002 |
| 1003 bool RenderProcessHostImpl::IgnoreInputEvents() const { |
| 1004 return ignore_input_events_; |
| 1005 } |
| 1006 |
| 1007 void RenderProcessHostImpl::Attach(IPC::Channel::Listener* listener, |
| 1008 int routing_id) { |
| 1009 listeners_.AddWithID(listener, routing_id); |
| 1010 } |
| 1011 |
| 1012 void RenderProcessHostImpl::Release(int listener_id) { |
| 1013 DCHECK(listeners_.Lookup(listener_id) != NULL); |
| 1014 listeners_.Remove(listener_id); |
| 1015 |
| 1016 // Make sure that all associated resource requests are stopped. |
| 1017 CancelResourceRequests(listener_id); |
| 1018 |
| 1019 #if defined(OS_WIN) |
| 1020 // Dump the handle table if handle auditing is enabled. |
| 1021 const CommandLine& browser_command_line = |
| 1022 *CommandLine::ForCurrentProcess(); |
| 1023 if (browser_command_line.HasSwitch(switches::kAuditHandles) || |
| 1024 browser_command_line.HasSwitch(switches::kAuditAllHandles)) { |
| 1025 DumpHandles(); |
| 1026 |
| 1027 // We wait to close the channels until the child process has finished |
| 1028 // dumping handles and sends us ChildProcessHostMsg_DumpHandlesDone. |
| 1029 return; |
| 1030 } |
| 1031 #endif |
| 1032 Cleanup(); |
| 1033 } |
| 1034 |
| 1035 void RenderProcessHostImpl::Cleanup() { |
| 1036 // When no other owners of this object, we can delete ourselves |
| 1037 if (listeners_.IsEmpty()) { |
| 1038 content::NotificationService::current()->Notify( |
| 1039 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| 1040 content::Source<RenderProcessHost>(this), |
| 1041 content::NotificationService::NoDetails()); |
| 1042 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 1043 deleting_soon_ = true; |
| 1044 // It's important not to wait for the DeleteTask to delete the channel |
| 1045 // proxy. Kill it off now. That way, in case the profile is going away, the |
| 1046 // rest of the objects attached to this RenderProcessHost start going |
| 1047 // away first, since deleting the channel proxy will post a |
| 1048 // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. |
| 1049 channel_.reset(); |
| 1050 |
| 1051 // Remove ourself from the list of renderer processes so that we can't be |
| 1052 // reused in between now and when the Delete task runs. |
| 1053 g_all_hosts.Get().Remove(GetID()); |
| 1054 } |
| 1055 } |
| 1056 |
| 1057 void RenderProcessHostImpl::ReportExpectingClose(int32 listener_id) { |
| 1058 listeners_expecting_close_.insert(listener_id); |
| 1059 } |
| 1060 |
| 1061 void RenderProcessHostImpl::AddPendingView() { |
| 1062 pending_views_++; |
| 1063 } |
| 1064 |
| 1065 void RenderProcessHostImpl::RemovePendingView() { |
| 1066 DCHECK(pending_views_); |
| 1067 pending_views_--; |
| 1068 } |
| 1069 |
| 1070 void RenderProcessHostImpl::UpdateMaxPageID(int32 page_id) { |
| 1071 if (page_id > max_page_id_) |
| 1072 max_page_id_ = page_id; |
| 1073 } |
| 1074 |
| 1075 void RenderProcessHostImpl::SetSuddenTerminationAllowed(bool enabled) { |
| 1076 sudden_termination_allowed_ = enabled; |
| 1077 } |
| 1078 |
| 1079 bool RenderProcessHostImpl::SuddenTerminationAllowed() const { |
| 1080 return sudden_termination_allowed_; |
| 1081 } |
| 1082 |
| 1083 base::TimeDelta RenderProcessHostImpl::GetChildProcessIdleTime() const { |
| 1084 return base::TimeTicks::Now() - child_process_activity_time_; |
| 1085 } |
| 1086 |
| 1087 IPC::ChannelProxy* RenderProcessHostImpl::GetChannel() { |
| 1088 return channel_.get(); |
| 1089 } |
| 1090 |
| 1091 content::RenderProcessHost::listeners_iterator |
| 1092 RenderProcessHostImpl::ListenersIterator() { |
| 1093 return listeners_iterator(&listeners_); |
| 1094 } |
| 1095 |
| 1096 bool RenderProcessHostImpl::FastShutdownForPageCount(size_t count) { |
| 1097 if (listeners_.size() == count) |
| 1098 return FastShutdownIfPossible(); |
| 1099 return false; |
| 1100 } |
| 1101 |
| 1102 bool RenderProcessHostImpl::FastShutdownStarted() const { |
| 1103 return fast_shutdown_started_; |
| 1104 } |
| 1105 |
| 1106 // static |
| 1107 bool content::RenderProcessHost::run_renderer_in_process() { |
| 1108 return g_run_renderer_in_process_; |
| 1109 } |
| 1110 |
| 1111 void content::RenderProcessHost::set_run_renderer_in_process(bool value) { |
| 1112 g_run_renderer_in_process_ = value; |
| 1113 } |
| 1114 |
| 1115 content::RenderProcessHost::iterator |
| 1116 content::RenderProcessHost::AllHostsIterator() { |
| 1117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1118 return iterator(g_all_hosts.Pointer()); |
| 1119 } |
| 1120 |
| 1121 // static |
| 1122 content::RenderProcessHost* content::RenderProcessHost::FromID( |
| 1123 int render_process_id) { |
| 1124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1125 return g_all_hosts.Get().Lookup(render_process_id); |
| 1126 } |
| 1127 |
| 1128 // static |
| 1129 bool content::RenderProcessHost::ShouldTryToUseExistingProcessHost() { |
| 1130 size_t renderer_process_count = g_all_hosts.Get().size(); |
| 1131 |
| 1132 // NOTE: Sometimes it's necessary to create more render processes than |
| 1133 // GetMaxRendererProcessCount(), for instance when we want to create |
| 1134 // a renderer process for a browser context that has no existing |
| 1135 // renderers. This is OK in moderation, since the |
| 1136 // GetMaxRendererProcessCount() is conservative. |
| 1137 |
| 1138 return run_renderer_in_process() || |
| 1139 (renderer_process_count >= GetMaxRendererProcessCount()); |
| 1140 } |
| 1141 |
| 1142 // static |
| 1143 content::RenderProcessHost* |
| 1144 content::RenderProcessHost::GetExistingProcessHost( |
| 1145 content::BrowserContext* browser_context, |
| 1146 const GURL& site_url) { |
| 1147 // First figure out which existing renderers we can use. |
| 1148 std::vector<content::RenderProcessHost*> suitable_renderers; |
| 1149 suitable_renderers.reserve(g_all_hosts.Get().size()); |
| 1150 |
| 1151 iterator iter(AllHostsIterator()); |
| 1152 while (!iter.IsAtEnd()) { |
| 1153 if (run_renderer_in_process() || |
| 1154 IsSuitableHost( |
| 1155 iter.GetCurrentValue(), |
| 1156 browser_context, site_url)) |
| 1157 suitable_renderers.push_back(iter.GetCurrentValue()); |
| 1158 |
| 1159 iter.Advance(); |
| 1160 } |
| 1161 |
| 1162 // Now pick a random suitable renderer, if we have any. |
| 1163 if (!suitable_renderers.empty()) { |
| 1164 int suitable_count = static_cast<int>(suitable_renderers.size()); |
| 1165 int random_index = base::RandInt(0, suitable_count - 1); |
| 1166 return suitable_renderers[random_index]; |
| 1167 } |
| 1168 |
| 1169 return NULL; |
| 1170 } |
| 1171 |
| 1172 void RenderProcessHostImpl::ProcessDied(base::ProcessHandle handle, |
876 base::TerminationStatus status, | 1173 base::TerminationStatus status, |
877 int exit_code, | 1174 int exit_code, |
878 bool was_alive) { | 1175 bool was_alive) { |
879 // Our child process has died. If we didn't expect it, it's a crash. | 1176 // Our child process has died. If we didn't expect it, it's a crash. |
880 // In any case, we need to let everyone know it's gone. | 1177 // In any case, we need to let everyone know it's gone. |
881 // The OnChannelError notification can fire multiple times due to nested sync | 1178 // The OnChannelError notification can fire multiple times due to nested sync |
882 // calls to a renderer. If we don't have a valid channel here it means we | 1179 // calls to a renderer. If we don't have a valid channel here it means we |
883 // already handled the error. | 1180 // already handled the error. |
884 | 1181 |
885 RendererClosedDetails details(handle, status, exit_code, was_alive); | 1182 RendererClosedDetails details(handle, status, exit_code, was_alive); |
(...skipping 13 matching lines...) Expand all Loading... |
899 exit_code)); | 1196 exit_code)); |
900 iter.Advance(); | 1197 iter.Advance(); |
901 } | 1198 } |
902 | 1199 |
903 ClearTransportDIBCache(); | 1200 ClearTransportDIBCache(); |
904 | 1201 |
905 // this object is not deleted at this point and may be reused later. | 1202 // this object is not deleted at this point and may be reused later. |
906 // TODO(darin): clean this up | 1203 // TODO(darin): clean this up |
907 } | 1204 } |
908 | 1205 |
909 void BrowserRenderProcessHost::OnShutdownRequest() { | 1206 void RenderProcessHostImpl::OnShutdownRequest() { |
910 // Don't shutdown if there are pending RenderViews being swapped back in. | 1207 // Don't shutdown if there are pending RenderViews being swapped back in. |
911 if (pending_views_) | 1208 if (pending_views_) |
912 return; | 1209 return; |
913 | 1210 |
914 // Notify any tabs that might have swapped out renderers from this process. | 1211 // Notify any tabs that might have swapped out renderers from this process. |
915 // They should not attempt to swap them back in. | 1212 // They should not attempt to swap them back in. |
916 content::NotificationService::current()->Notify( | 1213 content::NotificationService::current()->Notify( |
917 content::NOTIFICATION_RENDERER_PROCESS_CLOSING, | 1214 content::NOTIFICATION_RENDERER_PROCESS_CLOSING, |
918 content::Source<RenderProcessHost>(this), | 1215 content::Source<RenderProcessHost>(this), |
919 content::NotificationService::NoDetails()); | 1216 content::NotificationService::NoDetails()); |
920 | 1217 |
921 Send(new ChildProcessMsg_Shutdown()); | 1218 Send(new ChildProcessMsg_Shutdown()); |
922 } | 1219 } |
923 | 1220 |
924 void BrowserRenderProcessHost::OnDumpHandlesDone() { | 1221 void RenderProcessHostImpl::SuddenTerminationChanged(bool enabled) { |
| 1222 SetSuddenTerminationAllowed(enabled); |
| 1223 } |
| 1224 |
| 1225 void RenderProcessHostImpl::OnDumpHandlesDone() { |
925 Cleanup(); | 1226 Cleanup(); |
926 } | 1227 } |
927 | 1228 |
928 void BrowserRenderProcessHost::SuddenTerminationChanged(bool enabled) { | 1229 void RenderProcessHostImpl::SetBackgrounded(bool backgrounded) { |
929 set_sudden_termination_allowed(enabled); | |
930 } | |
931 | |
932 void BrowserRenderProcessHost::SetBackgrounded(bool backgrounded) { | |
933 // Note: we always set the backgrounded_ value. If the process is NULL | 1230 // Note: we always set the backgrounded_ value. If the process is NULL |
934 // (and hence hasn't been created yet), we will set the process priority | 1231 // (and hence hasn't been created yet), we will set the process priority |
935 // later when we create the process. | 1232 // later when we create the process. |
936 backgrounded_ = backgrounded; | 1233 backgrounded_ = backgrounded; |
937 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) | 1234 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) |
938 return; | 1235 return; |
939 | 1236 |
940 #if defined(OS_WIN) | 1237 #if defined(OS_WIN) |
941 // The cbstext.dll loads as a global GetMessage hook in the browser process | 1238 // The cbstext.dll loads as a global GetMessage hook in the browser process |
942 // and intercepts/unintercepts the kernel32 API SetPriorityClass in a | 1239 // and intercepts/unintercepts the kernel32 API SetPriorityClass in a |
943 // background thread. If the UI thread invokes this API just when it is | 1240 // background thread. If the UI thread invokes this API just when it is |
944 // intercepted the stack is messed up on return from the interceptor | 1241 // intercepted the stack is messed up on return from the interceptor |
945 // which causes random crashes in the browser process. Our hack for now | 1242 // which causes random crashes in the browser process. Our hack for now |
946 // is to not invoke the SetPriorityClass API if the dll is loaded. | 1243 // is to not invoke the SetPriorityClass API if the dll is loaded. |
947 if (GetModuleHandle(L"cbstext.dll")) | 1244 if (GetModuleHandle(L"cbstext.dll")) |
948 return; | 1245 return; |
949 #endif // OS_WIN | 1246 #endif // OS_WIN |
950 | 1247 |
951 child_process_launcher_->SetProcessBackgrounded(backgrounded); | 1248 child_process_launcher_->SetProcessBackgrounded(backgrounded); |
952 } | 1249 } |
953 | 1250 |
954 void BrowserRenderProcessHost::OnProcessLaunched() { | 1251 void RenderProcessHostImpl::OnProcessLaunched() { |
955 // No point doing anything, since this object will be destructed soon. We | 1252 // No point doing anything, since this object will be destructed soon. We |
956 // especially don't want to send the RENDERER_PROCESS_CREATED notification, | 1253 // especially don't want to send the RENDERER_PROCESS_CREATED notification, |
957 // since some clients might expect a RENDERER_PROCESS_TERMINATED afterwards to | 1254 // since some clients might expect a RENDERER_PROCESS_TERMINATED afterwards to |
958 // properly cleanup. | 1255 // properly cleanup. |
959 if (deleting_soon_) | 1256 if (deleting_soon_) |
960 return; | 1257 return; |
961 | 1258 |
962 if (child_process_launcher_.get()) { | 1259 if (child_process_launcher_.get()) { |
963 if (!child_process_launcher_->GetHandle()) { | 1260 if (!child_process_launcher_->GetHandle()) { |
964 OnChannelError(); | 1261 OnChannelError(); |
(...skipping 17 matching lines...) Expand all Loading... |
982 content::NOTIFICATION_RENDERER_PROCESS_CREATED, | 1279 content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
983 content::Source<RenderProcessHost>(this), | 1280 content::Source<RenderProcessHost>(this), |
984 content::NotificationService::NoDetails()); | 1281 content::NotificationService::NoDetails()); |
985 | 1282 |
986 while (!queued_messages_.empty()) { | 1283 while (!queued_messages_.empty()) { |
987 Send(queued_messages_.front()); | 1284 Send(queued_messages_.front()); |
988 queued_messages_.pop(); | 1285 queued_messages_.pop(); |
989 } | 1286 } |
990 } | 1287 } |
991 | 1288 |
992 void BrowserRenderProcessHost::OnUserMetricsRecordAction( | 1289 void RenderProcessHostImpl::OnUserMetricsRecordAction( |
993 const std::string& action) { | 1290 const std::string& action) { |
994 UserMetrics::RecordComputedAction(action); | 1291 UserMetrics::RecordComputedAction(action); |
995 } | 1292 } |
996 | 1293 |
997 void BrowserRenderProcessHost::OnRevealFolderInOS(const FilePath& path) { | 1294 void RenderProcessHostImpl::OnRevealFolderInOS(const FilePath& path) { |
998 // Only honor the request if appropriate persmissions are granted. | 1295 // Only honor the request if appropriate persmissions are granted. |
999 if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(id(), path)) | 1296 if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(GetID(), path)) |
1000 content::GetContentClient()->browser()->OpenItem(path); | 1297 content::GetContentClient()->browser()->OpenItem(path); |
1001 } | 1298 } |
1002 | 1299 |
1003 void BrowserRenderProcessHost::OnSavedPageAsMHTML(int job_id, int64 data_size) { | 1300 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) { |
1004 content::GetContentClient()->browser()->GetMHTMLGenerationManager()-> | 1301 content::GetContentClient()->browser()->GetMHTMLGenerationManager()-> |
1005 MHTMLGenerated(job_id, data_size); | 1302 MHTMLGenerated(job_id, data_size); |
1006 } | 1303 } |
OLD | NEW |