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