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