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