| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // 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/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 } | 252 } |
| 253 | 253 |
| 254 void GetContexts( | 254 void GetContexts( |
| 255 ResourceContext* resource_context, | 255 ResourceContext* resource_context, |
| 256 scoped_refptr<net::URLRequestContextGetter> request_context, | 256 scoped_refptr<net::URLRequestContextGetter> request_context, |
| 257 scoped_refptr<net::URLRequestContextGetter> media_request_context, | 257 scoped_refptr<net::URLRequestContextGetter> media_request_context, |
| 258 const ResourceHostMsg_Request& request, | 258 const ResourceHostMsg_Request& request, |
| 259 ResourceContext** resource_context_out, | 259 ResourceContext** resource_context_out, |
| 260 net::URLRequestContext** request_context_out) { | 260 net::URLRequestContext** request_context_out) { |
| 261 *resource_context_out = resource_context; | 261 *resource_context_out = resource_context; |
| 262 *request_context_out = GetRequestContext( | 262 *request_context_out = |
| 263 request_context, media_request_context, request.resource_type); | 263 GetRequestContext(request_context, media_request_context, |
| 264 request.resource_type); |
| 264 } | 265 } |
| 265 | 266 |
| 266 #if defined(ENABLE_WEBRTC) | 267 #if defined(ENABLE_WEBRTC) |
| 267 | 268 |
| 268 // Allow us to only run the trial in the first renderer. | 269 // Allow us to only run the trial in the first renderer. |
| 269 bool has_done_stun_trials = false; | 270 bool has_done_stun_trials = false; |
| 270 | 271 |
| 271 // Creates a file used for diagnostic echo canceller recordings for handing | 272 // Creates a file used for diagnostic echo canceller recordings for handing |
| 272 // over to the renderer. | 273 // over to the renderer. |
| 273 IPC::PlatformFileForTransit CreateAecDumpFileForProcess( | 274 IPC::PlatformFileForTransit CreateAecDumpFileForProcess( |
| 274 base::FilePath file_path, | 275 base::FilePath file_path, |
| 275 base::ProcessHandle process) { | 276 base::ProcessHandle process) { |
| 276 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 277 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 277 base::File dump_file(file_path, | 278 base::File dump_file(file_path, |
| 278 base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_APPEND); | 279 base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_APPEND); |
| 279 if (!dump_file.IsValid()) { | 280 if (!dump_file.IsValid()) { |
| 280 VLOG(1) << "Could not open AEC dump file, error=" | 281 VLOG(1) << "Could not open AEC dump file, error=" << |
| 281 << dump_file.error_details(); | 282 dump_file.error_details(); |
| 282 return IPC::InvalidPlatformFileForTransit(); | 283 return IPC::InvalidPlatformFileForTransit(); |
| 283 } | 284 } |
| 284 return IPC::TakeFileHandleForProcess(dump_file.Pass(), process); | 285 return IPC::TakeFileHandleForProcess(dump_file.Pass(), process); |
| 285 } | 286 } |
| 286 | 287 |
| 287 // Does nothing. Just to avoid races between enable and disable. | 288 // Does nothing. Just to avoid races between enable and disable. |
| 288 void DisableAecDumpOnFileThread() { | 289 void DisableAecDumpOnFileThread() { |
| 289 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 290 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 290 } | 291 } |
| 291 #endif | 292 #endif |
| 292 | 293 |
| 293 // the global list of all renderer processes | 294 // the global list of all renderer processes |
| 294 base::LazyInstance<IDMap<RenderProcessHost>>::Leaky g_all_hosts = | 295 base::LazyInstance<IDMap<RenderProcessHost> >::Leaky |
| 295 LAZY_INSTANCE_INITIALIZER; | 296 g_all_hosts = LAZY_INSTANCE_INITIALIZER; |
| 296 | 297 |
| 297 // Map of site to process, to ensure we only have one RenderProcessHost per | 298 // Map of site to process, to ensure we only have one RenderProcessHost per |
| 298 // site in process-per-site mode. Each map is specific to a BrowserContext. | 299 // site in process-per-site mode. Each map is specific to a BrowserContext. |
| 299 class SiteProcessMap : public base::SupportsUserData::Data { | 300 class SiteProcessMap : public base::SupportsUserData::Data { |
| 300 public: | 301 public: |
| 301 typedef base::hash_map<std::string, RenderProcessHost*> SiteToProcessMap; | 302 typedef base::hash_map<std::string, RenderProcessHost*> SiteToProcessMap; |
| 302 SiteProcessMap() {} | 303 SiteProcessMap() {} |
| 303 | 304 |
| 304 void RegisterProcess(const std::string& site, RenderProcessHost* process) { | 305 void RegisterProcess(const std::string& site, RenderProcessHost* process) { |
| 305 map_[site] = process; | 306 map_[site] = process; |
| 306 } | 307 } |
| 307 | 308 |
| 308 RenderProcessHost* FindProcess(const std::string& site) { | 309 RenderProcessHost* FindProcess(const std::string& site) { |
| 309 SiteToProcessMap::iterator i = map_.find(site); | 310 SiteToProcessMap::iterator i = map_.find(site); |
| 310 if (i != map_.end()) | 311 if (i != map_.end()) |
| 311 return i->second; | 312 return i->second; |
| 312 return NULL; | 313 return NULL; |
| 313 } | 314 } |
| 314 | 315 |
| 315 void RemoveProcess(RenderProcessHost* host) { | 316 void RemoveProcess(RenderProcessHost* host) { |
| 316 // Find all instances of this process in the map, then separately remove | 317 // Find all instances of this process in the map, then separately remove |
| 317 // them. | 318 // them. |
| 318 std::set<std::string> sites; | 319 std::set<std::string> sites; |
| 319 for (SiteToProcessMap::const_iterator i = map_.begin(); i != map_.end(); | 320 for (SiteToProcessMap::const_iterator i = map_.begin(); |
| 321 i != map_.end(); |
| 320 i++) { | 322 i++) { |
| 321 if (i->second == host) | 323 if (i->second == host) |
| 322 sites.insert(i->first); | 324 sites.insert(i->first); |
| 323 } | 325 } |
| 324 for (std::set<std::string>::iterator i = sites.begin(); i != sites.end(); | 326 for (std::set<std::string>::iterator i = sites.begin(); |
| 327 i != sites.end(); |
| 325 i++) { | 328 i++) { |
| 326 SiteToProcessMap::iterator iter = map_.find(*i); | 329 SiteToProcessMap::iterator iter = map_.find(*i); |
| 327 if (iter != map_.end()) { | 330 if (iter != map_.end()) { |
| 328 DCHECK_EQ(iter->second, host); | 331 DCHECK_EQ(iter->second, host); |
| 329 map_.erase(iter); | 332 map_.erase(iter); |
| 330 } | 333 } |
| 331 } | 334 } |
| 332 } | 335 } |
| 333 | 336 |
| 334 private: | 337 private: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 348 } | 351 } |
| 349 | 352 |
| 350 // NOTE: changes to this class need to be reviewed by the security team. | 353 // NOTE: changes to this class need to be reviewed by the security team. |
| 351 class RendererSandboxedProcessLauncherDelegate | 354 class RendererSandboxedProcessLauncherDelegate |
| 352 : public SandboxedProcessLauncherDelegate { | 355 : public SandboxedProcessLauncherDelegate { |
| 353 public: | 356 public: |
| 354 explicit RendererSandboxedProcessLauncherDelegate(IPC::ChannelProxy* channel) | 357 explicit RendererSandboxedProcessLauncherDelegate(IPC::ChannelProxy* channel) |
| 355 #if defined(OS_POSIX) | 358 #if defined(OS_POSIX) |
| 356 : ipc_fd_(channel->TakeClientFileDescriptor()) | 359 : ipc_fd_(channel->TakeClientFileDescriptor()) |
| 357 #endif // OS_POSIX | 360 #endif // OS_POSIX |
| 358 { | 361 {} |
| 359 } | |
| 360 | 362 |
| 361 ~RendererSandboxedProcessLauncherDelegate() override {} | 363 ~RendererSandboxedProcessLauncherDelegate() override {} |
| 362 | 364 |
| 363 #if defined(OS_WIN) | 365 #if defined(OS_WIN) |
| 364 void PreSpawnTarget(sandbox::TargetPolicy* policy, bool* success) override { | 366 void PreSpawnTarget(sandbox::TargetPolicy* policy, bool* success) override { |
| 365 AddBaseHandleClosePolicy(policy); | 367 AddBaseHandleClosePolicy(policy); |
| 366 | 368 |
| 367 const base::string16& sid = | 369 const base::string16& sid = |
| 368 GetContentClient()->browser()->GetAppContainerSidForSandboxType( | 370 GetContentClient()->browser()->GetAppContainerSidForSandboxType( |
| 369 GetSandboxType()); | 371 GetSandboxType()); |
| 370 if (!sid.empty()) | 372 if (!sid.empty()) |
| 371 AddAppContainerPolicy(policy, sid.c_str()); | 373 AddAppContainerPolicy(policy, sid.c_str()); |
| 372 | 374 |
| 373 GetContentClient()->browser()->PreSpawnRenderer(policy, success); | 375 GetContentClient()->browser()->PreSpawnRenderer(policy, success); |
| 374 } | 376 } |
| 375 | 377 |
| 376 #elif defined(OS_POSIX) | 378 #elif defined(OS_POSIX) |
| 377 bool ShouldUseZygote() override { | 379 bool ShouldUseZygote() override { |
| 378 const base::CommandLine& browser_command_line = | 380 const base::CommandLine& browser_command_line = |
| 379 *base::CommandLine::ForCurrentProcess(); | 381 *base::CommandLine::ForCurrentProcess(); |
| 380 base::CommandLine::StringType renderer_prefix = | 382 base::CommandLine::StringType renderer_prefix = |
| 381 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); | 383 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); |
| 382 return renderer_prefix.empty(); | 384 return renderer_prefix.empty(); |
| 383 } | 385 } |
| 384 base::ScopedFD TakeIpcFd() override { return ipc_fd_.Pass(); } | 386 base::ScopedFD TakeIpcFd() override { return ipc_fd_.Pass(); } |
| 385 #endif // OS_WIN | 387 #endif // OS_WIN |
| 386 | 388 |
| 387 SandboxType GetSandboxType() override { return SANDBOX_TYPE_RENDERER; } | 389 SandboxType GetSandboxType() override { |
| 390 return SANDBOX_TYPE_RENDERER; |
| 391 } |
| 388 | 392 |
| 389 private: | 393 private: |
| 390 #if defined(OS_POSIX) | 394 #if defined(OS_POSIX) |
| 391 base::ScopedFD ipc_fd_; | 395 base::ScopedFD ipc_fd_; |
| 392 #endif // OS_POSIX | 396 #endif // OS_POSIX |
| 393 }; | 397 }; |
| 394 | 398 |
| 395 const char kSessionStorageHolderKey[] = "kSessionStorageHolderKey"; | 399 const char kSessionStorageHolderKey[] = "kSessionStorageHolderKey"; |
| 396 | 400 |
| 397 class SessionStorageHolder : public base::SupportsUserData::Data { | 401 class SessionStorageHolder : public base::SupportsUserData::Data { |
| 398 public: | 402 public: |
| 399 SessionStorageHolder() {} | 403 SessionStorageHolder() {} |
| 400 ~SessionStorageHolder() override {} | 404 ~SessionStorageHolder() override {} |
| 401 | 405 |
| 402 void Hold(const SessionStorageNamespaceMap& sessions, int view_route_id) { | 406 void Hold(const SessionStorageNamespaceMap& sessions, int view_route_id) { |
| 403 session_storage_namespaces_awaiting_close_[view_route_id] = sessions; | 407 session_storage_namespaces_awaiting_close_[view_route_id] = sessions; |
| 404 } | 408 } |
| 405 | 409 |
| 406 void Release(int old_route_id) { | 410 void Release(int old_route_id) { |
| 407 session_storage_namespaces_awaiting_close_.erase(old_route_id); | 411 session_storage_namespaces_awaiting_close_.erase(old_route_id); |
| 408 } | 412 } |
| 409 | 413 |
| 410 private: | 414 private: |
| 411 std::map<int, SessionStorageNamespaceMap> | 415 std::map<int, SessionStorageNamespaceMap > |
| 412 session_storage_namespaces_awaiting_close_; | 416 session_storage_namespaces_awaiting_close_; |
| 413 DISALLOW_COPY_AND_ASSIGN(SessionStorageHolder); | 417 DISALLOW_COPY_AND_ASSIGN(SessionStorageHolder); |
| 414 }; | 418 }; |
| 415 | 419 |
| 416 std::string UintVectorToString(const std::vector<unsigned>& vector) { | 420 std::string UintVectorToString(const std::vector<unsigned>& vector) { |
| 417 std::string str; | 421 std::string str; |
| 418 for (auto it : vector) { | 422 for (auto it : vector) { |
| 419 if (!str.empty()) | 423 if (!str.empty()) |
| 420 str += ","; | 424 str += ","; |
| 421 str += base::UintToString(it); | 425 str += base::UintToString(it); |
| 422 } | 426 } |
| 423 return str; | 427 return str; |
| 424 } | 428 } |
| 425 | 429 |
| 426 } // namespace | 430 } // namespace |
| 427 | 431 |
| 428 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; | 432 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; |
| 429 | 433 |
| 430 base::MessageLoop* g_in_process_thread; | 434 base::MessageLoop* g_in_process_thread; |
| 431 | 435 |
| 432 base::MessageLoop* | 436 base::MessageLoop* |
| 433 RenderProcessHostImpl::GetInProcessRendererThreadForTesting() { | 437 RenderProcessHostImpl::GetInProcessRendererThreadForTesting() { |
| 434 return g_in_process_thread; | 438 return g_in_process_thread; |
| 435 } | 439 } |
| 436 | 440 |
| 437 // Stores the maximum number of renderer processes the content module can | 441 // Stores the maximum number of renderer processes the content module can |
| 438 // create. | 442 // create. |
| 439 static size_t g_max_renderer_count_override = 0; | 443 static size_t g_max_renderer_count_override = 0; |
| 440 | 444 |
| 441 // static | 445 // static |
| 442 size_t RenderProcessHost::GetMaxRendererProcessCount() { | 446 size_t RenderProcessHost::GetMaxRendererProcessCount() { |
| 443 if (g_max_renderer_count_override) | 447 if (g_max_renderer_count_override) |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 StoragePartitionImpl* storage_partition_impl, | 501 StoragePartitionImpl* storage_partition_impl, |
| 498 bool is_for_guests_only) | 502 bool is_for_guests_only) |
| 499 : fast_shutdown_started_(false), | 503 : fast_shutdown_started_(false), |
| 500 deleting_soon_(false), | 504 deleting_soon_(false), |
| 501 #ifndef NDEBUG | 505 #ifndef NDEBUG |
| 502 is_self_deleted_(false), | 506 is_self_deleted_(false), |
| 503 #endif | 507 #endif |
| 504 pending_views_(0), | 508 pending_views_(0), |
| 505 mojo_application_host_(new MojoApplicationHost), | 509 mojo_application_host_(new MojoApplicationHost), |
| 506 visible_widgets_(0), | 510 visible_widgets_(0), |
| 507 is_process_backgrounded_(false), | 511 backgrounded_(true), |
| 508 is_initialized_(false), | 512 is_initialized_(false), |
| 509 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 513 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
| 510 browser_context_(browser_context), | 514 browser_context_(browser_context), |
| 511 storage_partition_impl_(storage_partition_impl), | 515 storage_partition_impl_(storage_partition_impl), |
| 512 sudden_termination_allowed_(true), | 516 sudden_termination_allowed_(true), |
| 513 ignore_input_events_(false), | 517 ignore_input_events_(false), |
| 514 is_for_guests_only_(is_for_guests_only), | 518 is_for_guests_only_(is_for_guests_only), |
| 515 gpu_observer_registered_(false), | 519 gpu_observer_registered_(false), |
| 516 delayed_cleanup_needed_(false), | 520 delayed_cleanup_needed_(false), |
| 517 within_process_died_observer_(false), | 521 within_process_died_observer_(false), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 542 storage_partition_impl_->GetPath())); | 546 storage_partition_impl_->GetPath())); |
| 543 } | 547 } |
| 544 subscribe_uniform_enabled_ = | 548 subscribe_uniform_enabled_ = |
| 545 base::CommandLine::ForCurrentProcess()->HasSwitch( | 549 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 546 switches::kEnableSubscribeUniformExtension); | 550 switches::kEnableSubscribeUniformExtension); |
| 547 | 551 |
| 548 #if defined(OS_MACOSX) | 552 #if defined(OS_MACOSX) |
| 549 if (BootstrapSandboxManager::ShouldEnable()) | 553 if (BootstrapSandboxManager::ShouldEnable()) |
| 550 AddObserver(BootstrapSandboxManager::GetInstance()); | 554 AddObserver(BootstrapSandboxManager::GetInstance()); |
| 551 #endif | 555 #endif |
| 556 |
| 557 // Note: When we create the RenderProcessHostImpl, it's technically |
| 558 // backgrounded, because it has no visible listeners. But the process |
| 559 // doesn't actually exist yet, so we'll Background it later, after |
| 560 // creation. |
| 552 } | 561 } |
| 553 | 562 |
| 554 // static | 563 // static |
| 555 void RenderProcessHostImpl::ShutDownInProcessRenderer() { | 564 void RenderProcessHostImpl::ShutDownInProcessRenderer() { |
| 556 DCHECK(g_run_renderer_in_process_); | 565 DCHECK(g_run_renderer_in_process_); |
| 557 | 566 |
| 558 switch (g_all_hosts.Pointer()->size()) { | 567 switch (g_all_hosts.Pointer()->size()) { |
| 559 case 0: | 568 case 0: |
| 560 return; | 569 return; |
| 561 case 1: { | 570 case 1: { |
| 562 RenderProcessHostImpl* host = static_cast<RenderProcessHostImpl*>( | 571 RenderProcessHostImpl* host = static_cast<RenderProcessHostImpl*>( |
| 563 AllHostsIterator().GetCurrentValue()); | 572 AllHostsIterator().GetCurrentValue()); |
| 564 FOR_EACH_OBSERVER(RenderProcessHostObserver, host->observers_, | 573 FOR_EACH_OBSERVER(RenderProcessHostObserver, |
| 574 host->observers_, |
| 565 RenderProcessHostDestroyed(host)); | 575 RenderProcessHostDestroyed(host)); |
| 566 #ifndef NDEBUG | 576 #ifndef NDEBUG |
| 567 host->is_self_deleted_ = true; | 577 host->is_self_deleted_ = true; |
| 568 #endif | 578 #endif |
| 569 delete host; | 579 delete host; |
| 570 return; | 580 return; |
| 571 } | 581 } |
| 572 default: | 582 default: |
| 573 NOTREACHED() << "There should be only one RenderProcessHost when running " | 583 NOTREACHED() << "There should be only one RenderProcessHost when running " |
| 574 << "in-process."; | 584 << "in-process."; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 600 // We may have some unsent messages at this point, but that's OK. | 610 // We may have some unsent messages at this point, but that's OK. |
| 601 channel_.reset(); | 611 channel_.reset(); |
| 602 while (!queued_messages_.empty()) { | 612 while (!queued_messages_.empty()) { |
| 603 delete queued_messages_.front(); | 613 delete queued_messages_.front(); |
| 604 queued_messages_.pop(); | 614 queued_messages_.pop(); |
| 605 } | 615 } |
| 606 | 616 |
| 607 UnregisterHost(GetID()); | 617 UnregisterHost(GetID()); |
| 608 | 618 |
| 609 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 619 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 610 switches::kDisableGpuShaderDiskCache)) { | 620 switches::kDisableGpuShaderDiskCache)) { |
| 611 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 621 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 612 base::Bind(&RemoveShaderInfo, GetID())); | 622 base::Bind(&RemoveShaderInfo, GetID())); |
| 613 } | 623 } |
| 614 } | 624 } |
| 615 | 625 |
| 616 void RenderProcessHostImpl::EnableSendQueue() { | 626 void RenderProcessHostImpl::EnableSendQueue() { |
| 617 is_initialized_ = false; | 627 is_initialized_ = false; |
| 618 } | 628 } |
| 619 | 629 |
| 620 bool RenderProcessHostImpl::Init() { | 630 bool RenderProcessHostImpl::Init() { |
| 621 // calling Init() more than once does nothing, this makes it more convenient | 631 // calling Init() more than once does nothing, this makes it more convenient |
| 622 // for the view host which may not be sure in some cases | 632 // for the view host which may not be sure in some cases |
| 623 if (channel_) | 633 if (channel_) |
| 624 return true; | 634 return true; |
| 625 | 635 |
| 626 base::CommandLine::StringType renderer_prefix; | 636 base::CommandLine::StringType renderer_prefix; |
| 627 // A command prefix is something prepended to the command line of the spawned | 637 // A command prefix is something prepended to the command line of the spawned |
| 628 // process. | 638 // process. |
| 629 const base::CommandLine& browser_command_line = | 639 const base::CommandLine& browser_command_line = |
| 630 *base::CommandLine::ForCurrentProcess(); | 640 *base::CommandLine::ForCurrentProcess(); |
| 631 renderer_prefix = | 641 renderer_prefix = |
| 632 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); | 642 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); |
| 633 | 643 |
| 634 #if defined(OS_LINUX) | 644 #if defined(OS_LINUX) |
| 635 int flags = renderer_prefix.empty() ? ChildProcessHost::CHILD_ALLOW_SELF | 645 int flags = renderer_prefix.empty() ? ChildProcessHost::CHILD_ALLOW_SELF : |
| 636 : ChildProcessHost::CHILD_NORMAL; | 646 ChildProcessHost::CHILD_NORMAL; |
| 637 #else | 647 #else |
| 638 int flags = ChildProcessHost::CHILD_NORMAL; | 648 int flags = ChildProcessHost::CHILD_NORMAL; |
| 639 #endif | 649 #endif |
| 640 | 650 |
| 641 // Find the renderer before creating the channel so if this fails early we | 651 // Find the renderer before creating the channel so if this fails early we |
| 642 // return without creating the channel. | 652 // return without creating the channel. |
| 643 base::FilePath renderer_path = ChildProcessHost::GetChildPath(flags); | 653 base::FilePath renderer_path = ChildProcessHost::GetChildPath(flags); |
| 644 if (renderer_path.empty()) | 654 if (renderer_path.empty()) |
| 645 return false; | 655 return false; |
| 646 | 656 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 664 if (run_renderer_in_process()) { | 674 if (run_renderer_in_process()) { |
| 665 DCHECK(g_renderer_main_thread_factory); | 675 DCHECK(g_renderer_main_thread_factory); |
| 666 // Crank up a thread and run the initialization there. With the way that | 676 // Crank up a thread and run the initialization there. With the way that |
| 667 // messages flow between the browser and renderer, this thread is required | 677 // messages flow between the browser and renderer, this thread is required |
| 668 // to prevent a deadlock in single-process mode. Since the primordial | 678 // to prevent a deadlock in single-process mode. Since the primordial |
| 669 // thread in the renderer process runs the WebKit code and can sometimes | 679 // thread in the renderer process runs the WebKit code and can sometimes |
| 670 // make blocking calls to the UI thread (i.e. this thread), they need to run | 680 // make blocking calls to the UI thread (i.e. this thread), they need to run |
| 671 // on separate threads. | 681 // on separate threads. |
| 672 in_process_renderer_.reset( | 682 in_process_renderer_.reset( |
| 673 g_renderer_main_thread_factory(InProcessChildThreadParams( | 683 g_renderer_main_thread_factory(InProcessChildThreadParams( |
| 674 channel_id, | 684 channel_id, BrowserThread::UnsafeGetMessageLoopForThread( |
| 675 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO) | 685 BrowserThread::IO)->task_runner()))); |
| 676 ->task_runner()))); | |
| 677 | 686 |
| 678 base::Thread::Options options; | 687 base::Thread::Options options; |
| 679 #if defined(OS_WIN) && !defined(OS_MACOSX) | 688 #if defined(OS_WIN) && !defined(OS_MACOSX) |
| 680 // In-process plugins require this to be a UI message loop. | 689 // In-process plugins require this to be a UI message loop. |
| 681 options.message_loop_type = base::MessageLoop::TYPE_UI; | 690 options.message_loop_type = base::MessageLoop::TYPE_UI; |
| 682 #else | 691 #else |
| 683 // We can't have multiple UI loops on Linux and Android, so we don't support | 692 // We can't have multiple UI loops on Linux and Android, so we don't support |
| 684 // in-process plugins. | 693 // in-process plugins. |
| 685 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; | 694 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; |
| 686 #endif | 695 #endif |
| (...skipping 14 matching lines...) Expand all Loading... |
| 701 base::CommandLine* cmd_line = new base::CommandLine(renderer_path); | 710 base::CommandLine* cmd_line = new base::CommandLine(renderer_path); |
| 702 if (!renderer_prefix.empty()) | 711 if (!renderer_prefix.empty()) |
| 703 cmd_line->PrependWrapper(renderer_prefix); | 712 cmd_line->PrependWrapper(renderer_prefix); |
| 704 AppendRendererCommandLine(cmd_line); | 713 AppendRendererCommandLine(cmd_line); |
| 705 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); | 714 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
| 706 | 715 |
| 707 // Spawn the child process asynchronously to avoid blocking the UI thread. | 716 // Spawn the child process asynchronously to avoid blocking the UI thread. |
| 708 // As long as there's no renderer prefix, we can use the zygote process | 717 // As long as there's no renderer prefix, we can use the zygote process |
| 709 // at this stage. | 718 // at this stage. |
| 710 child_process_launcher_.reset(new ChildProcessLauncher( | 719 child_process_launcher_.reset(new ChildProcessLauncher( |
| 711 new RendererSandboxedProcessLauncherDelegate(channel_.get()), cmd_line, | 720 new RendererSandboxedProcessLauncherDelegate(channel_.get()), |
| 712 GetID(), this)); | 721 cmd_line, |
| 722 GetID(), |
| 723 this)); |
| 713 | 724 |
| 714 fast_shutdown_started_ = false; | 725 fast_shutdown_started_ = false; |
| 715 } | 726 } |
| 716 | 727 |
| 717 if (!gpu_observer_registered_) { | 728 if (!gpu_observer_registered_) { |
| 718 gpu_observer_registered_ = true; | 729 gpu_observer_registered_ = true; |
| 719 ui::GpuSwitchingManager::GetInstance()->AddObserver(this); | 730 ui::GpuSwitchingManager::GetInstance()->AddObserver(this); |
| 720 } | 731 } |
| 721 | 732 |
| 722 power_monitor_broadcaster_.Init(); | 733 power_monitor_broadcaster_.Init(); |
| 723 | 734 |
| 724 is_initialized_ = true; | 735 is_initialized_ = true; |
| 725 init_time_ = base::TimeTicks::Now(); | 736 init_time_ = base::TimeTicks::Now(); |
| 726 return true; | 737 return true; |
| 727 } | 738 } |
| 728 | 739 |
| 729 scoped_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( | 740 scoped_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( |
| 730 const std::string& channel_id) { | 741 const std::string& channel_id) { |
| 731 scoped_refptr<base::SingleThreadTaskRunner> runner = | 742 scoped_refptr<base::SingleThreadTaskRunner> runner = |
| 732 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 743 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| 733 scoped_refptr<base::SequencedTaskRunner> mojo_task_runner = | 744 scoped_refptr<base::SequencedTaskRunner> mojo_task_runner = |
| 734 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO) | 745 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO) |
| 735 ->task_runner(); | 746 ->task_runner(); |
| 736 if (ShouldUseMojoChannel()) { | 747 if (ShouldUseMojoChannel()) { |
| 737 VLOG(1) << "Mojo Channel is enabled on host"; | 748 VLOG(1) << "Mojo Channel is enabled on host"; |
| 738 | 749 |
| 739 return IPC::ChannelProxy::Create( | 750 return IPC::ChannelProxy::Create( |
| 740 IPC::ChannelMojo::CreateServerFactory(mojo_task_runner, channel_id), | 751 IPC::ChannelMojo::CreateServerFactory(mojo_task_runner, channel_id), |
| 741 this, runner.get()); | 752 this, runner.get()); |
| 742 } | 753 } |
| 743 | 754 |
| 744 return IPC::ChannelProxy::Create(channel_id, IPC::Channel::MODE_SERVER, this, | 755 return IPC::ChannelProxy::Create(channel_id, IPC::Channel::MODE_SERVER, this, |
| 745 runner.get()); | 756 runner.get()); |
| 746 } | 757 } |
| 747 | 758 |
| 748 void RenderProcessHostImpl::CreateMessageFilters() { | 759 void RenderProcessHostImpl::CreateMessageFilters() { |
| 749 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 760 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 750 const base::CommandLine& browser_command_line = | 761 const base::CommandLine& browser_command_line = |
| 751 *base::CommandLine::ForCurrentProcess(); | 762 *base::CommandLine::ForCurrentProcess(); |
| 752 AddFilter(new ResourceSchedulerFilter(GetID())); | 763 AddFilter(new ResourceSchedulerFilter(GetID())); |
| 753 MediaInternals* media_internals = MediaInternals::GetInstance(); | 764 MediaInternals* media_internals = MediaInternals::GetInstance(); |
| 754 media::AudioManager* audio_manager = | 765 media::AudioManager* audio_manager = |
| 755 BrowserMainLoop::GetInstance()->audio_manager(); | 766 BrowserMainLoop::GetInstance()->audio_manager(); |
| 756 // Add BrowserPluginMessageFilter to ensure it gets the first stab at messages | 767 // Add BrowserPluginMessageFilter to ensure it gets the first stab at messages |
| 757 // from guests. | 768 // from guests. |
| 758 scoped_refptr<BrowserPluginMessageFilter> bp_message_filter( | 769 scoped_refptr<BrowserPluginMessageFilter> bp_message_filter( |
| 759 new BrowserPluginMessageFilter(GetID())); | 770 new BrowserPluginMessageFilter(GetID())); |
| 760 AddFilter(bp_message_filter.get()); | 771 AddFilter(bp_message_filter.get()); |
| 761 | 772 |
| 762 scoped_refptr<RenderMessageFilter> render_message_filter( | 773 scoped_refptr<RenderMessageFilter> render_message_filter( |
| 763 new RenderMessageFilter( | 774 new RenderMessageFilter( |
| 764 GetID(), GetBrowserContext(), | 775 GetID(), |
| 776 GetBrowserContext(), |
| 765 GetBrowserContext()->GetRequestContextForRenderProcess(GetID()), | 777 GetBrowserContext()->GetRequestContextForRenderProcess(GetID()), |
| 766 widget_helper_.get(), audio_manager, media_internals, | 778 widget_helper_.get(), |
| 779 audio_manager, |
| 780 media_internals, |
| 767 storage_partition_impl_->GetDOMStorageContext())); | 781 storage_partition_impl_->GetDOMStorageContext())); |
| 768 AddFilter(render_message_filter.get()); | 782 AddFilter(render_message_filter.get()); |
| 769 AddFilter(new RenderFrameMessageFilter( | 783 AddFilter(new RenderFrameMessageFilter( |
| 770 GetID(), | 784 GetID(), |
| 771 #if defined(ENABLE_PLUGINS) | 785 #if defined(ENABLE_PLUGINS) |
| 772 PluginServiceImpl::GetInstance(), | 786 PluginServiceImpl::GetInstance(), |
| 773 #else | 787 #else |
| 774 nullptr, | 788 nullptr, |
| 775 #endif | 789 #endif |
| 776 GetBrowserContext(), | 790 GetBrowserContext(), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 796 storage_partition_impl_->GetServiceWorkerContext(), | 810 storage_partition_impl_->GetServiceWorkerContext(), |
| 797 storage_partition_impl_->GetHostZoomLevelContext(), | 811 storage_partition_impl_->GetHostZoomLevelContext(), |
| 798 get_contexts_callback); | 812 get_contexts_callback); |
| 799 | 813 |
| 800 AddFilter(resource_message_filter); | 814 AddFilter(resource_message_filter); |
| 801 MediaStreamManager* media_stream_manager = | 815 MediaStreamManager* media_stream_manager = |
| 802 BrowserMainLoop::GetInstance()->media_stream_manager(); | 816 BrowserMainLoop::GetInstance()->media_stream_manager(); |
| 803 // The AudioInputRendererHost and AudioRendererHost needs to be available for | 817 // The AudioInputRendererHost and AudioRendererHost needs to be available for |
| 804 // lookup, so it's stashed in a member variable. | 818 // lookup, so it's stashed in a member variable. |
| 805 audio_input_renderer_host_ = new AudioInputRendererHost( | 819 audio_input_renderer_host_ = new AudioInputRendererHost( |
| 806 GetID(), base::GetProcId(GetHandle()), audio_manager, | 820 GetID(), |
| 807 media_stream_manager, AudioMirroringManager::GetInstance(), | 821 base::GetProcId(GetHandle()), |
| 822 audio_manager, |
| 823 media_stream_manager, |
| 824 AudioMirroringManager::GetInstance(), |
| 808 BrowserMainLoop::GetInstance()->user_input_monitor()); | 825 BrowserMainLoop::GetInstance()->user_input_monitor()); |
| 809 AddFilter(audio_input_renderer_host_.get()); | 826 AddFilter(audio_input_renderer_host_.get()); |
| 810 audio_renderer_host_ = new AudioRendererHost( | 827 audio_renderer_host_ = new AudioRendererHost( |
| 811 GetID(), audio_manager, AudioMirroringManager::GetInstance(), | 828 GetID(), |
| 812 media_internals, media_stream_manager, | 829 audio_manager, |
| 830 AudioMirroringManager::GetInstance(), |
| 831 media_internals, |
| 832 media_stream_manager, |
| 813 browser_context->GetResourceContext()->GetMediaDeviceIDSalt()); | 833 browser_context->GetResourceContext()->GetMediaDeviceIDSalt()); |
| 814 AddFilter(audio_renderer_host_.get()); | 834 AddFilter(audio_renderer_host_.get()); |
| 815 AddFilter( | 835 AddFilter( |
| 816 new MidiHost(GetID(), BrowserMainLoop::GetInstance()->midi_manager())); | 836 new MidiHost(GetID(), BrowserMainLoop::GetInstance()->midi_manager())); |
| 817 AddFilter(new VideoCaptureHost(media_stream_manager)); | 837 AddFilter(new VideoCaptureHost(media_stream_manager)); |
| 818 AddFilter(new AppCacheDispatcherHost( | 838 AddFilter(new AppCacheDispatcherHost( |
| 819 storage_partition_impl_->GetAppCacheService(), GetID())); | 839 storage_partition_impl_->GetAppCacheService(), |
| 840 GetID())); |
| 820 AddFilter(new ClipboardMessageFilter); | 841 AddFilter(new ClipboardMessageFilter); |
| 821 AddFilter(new DOMStorageMessageFilter( | 842 AddFilter(new DOMStorageMessageFilter( |
| 822 storage_partition_impl_->GetDOMStorageContext())); | 843 storage_partition_impl_->GetDOMStorageContext())); |
| 823 AddFilter(new IndexedDBDispatcherHost( | 844 AddFilter(new IndexedDBDispatcherHost( |
| 824 GetID(), storage_partition_impl_->GetURLRequestContext(), | 845 GetID(), |
| 846 storage_partition_impl_->GetURLRequestContext(), |
| 825 storage_partition_impl_->GetIndexedDBContext(), | 847 storage_partition_impl_->GetIndexedDBContext(), |
| 826 ChromeBlobStorageContext::GetFor(browser_context))); | 848 ChromeBlobStorageContext::GetFor(browser_context))); |
| 827 | 849 |
| 828 gpu_message_filter_ = new GpuMessageFilter(GetID(), widget_helper_.get()); | 850 gpu_message_filter_ = new GpuMessageFilter(GetID(), widget_helper_.get()); |
| 829 AddFilter(gpu_message_filter_); | 851 AddFilter(gpu_message_filter_); |
| 830 #if defined(ENABLE_WEBRTC) | 852 #if defined(ENABLE_WEBRTC) |
| 831 AddFilter(new WebRTCIdentityServiceHost( | 853 AddFilter(new WebRTCIdentityServiceHost( |
| 832 GetID(), storage_partition_impl_->GetWebRTCIdentityStore(), | 854 GetID(), |
| 855 storage_partition_impl_->GetWebRTCIdentityStore(), |
| 833 resource_context)); | 856 resource_context)); |
| 834 peer_connection_tracker_host_ = new PeerConnectionTrackerHost(GetID()); | 857 peer_connection_tracker_host_ = new PeerConnectionTrackerHost(GetID()); |
| 835 AddFilter(peer_connection_tracker_host_.get()); | 858 AddFilter(peer_connection_tracker_host_.get()); |
| 836 AddFilter(new MediaStreamDispatcherHost( | 859 AddFilter(new MediaStreamDispatcherHost( |
| 837 GetID(), browser_context->GetResourceContext()->GetMediaDeviceIDSalt(), | 860 GetID(), |
| 861 browser_context->GetResourceContext()->GetMediaDeviceIDSalt(), |
| 838 media_stream_manager)); | 862 media_stream_manager)); |
| 839 AddFilter(new MediaStreamTrackMetricsHost()); | 863 AddFilter(new MediaStreamTrackMetricsHost()); |
| 840 #endif | 864 #endif |
| 841 #if defined(ENABLE_PLUGINS) | 865 #if defined(ENABLE_PLUGINS) |
| 842 AddFilter(new PepperRendererConnection(GetID())); | 866 AddFilter(new PepperRendererConnection(GetID())); |
| 843 #endif | 867 #endif |
| 844 AddFilter(new SpeechRecognitionDispatcherHost( | 868 AddFilter(new SpeechRecognitionDispatcherHost( |
| 845 GetID(), storage_partition_impl_->GetURLRequestContext())); | 869 GetID(), storage_partition_impl_->GetURLRequestContext())); |
| 846 AddFilter(new FileAPIMessageFilter( | 870 AddFilter(new FileAPIMessageFilter( |
| 847 GetID(), storage_partition_impl_->GetURLRequestContext(), | 871 GetID(), |
| 872 storage_partition_impl_->GetURLRequestContext(), |
| 848 storage_partition_impl_->GetFileSystemContext(), | 873 storage_partition_impl_->GetFileSystemContext(), |
| 849 ChromeBlobStorageContext::GetFor(browser_context), | 874 ChromeBlobStorageContext::GetFor(browser_context), |
| 850 StreamContext::GetFor(browser_context))); | 875 StreamContext::GetFor(browser_context))); |
| 851 AddFilter(new FileUtilitiesMessageFilter(GetID())); | 876 AddFilter(new FileUtilitiesMessageFilter(GetID())); |
| 852 AddFilter(new MimeRegistryMessageFilter()); | 877 AddFilter(new MimeRegistryMessageFilter()); |
| 853 AddFilter( | 878 AddFilter(new DatabaseMessageFilter( |
| 854 new DatabaseMessageFilter(storage_partition_impl_->GetDatabaseTracker())); | 879 storage_partition_impl_->GetDatabaseTracker())); |
| 855 #if defined(OS_MACOSX) | 880 #if defined(OS_MACOSX) |
| 856 AddFilter(new TextInputClientMessageFilter(GetID())); | 881 AddFilter(new TextInputClientMessageFilter(GetID())); |
| 857 #elif defined(OS_WIN) | 882 #elif defined(OS_WIN) |
| 858 // The FontCacheDispatcher is required only when we're using GDI rendering. | 883 // The FontCacheDispatcher is required only when we're using GDI rendering. |
| 859 // TODO(scottmg): pdf/ppapi still require the renderer to be able to precache | 884 // TODO(scottmg): pdf/ppapi still require the renderer to be able to precache |
| 860 // GDI fonts (http://crbug.com/383227), even when using DirectWrite. This | 885 // GDI fonts (http://crbug.com/383227), even when using DirectWrite. This |
| 861 // should eventually be if (!ShouldUseDirectWrite()) guarded. | 886 // should eventually be if (!ShouldUseDirectWrite()) guarded. |
| 862 channel_->AddFilter(new FontCacheDispatcher()); | 887 channel_->AddFilter(new FontCacheDispatcher()); |
| 863 #elif defined(OS_ANDROID) | 888 #elif defined(OS_ANDROID) |
| 864 browser_demuxer_android_ = new BrowserDemuxerAndroid(); | 889 browser_demuxer_android_ = new BrowserDemuxerAndroid(); |
| 865 AddFilter(browser_demuxer_android_.get()); | 890 AddFilter(browser_demuxer_android_.get()); |
| 866 #endif | 891 #endif |
| 867 #if defined(ENABLE_BROWSER_CDMS) | 892 #if defined(ENABLE_BROWSER_CDMS) |
| 868 AddFilter(new BrowserCdmManager(GetID(), NULL)); | 893 AddFilter(new BrowserCdmManager(GetID(), NULL)); |
| 869 #endif | 894 #endif |
| 870 | 895 |
| 871 WebSocketDispatcherHost::GetRequestContextCallback | 896 WebSocketDispatcherHost::GetRequestContextCallback |
| 872 websocket_request_context_callback( | 897 websocket_request_context_callback( |
| 873 base::Bind(&GetRequestContext, request_context, media_request_context, | 898 base::Bind(&GetRequestContext, request_context, |
| 874 RESOURCE_TYPE_SUB_RESOURCE)); | 899 media_request_context, RESOURCE_TYPE_SUB_RESOURCE)); |
| 875 | 900 |
| 876 AddFilter( | 901 AddFilter( |
| 877 new WebSocketDispatcherHost(GetID(), websocket_request_context_callback)); | 902 new WebSocketDispatcherHost(GetID(), websocket_request_context_callback)); |
| 878 | 903 |
| 879 message_port_message_filter_ = new MessagePortMessageFilter( | 904 message_port_message_filter_ = new MessagePortMessageFilter( |
| 880 base::Bind(&RenderWidgetHelper::GetNextRoutingID, | 905 base::Bind(&RenderWidgetHelper::GetNextRoutingID, |
| 881 base::Unretained(widget_helper_.get()))); | 906 base::Unretained(widget_helper_.get()))); |
| 882 AddFilter(message_port_message_filter_.get()); | 907 AddFilter(message_port_message_filter_.get()); |
| 883 | 908 |
| 884 scoped_refptr<CacheStorageDispatcherHost> cache_storage_filter = | 909 scoped_refptr<CacheStorageDispatcherHost> cache_storage_filter = |
| 885 new CacheStorageDispatcherHost(); | 910 new CacheStorageDispatcherHost(); |
| 886 cache_storage_filter->Init(storage_partition_impl_->GetCacheStorageContext()); | 911 cache_storage_filter->Init(storage_partition_impl_->GetCacheStorageContext()); |
| 887 AddFilter(cache_storage_filter.get()); | 912 AddFilter(cache_storage_filter.get()); |
| 888 | 913 |
| 889 scoped_refptr<ServiceWorkerDispatcherHost> service_worker_filter = | 914 scoped_refptr<ServiceWorkerDispatcherHost> service_worker_filter = |
| 890 new ServiceWorkerDispatcherHost( | 915 new ServiceWorkerDispatcherHost( |
| 891 GetID(), message_port_message_filter_.get(), resource_context); | 916 GetID(), message_port_message_filter_.get(), resource_context); |
| 892 service_worker_filter->Init( | 917 service_worker_filter->Init( |
| 893 storage_partition_impl_->GetServiceWorkerContext()); | 918 storage_partition_impl_->GetServiceWorkerContext()); |
| 894 AddFilter(service_worker_filter.get()); | 919 AddFilter(service_worker_filter.get()); |
| 895 | 920 |
| 896 AddFilter(new SharedWorkerMessageFilter( | 921 AddFilter(new SharedWorkerMessageFilter( |
| 897 GetID(), resource_context, | 922 GetID(), |
| 923 resource_context, |
| 898 WorkerStoragePartition( | 924 WorkerStoragePartition( |
| 899 storage_partition_impl_->GetURLRequestContext(), | 925 storage_partition_impl_->GetURLRequestContext(), |
| 900 storage_partition_impl_->GetMediaURLRequestContext(), | 926 storage_partition_impl_->GetMediaURLRequestContext(), |
| 901 storage_partition_impl_->GetAppCacheService(), | 927 storage_partition_impl_->GetAppCacheService(), |
| 902 storage_partition_impl_->GetQuotaManager(), | 928 storage_partition_impl_->GetQuotaManager(), |
| 903 storage_partition_impl_->GetFileSystemContext(), | 929 storage_partition_impl_->GetFileSystemContext(), |
| 904 storage_partition_impl_->GetDatabaseTracker(), | 930 storage_partition_impl_->GetDatabaseTracker(), |
| 905 storage_partition_impl_->GetIndexedDBContext(), | 931 storage_partition_impl_->GetIndexedDBContext(), |
| 906 storage_partition_impl_->GetServiceWorkerContext()), | 932 storage_partition_impl_->GetServiceWorkerContext()), |
| 907 message_port_message_filter_.get())); | 933 message_port_message_filter_.get())); |
| 908 | 934 |
| 909 #if defined(ENABLE_WEBRTC) | 935 #if defined(ENABLE_WEBRTC) |
| 910 p2p_socket_dispatcher_host_ = new P2PSocketDispatcherHost( | 936 p2p_socket_dispatcher_host_ = new P2PSocketDispatcherHost( |
| 911 resource_context, | 937 resource_context, |
| 912 browser_context->GetRequestContextForRenderProcess(GetID())); | 938 browser_context->GetRequestContextForRenderProcess(GetID())); |
| 913 AddFilter(p2p_socket_dispatcher_host_.get()); | 939 AddFilter(p2p_socket_dispatcher_host_.get()); |
| 914 #endif | 940 #endif |
| 915 | 941 |
| 916 AddFilter(new TraceMessageFilter(GetID())); | 942 AddFilter(new TraceMessageFilter(GetID())); |
| 917 AddFilter(new ResolveProxyMsgHelper( | 943 AddFilter(new ResolveProxyMsgHelper( |
| 918 browser_context->GetRequestContextForRenderProcess(GetID()))); | 944 browser_context->GetRequestContextForRenderProcess(GetID()))); |
| 919 AddFilter(new QuotaDispatcherHost( | 945 AddFilter(new QuotaDispatcherHost( |
| 920 GetID(), storage_partition_impl_->GetQuotaManager(), | 946 GetID(), |
| 947 storage_partition_impl_->GetQuotaManager(), |
| 921 GetContentClient()->browser()->CreateQuotaPermissionContext())); | 948 GetContentClient()->browser()->CreateQuotaPermissionContext())); |
| 922 | 949 |
| 923 notification_message_filter_ = new NotificationMessageFilter( | 950 notification_message_filter_ = new NotificationMessageFilter( |
| 924 GetID(), storage_partition_impl_->GetPlatformNotificationContext(), | 951 GetID(), |
| 925 resource_context, browser_context); | 952 storage_partition_impl_->GetPlatformNotificationContext(), |
| 953 resource_context, |
| 954 browser_context); |
| 926 AddFilter(notification_message_filter_.get()); | 955 AddFilter(notification_message_filter_.get()); |
| 927 | 956 |
| 928 AddFilter(new GamepadBrowserMessageFilter()); | 957 AddFilter(new GamepadBrowserMessageFilter()); |
| 929 AddFilter(new DeviceLightMessageFilter()); | 958 AddFilter(new DeviceLightMessageFilter()); |
| 930 AddFilter(new DeviceMotionMessageFilter()); | 959 AddFilter(new DeviceMotionMessageFilter()); |
| 931 AddFilter(new DeviceOrientationMessageFilter()); | 960 AddFilter(new DeviceOrientationMessageFilter()); |
| 932 AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); | 961 AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); |
| 933 AddFilter(new HistogramMessageFilter()); | 962 AddFilter(new HistogramMessageFilter()); |
| 934 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) | 963 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) |
| 935 if (browser_command_line.HasSwitch(switches::kEnableMemoryBenchmarking)) | 964 if (browser_command_line.HasSwitch(switches::kEnableMemoryBenchmarking)) |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 | 1047 |
| 1019 void RenderProcessHostImpl::OnRemoveSubscription(unsigned int target) { | 1048 void RenderProcessHostImpl::OnRemoveSubscription(unsigned int target) { |
| 1020 DCHECK(subscribe_uniform_enabled_); | 1049 DCHECK(subscribe_uniform_enabled_); |
| 1021 subscription_set_.erase(target); | 1050 subscription_set_.erase(target); |
| 1022 } | 1051 } |
| 1023 | 1052 |
| 1024 void RenderProcessHostImpl::SendUpdateValueState(unsigned int target, | 1053 void RenderProcessHostImpl::SendUpdateValueState(unsigned int target, |
| 1025 const gpu::ValueState& state) { | 1054 const gpu::ValueState& state) { |
| 1026 DCHECK(subscribe_uniform_enabled_); | 1055 DCHECK(subscribe_uniform_enabled_); |
| 1027 if (subscription_set_.find(target) != subscription_set_.end()) { | 1056 if (subscription_set_.find(target) != subscription_set_.end()) { |
| 1028 GpuProcessHost::SendOnIO(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 1057 GpuProcessHost::SendOnIO( |
| 1029 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, | 1058 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
| 1030 new GpuMsg_UpdateValueState(id_, target, state)); | 1059 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, |
| 1060 new GpuMsg_UpdateValueState(id_, target, state)); |
| 1031 } else { | 1061 } else { |
| 1032 // Store the ValueState locally in case a Valuebuffer subscribes to it later | 1062 // Store the ValueState locally in case a Valuebuffer subscribes to it later |
| 1033 pending_valuebuffer_state_->UpdateState(target, state); | 1063 pending_valuebuffer_state_->UpdateState(target, state); |
| 1034 } | 1064 } |
| 1035 } | 1065 } |
| 1036 | 1066 |
| 1037 #if defined(ENABLE_BROWSER_CDMS) | 1067 #if defined(ENABLE_BROWSER_CDMS) |
| 1038 media::BrowserCdm* RenderProcessHostImpl::GetBrowserCdm(int render_frame_id, | 1068 media::BrowserCdm* RenderProcessHostImpl::GetBrowserCdm(int render_frame_id, |
| 1039 int cdm_id) const { | 1069 int cdm_id) const { |
| 1040 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1070 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1041 BrowserCdmManager* manager = BrowserCdmManager::FromProcess(GetID()); | 1071 BrowserCdmManager* manager = BrowserCdmManager::FromProcess(GetID()); |
| 1042 if (!manager) | 1072 if (!manager) |
| 1043 return nullptr; | 1073 return nullptr; |
| 1044 return manager->GetCdm(render_frame_id, cdm_id); | 1074 return manager->GetCdm(render_frame_id, cdm_id); |
| 1045 } | 1075 } |
| 1046 #endif | 1076 #endif |
| 1047 | 1077 |
| 1048 void RenderProcessHostImpl::AddRoute(int32 routing_id, | 1078 void RenderProcessHostImpl::AddRoute( |
| 1049 IPC::Listener* listener) { | 1079 int32 routing_id, |
| 1050 CHECK(!listeners_.Lookup(routing_id)) << "Found Routing ID Conflict: " | 1080 IPC::Listener* listener) { |
| 1051 << routing_id; | 1081 CHECK(!listeners_.Lookup(routing_id)) |
| 1082 << "Found Routing ID Conflict: " << routing_id; |
| 1052 listeners_.AddWithID(listener, routing_id); | 1083 listeners_.AddWithID(listener, routing_id); |
| 1053 } | 1084 } |
| 1054 | 1085 |
| 1055 void RenderProcessHostImpl::RemoveRoute(int32 routing_id) { | 1086 void RenderProcessHostImpl::RemoveRoute(int32 routing_id) { |
| 1056 DCHECK(listeners_.Lookup(routing_id) != NULL); | 1087 DCHECK(listeners_.Lookup(routing_id) != NULL); |
| 1057 listeners_.Remove(routing_id); | 1088 listeners_.Remove(routing_id); |
| 1058 | 1089 |
| 1059 // Keep the one renderer thread around forever in single process mode. | 1090 // Keep the one renderer thread around forever in single process mode. |
| 1060 if (!run_renderer_in_process()) | 1091 if (!run_renderer_in_process()) |
| 1061 Cleanup(); | 1092 Cleanup(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1079 // In single process mode it is better if we don't suicide but just | 1110 // In single process mode it is better if we don't suicide but just |
| 1080 // crash. | 1111 // crash. |
| 1081 CHECK(false); | 1112 CHECK(false); |
| 1082 } | 1113 } |
| 1083 // We kill the renderer but don't include a NOTREACHED, because we want the | 1114 // We kill the renderer but don't include a NOTREACHED, because we want the |
| 1084 // browser to try to survive when it gets illegal messages from the renderer. | 1115 // browser to try to survive when it gets illegal messages from the renderer. |
| 1085 Shutdown(RESULT_CODE_KILLED_BAD_MESSAGE, false); | 1116 Shutdown(RESULT_CODE_KILLED_BAD_MESSAGE, false); |
| 1086 } | 1117 } |
| 1087 | 1118 |
| 1088 void RenderProcessHostImpl::WidgetRestored() { | 1119 void RenderProcessHostImpl::WidgetRestored() { |
| 1120 // Verify we were properly backgrounded. |
| 1121 DCHECK_EQ(backgrounded_, (visible_widgets_ == 0)); |
| 1089 visible_widgets_++; | 1122 visible_widgets_++; |
| 1090 UpdateProcessPriority(); | 1123 SetBackgrounded(false); |
| 1091 DCHECK(!is_process_backgrounded_); | |
| 1092 } | 1124 } |
| 1093 | 1125 |
| 1094 void RenderProcessHostImpl::WidgetHidden() { | 1126 void RenderProcessHostImpl::WidgetHidden() { |
| 1095 // On startup, the browser will call Hide. We ignore this call. | 1127 // On startup, the browser will call Hide |
| 1096 if (visible_widgets_ == 0) | 1128 if (backgrounded_) |
| 1097 return; | 1129 return; |
| 1098 | 1130 |
| 1099 --visible_widgets_; | 1131 DCHECK_EQ(backgrounded_, (visible_widgets_ == 0)); |
| 1132 visible_widgets_--; |
| 1133 DCHECK_GE(visible_widgets_, 0); |
| 1100 if (visible_widgets_ == 0) { | 1134 if (visible_widgets_ == 0) { |
| 1101 DCHECK(!is_process_backgrounded_); | 1135 DCHECK(!backgrounded_); |
| 1102 UpdateProcessPriority(); | 1136 SetBackgrounded(true); |
| 1103 } | 1137 } |
| 1104 } | 1138 } |
| 1105 | 1139 |
| 1106 int RenderProcessHostImpl::VisibleWidgetCount() const { | 1140 int RenderProcessHostImpl::VisibleWidgetCount() const { |
| 1107 return visible_widgets_; | 1141 return visible_widgets_; |
| 1108 } | 1142 } |
| 1109 | 1143 |
| 1110 void RenderProcessHostImpl::AudioStateChanged() { | |
| 1111 UpdateProcessPriority(); | |
| 1112 } | |
| 1113 | |
| 1114 bool RenderProcessHostImpl::IsForGuestsOnly() const { | 1144 bool RenderProcessHostImpl::IsForGuestsOnly() const { |
| 1115 return is_for_guests_only_; | 1145 return is_for_guests_only_; |
| 1116 } | 1146 } |
| 1117 | 1147 |
| 1118 StoragePartition* RenderProcessHostImpl::GetStoragePartition() const { | 1148 StoragePartition* RenderProcessHostImpl::GetStoragePartition() const { |
| 1119 return storage_partition_impl_; | 1149 return storage_partition_impl_; |
| 1120 } | 1150 } |
| 1121 | 1151 |
| 1122 static void AppendCompositorCommandLineFlags(base::CommandLine* command_line) { | 1152 static void AppendCompositorCommandLineFlags(base::CommandLine* command_line) { |
| 1123 if (IsPropertyTreeVerificationEnabled()) | 1153 if (IsPropertyTreeVerificationEnabled()) |
| 1124 command_line->AppendSwitch(cc::switches::kEnablePropertyTreeVerification); | 1154 command_line->AppendSwitch(cc::switches::kEnablePropertyTreeVerification); |
| 1125 | 1155 |
| 1126 command_line->AppendSwitchASCII( | 1156 command_line->AppendSwitchASCII( |
| 1127 switches::kNumRasterThreads, | 1157 switches::kNumRasterThreads, |
| 1128 base::IntToString(NumberOfRendererRasterThreads())); | 1158 base::IntToString(NumberOfRendererRasterThreads())); |
| 1129 | 1159 |
| 1130 if (IsGpuRasterizationEnabled()) | 1160 if (IsGpuRasterizationEnabled()) |
| 1131 command_line->AppendSwitch(switches::kEnableGpuRasterization); | 1161 command_line->AppendSwitch(switches::kEnableGpuRasterization); |
| 1132 | 1162 |
| 1133 int msaa_sample_count = GpuRasterizationMSAASampleCount(); | 1163 int msaa_sample_count = GpuRasterizationMSAASampleCount(); |
| 1134 if (msaa_sample_count >= 0) { | 1164 if (msaa_sample_count >= 0) { |
| 1135 command_line->AppendSwitchASCII(switches::kGpuRasterizationMSAASampleCount, | 1165 command_line->AppendSwitchASCII( |
| 1136 base::IntToString(msaa_sample_count)); | 1166 switches::kGpuRasterizationMSAASampleCount, |
| 1167 base::IntToString(msaa_sample_count)); |
| 1137 } | 1168 } |
| 1138 | 1169 |
| 1139 if (IsZeroCopyUploadEnabled()) | 1170 if (IsZeroCopyUploadEnabled()) |
| 1140 command_line->AppendSwitch(switches::kEnableZeroCopy); | 1171 command_line->AppendSwitch(switches::kEnableZeroCopy); |
| 1141 if (IsPersistentGpuMemoryBufferEnabled()) | 1172 if (IsPersistentGpuMemoryBufferEnabled()) |
| 1142 command_line->AppendSwitch(switches::kEnablePersistentGpuMemoryBuffer); | 1173 command_line->AppendSwitch(switches::kEnablePersistentGpuMemoryBuffer); |
| 1143 | 1174 |
| 1144 if (IsForceGpuRasterizationEnabled()) | 1175 if (IsForceGpuRasterizationEnabled()) |
| 1145 command_line->AppendSwitch(switches::kForceGpuRasterization); | 1176 command_line->AppendSwitch(switches::kForceGpuRasterization); |
| 1146 | 1177 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 // If we run base::FieldTrials, we want to pass to their state to the | 1219 // If we run base::FieldTrials, we want to pass to their state to the |
| 1189 // renderer so that it can act in accordance with each state, or record | 1220 // renderer so that it can act in accordance with each state, or record |
| 1190 // histograms relating to the base::FieldTrial states. | 1221 // histograms relating to the base::FieldTrial states. |
| 1191 std::string field_trial_states; | 1222 std::string field_trial_states; |
| 1192 base::FieldTrialList::AllStatesToString(&field_trial_states); | 1223 base::FieldTrialList::AllStatesToString(&field_trial_states); |
| 1193 if (!field_trial_states.empty()) { | 1224 if (!field_trial_states.empty()) { |
| 1194 command_line->AppendSwitchASCII(switches::kForceFieldTrials, | 1225 command_line->AppendSwitchASCII(switches::kForceFieldTrials, |
| 1195 field_trial_states); | 1226 field_trial_states); |
| 1196 } | 1227 } |
| 1197 | 1228 |
| 1198 GetContentClient()->browser()->AppendExtraCommandLineSwitches(command_line, | 1229 GetContentClient()->browser()->AppendExtraCommandLineSwitches( |
| 1199 GetID()); | 1230 command_line, GetID()); |
| 1200 | 1231 |
| 1201 if (IsPinchToZoomEnabled()) | 1232 if (IsPinchToZoomEnabled()) |
| 1202 command_line->AppendSwitch(switches::kEnablePinch); | 1233 command_line->AppendSwitch(switches::kEnablePinch); |
| 1203 | 1234 |
| 1204 #if defined(OS_WIN) | 1235 #if defined(OS_WIN) |
| 1205 command_line->AppendSwitchASCII(switches::kDeviceScaleFactor, | 1236 command_line->AppendSwitchASCII(switches::kDeviceScaleFactor, |
| 1206 base::DoubleToString(gfx::GetDPIScale())); | 1237 base::DoubleToString(gfx::GetDPIScale())); |
| 1207 #endif | 1238 #endif |
| 1208 | 1239 |
| 1209 AppendCompositorCommandLineFlags(command_line); | 1240 AppendCompositorCommandLineFlags(command_line); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1478 #endif | 1509 #endif |
| 1479 } | 1510 } |
| 1480 | 1511 |
| 1481 bool RenderProcessHostImpl::FastShutdownIfPossible() { | 1512 bool RenderProcessHostImpl::FastShutdownIfPossible() { |
| 1482 if (run_renderer_in_process()) | 1513 if (run_renderer_in_process()) |
| 1483 return false; // Single process mode never shuts down the renderer. | 1514 return false; // Single process mode never shuts down the renderer. |
| 1484 | 1515 |
| 1485 if (!GetContentClient()->browser()->IsFastShutdownPossible()) | 1516 if (!GetContentClient()->browser()->IsFastShutdownPossible()) |
| 1486 return false; | 1517 return false; |
| 1487 | 1518 |
| 1488 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting() || | 1519 if (!child_process_launcher_.get() || |
| 1520 child_process_launcher_->IsStarting() || |
| 1489 !GetHandle()) | 1521 !GetHandle()) |
| 1490 return false; // Render process hasn't started or is probably crashed. | 1522 return false; // Render process hasn't started or is probably crashed. |
| 1491 | 1523 |
| 1492 // Test if there's an unload listener. | 1524 // Test if there's an unload listener. |
| 1493 // NOTE: It's possible that an onunload listener may be installed | 1525 // NOTE: It's possible that an onunload listener may be installed |
| 1494 // while we're shutting down, so there's a small race here. Given that | 1526 // while we're shutting down, so there's a small race here. Given that |
| 1495 // the window is small, it's unlikely that the web page has much | 1527 // the window is small, it's unlikely that the web page has much |
| 1496 // state that will be lost by not calling its unload handlers properly. | 1528 // state that will be lost by not calling its unload handlers properly. |
| 1497 if (!SuddenTerminationAllowed()) | 1529 if (!SuddenTerminationAllowed()) |
| 1498 return false; | 1530 return false; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1549 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, | 1581 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, |
| 1550 OnUserMetricsRecordAction) | 1582 OnUserMetricsRecordAction) |
| 1551 IPC_MESSAGE_HANDLER(ViewHostMsg_SavedPageAsMHTML, OnSavedPageAsMHTML) | 1583 IPC_MESSAGE_HANDLER(ViewHostMsg_SavedPageAsMHTML, OnSavedPageAsMHTML) |
| 1552 IPC_MESSAGE_HANDLER(ViewHostMsg_Close_ACK, OnCloseACK) | 1584 IPC_MESSAGE_HANDLER(ViewHostMsg_Close_ACK, OnCloseACK) |
| 1553 #if defined(ENABLE_WEBRTC) | 1585 #if defined(ENABLE_WEBRTC) |
| 1554 IPC_MESSAGE_HANDLER(AecDumpMsg_RegisterAecDumpConsumer, | 1586 IPC_MESSAGE_HANDLER(AecDumpMsg_RegisterAecDumpConsumer, |
| 1555 OnRegisterAecDumpConsumer) | 1587 OnRegisterAecDumpConsumer) |
| 1556 IPC_MESSAGE_HANDLER(AecDumpMsg_UnregisterAecDumpConsumer, | 1588 IPC_MESSAGE_HANDLER(AecDumpMsg_UnregisterAecDumpConsumer, |
| 1557 OnUnregisterAecDumpConsumer) | 1589 OnUnregisterAecDumpConsumer) |
| 1558 #endif | 1590 #endif |
| 1559 // Adding single handlers for your service here is fine, but once your | 1591 // Adding single handlers for your service here is fine, but once your |
| 1560 // service needs more than one handler, please extract them into a new | 1592 // service needs more than one handler, please extract them into a new |
| 1561 // message filter and add that filter to CreateMessageFilters(). | 1593 // message filter and add that filter to CreateMessageFilters(). |
| 1562 IPC_END_MESSAGE_MAP() | 1594 IPC_END_MESSAGE_MAP() |
| 1563 | 1595 |
| 1564 return true; | 1596 return true; |
| 1565 } | 1597 } |
| 1566 | 1598 |
| 1567 // Dispatch incoming messages to the appropriate IPC::Listener. | 1599 // Dispatch incoming messages to the appropriate IPC::Listener. |
| 1568 IPC::Listener* listener = listeners_.Lookup(msg.routing_id()); | 1600 IPC::Listener* listener = listeners_.Lookup(msg.routing_id()); |
| 1569 if (!listener) { | 1601 if (!listener) { |
| 1570 if (msg.is_sync()) { | 1602 if (msg.is_sync()) { |
| 1571 // The listener has gone away, so we must respond or else the caller will | 1603 // The listener has gone away, so we must respond or else the caller will |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1608 | 1640 |
| 1609 #if defined(USE_OZONE) | 1641 #if defined(USE_OZONE) |
| 1610 Send(new ChildProcessMsg_InitializeClientNativePixmapFactory( | 1642 Send(new ChildProcessMsg_InitializeClientNativePixmapFactory( |
| 1611 base::FileDescriptor( | 1643 base::FileDescriptor( |
| 1612 ui::OzonePlatform::GetInstance()->OpenClientNativePixmapDevice()))); | 1644 ui::OzonePlatform::GetInstance()->OpenClientNativePixmapDevice()))); |
| 1613 #endif | 1645 #endif |
| 1614 | 1646 |
| 1615 // Inform AudioInputRendererHost about the new render process PID. | 1647 // Inform AudioInputRendererHost about the new render process PID. |
| 1616 // AudioInputRendererHost is reference counted, so it's lifetime is | 1648 // AudioInputRendererHost is reference counted, so it's lifetime is |
| 1617 // guarantueed during the lifetime of the closure. | 1649 // guarantueed during the lifetime of the closure. |
| 1618 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 1650 BrowserThread::PostTask( |
| 1619 base::Bind(&AudioInputRendererHost::set_renderer_pid, | 1651 BrowserThread::IO, FROM_HERE, |
| 1620 audio_input_renderer_host_, peer_pid)); | 1652 base::Bind(&AudioInputRendererHost::set_renderer_pid, |
| 1653 audio_input_renderer_host_, |
| 1654 peer_pid)); |
| 1621 } | 1655 } |
| 1622 | 1656 |
| 1623 void RenderProcessHostImpl::OnChannelError() { | 1657 void RenderProcessHostImpl::OnChannelError() { |
| 1624 ProcessDied(true /* already_dead */, nullptr); | 1658 ProcessDied(true /* already_dead */, nullptr); |
| 1625 } | 1659 } |
| 1626 | 1660 |
| 1627 void RenderProcessHostImpl::OnBadMessageReceived(const IPC::Message& message) { | 1661 void RenderProcessHostImpl::OnBadMessageReceived(const IPC::Message& message) { |
| 1628 // Message de-serialization failed. We consider this a capital crime. Kill the | 1662 // Message de-serialization failed. We consider this a capital crime. Kill the |
| 1629 // renderer if we have one. | 1663 // renderer if we have one. |
| 1630 auto type = message.type(); | 1664 auto type = message.type(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1697 // that are simultaneously hosted in this renderer process. | 1731 // that are simultaneously hosted in this renderer process. |
| 1698 UMA_HISTOGRAM_COUNTS("Render.Workers.MaxWorkerCountInRendererProcess", | 1732 UMA_HISTOGRAM_COUNTS("Render.Workers.MaxWorkerCountInRendererProcess", |
| 1699 max_worker_count_); | 1733 max_worker_count_); |
| 1700 } | 1734 } |
| 1701 | 1735 |
| 1702 // We cannot clean up twice; if this fails, there is an issue with our | 1736 // We cannot clean up twice; if this fails, there is an issue with our |
| 1703 // control flow. | 1737 // control flow. |
| 1704 DCHECK(!deleting_soon_); | 1738 DCHECK(!deleting_soon_); |
| 1705 | 1739 |
| 1706 DCHECK_EQ(0, pending_views_); | 1740 DCHECK_EQ(0, pending_views_); |
| 1707 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, | 1741 FOR_EACH_OBSERVER(RenderProcessHostObserver, |
| 1742 observers_, |
| 1708 RenderProcessHostDestroyed(this)); | 1743 RenderProcessHostDestroyed(this)); |
| 1709 NotificationService::current()->Notify( | 1744 NotificationService::current()->Notify( |
| 1710 NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 1745 NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| 1711 Source<RenderProcessHost>(this), NotificationService::NoDetails()); | 1746 Source<RenderProcessHost>(this), |
| 1747 NotificationService::NoDetails()); |
| 1712 | 1748 |
| 1713 #ifndef NDEBUG | 1749 #ifndef NDEBUG |
| 1714 is_self_deleted_ = true; | 1750 is_self_deleted_ = true; |
| 1715 #endif | 1751 #endif |
| 1716 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 1752 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 1717 deleting_soon_ = true; | 1753 deleting_soon_ = true; |
| 1718 // It's important not to wait for the DeleteTask to delete the channel | 1754 // It's important not to wait for the DeleteTask to delete the channel |
| 1719 // proxy. Kill it off now. That way, in case the profile is going away, the | 1755 // proxy. Kill it off now. That way, in case the profile is going away, the |
| 1720 // rest of the objects attached to this RenderProcessHost start going | 1756 // rest of the objects attached to this RenderProcessHost start going |
| 1721 // away first, since deleting the channel proxy will post a | 1757 // away first, since deleting the channel proxy will post a |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1770 void RenderProcessHostImpl::FilterURL(bool empty_allowed, GURL* url) { | 1806 void RenderProcessHostImpl::FilterURL(bool empty_allowed, GURL* url) { |
| 1771 FilterURL(this, empty_allowed, url); | 1807 FilterURL(this, empty_allowed, url); |
| 1772 } | 1808 } |
| 1773 | 1809 |
| 1774 #if defined(ENABLE_WEBRTC) | 1810 #if defined(ENABLE_WEBRTC) |
| 1775 void RenderProcessHostImpl::EnableAudioDebugRecordings( | 1811 void RenderProcessHostImpl::EnableAudioDebugRecordings( |
| 1776 const base::FilePath& file) { | 1812 const base::FilePath& file) { |
| 1777 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1813 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1778 | 1814 |
| 1779 // Enable AEC dump for each registered consumer. | 1815 // Enable AEC dump for each registered consumer. |
| 1780 base::FilePath file_with_extensions = GetAecDumpFilePathWithExtensions(file); | 1816 base::FilePath file_with_extensions = |
| 1817 GetAecDumpFilePathWithExtensions(file); |
| 1781 for (std::vector<int>::iterator it = aec_dump_consumers_.begin(); | 1818 for (std::vector<int>::iterator it = aec_dump_consumers_.begin(); |
| 1782 it != aec_dump_consumers_.end(); ++it) { | 1819 it != aec_dump_consumers_.end(); ++it) { |
| 1783 EnableAecDumpForId(file_with_extensions, *it); | 1820 EnableAecDumpForId(file_with_extensions, *it); |
| 1784 } | 1821 } |
| 1785 | 1822 |
| 1786 // Enable mic input recording. AudioInputRendererHost is reference counted, so | 1823 // Enable mic input recording. AudioInputRendererHost is reference counted, so |
| 1787 // it's lifetime is guarantueed during the lifetime of the closure. | 1824 // it's lifetime is guarantueed during the lifetime of the closure. |
| 1788 BrowserThread::PostTask( | 1825 BrowserThread::PostTask( |
| 1789 BrowserThread::IO, FROM_HERE, | 1826 BrowserThread::IO, FROM_HERE, |
| 1790 base::Bind(&AudioInputRendererHost::EnableDebugRecording, | 1827 base::Bind(&AudioInputRendererHost::EnableDebugRecording, |
| 1791 audio_input_renderer_host_, file)); | 1828 audio_input_renderer_host_, |
| 1829 file)); |
| 1792 } | 1830 } |
| 1793 | 1831 |
| 1794 void RenderProcessHostImpl::DisableAudioDebugRecordings() { | 1832 void RenderProcessHostImpl::DisableAudioDebugRecordings() { |
| 1795 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1833 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1796 | 1834 |
| 1797 // Posting on the FILE thread and then replying back on the UI thread is only | 1835 // Posting on the FILE thread and then replying back on the UI thread is only |
| 1798 // for avoiding races between enable and disable. Nothing is done on the FILE | 1836 // for avoiding races between enable and disable. Nothing is done on the FILE |
| 1799 // thread. | 1837 // thread. |
| 1800 BrowserThread::PostTaskAndReply( | 1838 BrowserThread::PostTaskAndReply( |
| 1801 BrowserThread::FILE, FROM_HERE, base::Bind(&DisableAecDumpOnFileThread), | 1839 BrowserThread::FILE, FROM_HERE, |
| 1840 base::Bind(&DisableAecDumpOnFileThread), |
| 1802 base::Bind(&RenderProcessHostImpl::SendDisableAecDumpToRenderer, | 1841 base::Bind(&RenderProcessHostImpl::SendDisableAecDumpToRenderer, |
| 1803 weak_factory_.GetWeakPtr())); | 1842 weak_factory_.GetWeakPtr())); |
| 1804 | 1843 |
| 1805 // AudioInputRendererHost is reference counted, so it's lifetime is | 1844 // AudioInputRendererHost is reference counted, so it's lifetime is |
| 1806 // guaranteed during the lifetime of the closure. | 1845 // guaranteed during the lifetime of the closure. |
| 1807 BrowserThread::PostTask( | 1846 BrowserThread::PostTask( |
| 1808 BrowserThread::IO, FROM_HERE, | 1847 BrowserThread::IO, FROM_HERE, |
| 1809 base::Bind(&AudioInputRendererHost::DisableDebugRecording, | 1848 base::Bind( |
| 1810 audio_input_renderer_host_)); | 1849 &AudioInputRendererHost::DisableDebugRecording, |
| 1850 audio_input_renderer_host_)); |
| 1811 } | 1851 } |
| 1812 | 1852 |
| 1813 void RenderProcessHostImpl::SetWebRtcLogMessageCallback( | 1853 void RenderProcessHostImpl::SetWebRtcLogMessageCallback( |
| 1814 base::Callback<void(const std::string&)> callback) { | 1854 base::Callback<void(const std::string&)> callback) { |
| 1815 webrtc_log_message_callback_ = callback; | 1855 webrtc_log_message_callback_ = callback; |
| 1816 } | 1856 } |
| 1817 | 1857 |
| 1818 RenderProcessHostImpl::WebRtcStopRtpDumpCallback | 1858 RenderProcessHostImpl::WebRtcStopRtpDumpCallback |
| 1819 RenderProcessHostImpl::StartRtpDump( | 1859 RenderProcessHostImpl::StartRtpDump( |
| 1820 bool incoming, | 1860 bool incoming, |
| 1821 bool outgoing, | 1861 bool outgoing, |
| 1822 const WebRtcRtpPacketCallback& packet_callback) { | 1862 const WebRtcRtpPacketCallback& packet_callback) { |
| 1823 if (!p2p_socket_dispatcher_host_.get()) | 1863 if (!p2p_socket_dispatcher_host_.get()) |
| 1824 return WebRtcStopRtpDumpCallback(); | 1864 return WebRtcStopRtpDumpCallback(); |
| 1825 | 1865 |
| 1826 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 1866 BrowserThread::PostTask(BrowserThread::IO, |
| 1867 FROM_HERE, |
| 1827 base::Bind(&P2PSocketDispatcherHost::StartRtpDump, | 1868 base::Bind(&P2PSocketDispatcherHost::StartRtpDump, |
| 1828 p2p_socket_dispatcher_host_, incoming, | 1869 p2p_socket_dispatcher_host_, |
| 1829 outgoing, packet_callback)); | 1870 incoming, |
| 1871 outgoing, |
| 1872 packet_callback)); |
| 1830 | 1873 |
| 1831 if (stop_rtp_dump_callback_.is_null()) { | 1874 if (stop_rtp_dump_callback_.is_null()) { |
| 1832 stop_rtp_dump_callback_ = | 1875 stop_rtp_dump_callback_ = |
| 1833 base::Bind(&P2PSocketDispatcherHost::StopRtpDumpOnUIThread, | 1876 base::Bind(&P2PSocketDispatcherHost::StopRtpDumpOnUIThread, |
| 1834 p2p_socket_dispatcher_host_); | 1877 p2p_socket_dispatcher_host_); |
| 1835 } | 1878 } |
| 1836 return stop_rtp_dump_callback_; | 1879 return stop_rtp_dump_callback_; |
| 1837 } | 1880 } |
| 1838 #endif | 1881 #endif |
| 1839 | 1882 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1901 } | 1944 } |
| 1902 | 1945 |
| 1903 if (url->SchemeIs(url::kAboutScheme)) { | 1946 if (url->SchemeIs(url::kAboutScheme)) { |
| 1904 // The renderer treats all URLs in the about: scheme as being about:blank. | 1947 // The renderer treats all URLs in the about: scheme as being about:blank. |
| 1905 // Canonicalize about: URLs to about:blank. | 1948 // Canonicalize about: URLs to about:blank. |
| 1906 *url = GURL(url::kAboutBlankURL); | 1949 *url = GURL(url::kAboutBlankURL); |
| 1907 } | 1950 } |
| 1908 | 1951 |
| 1909 // Do not allow browser plugin guests to navigate to non-web URLs, since they | 1952 // Do not allow browser plugin guests to navigate to non-web URLs, since they |
| 1910 // cannot swap processes or grant bindings. | 1953 // cannot swap processes or grant bindings. |
| 1911 bool non_web_url_in_guest = | 1954 bool non_web_url_in_guest = rph->IsForGuestsOnly() && |
| 1912 rph->IsForGuestsOnly() && | |
| 1913 !(url->is_valid() && policy->IsWebSafeScheme(url->scheme())); | 1955 !(url->is_valid() && policy->IsWebSafeScheme(url->scheme())); |
| 1914 | 1956 |
| 1915 if (non_web_url_in_guest || !policy->CanRequestURL(rph->GetID(), *url)) { | 1957 if (non_web_url_in_guest || !policy->CanRequestURL(rph->GetID(), *url)) { |
| 1916 // If this renderer is not permitted to request this URL, we invalidate the | 1958 // If this renderer is not permitted to request this URL, we invalidate the |
| 1917 // URL. This prevents us from storing the blocked URL and becoming confused | 1959 // URL. This prevents us from storing the blocked URL and becoming confused |
| 1918 // later. | 1960 // later. |
| 1919 VLOG(1) << "Blocked URL " << url->spec(); | 1961 VLOG(1) << "Blocked URL " << url->spec(); |
| 1920 *url = GURL(url::kAboutBlankURL); | 1962 *url = GURL(url::kAboutBlankURL); |
| 1921 } | 1963 } |
| 1922 } | 1964 } |
| 1923 | 1965 |
| 1924 // static | 1966 // static |
| 1925 bool RenderProcessHostImpl::IsSuitableHost(RenderProcessHost* host, | 1967 bool RenderProcessHostImpl::IsSuitableHost( |
| 1926 BrowserContext* browser_context, | 1968 RenderProcessHost* host, |
| 1927 const GURL& site_url) { | 1969 BrowserContext* browser_context, |
| 1970 const GURL& site_url) { |
| 1928 if (run_renderer_in_process()) | 1971 if (run_renderer_in_process()) |
| 1929 return true; | 1972 return true; |
| 1930 | 1973 |
| 1931 if (host->GetBrowserContext() != browser_context) | 1974 if (host->GetBrowserContext() != browser_context) |
| 1932 return false; | 1975 return false; |
| 1933 | 1976 |
| 1934 // Do not allow sharing of guest hosts. This is to prevent bugs where guest | 1977 // Do not allow sharing of guest hosts. This is to prevent bugs where guest |
| 1935 // and non-guest storage gets mixed. In the future, we might consider enabling | 1978 // and non-guest storage gets mixed. In the future, we might consider enabling |
| 1936 // the sharing of guests, in this case this check should be removed and | 1979 // the sharing of guests, in this case this check should be removed and |
| 1937 // InSameStoragePartition should handle the possible sharing. | 1980 // InSameStoragePartition should handle the possible sharing. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1989 } | 2032 } |
| 1990 | 2033 |
| 1991 // static | 2034 // static |
| 1992 RenderProcessHost* RenderProcessHost::FromID(int render_process_id) { | 2035 RenderProcessHost* RenderProcessHost::FromID(int render_process_id) { |
| 1993 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2036 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1994 return g_all_hosts.Get().Lookup(render_process_id); | 2037 return g_all_hosts.Get().Lookup(render_process_id); |
| 1995 } | 2038 } |
| 1996 | 2039 |
| 1997 // static | 2040 // static |
| 1998 bool RenderProcessHost::ShouldTryToUseExistingProcessHost( | 2041 bool RenderProcessHost::ShouldTryToUseExistingProcessHost( |
| 1999 BrowserContext* browser_context, | 2042 BrowserContext* browser_context, const GURL& url) { |
| 2000 const GURL& url) { | |
| 2001 // If --site-per-process is enabled, do not try to reuse renderer processes | 2043 // If --site-per-process is enabled, do not try to reuse renderer processes |
| 2002 // when over the limit. | 2044 // when over the limit. |
| 2003 // TODO(nick): This is overly conservative and isn't launchable. Move this | 2045 // TODO(nick): This is overly conservative and isn't launchable. Move this |
| 2004 // logic into IsSuitableHost, and check |url| against the URL the process is | 2046 // logic into IsSuitableHost, and check |url| against the URL the process is |
| 2005 // dedicated to. This will allow pages from the same site to share, and will | 2047 // dedicated to. This will allow pages from the same site to share, and will |
| 2006 // also allow non-isolated sites to share processes. https://crbug.com/513036 | 2048 // also allow non-isolated sites to share processes. https://crbug.com/513036 |
| 2007 if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) | 2049 if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) |
| 2008 return false; | 2050 return false; |
| 2009 | 2051 |
| 2010 if (run_renderer_in_process()) | 2052 if (run_renderer_in_process()) |
| 2011 return true; | 2053 return true; |
| 2012 | 2054 |
| 2013 // NOTE: Sometimes it's necessary to create more render processes than | 2055 // NOTE: Sometimes it's necessary to create more render processes than |
| 2014 // GetMaxRendererProcessCount(), for instance when we want to create | 2056 // GetMaxRendererProcessCount(), for instance when we want to create |
| 2015 // a renderer process for a browser context that has no existing | 2057 // a renderer process for a browser context that has no existing |
| 2016 // renderers. This is OK in moderation, since the | 2058 // renderers. This is OK in moderation, since the |
| 2017 // GetMaxRendererProcessCount() is conservative. | 2059 // GetMaxRendererProcessCount() is conservative. |
| 2018 if (g_all_hosts.Get().size() >= GetMaxRendererProcessCount()) | 2060 if (g_all_hosts.Get().size() >= GetMaxRendererProcessCount()) |
| 2019 return true; | 2061 return true; |
| 2020 | 2062 |
| 2021 return GetContentClient()->browser()->ShouldTryToUseExistingProcessHost( | 2063 return GetContentClient()->browser()-> |
| 2022 browser_context, url); | 2064 ShouldTryToUseExistingProcessHost(browser_context, url); |
| 2023 } | 2065 } |
| 2024 | 2066 |
| 2025 // static | 2067 // static |
| 2026 RenderProcessHost* RenderProcessHost::GetExistingProcessHost( | 2068 RenderProcessHost* RenderProcessHost::GetExistingProcessHost( |
| 2027 BrowserContext* browser_context, | 2069 BrowserContext* browser_context, |
| 2028 const GURL& site_url) { | 2070 const GURL& site_url) { |
| 2029 // First figure out which existing renderers we can use. | 2071 // First figure out which existing renderers we can use. |
| 2030 std::vector<RenderProcessHost*> suitable_renderers; | 2072 std::vector<RenderProcessHost*> suitable_renderers; |
| 2031 suitable_renderers.reserve(g_all_hosts.Get().size()); | 2073 suitable_renderers.reserve(g_all_hosts.Get().size()); |
| 2032 | 2074 |
| 2033 iterator iter(AllHostsIterator()); | 2075 iterator iter(AllHostsIterator()); |
| 2034 while (!iter.IsAtEnd()) { | 2076 while (!iter.IsAtEnd()) { |
| 2035 if (GetContentClient()->browser()->MayReuseHost(iter.GetCurrentValue()) && | 2077 if (GetContentClient()->browser()->MayReuseHost(iter.GetCurrentValue()) && |
| 2036 RenderProcessHostImpl::IsSuitableHost(iter.GetCurrentValue(), | 2078 RenderProcessHostImpl::IsSuitableHost( |
| 2037 browser_context, site_url)) { | 2079 iter.GetCurrentValue(), |
| 2080 browser_context, site_url)) { |
| 2038 suitable_renderers.push_back(iter.GetCurrentValue()); | 2081 suitable_renderers.push_back(iter.GetCurrentValue()); |
| 2039 } | 2082 } |
| 2040 iter.Advance(); | 2083 iter.Advance(); |
| 2041 } | 2084 } |
| 2042 | 2085 |
| 2043 // Now pick a random suitable renderer, if we have any. | 2086 // Now pick a random suitable renderer, if we have any. |
| 2044 if (!suitable_renderers.empty()) { | 2087 if (!suitable_renderers.empty()) { |
| 2045 int suitable_count = static_cast<int>(suitable_renderers.size()); | 2088 int suitable_count = static_cast<int>(suitable_renderers.size()); |
| 2046 int random_index = base::RandInt(0, suitable_count - 1); | 2089 int random_index = base::RandInt(0, suitable_count - 1); |
| 2047 return suitable_renderers[random_index]; | 2090 return suitable_renderers[random_index]; |
| 2048 } | 2091 } |
| 2049 | 2092 |
| 2050 return NULL; | 2093 return NULL; |
| 2051 } | 2094 } |
| 2052 | 2095 |
| 2053 // static | 2096 // static |
| 2054 bool RenderProcessHost::ShouldUseProcessPerSite(BrowserContext* browser_context, | 2097 bool RenderProcessHost::ShouldUseProcessPerSite( |
| 2055 const GURL& url) { | 2098 BrowserContext* browser_context, |
| 2099 const GURL& url) { |
| 2056 // Returns true if we should use the process-per-site model. This will be | 2100 // Returns true if we should use the process-per-site model. This will be |
| 2057 // the case if the --process-per-site switch is specified, or in | 2101 // the case if the --process-per-site switch is specified, or in |
| 2058 // process-per-site-instance for particular sites (e.g., WebUI). | 2102 // process-per-site-instance for particular sites (e.g., WebUI). |
| 2059 // Note that --single-process is handled in ShouldTryToUseExistingProcessHost. | 2103 // Note that --single-process is handled in ShouldTryToUseExistingProcessHost. |
| 2060 const base::CommandLine& command_line = | 2104 const base::CommandLine& command_line = |
| 2061 *base::CommandLine::ForCurrentProcess(); | 2105 *base::CommandLine::ForCurrentProcess(); |
| 2062 if (command_line.HasSwitch(switches::kProcessPerSite)) | 2106 if (command_line.HasSwitch(switches::kProcessPerSite)) |
| 2063 return true; | 2107 return true; |
| 2064 | 2108 |
| 2065 // We want to consolidate particular sites like WebUI even when we are using | 2109 // We want to consolidate particular sites like WebUI even when we are using |
| 2066 // the process-per-tab or process-per-site-instance models. | 2110 // the process-per-tab or process-per-site-instance models. |
| 2067 // Note: DevTools pages have WebUI type but should not reuse the same host. | 2111 // Note: DevTools pages have WebUI type but should not reuse the same host. |
| 2068 if (WebUIControllerFactoryRegistry::GetInstance()->UseWebUIForURL( | 2112 if (WebUIControllerFactoryRegistry::GetInstance()->UseWebUIForURL( |
| 2069 browser_context, url) && | 2113 browser_context, url) && |
| 2070 !url.SchemeIs(kChromeDevToolsScheme)) { | 2114 !url.SchemeIs(kChromeDevToolsScheme)) { |
| 2071 return true; | 2115 return true; |
| 2072 } | 2116 } |
| 2073 | 2117 |
| 2074 // Otherwise let the content client decide, defaulting to false. | 2118 // Otherwise let the content client decide, defaulting to false. |
| 2075 return GetContentClient()->browser()->ShouldUseProcessPerSite(browser_context, | 2119 return GetContentClient()->browser()->ShouldUseProcessPerSite(browser_context, |
| 2076 url); | 2120 url); |
| 2077 } | 2121 } |
| 2078 | 2122 |
| 2079 // static | 2123 // static |
| 2080 RenderProcessHost* RenderProcessHostImpl::GetProcessHostForSite( | 2124 RenderProcessHost* RenderProcessHostImpl::GetProcessHostForSite( |
| 2081 BrowserContext* browser_context, | 2125 BrowserContext* browser_context, |
| 2082 const GURL& url) { | 2126 const GURL& url) { |
| 2083 // Look up the map of site to process for the given browser_context. | 2127 // Look up the map of site to process for the given browser_context. |
| 2084 SiteProcessMap* map = GetSiteProcessMapForBrowserContext(browser_context); | 2128 SiteProcessMap* map = |
| 2129 GetSiteProcessMapForBrowserContext(browser_context); |
| 2085 | 2130 |
| 2086 // See if we have an existing process with appropriate bindings for this site. | 2131 // See if we have an existing process with appropriate bindings for this site. |
| 2087 // If not, the caller should create a new process and register it. | 2132 // If not, the caller should create a new process and register it. |
| 2088 std::string site = | 2133 std::string site = SiteInstance::GetSiteForURL(browser_context, url) |
| 2089 SiteInstance::GetSiteForURL(browser_context, url).possibly_invalid_spec(); | 2134 .possibly_invalid_spec(); |
| 2090 RenderProcessHost* host = map->FindProcess(site); | 2135 RenderProcessHost* host = map->FindProcess(site); |
| 2091 if (host && (!GetContentClient()->browser()->MayReuseHost(host) || | 2136 if (host && (!GetContentClient()->browser()->MayReuseHost(host) || |
| 2092 !IsSuitableHost(host, browser_context, url))) { | 2137 !IsSuitableHost(host, browser_context, url))) { |
| 2093 // The registered process does not have an appropriate set of bindings for | 2138 // The registered process does not have an appropriate set of bindings for |
| 2094 // the url. Remove it from the map so we can register a better one. | 2139 // the url. Remove it from the map so we can register a better one. |
| 2095 RecordAction( | 2140 RecordAction( |
| 2096 base::UserMetricsAction("BindingsMismatch_GetProcessHostPerSite")); | 2141 base::UserMetricsAction("BindingsMismatch_GetProcessHostPerSite")); |
| 2097 map->RemoveProcess(host); | 2142 map->RemoveProcess(host); |
| 2098 host = NULL; | 2143 host = NULL; |
| 2099 } | 2144 } |
| 2100 | 2145 |
| 2101 return host; | 2146 return host; |
| 2102 } | 2147 } |
| 2103 | 2148 |
| 2104 void RenderProcessHostImpl::RegisterProcessHostForSite( | 2149 void RenderProcessHostImpl::RegisterProcessHostForSite( |
| 2105 BrowserContext* browser_context, | 2150 BrowserContext* browser_context, |
| 2106 RenderProcessHost* process, | 2151 RenderProcessHost* process, |
| 2107 const GURL& url) { | 2152 const GURL& url) { |
| 2108 // Look up the map of site to process for the given browser_context. | 2153 // Look up the map of site to process for the given browser_context. |
| 2109 SiteProcessMap* map = GetSiteProcessMapForBrowserContext(browser_context); | 2154 SiteProcessMap* map = |
| 2155 GetSiteProcessMapForBrowserContext(browser_context); |
| 2110 | 2156 |
| 2111 // Only register valid, non-empty sites. Empty or invalid sites will not | 2157 // Only register valid, non-empty sites. Empty or invalid sites will not |
| 2112 // use process-per-site mode. We cannot check whether the process has | 2158 // use process-per-site mode. We cannot check whether the process has |
| 2113 // appropriate bindings here, because the bindings have not yet been granted. | 2159 // appropriate bindings here, because the bindings have not yet been granted. |
| 2114 std::string site = | 2160 std::string site = SiteInstance::GetSiteForURL(browser_context, url) |
| 2115 SiteInstance::GetSiteForURL(browser_context, url).possibly_invalid_spec(); | 2161 .possibly_invalid_spec(); |
| 2116 if (!site.empty()) | 2162 if (!site.empty()) |
| 2117 map->RegisterProcess(site, process); | 2163 map->RegisterProcess(site, process); |
| 2118 } | 2164 } |
| 2119 | 2165 |
| 2120 void RenderProcessHostImpl::ProcessDied(bool already_dead, | 2166 void RenderProcessHostImpl::ProcessDied(bool already_dead, |
| 2121 RendererClosedDetails* known_details) { | 2167 RendererClosedDetails* known_details) { |
| 2122 // Our child process has died. If we didn't expect it, it's a crash. | 2168 // Our child process has died. If we didn't expect it, it's a crash. |
| 2123 // In any case, we need to let everyone know it's gone. | 2169 // In any case, we need to let everyone know it's gone. |
| 2124 // The OnChannelError notification can fire multiple times due to nested sync | 2170 // The OnChannelError notification can fire multiple times due to nested sync |
| 2125 // calls to a renderer. If we don't have a valid channel here it means we | 2171 // calls to a renderer. If we don't have a valid channel here it means we |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2155 | 2201 |
| 2156 RendererClosedDetails details(status, exit_code); | 2202 RendererClosedDetails details(status, exit_code); |
| 2157 mojo_application_host_->WillDestroySoon(); | 2203 mojo_application_host_->WillDestroySoon(); |
| 2158 | 2204 |
| 2159 child_process_launcher_.reset(); | 2205 child_process_launcher_.reset(); |
| 2160 channel_.reset(); | 2206 channel_.reset(); |
| 2161 while (!queued_messages_.empty()) { | 2207 while (!queued_messages_.empty()) { |
| 2162 delete queued_messages_.front(); | 2208 delete queued_messages_.front(); |
| 2163 queued_messages_.pop(); | 2209 queued_messages_.pop(); |
| 2164 } | 2210 } |
| 2165 UpdateProcessPriority(); | |
| 2166 DCHECK(!is_process_backgrounded_); | |
| 2167 | 2211 |
| 2168 within_process_died_observer_ = true; | 2212 within_process_died_observer_ = true; |
| 2169 NotificationService::current()->Notify( | 2213 NotificationService::current()->Notify( |
| 2170 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), | 2214 NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 2215 Source<RenderProcessHost>(this), |
| 2171 Details<RendererClosedDetails>(&details)); | 2216 Details<RendererClosedDetails>(&details)); |
| 2172 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, | 2217 FOR_EACH_OBSERVER(RenderProcessHostObserver, |
| 2218 observers_, |
| 2173 RenderProcessExited(this, status, exit_code)); | 2219 RenderProcessExited(this, status, exit_code)); |
| 2174 within_process_died_observer_ = false; | 2220 within_process_died_observer_ = false; |
| 2175 | 2221 |
| 2176 gpu_message_filter_ = NULL; | 2222 gpu_message_filter_ = NULL; |
| 2177 message_port_message_filter_ = NULL; | 2223 message_port_message_filter_ = NULL; |
| 2178 RemoveUserData(kSessionStorageHolderKey); | 2224 RemoveUserData(kSessionStorageHolderKey); |
| 2179 | 2225 |
| 2180 // RenderProcessGone handlers might navigate or perform other actions that | 2226 // RenderProcessGone handlers might navigate or perform other actions that |
| 2181 // require a connection. Ensure that there is one before calling them. | 2227 // require a connection. Ensure that there is one before calling them. |
| 2182 mojo_application_host_.reset(new MojoApplicationHost); | 2228 mojo_application_host_.reset(new MojoApplicationHost); |
| 2183 | 2229 |
| 2184 IDMap<IPC::Listener>::iterator iter(&listeners_); | 2230 IDMap<IPC::Listener>::iterator iter(&listeners_); |
| 2185 while (!iter.IsAtEnd()) { | 2231 while (!iter.IsAtEnd()) { |
| 2186 iter.GetCurrentValue()->OnMessageReceived(FrameHostMsg_RenderProcessGone( | 2232 iter.GetCurrentValue()->OnMessageReceived( |
| 2187 iter.GetCurrentKey(), static_cast<int>(status), exit_code)); | 2233 FrameHostMsg_RenderProcessGone(iter.GetCurrentKey(), |
| 2234 static_cast<int>(status), |
| 2235 exit_code)); |
| 2188 iter.Advance(); | 2236 iter.Advance(); |
| 2189 } | 2237 } |
| 2190 | 2238 |
| 2191 // It's possible that one of the calls out to the observers might have caused | 2239 // It's possible that one of the calls out to the observers might have caused |
| 2192 // this object to be no longer needed. | 2240 // this object to be no longer needed. |
| 2193 if (delayed_cleanup_needed_) | 2241 if (delayed_cleanup_needed_) |
| 2194 Cleanup(); | 2242 Cleanup(); |
| 2195 | 2243 |
| 2196 // This object is not deleted at this point and might be reused later. | 2244 // This object is not deleted at this point and might be reused later. |
| 2197 // TODO(darin): clean this up | 2245 // TODO(darin): clean this up |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2217 } | 2265 } |
| 2218 #endif | 2266 #endif |
| 2219 | 2267 |
| 2220 void RenderProcessHostImpl::ReleaseOnCloseACK( | 2268 void RenderProcessHostImpl::ReleaseOnCloseACK( |
| 2221 RenderProcessHost* host, | 2269 RenderProcessHost* host, |
| 2222 const SessionStorageNamespaceMap& sessions, | 2270 const SessionStorageNamespaceMap& sessions, |
| 2223 int view_route_id) { | 2271 int view_route_id) { |
| 2224 DCHECK(host); | 2272 DCHECK(host); |
| 2225 if (sessions.empty()) | 2273 if (sessions.empty()) |
| 2226 return; | 2274 return; |
| 2227 SessionStorageHolder* holder = static_cast<SessionStorageHolder*>( | 2275 SessionStorageHolder* holder = static_cast<SessionStorageHolder*> |
| 2228 host->GetUserData(kSessionStorageHolderKey)); | 2276 (host->GetUserData(kSessionStorageHolderKey)); |
| 2229 if (!holder) { | 2277 if (!holder) { |
| 2230 holder = new SessionStorageHolder(); | 2278 holder = new SessionStorageHolder(); |
| 2231 host->SetUserData(kSessionStorageHolderKey, holder); | 2279 host->SetUserData( |
| 2280 kSessionStorageHolderKey, |
| 2281 holder); |
| 2232 } | 2282 } |
| 2233 holder->Hold(sessions, view_route_id); | 2283 holder->Hold(sessions, view_route_id); |
| 2234 } | 2284 } |
| 2235 | 2285 |
| 2236 void RenderProcessHostImpl::OnShutdownRequest() { | 2286 void RenderProcessHostImpl::OnShutdownRequest() { |
| 2237 // Don't shut down if there are active RenderViews, or if there are pending | 2287 // Don't shut down if there are active RenderViews, or if there are pending |
| 2238 // RenderViews being swapped back in. | 2288 // RenderViews being swapped back in. |
| 2239 // In single process mode, we never shutdown the renderer. | 2289 // In single process mode, we never shutdown the renderer. |
| 2240 if (pending_views_ || run_renderer_in_process() || GetActiveViewCount() > 0) | 2290 if (pending_views_ || run_renderer_in_process() || GetActiveViewCount() > 0) |
| 2241 return; | 2291 return; |
| 2242 | 2292 |
| 2243 // Notify any contents that might have swapped out renderers from this | 2293 // Notify any contents that might have swapped out renderers from this |
| 2244 // process. They should not attempt to swap them back in. | 2294 // process. They should not attempt to swap them back in. |
| 2245 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, | 2295 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, |
| 2246 RenderProcessWillExit(this)); | 2296 RenderProcessWillExit(this)); |
| 2247 | 2297 |
| 2248 mojo_application_host_->WillDestroySoon(); | 2298 mojo_application_host_->WillDestroySoon(); |
| 2249 | 2299 |
| 2250 Send(new ChildProcessMsg_Shutdown()); | 2300 Send(new ChildProcessMsg_Shutdown()); |
| 2251 } | 2301 } |
| 2252 | 2302 |
| 2253 void RenderProcessHostImpl::SuddenTerminationChanged(bool enabled) { | 2303 void RenderProcessHostImpl::SuddenTerminationChanged(bool enabled) { |
| 2254 SetSuddenTerminationAllowed(enabled); | 2304 SetSuddenTerminationAllowed(enabled); |
| 2255 } | 2305 } |
| 2256 | 2306 |
| 2257 void RenderProcessHostImpl::UpdateProcessPriority() { | 2307 void RenderProcessHostImpl::SetBackgrounded(bool backgrounded) { |
| 2258 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) { | 2308 TRACE_EVENT1("renderer_host", "RenderProcessHostImpl::SetBackgrounded", |
| 2259 is_process_backgrounded_ = false; | 2309 "backgrounded", backgrounded); |
| 2310 // Note: we always set the backgrounded_ value. If the process is NULL |
| 2311 // (and hence hasn't been created yet), we will set the process priority |
| 2312 // later when we create the process. |
| 2313 backgrounded_ = backgrounded; |
| 2314 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) |
| 2260 return; | 2315 return; |
| 2261 } | |
| 2262 | 2316 |
| 2263 // We background a process as soon as it hosts no active audio streams and no | 2317 // Don't background processes which have active audio streams. |
| 2264 // visible widgets -- the callers must call this function whenever we | 2318 if (backgrounded_ && audio_renderer_host_->HasActiveAudio()) |
| 2265 // transition in/out of those states. | 2319 return; |
| 2266 const bool should_background = | |
| 2267 visible_widgets_ == 0 && !audio_renderer_host_->HasActiveAudio() && | |
| 2268 !base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 2269 switches::kDisableRendererBackgrounding); | |
| 2270 | 2320 |
| 2271 // TODO(sebsg): Remove this ifdef when https://crbug.com/537671 is fixed. | 2321 const base::CommandLine* command_line = |
| 2272 #if !defined(OS_ANDROID) | 2322 base::CommandLine::ForCurrentProcess(); |
| 2273 if (is_process_backgrounded_ == should_background) | 2323 if (command_line->HasSwitch(switches::kDisableRendererBackgrounding)) |
| 2274 return; | 2324 return; |
| 2275 #endif | |
| 2276 | |
| 2277 TRACE_EVENT1("renderer_host", "RenderProcessHostImpl::UpdateProcessPriority", | |
| 2278 "should_background", should_background); | |
| 2279 is_process_backgrounded_ = should_background; | |
| 2280 | 2325 |
| 2281 #if defined(OS_WIN) | 2326 #if defined(OS_WIN) |
| 2282 // The cbstext.dll loads as a global GetMessage hook in the browser process | 2327 // The cbstext.dll loads as a global GetMessage hook in the browser process |
| 2283 // and intercepts/unintercepts the kernel32 API SetPriorityClass in a | 2328 // and intercepts/unintercepts the kernel32 API SetPriorityClass in a |
| 2284 // background thread. If the UI thread invokes this API just when it is | 2329 // background thread. If the UI thread invokes this API just when it is |
| 2285 // intercepted the stack is messed up on return from the interceptor | 2330 // intercepted the stack is messed up on return from the interceptor |
| 2286 // which causes random crashes in the browser process. Our hack for now | 2331 // which causes random crashes in the browser process. Our hack for now |
| 2287 // is to not invoke the SetPriorityClass API if the dll is loaded. | 2332 // is to not invoke the SetPriorityClass API if the dll is loaded. |
| 2288 if (GetModuleHandle(L"cbstext.dll")) | 2333 if (GetModuleHandle(L"cbstext.dll")) |
| 2289 return; | 2334 return; |
| 2290 #endif // OS_WIN | 2335 #endif // OS_WIN |
| 2291 | 2336 |
| 2292 // Control the background state from the browser process, otherwise the task | 2337 // Control the background state from the browser process, otherwise the task |
| 2293 // telling the renderer to "unbackground" itself may be preempted by other | 2338 // telling the renderer to "unbackground" itself may be preempted by other |
| 2294 // tasks executing at lowered priority ahead of it or simply by not being | 2339 // tasks executing at lowered priority ahead of it or simply by not being |
| 2295 // swiftly scheduled by the OS per the low process priority | 2340 // swiftly scheduled by the OS per the low process priority |
| 2296 // (http://crbug.com/398103). | 2341 // (http://crbug.com/398103). |
| 2297 child_process_launcher_->SetProcessBackgrounded(should_background); | 2342 child_process_launcher_->SetProcessBackgrounded(backgrounded); |
| 2298 | 2343 |
| 2299 // Notify the child process of background state. | 2344 // Notify the child process of background state. |
| 2300 Send(new ChildProcessMsg_SetProcessBackgrounded(should_background)); | 2345 Send(new ChildProcessMsg_SetProcessBackgrounded(backgrounded)); |
| 2301 } | 2346 } |
| 2302 | 2347 |
| 2303 void RenderProcessHostImpl::OnProcessLaunched() { | 2348 void RenderProcessHostImpl::OnProcessLaunched() { |
| 2304 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841 | 2349 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841 |
| 2305 // is fixed. | 2350 // is fixed. |
| 2306 tracked_objects::ScopedTracker tracking_profile1( | 2351 tracked_objects::ScopedTracker tracking_profile1( |
| 2307 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 2352 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 2308 "465841 RenderProcessHostImpl::OnProcessLaunched::Start")); | 2353 "465841 RenderProcessHostImpl::OnProcessLaunched::Start")); |
| 2309 // No point doing anything, since this object will be destructed soon. We | 2354 // No point doing anything, since this object will be destructed soon. We |
| 2310 // especially don't want to send the RENDERER_PROCESS_CREATED notification, | 2355 // especially don't want to send the RENDERER_PROCESS_CREATED notification, |
| 2311 // since some clients might expect a RENDERER_PROCESS_TERMINATED afterwards to | 2356 // since some clients might expect a RENDERER_PROCESS_TERMINATED afterwards to |
| 2312 // properly cleanup. | 2357 // properly cleanup. |
| 2313 if (deleting_soon_) | 2358 if (deleting_soon_) |
| 2314 return; | 2359 return; |
| 2315 | 2360 |
| 2316 if (child_process_launcher_) { | 2361 if (child_process_launcher_) { |
| 2317 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841 | 2362 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841 |
| 2318 // is fixed. | 2363 // is fixed. |
| 2319 tracked_objects::ScopedTracker tracking_profile2( | 2364 tracked_objects::ScopedTracker tracking_profile2( |
| 2320 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 2365 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 2321 "465841 RenderProcessHostImpl::OnProcessLaunched::Backgrounded")); | 2366 "465841 RenderProcessHostImpl::OnProcessLaunched::Backgrounded")); |
| 2322 DCHECK(child_process_launcher_->GetProcess().IsValid()); | 2367 DCHECK(child_process_launcher_->GetProcess().IsValid()); |
| 2323 DCHECK(!is_process_backgrounded_); | 2368 SetBackgrounded(backgrounded_); |
| 2324 | |
| 2325 // Not all platforms launch processes in the same backgrounded state. Make | |
| 2326 // sure |is_process_backgrounded_| reflects this platform's initial process | |
| 2327 // state. | |
| 2328 is_process_backgrounded_ = | |
| 2329 child_process_launcher_->GetProcess().IsProcessBackgrounded(); | |
| 2330 | |
| 2331 UpdateProcessPriority(); | |
| 2332 } | 2369 } |
| 2333 | 2370 |
| 2334 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841 | 2371 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841 |
| 2335 // is fixed. | 2372 // is fixed. |
| 2336 tracked_objects::ScopedTracker tracking_profile3( | 2373 tracked_objects::ScopedTracker tracking_profile3( |
| 2337 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 2374 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 2338 "465841 RenderProcessHostImpl::OnProcessLaunched::Notify")); | 2375 "465841 RenderProcessHostImpl::OnProcessLaunched::Notify")); |
| 2339 // NOTE: This needs to be before sending queued messages because | 2376 // NOTE: This needs to be before sending queued messages because |
| 2340 // ExtensionService uses this notification to initialize the renderer process | 2377 // ExtensionService uses this notification to initialize the renderer process |
| 2341 // with state that must be there before any JavaScript executes. | 2378 // with state that must be there before any JavaScript executes. |
| 2342 // | 2379 // |
| 2343 // The queued messages contain such things as "navigate". If this notification | 2380 // The queued messages contain such things as "navigate". If this notification |
| 2344 // was after, we can end up executing JavaScript before the initialization | 2381 // was after, we can end up executing JavaScript before the initialization |
| 2345 // happens. | 2382 // happens. |
| 2346 NotificationService::current()->Notify(NOTIFICATION_RENDERER_PROCESS_CREATED, | 2383 NotificationService::current()->Notify( |
| 2347 Source<RenderProcessHost>(this), | 2384 NOTIFICATION_RENDERER_PROCESS_CREATED, |
| 2348 NotificationService::NoDetails()); | 2385 Source<RenderProcessHost>(this), |
| 2386 NotificationService::NoDetails()); |
| 2349 | 2387 |
| 2350 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841 | 2388 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841 |
| 2351 // is fixed. | 2389 // is fixed. |
| 2352 tracked_objects::ScopedTracker tracking_profile4( | 2390 tracked_objects::ScopedTracker tracking_profile4( |
| 2353 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 2391 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 2354 "465841 RenderProcessHostImpl::OnProcessLaunched::MojoActivate")); | 2392 "465841 RenderProcessHostImpl::OnProcessLaunched::MojoActivate")); |
| 2355 // Allow Mojo to be setup before the renderer sees any Chrome IPC messages. | 2393 // Allow Mojo to be setup before the renderer sees any Chrome IPC messages. |
| 2356 // This way, Mojo can be safely used from the renderer in response to any | 2394 // This way, Mojo can be safely used from the renderer in response to any |
| 2357 // Chrome IPC message. | 2395 // Chrome IPC message. |
| 2358 mojo_application_host_->Activate(this, GetHandle()); | 2396 mojo_application_host_->Activate(this, GetHandle()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2397 } | 2435 } |
| 2398 | 2436 |
| 2399 void RenderProcessHostImpl::OnProcessLaunchFailed() { | 2437 void RenderProcessHostImpl::OnProcessLaunchFailed() { |
| 2400 // If this object will be destructed soon, then observers have already been | 2438 // If this object will be destructed soon, then observers have already been |
| 2401 // sent a RenderProcessHostDestroyed notification, and we must observe our | 2439 // sent a RenderProcessHostDestroyed notification, and we must observe our |
| 2402 // contract that says that will be the last call. | 2440 // contract that says that will be the last call. |
| 2403 if (deleting_soon_) | 2441 if (deleting_soon_) |
| 2404 return; | 2442 return; |
| 2405 | 2443 |
| 2406 // TODO(wfh): Fill in the real error code here see crbug.com/526198. | 2444 // TODO(wfh): Fill in the real error code here see crbug.com/526198. |
| 2407 RendererClosedDetails details{base::TERMINATION_STATUS_LAUNCH_FAILED, -1}; | 2445 RendererClosedDetails details { base::TERMINATION_STATUS_LAUNCH_FAILED, |
| 2446 -1 }; |
| 2408 ProcessDied(true, &details); | 2447 ProcessDied(true, &details); |
| 2409 } | 2448 } |
| 2410 | 2449 |
| 2411 scoped_refptr<AudioRendererHost> RenderProcessHostImpl::audio_renderer_host() | 2450 scoped_refptr<AudioRendererHost> |
| 2412 const { | 2451 RenderProcessHostImpl::audio_renderer_host() const { |
| 2413 return audio_renderer_host_; | 2452 return audio_renderer_host_; |
| 2414 } | 2453 } |
| 2415 | 2454 |
| 2416 void RenderProcessHostImpl::OnUserMetricsRecordAction( | 2455 void RenderProcessHostImpl::OnUserMetricsRecordAction( |
| 2417 const std::string& action) { | 2456 const std::string& action) { |
| 2418 RecordComputedAction(action); | 2457 RecordComputedAction(action); |
| 2419 } | 2458 } |
| 2420 | 2459 |
| 2421 void RenderProcessHostImpl::OnCloseACK(int old_route_id) { | 2460 void RenderProcessHostImpl::OnCloseACK(int old_route_id) { |
| 2422 SessionStorageHolder* holder = | 2461 SessionStorageHolder* holder = static_cast<SessionStorageHolder*> |
| 2423 static_cast<SessionStorageHolder*>(GetUserData(kSessionStorageHolderKey)); | 2462 (GetUserData(kSessionStorageHolderKey)); |
| 2424 if (!holder) | 2463 if (!holder) |
| 2425 return; | 2464 return; |
| 2426 holder->Release(old_route_id); | 2465 holder->Release(old_route_id); |
| 2427 } | 2466 } |
| 2428 | 2467 |
| 2429 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) { | 2468 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) { |
| 2430 MHTMLGenerationManager::GetInstance()->MHTMLGenerated(job_id, data_size); | 2469 MHTMLGenerationManager::GetInstance()->MHTMLGenerated(job_id, data_size); |
| 2431 } | 2470 } |
| 2432 | 2471 |
| 2433 void RenderProcessHostImpl::OnGpuSwitched() { | 2472 void RenderProcessHostImpl::OnGpuSwitched() { |
| 2434 // We are updating all widgets including swapped out ones. | 2473 // We are updating all widgets including swapped out ones. |
| 2435 scoped_ptr<RenderWidgetHostIterator> widgets( | 2474 scoped_ptr<RenderWidgetHostIterator> widgets( |
| 2436 RenderWidgetHostImpl::GetAllRenderWidgetHosts()); | 2475 RenderWidgetHostImpl::GetAllRenderWidgetHosts()); |
| 2437 while (RenderWidgetHost* widget = widgets->GetNextHost()) { | 2476 while (RenderWidgetHost* widget = widgets->GetNextHost()) { |
| 2438 if (!widget->IsRenderView()) | 2477 if (!widget->IsRenderView()) |
| 2439 continue; | 2478 continue; |
| 2440 | 2479 |
| 2441 // Skip widgets in other processes. | 2480 // Skip widgets in other processes. |
| 2442 if (widget->GetProcess()->GetID() != GetID()) | 2481 if (widget->GetProcess()->GetID() != GetID()) |
| 2443 continue; | 2482 continue; |
| 2444 | 2483 |
| 2445 RenderViewHost* rvh = RenderViewHost::From(widget); | 2484 RenderViewHost* rvh = RenderViewHost::From(widget); |
| 2446 rvh->OnWebkitPreferencesChanged(); | 2485 rvh->OnWebkitPreferencesChanged(); |
| 2447 } | 2486 } |
| 2448 } | 2487 } |
| 2449 | 2488 |
| 2450 #if defined(ENABLE_WEBRTC) | 2489 #if defined(ENABLE_WEBRTC) |
| 2451 void RenderProcessHostImpl::OnRegisterAecDumpConsumer(int id) { | 2490 void RenderProcessHostImpl::OnRegisterAecDumpConsumer(int id) { |
| 2452 BrowserThread::PostTask( | 2491 BrowserThread::PostTask( |
| 2453 BrowserThread::UI, FROM_HERE, | 2492 BrowserThread::UI, |
| 2454 base::Bind(&RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread, | 2493 FROM_HERE, |
| 2455 weak_factory_.GetWeakPtr(), id)); | 2494 base::Bind( |
| 2495 &RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread, |
| 2496 weak_factory_.GetWeakPtr(), |
| 2497 id)); |
| 2456 } | 2498 } |
| 2457 | 2499 |
| 2458 void RenderProcessHostImpl::OnUnregisterAecDumpConsumer(int id) { | 2500 void RenderProcessHostImpl::OnUnregisterAecDumpConsumer(int id) { |
| 2459 BrowserThread::PostTask( | 2501 BrowserThread::PostTask( |
| 2460 BrowserThread::UI, FROM_HERE, | 2502 BrowserThread::UI, |
| 2461 base::Bind(&RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread, | 2503 FROM_HERE, |
| 2462 weak_factory_.GetWeakPtr(), id)); | 2504 base::Bind( |
| 2505 &RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread, |
| 2506 weak_factory_.GetWeakPtr(), |
| 2507 id)); |
| 2463 } | 2508 } |
| 2464 | 2509 |
| 2465 void RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread(int id) { | 2510 void RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread(int id) { |
| 2466 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2511 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2467 aec_dump_consumers_.push_back(id); | 2512 aec_dump_consumers_.push_back(id); |
| 2468 | 2513 |
| 2469 if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) { | 2514 if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) { |
| 2470 base::FilePath file_with_extensions = GetAecDumpFilePathWithExtensions( | 2515 base::FilePath file_with_extensions = GetAecDumpFilePathWithExtensions( |
| 2471 WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath()); | 2516 WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath()); |
| 2472 EnableAecDumpForId(file_with_extensions, id); | 2517 EnableAecDumpForId(file_with_extensions, id); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2483 } | 2528 } |
| 2484 } | 2529 } |
| 2485 } | 2530 } |
| 2486 | 2531 |
| 2487 void RenderProcessHostImpl::EnableAecDumpForId(const base::FilePath& file, | 2532 void RenderProcessHostImpl::EnableAecDumpForId(const base::FilePath& file, |
| 2488 int id) { | 2533 int id) { |
| 2489 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2534 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2490 BrowserThread::PostTaskAndReplyWithResult( | 2535 BrowserThread::PostTaskAndReplyWithResult( |
| 2491 BrowserThread::FILE, FROM_HERE, | 2536 BrowserThread::FILE, FROM_HERE, |
| 2492 base::Bind(&CreateAecDumpFileForProcess, | 2537 base::Bind(&CreateAecDumpFileForProcess, |
| 2493 file.AddExtension(IntToStringType(id)), GetHandle()), | 2538 file.AddExtension(IntToStringType(id)), |
| 2539 GetHandle()), |
| 2494 base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer, | 2540 base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer, |
| 2495 weak_factory_.GetWeakPtr(), id)); | 2541 weak_factory_.GetWeakPtr(), |
| 2542 id)); |
| 2496 } | 2543 } |
| 2497 | 2544 |
| 2498 void RenderProcessHostImpl::SendAecDumpFileToRenderer( | 2545 void RenderProcessHostImpl::SendAecDumpFileToRenderer( |
| 2499 int id, | 2546 int id, |
| 2500 IPC::PlatformFileForTransit file_for_transit) { | 2547 IPC::PlatformFileForTransit file_for_transit) { |
| 2501 if (file_for_transit == IPC::InvalidPlatformFileForTransit()) | 2548 if (file_for_transit == IPC::InvalidPlatformFileForTransit()) |
| 2502 return; | 2549 return; |
| 2503 Send(new AecDumpMsg_EnableAecDump(id, file_for_transit)); | 2550 Send(new AecDumpMsg_EnableAecDump(id, file_for_transit)); |
| 2504 } | 2551 } |
| 2505 | 2552 |
| 2506 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { | 2553 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { |
| 2507 Send(new AecDumpMsg_DisableAecDump()); | 2554 Send(new AecDumpMsg_DisableAecDump()); |
| 2508 } | 2555 } |
| 2509 | 2556 |
| 2510 base::FilePath RenderProcessHostImpl::GetAecDumpFilePathWithExtensions( | 2557 base::FilePath RenderProcessHostImpl::GetAecDumpFilePathWithExtensions( |
| 2511 const base::FilePath& file) { | 2558 const base::FilePath& file) { |
| 2512 return file.AddExtension(IntToStringType(base::GetProcId(GetHandle()))) | 2559 return file.AddExtension(IntToStringType(base::GetProcId(GetHandle()))) |
| 2513 .AddExtension(kAecDumpFileNameAddition); | 2560 .AddExtension(kAecDumpFileNameAddition); |
| 2514 } | 2561 } |
| 2515 #endif // defined(ENABLE_WEBRTC) | 2562 #endif // defined(ENABLE_WEBRTC) |
| 2516 | 2563 |
| 2517 void RenderProcessHostImpl::IncrementWorkerRefCount() { | 2564 void RenderProcessHostImpl::IncrementWorkerRefCount() { |
| 2518 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2565 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2519 ++worker_ref_count_; | 2566 ++worker_ref_count_; |
| 2520 if (worker_ref_count_ > max_worker_count_) | 2567 if (worker_ref_count_ > max_worker_count_) |
| 2521 max_worker_count_ = worker_ref_count_; | 2568 max_worker_count_ = worker_ref_count_; |
| 2522 } | 2569 } |
| 2523 | 2570 |
| 2524 void RenderProcessHostImpl::DecrementWorkerRefCount() { | 2571 void RenderProcessHostImpl::DecrementWorkerRefCount() { |
| 2525 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2572 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2526 DCHECK_GT(worker_ref_count_, 0); | 2573 DCHECK_GT(worker_ref_count_, 0); |
| 2527 --worker_ref_count_; | 2574 --worker_ref_count_; |
| 2528 if (worker_ref_count_ == 0) | 2575 if (worker_ref_count_ == 0) |
| 2529 Cleanup(); | 2576 Cleanup(); |
| 2530 } | 2577 } |
| 2531 | 2578 |
| 2532 void RenderProcessHostImpl::GetAudioOutputControllers( | 2579 void RenderProcessHostImpl::GetAudioOutputControllers( |
| 2533 const GetAudioOutputControllersCallback& callback) const { | 2580 const GetAudioOutputControllersCallback& callback) const { |
| 2534 audio_renderer_host()->GetOutputControllers(callback); | 2581 audio_renderer_host()->GetOutputControllers(callback); |
| 2535 } | 2582 } |
| 2536 | 2583 |
| 2537 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { | 2584 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { |
| 2538 return bluetooth_dispatcher_host_.get(); | 2585 return bluetooth_dispatcher_host_.get(); |
| 2539 } | 2586 } |
| 2540 | 2587 |
| 2541 } // namespace content | 2588 } // namespace content |
| OLD | NEW |