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