OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "content/renderer/render_thread_impl.h" | 5 #include "content/renderer/render_thread_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 | 550 |
551 void RenderThreadImpl::HistogramCustomizer::SetCommonHost( | 551 void RenderThreadImpl::HistogramCustomizer::SetCommonHost( |
552 const std::string& host) { | 552 const std::string& host) { |
553 if (host != common_host_) { | 553 if (host != common_host_) { |
554 common_host_ = host; | 554 common_host_ = host; |
555 common_host_histogram_suffix_ = HostToCustomHistogramSuffix(host); | 555 common_host_histogram_suffix_ = HostToCustomHistogramSuffix(host); |
556 blink::mainThreadIsolate()->SetCreateHistogramFunction(CreateHistogram); | 556 blink::mainThreadIsolate()->SetCreateHistogramFunction(CreateHistogram); |
557 } | 557 } |
558 } | 558 } |
559 | 559 |
| 560 // static |
| 561 RenderThreadImpl* RenderThreadImpl::Create( |
| 562 const InProcessChildThreadParams& params) { |
| 563 scoped_ptr<scheduler::RendererScheduler> renderer_scheduler = |
| 564 scheduler::RendererScheduler::Create(); |
| 565 return new RenderThreadImpl(params, renderer_scheduler.Pass()); |
| 566 } |
| 567 |
| 568 // static |
| 569 RenderThreadImpl* RenderThreadImpl::Create( |
| 570 scoped_ptr<base::MessageLoop> main_message_loop) { |
| 571 scoped_ptr<scheduler::RendererScheduler> renderer_scheduler = |
| 572 scheduler::RendererScheduler::Create(); |
| 573 return new RenderThreadImpl(main_message_loop.Pass(), |
| 574 renderer_scheduler.Pass()); |
| 575 } |
| 576 |
560 RenderThreadImpl* RenderThreadImpl::current() { | 577 RenderThreadImpl* RenderThreadImpl::current() { |
561 return lazy_tls.Pointer()->Get(); | 578 return lazy_tls.Pointer()->Get(); |
562 } | 579 } |
563 | 580 |
564 RenderThreadImpl::RenderThreadImpl(const InProcessChildThreadParams& params) | 581 RenderThreadImpl::RenderThreadImpl( |
| 582 const InProcessChildThreadParams& params, |
| 583 scoped_ptr<scheduler::RendererScheduler> scheduler) |
565 : ChildThreadImpl(Options::Builder() | 584 : ChildThreadImpl(Options::Builder() |
566 .InBrowserProcess(params) | 585 .InBrowserProcess(params) |
567 .UseMojoChannel(ShouldUseMojoChannel()) | 586 .UseMojoChannel(ShouldUseMojoChannel()) |
| 587 .ListenerTaskRunner(scheduler->DefaultTaskRunner()) |
568 .Build()), | 588 .Build()), |
| 589 renderer_scheduler_(scheduler.Pass()), |
569 raster_worker_pool_(new RasterWorkerPool()) { | 590 raster_worker_pool_(new RasterWorkerPool()) { |
570 Init(); | 591 Init(); |
571 } | 592 } |
572 | 593 |
573 // When we run plugins in process, we actually run them on the render thread, | 594 // When we run plugins in process, we actually run them on the render thread, |
574 // which means that we need to make the render thread pump UI events. | 595 // which means that we need to make the render thread pump UI events. |
575 RenderThreadImpl::RenderThreadImpl( | 596 RenderThreadImpl::RenderThreadImpl( |
576 scoped_ptr<base::MessageLoop> main_message_loop) | 597 scoped_ptr<base::MessageLoop> main_message_loop, |
| 598 scoped_ptr<scheduler::RendererScheduler> scheduler) |
577 : ChildThreadImpl(Options::Builder() | 599 : ChildThreadImpl(Options::Builder() |
578 .UseMojoChannel(ShouldUseMojoChannel()) | 600 .UseMojoChannel(ShouldUseMojoChannel()) |
| 601 .ListenerTaskRunner(scheduler->DefaultTaskRunner()) |
579 .Build()), | 602 .Build()), |
| 603 renderer_scheduler_(scheduler.Pass()), |
580 main_message_loop_(main_message_loop.Pass()), | 604 main_message_loop_(main_message_loop.Pass()), |
581 raster_worker_pool_(new RasterWorkerPool()) { | 605 raster_worker_pool_(new RasterWorkerPool()) { |
582 Init(); | 606 Init(); |
583 } | 607 } |
584 | 608 |
585 void RenderThreadImpl::Init() { | 609 void RenderThreadImpl::Init() { |
586 TRACE_EVENT_BEGIN_ETW("RenderThreadImpl::Init", 0, ""); | 610 TRACE_EVENT_BEGIN_ETW("RenderThreadImpl::Init", 0, ""); |
587 | 611 |
588 base::trace_event::TraceLog::GetInstance()->SetThreadSortIndex( | 612 base::trace_event::TraceLog::GetInstance()->SetThreadSortIndex( |
589 base::PlatformThread::CurrentId(), | 613 base::PlatformThread::CurrentId(), |
(...skipping 16 matching lines...) Expand all Loading... |
606 hidden_widget_count_ = 0; | 630 hidden_widget_count_ = 0; |
607 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; | 631 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; |
608 idle_notifications_to_skip_ = 0; | 632 idle_notifications_to_skip_ = 0; |
609 layout_test_mode_ = false; | 633 layout_test_mode_ = false; |
610 | 634 |
611 appcache_dispatcher_.reset( | 635 appcache_dispatcher_.reset( |
612 new AppCacheDispatcher(Get(), new AppCacheFrontendImpl())); | 636 new AppCacheDispatcher(Get(), new AppCacheFrontendImpl())); |
613 dom_storage_dispatcher_.reset(new DomStorageDispatcher()); | 637 dom_storage_dispatcher_.reset(new DomStorageDispatcher()); |
614 main_thread_indexed_db_dispatcher_.reset(new IndexedDBDispatcher( | 638 main_thread_indexed_db_dispatcher_.reset(new IndexedDBDispatcher( |
615 thread_safe_sender())); | 639 thread_safe_sender())); |
616 renderer_scheduler_ = scheduler::RendererScheduler::Create(); | |
617 channel()->SetListenerTaskRunner(renderer_scheduler_->DefaultTaskRunner()); | |
618 main_thread_cache_storage_dispatcher_.reset( | 640 main_thread_cache_storage_dispatcher_.reset( |
619 new CacheStorageDispatcher(thread_safe_sender())); | 641 new CacheStorageDispatcher(thread_safe_sender())); |
620 embedded_worker_dispatcher_.reset(new EmbeddedWorkerDispatcher()); | 642 embedded_worker_dispatcher_.reset(new EmbeddedWorkerDispatcher()); |
621 | 643 |
622 // Note: This may reorder messages from the ResourceDispatcher with respect to | 644 // Note: This may reorder messages from the ResourceDispatcher with respect to |
623 // other subsystems. | 645 // other subsystems. |
624 resource_dispatch_throttler_.reset(new ResourceDispatchThrottler( | 646 resource_dispatch_throttler_.reset(new ResourceDispatchThrottler( |
625 static_cast<RenderThread*>(this), renderer_scheduler_.get(), | 647 static_cast<RenderThread*>(this), renderer_scheduler_.get(), |
626 base::TimeDelta::FromSecondsD(kThrottledResourceRequestFlushPeriodS), | 648 base::TimeDelta::FromSecondsD(kThrottledResourceRequestFlushPeriodS), |
627 kMaxResourceRequestsPerFlushWhenThrottled)); | 649 kMaxResourceRequestsPerFlushWhenThrottled)); |
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1971 } | 1993 } |
1972 | 1994 |
1973 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { | 1995 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { |
1974 size_t erased = | 1996 size_t erased = |
1975 RenderThreadImpl::current()->pending_render_frame_connects_.erase( | 1997 RenderThreadImpl::current()->pending_render_frame_connects_.erase( |
1976 routing_id_); | 1998 routing_id_); |
1977 DCHECK_EQ(1u, erased); | 1999 DCHECK_EQ(1u, erased); |
1978 } | 2000 } |
1979 | 2001 |
1980 } // namespace content | 2002 } // namespace content |
OLD | NEW |